favesalon-embed 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/dist/custom-elements/index.d.ts +12 -0
  2. package/dist/{cjs/_commonjsHelpers-5cfcba41.js → favesalon-embed/_commonjsHelpers-a4f66ccd.js} +14 -6
  3. package/dist/{cjs/global-9073d10e.js → favesalon-embed/app-globals-15861a7f.js} +15 -8
  4. package/dist/{esm/global-e1089ffd.js → favesalon-embed/app-globals-270fe240.js} +16 -7
  5. package/dist/favesalon-embed/app-globals-437cc3f3.js +712 -0
  6. package/dist/favesalon-embed/app-globals-b8b0fc7a.js +712 -0
  7. package/dist/favesalon-embed/chat-button.entry.js +56 -0
  8. package/dist/favesalon-embed/chat-form.entry.js +39 -0
  9. package/dist/favesalon-embed/chat-messages.entry.js +51 -0
  10. package/dist/favesalon-embed/css-shim-b7d3d95f.js +4 -0
  11. package/dist/favesalon-embed/dom-64053c71.js +73 -0
  12. package/dist/favesalon-embed/favesalon-embed.css +2433 -4
  13. package/dist/favesalon-embed/favesalon-embed.esm.js +148 -1
  14. package/dist/{collection/components/google-map/index.js → favesalon-embed/google-map.entry.js} +12 -54
  15. package/dist/{esm/index-80523fec.js → favesalon-embed/index-00b83e1c.js} +425 -15
  16. package/dist/favesalon-embed/index-888e99e3.js +3371 -0
  17. package/dist/favesalon-embed/index-9ad82b12.js +3371 -0
  18. package/dist/favesalon-embed/index-aa906326.js +3371 -0
  19. package/dist/favesalon-embed/index-b97af793.js +3371 -0
  20. package/dist/favesalon-embed/index.esm.js +1 -0
  21. package/dist/favesalon-embed/relativeTime-268e64b0.js +7 -0
  22. package/dist/{esm → favesalon-embed}/salon-booking-modal.entry.js +1 -1
  23. package/dist/{esm → favesalon-embed}/salon-booking.entry.js +3 -3
  24. package/dist/{esm → favesalon-embed}/salon-gift-card-modal.entry.js +1 -1
  25. package/dist/{esm → favesalon-embed}/salon-gift-card.entry.js +3 -3
  26. package/dist/favesalon-embed/salon-info.entry.js +29 -0
  27. package/dist/{esm → favesalon-embed}/salon-latest-reviews.entry.js +4 -4
  28. package/dist/{collection/components/salon-latest-styles/index.js → favesalon-embed/salon-latest-styles.entry.js} +14 -99
  29. package/dist/{collection/components/salon-locations/index.js → favesalon-embed/salon-locations.entry.js} +15 -95
  30. package/dist/{esm → favesalon-embed}/salon-lookbook.entry.js +3 -3
  31. package/dist/{esm → favesalon-embed}/salon-ranking.entry.js +1 -1
  32. package/dist/{esm → favesalon-embed}/salon-reviews.entry.js +3 -3
  33. package/dist/{collection/components/salon-schedules/index.js → favesalon-embed/salon-schedules.entry.js} +14 -95
  34. package/dist/{esm → favesalon-embed}/salon-services.entry.js +3 -3
  35. package/dist/{esm → favesalon-embed}/salon-stylists.entry.js +3 -3
  36. package/dist/{esm/services-40a3e622.js → favesalon-embed/services-7cb8f2a6.js} +2469 -100
  37. package/dist/favesalon-embed/shadow-css-98135883.js +387 -0
  38. package/dist/{esm → favesalon-embed}/style-detail.entry.js +4 -4
  39. package/dist/{esm → favesalon-embed}/user-avatar.entry.js +2 -1
  40. package/dist/{esm/utils-e97485e0.js → favesalon-embed/utils-7de9628a.js} +3 -0
  41. package/dist/types/components/chat-button/index.d.ts +0 -8
  42. package/dist/types/components/chat-form/index.d.ts +6 -0
  43. package/dist/types/components/chat-messages/index.d.ts +14 -0
  44. package/dist/types/components.d.ts +40 -0
  45. package/package.json +1 -1
  46. package/dist/cjs/chat-button.cjs.entry.js +0 -118
  47. package/dist/cjs/colors-38421769.js +0 -69
  48. package/dist/cjs/favesalon-embed.cjs.js +0 -24
  49. package/dist/cjs/google-map_5.cjs.entry.js +0 -310
  50. package/dist/cjs/index-47c2a5f6.js +0 -1533
  51. package/dist/cjs/index-7f190886.js +0 -4396
  52. package/dist/cjs/index.cjs.js +0 -2
  53. package/dist/cjs/loader.cjs.js +0 -23
  54. package/dist/cjs/relativeTime-3721080d.js +0 -9
  55. package/dist/cjs/salon-booking-modal.cjs.entry.js +0 -30
  56. package/dist/cjs/salon-booking.cjs.entry.js +0 -51
  57. package/dist/cjs/salon-gift-card-modal.cjs.entry.js +0 -29
  58. package/dist/cjs/salon-gift-card.cjs.entry.js +0 -51
  59. package/dist/cjs/salon-latest-reviews.cjs.entry.js +0 -97
  60. package/dist/cjs/salon-lookbook.cjs.entry.js +0 -222
  61. package/dist/cjs/salon-ranking.cjs.entry.js +0 -60
  62. package/dist/cjs/salon-reviews.cjs.entry.js +0 -193
  63. package/dist/cjs/salon-services.cjs.entry.js +0 -81
  64. package/dist/cjs/salon-stylists.cjs.entry.js +0 -118
  65. package/dist/cjs/services-125c82d8.js +0 -21492
  66. package/dist/cjs/style-detail.cjs.entry.js +0 -312
  67. package/dist/cjs/user-avatar.cjs.entry.js +0 -45
  68. package/dist/cjs/utils-c5a33b3c.js +0 -23
  69. package/dist/collection/collection-manifest.json +0 -29
  70. package/dist/collection/components/chat-button/index.css +0 -122
  71. package/dist/collection/components/chat-button/index.js +0 -218
  72. package/dist/collection/components/chat-conversation/index.js +0 -103
  73. package/dist/collection/components/google-map/assets/map--placeholder.jpeg +0 -0
  74. package/dist/collection/components/google-map/index.css +0 -5
  75. package/dist/collection/components/salon-booking/index.css +0 -30
  76. package/dist/collection/components/salon-booking/index.js +0 -126
  77. package/dist/collection/components/salon-booking/salon-booking-modal.js +0 -92
  78. package/dist/collection/components/salon-gift-card/index.css +0 -30
  79. package/dist/collection/components/salon-gift-card/index.js +0 -126
  80. package/dist/collection/components/salon-gift-card/salon-gift-card-modal.js +0 -73
  81. package/dist/collection/components/salon-info/index.css +0 -1
  82. package/dist/collection/components/salon-info/index.js +0 -77
  83. package/dist/collection/components/salon-latest-reviews/index.css +0 -11
  84. package/dist/collection/components/salon-latest-reviews/index.js +0 -163
  85. package/dist/collection/components/salon-latest-styles/index.css +0 -12
  86. package/dist/collection/components/salon-locations/index.css +0 -24
  87. package/dist/collection/components/salon-lookbook/index.css +0 -15
  88. package/dist/collection/components/salon-lookbook/index.js +0 -368
  89. package/dist/collection/components/salon-ranking/index.css +0 -3
  90. package/dist/collection/components/salon-ranking/index.js +0 -117
  91. package/dist/collection/components/salon-reviews/index.css +0 -18
  92. package/dist/collection/components/salon-reviews/index.js +0 -249
  93. package/dist/collection/components/salon-schedules/index.css +0 -18
  94. package/dist/collection/components/salon-services/index.css +0 -1
  95. package/dist/collection/components/salon-services/index.js +0 -146
  96. package/dist/collection/components/salon-stylists/index.css +0 -43
  97. package/dist/collection/components/salon-stylists/index.js +0 -184
  98. package/dist/collection/components/style-detail/index.css +0 -76
  99. package/dist/collection/components/style-detail/index.js +0 -386
  100. package/dist/collection/components/user-avatar/index.css +0 -0
  101. package/dist/collection/components/user-avatar/index.js +0 -134
  102. package/dist/collection/constants/colors.js +0 -65
  103. package/dist/collection/global/global.js +0 -8
  104. package/dist/collection/index.js +0 -1
  105. package/dist/collection/mocks/users.js +0 -10
  106. package/dist/collection/services/services.js +0 -295
  107. package/dist/collection/types/chat.js +0 -23
  108. package/dist/collection/types/common.js +0 -11
  109. package/dist/collection/types/review.js +0 -39
  110. package/dist/collection/types/salon.js +0 -58
  111. package/dist/collection/types/service.js +0 -24
  112. package/dist/collection/types/style.js +0 -128
  113. package/dist/collection/types/stylist.js +0 -30
  114. package/dist/collection/types/user.js +0 -10
  115. package/dist/collection/utils/utils.js +0 -20
  116. package/dist/custom-elements/index.js +0 -28340
  117. package/dist/esm/_commonjsHelpers-098d5b27.js +0 -32
  118. package/dist/esm/chat-button.entry.js +0 -114
  119. package/dist/esm/favesalon-embed.js +0 -19
  120. package/dist/esm/google-map_5.entry.js +0 -302
  121. package/dist/esm/index-3fae868e.js +0 -1506
  122. package/dist/esm/index.js +0 -1
  123. package/dist/esm/loader.js +0 -19
  124. package/dist/esm/polyfills/core-js.js +0 -11
  125. package/dist/esm/polyfills/css-shim.js +0 -1
  126. package/dist/esm/polyfills/dom.js +0 -79
  127. package/dist/esm/polyfills/es5-html-element.js +0 -1
  128. package/dist/esm/polyfills/index.js +0 -34
  129. package/dist/esm/polyfills/system.js +0 -6
  130. package/dist/esm/relativeTime-cd452e6d.js +0 -7
  131. package/dist/favesalon-embed/p-019c5ccd.entry.js +0 -1
  132. package/dist/favesalon-embed/p-083a8821.entry.js +0 -1
  133. package/dist/favesalon-embed/p-0d0ed9ea.entry.js +0 -1
  134. package/dist/favesalon-embed/p-119db8de.entry.js +0 -1
  135. package/dist/favesalon-embed/p-1432c51b.entry.js +0 -1
  136. package/dist/favesalon-embed/p-22093506.entry.js +0 -1
  137. package/dist/favesalon-embed/p-32b314e9.js +0 -2
  138. package/dist/favesalon-embed/p-47e646f8.js +0 -1
  139. package/dist/favesalon-embed/p-4a5eca9a.js +0 -6
  140. package/dist/favesalon-embed/p-58d2e9be.js +0 -1
  141. package/dist/favesalon-embed/p-71404b6a.entry.js +0 -1
  142. package/dist/favesalon-embed/p-857c3a61.entry.js +0 -1
  143. package/dist/favesalon-embed/p-99ec77f7.entry.js +0 -1
  144. package/dist/favesalon-embed/p-a33331cc.js +0 -1
  145. package/dist/favesalon-embed/p-b0c3673a.entry.js +0 -1
  146. package/dist/favesalon-embed/p-b287b1ea.entry.js +0 -1
  147. package/dist/favesalon-embed/p-b3af7842.entry.js +0 -1
  148. package/dist/favesalon-embed/p-b630ae68.js +0 -1580
  149. package/dist/favesalon-embed/p-ce2c1c9a.entry.js +0 -1
  150. package/dist/favesalon-embed/p-d6083940.js +0 -1
  151. package/dist/favesalon-embed/p-d9b7ad58.entry.js +0 -1
  152. package/dist/favesalon-embed/p-fc9a5551.js +0 -6
  153. package/dist/index.cjs.js +0 -1
  154. package/dist/index.js +0 -1
  155. package/dist/types/components/chat-conversation/index.d.ts +0 -0
  156. /package/dist/{esm → favesalon-embed}/colors-ea36347a.js +0 -0
@@ -1,4 +1,4 @@
1
- import { c as commonjsGlobal, a as createCommonjsModule } from './_commonjsHelpers-098d5b27.js';
1
+ import { c as commonjsGlobal, a as createCommonjsModule } from './_commonjsHelpers-a4f66ccd.js';
2
2
  import { C as Colors } from './colors-ea36347a.js';
3
3
 
4
4
  /**
@@ -1181,12 +1181,12 @@ var _baseGet = baseGet;
1181
1181
  * _.get(object, 'a.b.c', 'default');
1182
1182
  * // => 'default'
1183
1183
  */
1184
- function get(object, path, defaultValue) {
1184
+ function get$1(object, path, defaultValue) {
1185
1185
  var result = object == null ? undefined : _baseGet(object, path);
1186
1186
  return result === undefined ? defaultValue : result;
1187
1187
  }
1188
1188
 
1189
- var get_1 = get;
1189
+ var get_1 = get$1;
1190
1190
 
1191
1191
  /**
1192
1192
  * A specialized version of `_.forEach` for arrays without support for
@@ -1344,7 +1344,7 @@ var stubFalse_1 = stubFalse;
1344
1344
 
1345
1345
  var isBuffer_1 = createCommonjsModule(function (module, exports) {
1346
1346
  /** Detect free variable `exports`. */
1347
- var freeExports = exports && !exports.nodeType && exports;
1347
+ var freeExports = 'object' == 'object' && exports && !exports.nodeType && exports;
1348
1348
 
1349
1349
  /** Detect free variable `module`. */
1350
1350
  var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
@@ -1516,7 +1516,7 @@ var _baseUnary = baseUnary;
1516
1516
 
1517
1517
  var _nodeUtil = createCommonjsModule(function (module, exports) {
1518
1518
  /** Detect free variable `exports`. */
1519
- var freeExports = exports && !exports.nodeType && exports;
1519
+ var freeExports = 'object' == 'object' && exports && !exports.nodeType && exports;
1520
1520
 
1521
1521
  /** Detect free variable `module`. */
1522
1522
  var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
@@ -3499,6 +3499,8 @@ var sortBy = _baseRest(function(collection, iteratees) {
3499
3499
 
3500
3500
  var sortBy_1 = sortBy;
3501
3501
 
3502
+ 'use strict';
3503
+
3502
3504
  var bind = function bind(fn, thisArg) {
3503
3505
  return function wrap() {
3504
3506
  var args = new Array(arguments.length);
@@ -3509,6 +3511,10 @@ var bind = function bind(fn, thisArg) {
3509
3511
  };
3510
3512
  };
3511
3513
 
3514
+ 'use strict';
3515
+
3516
+
3517
+
3512
3518
  // utils is a library of generic helper functions non-specific to axios
3513
3519
 
3514
3520
  var toString = Object.prototype.toString;
@@ -3855,6 +3861,10 @@ var utils = {
3855
3861
  stripBOM: stripBOM
3856
3862
  };
3857
3863
 
3864
+ 'use strict';
3865
+
3866
+
3867
+
3858
3868
  function encode(val) {
3859
3869
  return encodeURIComponent(val).
3860
3870
  replace(/%3A/gi, ':').
@@ -3922,6 +3932,10 @@ var buildURL = function buildURL(url, params, paramsSerializer) {
3922
3932
  return url;
3923
3933
  };
3924
3934
 
3935
+ 'use strict';
3936
+
3937
+
3938
+
3925
3939
  function InterceptorManager() {
3926
3940
  this.handlers = [];
3927
3941
  }
@@ -3973,6 +3987,10 @@ InterceptorManager.prototype.forEach = function forEach(fn) {
3973
3987
 
3974
3988
  var InterceptorManager_1 = InterceptorManager;
3975
3989
 
3990
+ 'use strict';
3991
+
3992
+
3993
+
3976
3994
  var normalizeHeaderName = function normalizeHeaderName(headers, normalizedName) {
3977
3995
  utils.forEach(headers, function processHeader(value, name) {
3978
3996
  if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
@@ -3982,6 +4000,8 @@ var normalizeHeaderName = function normalizeHeaderName(headers, normalizedName)
3982
4000
  });
3983
4001
  };
3984
4002
 
4003
+ 'use strict';
4004
+
3985
4005
  /**
3986
4006
  * Update an Error with the specified config, error code, and response.
3987
4007
  *
@@ -4024,6 +4044,10 @@ var enhanceError = function enhanceError(error, config, code, request, response)
4024
4044
  return error;
4025
4045
  };
4026
4046
 
4047
+ 'use strict';
4048
+
4049
+
4050
+
4027
4051
  /**
4028
4052
  * Create an Error with the specified message, config, error code, request and response.
4029
4053
  *
@@ -4039,6 +4063,10 @@ var createError = function createError(message, config, code, request, response)
4039
4063
  return enhanceError(error, config, code, request, response);
4040
4064
  };
4041
4065
 
4066
+ 'use strict';
4067
+
4068
+
4069
+
4042
4070
  /**
4043
4071
  * Resolve or reject a Promise based on response status.
4044
4072
  *
@@ -4061,6 +4089,10 @@ var settle = function settle(resolve, reject, response) {
4061
4089
  }
4062
4090
  };
4063
4091
 
4092
+ 'use strict';
4093
+
4094
+
4095
+
4064
4096
  var cookies = (
4065
4097
  utils.isStandardBrowserEnv() ?
4066
4098
 
@@ -4111,6 +4143,8 @@ var cookies = (
4111
4143
  })()
4112
4144
  );
4113
4145
 
4146
+ 'use strict';
4147
+
4114
4148
  /**
4115
4149
  * Determines whether the specified URL is absolute
4116
4150
  *
@@ -4124,6 +4158,8 @@ var isAbsoluteURL = function isAbsoluteURL(url) {
4124
4158
  return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
4125
4159
  };
4126
4160
 
4161
+ 'use strict';
4162
+
4127
4163
  /**
4128
4164
  * Creates a new URL by combining the specified URLs
4129
4165
  *
@@ -4137,6 +4173,11 @@ var combineURLs = function combineURLs(baseURL, relativeURL) {
4137
4173
  : baseURL;
4138
4174
  };
4139
4175
 
4176
+ 'use strict';
4177
+
4178
+
4179
+
4180
+
4140
4181
  /**
4141
4182
  * Creates a new URL by combining the baseURL with the requestedURL,
4142
4183
  * only when the requestedURL is not already an absolute URL.
@@ -4153,6 +4194,10 @@ var buildFullPath = function buildFullPath(baseURL, requestedURL) {
4153
4194
  return requestedURL;
4154
4195
  };
4155
4196
 
4197
+ 'use strict';
4198
+
4199
+
4200
+
4156
4201
  // Headers whose duplicates are ignored by node
4157
4202
  // c.f. https://nodejs.org/api/http.html#http_message_headers
4158
4203
  var ignoreDuplicateOf = [
@@ -4203,6 +4248,10 @@ var parseHeaders = function parseHeaders(headers) {
4203
4248
  return parsed;
4204
4249
  };
4205
4250
 
4251
+ 'use strict';
4252
+
4253
+
4254
+
4206
4255
  var isURLSameOrigin = (
4207
4256
  utils.isStandardBrowserEnv() ?
4208
4257
 
@@ -4268,6 +4317,8 @@ var isURLSameOrigin = (
4268
4317
  })()
4269
4318
  );
4270
4319
 
4320
+ 'use strict';
4321
+
4271
4322
  /**
4272
4323
  * A `Cancel` is an object that is thrown when an operation is canceled.
4273
4324
  *
@@ -4286,6 +4337,19 @@ Cancel.prototype.__CANCEL__ = true;
4286
4337
 
4287
4338
  var Cancel_1 = Cancel;
4288
4339
 
4340
+ 'use strict';
4341
+
4342
+
4343
+
4344
+
4345
+
4346
+
4347
+
4348
+
4349
+
4350
+
4351
+
4352
+
4289
4353
  var xhr = function xhrAdapter(config) {
4290
4354
  return new Promise(function dispatchXhrRequest(resolve, reject) {
4291
4355
  var requestData = config.data;
@@ -4486,6 +4550,12 @@ var xhr = function xhrAdapter(config) {
4486
4550
  });
4487
4551
  };
4488
4552
 
4553
+ 'use strict';
4554
+
4555
+
4556
+
4557
+
4558
+
4489
4559
  var DEFAULT_CONTENT_TYPE = {
4490
4560
  'Content-Type': 'application/x-www-form-urlencoded'
4491
4561
  };
@@ -4615,6 +4685,11 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
4615
4685
 
4616
4686
  var defaults_1 = defaults;
4617
4687
 
4688
+ 'use strict';
4689
+
4690
+
4691
+
4692
+
4618
4693
  /**
4619
4694
  * Transform the data for a request or a response
4620
4695
  *
@@ -4633,10 +4708,20 @@ var transformData = function transformData(data, headers, fns) {
4633
4708
  return data;
4634
4709
  };
4635
4710
 
4711
+ 'use strict';
4712
+
4636
4713
  var isCancel = function isCancel(value) {
4637
4714
  return !!(value && value.__CANCEL__);
4638
4715
  };
4639
4716
 
4717
+ 'use strict';
4718
+
4719
+
4720
+
4721
+
4722
+
4723
+
4724
+
4640
4725
  /**
4641
4726
  * Throws a `Cancel` if cancellation has been requested.
4642
4727
  */
@@ -4717,6 +4802,10 @@ var dispatchRequest = function dispatchRequest(config) {
4717
4802
  });
4718
4803
  };
4719
4804
 
4805
+ 'use strict';
4806
+
4807
+
4808
+
4720
4809
  /**
4721
4810
  * Config-specific merge-function which creates a new config-object
4722
4811
  * by merging two configuration objects together.
@@ -4817,6 +4906,8 @@ var data = {
4817
4906
  "version": "0.22.0"
4818
4907
  };
4819
4908
 
4909
+ 'use strict';
4910
+
4820
4911
  var VERSION = data.version;
4821
4912
 
4822
4913
  var validators$1 = {};
@@ -4898,6 +4989,15 @@ var validator = {
4898
4989
  validators: validators$1
4899
4990
  };
4900
4991
 
4992
+ 'use strict';
4993
+
4994
+
4995
+
4996
+
4997
+
4998
+
4999
+
5000
+
4901
5001
  var validators = validator.validators;
4902
5002
  /**
4903
5003
  * Create a new instance of Axios
@@ -5038,6 +5138,10 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
5038
5138
 
5039
5139
  var Axios_1 = Axios;
5040
5140
 
5141
+ 'use strict';
5142
+
5143
+
5144
+
5041
5145
  /**
5042
5146
  * A `CancelToken` is an object that can be used to request cancellation of an operation.
5043
5147
  *
@@ -5154,6 +5258,8 @@ CancelToken.source = function source() {
5154
5258
 
5155
5259
  var CancelToken_1 = CancelToken;
5156
5260
 
5261
+ 'use strict';
5262
+
5157
5263
  /**
5158
5264
  * Syntactic sugar for invoking a function and expanding an array for arguments.
5159
5265
  *
@@ -5180,6 +5286,8 @@ var spread = function spread(callback) {
5180
5286
  };
5181
5287
  };
5182
5288
 
5289
+ 'use strict';
5290
+
5183
5291
  /**
5184
5292
  * Determines whether the payload is an error thrown by Axios
5185
5293
  *
@@ -5190,6 +5298,14 @@ var isAxiosError = function isAxiosError(payload) {
5190
5298
  return (typeof payload === 'object') && (payload.isAxiosError === true);
5191
5299
  };
5192
5300
 
5301
+ 'use strict';
5302
+
5303
+
5304
+
5305
+
5306
+
5307
+
5308
+
5193
5309
  /**
5194
5310
  * Create an instance of Axios
5195
5311
  *
@@ -5243,9 +5359,16 @@ axios_1.default = _default;
5243
5359
 
5244
5360
  var axios = axios_1;
5245
5361
 
5362
+ const timeFormat = 'HH:mm:ss';
5363
+ const timeFormatAmPm = 'hh:mm A';
5364
+ const dateName = 'dddd';
5365
+ const dateFormat = 'YYYY-MM-DD';
5246
5366
  const dateTimeFormat = 'YYYY-MM-DD HH:mm:ss';
5367
+ const dateTimeFormatAmPm = 'YYYY-MM-DD hh:mm A';
5368
+ const shortDateFormat = 'ddd, MMM DD';
5247
5369
  const shortDateYearFormat = 'ddd, MMM DD YYYY';
5248
5370
  const apiV1Prefix = 'api';
5371
+ const apiV2Prefix$1 = 'api-ver2';
5249
5372
  const defaultImage = 'https://res.cloudinary.com/reckon-mini-sites/image/upload/v1636477599/FaveSalon%20Social%20Website/default/default--picture_w3jvfh.png';
5250
5373
 
5251
5374
  var BusinessHourStatus;
@@ -5908,6 +6031,12 @@ const getDefaultEmulatorHostnameAndPort = (productName) => {
5908
6031
  * @public
5909
6032
  */
5910
6033
  const getDefaultAppConfig = () => { var _a; return (_a = getDefaults()) === null || _a === void 0 ? void 0 : _a.config; };
6034
+ /**
6035
+ * Returns an experimental setting on the __FIREBASE_DEFAULTS__ object (properties
6036
+ * prefixed by "_")
6037
+ * @public
6038
+ */
6039
+ const getExperimentalSetting = (name) => { var _a; return (_a = getDefaults()) === null || _a === void 0 ? void 0 : _a[`_${name}`]; };
5911
6040
 
5912
6041
  /**
5913
6042
  * @license
@@ -6053,6 +6182,42 @@ function isMobileCordova() {
6053
6182
  !!(window['cordova'] || window['phonegap'] || window['PhoneGap']) &&
6054
6183
  /ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(getUA()));
6055
6184
  }
6185
+ /**
6186
+ * Detect Node.js.
6187
+ *
6188
+ * @return true if Node.js environment is detected or specified.
6189
+ */
6190
+ // Node detection logic from: https://github.com/iliakan/detect-node/
6191
+ function isNode() {
6192
+ var _a;
6193
+ const forceEnvironment = (_a = getDefaults()) === null || _a === void 0 ? void 0 : _a.forceEnvironment;
6194
+ if (forceEnvironment === 'node') {
6195
+ return true;
6196
+ }
6197
+ else if (forceEnvironment === 'browser') {
6198
+ return false;
6199
+ }
6200
+ try {
6201
+ return (Object.prototype.toString.call(global.process) === '[object process]');
6202
+ }
6203
+ catch (e) {
6204
+ return false;
6205
+ }
6206
+ }
6207
+ /**
6208
+ * Detect Browser Environment
6209
+ */
6210
+ function isBrowser() {
6211
+ return typeof self === 'object' && self.self === self;
6212
+ }
6213
+ function isBrowserExtension() {
6214
+ const runtime = typeof chrome === 'object'
6215
+ ? chrome.runtime
6216
+ : typeof browser === 'object'
6217
+ ? browser.runtime
6218
+ : undefined;
6219
+ return typeof runtime === 'object' && runtime.id !== undefined;
6220
+ }
6056
6221
  /**
6057
6222
  * Detect React Native.
6058
6223
  *
@@ -6061,13 +6226,32 @@ function isMobileCordova() {
6061
6226
  function isReactNative() {
6062
6227
  return (typeof navigator === 'object' && navigator['product'] === 'ReactNative');
6063
6228
  }
6229
+ /** Detects Electron apps. */
6230
+ function isElectron() {
6231
+ return getUA().indexOf('Electron/') >= 0;
6232
+ }
6233
+ /** Detects Internet Explorer. */
6234
+ function isIE() {
6235
+ const ua = getUA();
6236
+ return ua.indexOf('MSIE ') >= 0 || ua.indexOf('Trident/') >= 0;
6237
+ }
6238
+ /** Detects Universal Windows Platform apps. */
6239
+ function isUWP() {
6240
+ return getUA().indexOf('MSAppHost/') >= 0;
6241
+ }
6064
6242
  /**
6065
6243
  * Detect whether the current SDK build is the Node version.
6066
6244
  *
6067
6245
  * @return true if it's the Node SDK build.
6068
6246
  */
6069
6247
  function isNodeSdk() {
6070
- return CONSTANTS.NODE_ADMIN === true;
6248
+ return CONSTANTS.NODE_CLIENT === true || CONSTANTS.NODE_ADMIN === true;
6249
+ }
6250
+ /** Returns true if we are running in Safari. */
6251
+ function isSafari() {
6252
+ return (!isNode() &&
6253
+ navigator.userAgent.includes('Safari') &&
6254
+ !navigator.userAgent.includes('Chrome'));
6071
6255
  }
6072
6256
  /**
6073
6257
  * This method checks if indexedDB is supported by current browser/service worker context
@@ -6115,6 +6299,17 @@ function validateIndexedDBOpenable() {
6115
6299
  }
6116
6300
  });
6117
6301
  }
6302
+ /**
6303
+ *
6304
+ * This method checks whether cookie is enabled within current browser
6305
+ * @return true if cookie is enabled within current browser
6306
+ */
6307
+ function areCookiesEnabled() {
6308
+ if (typeof navigator === 'undefined' || !navigator.cookieEnabled) {
6309
+ return false;
6310
+ }
6311
+ return true;
6312
+ }
6118
6313
 
6119
6314
  /**
6120
6315
  * @license
@@ -6296,6 +6491,53 @@ const decode = function (token) {
6296
6491
  signature
6297
6492
  };
6298
6493
  };
6494
+ /**
6495
+ * Decodes a Firebase auth. token and checks the validity of its time-based claims. Will return true if the
6496
+ * token is within the time window authorized by the 'nbf' (not-before) and 'iat' (issued-at) claims.
6497
+ *
6498
+ * Notes:
6499
+ * - May return a false negative if there's no native base64 decoding support.
6500
+ * - Doesn't check if the token is actually valid.
6501
+ */
6502
+ const isValidTimestamp = function (token) {
6503
+ const claims = decode(token).claims;
6504
+ const now = Math.floor(new Date().getTime() / 1000);
6505
+ let validSince = 0, validUntil = 0;
6506
+ if (typeof claims === 'object') {
6507
+ if (claims.hasOwnProperty('nbf')) {
6508
+ validSince = claims['nbf'];
6509
+ }
6510
+ else if (claims.hasOwnProperty('iat')) {
6511
+ validSince = claims['iat'];
6512
+ }
6513
+ if (claims.hasOwnProperty('exp')) {
6514
+ validUntil = claims['exp'];
6515
+ }
6516
+ else {
6517
+ // token will expire after 24h by default
6518
+ validUntil = validSince + 86400;
6519
+ }
6520
+ }
6521
+ return (!!now &&
6522
+ !!validSince &&
6523
+ !!validUntil &&
6524
+ now >= validSince &&
6525
+ now <= validUntil);
6526
+ };
6527
+ /**
6528
+ * Decodes a Firebase auth. token and returns its issued at time if valid, null otherwise.
6529
+ *
6530
+ * Notes:
6531
+ * - May return null if there's no native base64 decoding support.
6532
+ * - Doesn't check if the token is actually valid.
6533
+ */
6534
+ const issuedAtTime = function (token) {
6535
+ const claims = decode(token).claims;
6536
+ if (typeof claims === 'object' && claims.hasOwnProperty('iat')) {
6537
+ return claims['iat'];
6538
+ }
6539
+ return null;
6540
+ };
6299
6541
  /**
6300
6542
  * Decodes a Firebase auth. token and checks the validity of its format. Expects a valid issued-at time.
6301
6543
  *
@@ -6398,6 +6640,33 @@ function isObject(thing) {
6398
6640
  return thing !== null && typeof thing === 'object';
6399
6641
  }
6400
6642
 
6643
+ /**
6644
+ * @license
6645
+ * Copyright 2022 Google LLC
6646
+ *
6647
+ * Licensed under the Apache License, Version 2.0 (the "License");
6648
+ * you may not use this file except in compliance with the License.
6649
+ * You may obtain a copy of the License at
6650
+ *
6651
+ * http://www.apache.org/licenses/LICENSE-2.0
6652
+ *
6653
+ * Unless required by applicable law or agreed to in writing, software
6654
+ * distributed under the License is distributed on an "AS IS" BASIS,
6655
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6656
+ * See the License for the specific language governing permissions and
6657
+ * limitations under the License.
6658
+ */
6659
+ /**
6660
+ * Rejects if the given promise doesn't resolve in timeInMS milliseconds.
6661
+ * @internal
6662
+ */
6663
+ function promiseWithTimeout(promise, timeInMS = 2000) {
6664
+ const deferredPromise = new Deferred();
6665
+ setTimeout(() => deferredPromise.reject('timeout!'), timeInMS);
6666
+ promise.then(deferredPromise.resolve, deferredPromise.reject);
6667
+ return deferredPromise.promise;
6668
+ }
6669
+
6401
6670
  /**
6402
6671
  * @license
6403
6672
  * Copyright 2017 Google LLC
@@ -6433,6 +6702,32 @@ function querystring(querystringParams) {
6433
6702
  }
6434
6703
  return params.length ? '&' + params.join('&') : '';
6435
6704
  }
6705
+ /**
6706
+ * Decodes a querystring (e.g. ?arg=val&arg2=val2) into a params object
6707
+ * (e.g. {arg: 'val', arg2: 'val2'})
6708
+ */
6709
+ function querystringDecode(querystring) {
6710
+ const obj = {};
6711
+ const tokens = querystring.replace(/^\?/, '').split('&');
6712
+ tokens.forEach(token => {
6713
+ if (token) {
6714
+ const [key, value] = token.split('=');
6715
+ obj[decodeURIComponent(key)] = decodeURIComponent(value);
6716
+ }
6717
+ });
6718
+ return obj;
6719
+ }
6720
+ /**
6721
+ * Extract the query string part of a URL, including the leading question mark (if present).
6722
+ */
6723
+ function extractQuerystring(url) {
6724
+ const queryStart = url.indexOf('?');
6725
+ if (!queryStart) {
6726
+ return '';
6727
+ }
6728
+ const fragmentStart = url.indexOf('#', queryStart);
6729
+ return url.substring(queryStart, fragmentStart > 0 ? fragmentStart : undefined);
6730
+ }
6436
6731
 
6437
6732
  /**
6438
6733
  * @license
@@ -6689,78 +6984,369 @@ class Sha1 {
6689
6984
  return digest;
6690
6985
  }
6691
6986
  }
6692
- /**
6693
- * Generates a string to prefix an error message about failed argument validation
6694
- *
6695
- * @param fnName The function name
6696
- * @param argName The name of the argument
6697
- * @return The prefix to add to the error thrown for validation.
6698
- */
6699
- function errorPrefix(fnName, argName) {
6700
- return `${fnName} failed: ${argName} argument `;
6701
- }
6702
6987
 
6703
6988
  /**
6704
- * @license
6705
- * Copyright 2017 Google LLC
6706
- *
6707
- * Licensed under the Apache License, Version 2.0 (the "License");
6708
- * you may not use this file except in compliance with the License.
6709
- * You may obtain a copy of the License at
6710
- *
6711
- * http://www.apache.org/licenses/LICENSE-2.0
6989
+ * Helper to make a Subscribe function (just like Promise helps make a
6990
+ * Thenable).
6712
6991
  *
6713
- * Unless required by applicable law or agreed to in writing, software
6714
- * distributed under the License is distributed on an "AS IS" BASIS,
6715
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6716
- * See the License for the specific language governing permissions and
6717
- * limitations under the License.
6992
+ * @param executor Function which can make calls to a single Observer
6993
+ * as a proxy.
6994
+ * @param onNoObservers Callback when count of Observers goes to zero.
6718
6995
  */
6719
- // Code originally came from goog.crypt.stringToUtf8ByteArray, but for some reason they
6720
- // automatically replaced '\r\n' with '\n', and they didn't handle surrogate pairs,
6721
- // so it's been modified.
6722
- // Note that not all Unicode characters appear as single characters in JavaScript strings.
6723
- // fromCharCode returns the UTF-16 encoding of a character - so some Unicode characters
6724
- // use 2 characters in Javascript. All 4-byte UTF-8 characters begin with a first
6725
- // character in the range 0xD800 - 0xDBFF (the first character of a so-called surrogate
6726
- // pair).
6727
- // See http://www.ecma-international.org/ecma-262/5.1/#sec-15.1.3
6996
+ function createSubscribe(executor, onNoObservers) {
6997
+ const proxy = new ObserverProxy(executor, onNoObservers);
6998
+ return proxy.subscribe.bind(proxy);
6999
+ }
6728
7000
  /**
6729
- * @param {string} str
6730
- * @return {Array}
7001
+ * Implement fan-out for any number of Observers attached via a subscribe
7002
+ * function.
6731
7003
  */
6732
- const stringToByteArray = function (str) {
6733
- const out = [];
6734
- let p = 0;
6735
- for (let i = 0; i < str.length; i++) {
6736
- let c = str.charCodeAt(i);
6737
- // Is this the lead surrogate in a surrogate pair?
6738
- if (c >= 0xd800 && c <= 0xdbff) {
6739
- const high = c - 0xd800; // the high 10 bits.
6740
- i++;
6741
- assert(i < str.length, 'Surrogate pair missing trail surrogate.');
6742
- const low = str.charCodeAt(i) - 0xdc00; // the low 10 bits.
6743
- c = 0x10000 + (high << 10) + low;
7004
+ class ObserverProxy {
7005
+ /**
7006
+ * @param executor Function which can make calls to a single Observer
7007
+ * as a proxy.
7008
+ * @param onNoObservers Callback when count of Observers goes to zero.
7009
+ */
7010
+ constructor(executor, onNoObservers) {
7011
+ this.observers = [];
7012
+ this.unsubscribes = [];
7013
+ this.observerCount = 0;
7014
+ // Micro-task scheduling by calling task.then().
7015
+ this.task = Promise.resolve();
7016
+ this.finalized = false;
7017
+ this.onNoObservers = onNoObservers;
7018
+ // Call the executor asynchronously so subscribers that are called
7019
+ // synchronously after the creation of the subscribe function
7020
+ // can still receive the very first value generated in the executor.
7021
+ this.task
7022
+ .then(() => {
7023
+ executor(this);
7024
+ })
7025
+ .catch(e => {
7026
+ this.error(e);
7027
+ });
7028
+ }
7029
+ next(value) {
7030
+ this.forEachObserver((observer) => {
7031
+ observer.next(value);
7032
+ });
7033
+ }
7034
+ error(error) {
7035
+ this.forEachObserver((observer) => {
7036
+ observer.error(error);
7037
+ });
7038
+ this.close(error);
7039
+ }
7040
+ complete() {
7041
+ this.forEachObserver((observer) => {
7042
+ observer.complete();
7043
+ });
7044
+ this.close();
7045
+ }
7046
+ /**
7047
+ * Subscribe function that can be used to add an Observer to the fan-out list.
7048
+ *
7049
+ * - We require that no event is sent to a subscriber sychronously to their
7050
+ * call to subscribe().
7051
+ */
7052
+ subscribe(nextOrObserver, error, complete) {
7053
+ let observer;
7054
+ if (nextOrObserver === undefined &&
7055
+ error === undefined &&
7056
+ complete === undefined) {
7057
+ throw new Error('Missing Observer.');
7058
+ }
7059
+ // Assemble an Observer object when passed as callback functions.
7060
+ if (implementsAnyMethods(nextOrObserver, [
7061
+ 'next',
7062
+ 'error',
7063
+ 'complete'
7064
+ ])) {
7065
+ observer = nextOrObserver;
6744
7066
  }
6745
- if (c < 128) {
6746
- out[p++] = c;
7067
+ else {
7068
+ observer = {
7069
+ next: nextOrObserver,
7070
+ error,
7071
+ complete
7072
+ };
6747
7073
  }
6748
- else if (c < 2048) {
6749
- out[p++] = (c >> 6) | 192;
6750
- out[p++] = (c & 63) | 128;
7074
+ if (observer.next === undefined) {
7075
+ observer.next = noop;
6751
7076
  }
6752
- else if (c < 65536) {
6753
- out[p++] = (c >> 12) | 224;
6754
- out[p++] = ((c >> 6) & 63) | 128;
6755
- out[p++] = (c & 63) | 128;
7077
+ if (observer.error === undefined) {
7078
+ observer.error = noop;
6756
7079
  }
6757
- else {
6758
- out[p++] = (c >> 18) | 240;
6759
- out[p++] = ((c >> 12) & 63) | 128;
6760
- out[p++] = ((c >> 6) & 63) | 128;
6761
- out[p++] = (c & 63) | 128;
7080
+ if (observer.complete === undefined) {
7081
+ observer.complete = noop;
6762
7082
  }
6763
- }
7083
+ const unsub = this.unsubscribeOne.bind(this, this.observers.length);
7084
+ // Attempt to subscribe to a terminated Observable - we
7085
+ // just respond to the Observer with the final error or complete
7086
+ // event.
7087
+ if (this.finalized) {
7088
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
7089
+ this.task.then(() => {
7090
+ try {
7091
+ if (this.finalError) {
7092
+ observer.error(this.finalError);
7093
+ }
7094
+ else {
7095
+ observer.complete();
7096
+ }
7097
+ }
7098
+ catch (e) {
7099
+ // nothing
7100
+ }
7101
+ return;
7102
+ });
7103
+ }
7104
+ this.observers.push(observer);
7105
+ return unsub;
7106
+ }
7107
+ // Unsubscribe is synchronous - we guarantee that no events are sent to
7108
+ // any unsubscribed Observer.
7109
+ unsubscribeOne(i) {
7110
+ if (this.observers === undefined || this.observers[i] === undefined) {
7111
+ return;
7112
+ }
7113
+ delete this.observers[i];
7114
+ this.observerCount -= 1;
7115
+ if (this.observerCount === 0 && this.onNoObservers !== undefined) {
7116
+ this.onNoObservers(this);
7117
+ }
7118
+ }
7119
+ forEachObserver(fn) {
7120
+ if (this.finalized) {
7121
+ // Already closed by previous event....just eat the additional values.
7122
+ return;
7123
+ }
7124
+ // Since sendOne calls asynchronously - there is no chance that
7125
+ // this.observers will become undefined.
7126
+ for (let i = 0; i < this.observers.length; i++) {
7127
+ this.sendOne(i, fn);
7128
+ }
7129
+ }
7130
+ // Call the Observer via one of it's callback function. We are careful to
7131
+ // confirm that the observe has not been unsubscribed since this asynchronous
7132
+ // function had been queued.
7133
+ sendOne(i, fn) {
7134
+ // Execute the callback asynchronously
7135
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
7136
+ this.task.then(() => {
7137
+ if (this.observers !== undefined && this.observers[i] !== undefined) {
7138
+ try {
7139
+ fn(this.observers[i]);
7140
+ }
7141
+ catch (e) {
7142
+ // Ignore exceptions raised in Observers or missing methods of an
7143
+ // Observer.
7144
+ // Log error to console. b/31404806
7145
+ if (typeof console !== 'undefined' && console.error) {
7146
+ console.error(e);
7147
+ }
7148
+ }
7149
+ }
7150
+ });
7151
+ }
7152
+ close(err) {
7153
+ if (this.finalized) {
7154
+ return;
7155
+ }
7156
+ this.finalized = true;
7157
+ if (err !== undefined) {
7158
+ this.finalError = err;
7159
+ }
7160
+ // Proxy is no longer needed - garbage collect references
7161
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
7162
+ this.task.then(() => {
7163
+ this.observers = undefined;
7164
+ this.onNoObservers = undefined;
7165
+ });
7166
+ }
7167
+ }
7168
+ /** Turn synchronous function into one called asynchronously. */
7169
+ // eslint-disable-next-line @typescript-eslint/ban-types
7170
+ function async(fn, onError) {
7171
+ return (...args) => {
7172
+ Promise.resolve(true)
7173
+ .then(() => {
7174
+ fn(...args);
7175
+ })
7176
+ .catch((error) => {
7177
+ if (onError) {
7178
+ onError(error);
7179
+ }
7180
+ });
7181
+ };
7182
+ }
7183
+ /**
7184
+ * Return true if the object passed in implements any of the named methods.
7185
+ */
7186
+ function implementsAnyMethods(obj, methods) {
7187
+ if (typeof obj !== 'object' || obj === null) {
7188
+ return false;
7189
+ }
7190
+ for (const method of methods) {
7191
+ if (method in obj && typeof obj[method] === 'function') {
7192
+ return true;
7193
+ }
7194
+ }
7195
+ return false;
7196
+ }
7197
+ function noop() {
7198
+ // do nothing
7199
+ }
7200
+
7201
+ /**
7202
+ * @license
7203
+ * Copyright 2017 Google LLC
7204
+ *
7205
+ * Licensed under the Apache License, Version 2.0 (the "License");
7206
+ * you may not use this file except in compliance with the License.
7207
+ * You may obtain a copy of the License at
7208
+ *
7209
+ * http://www.apache.org/licenses/LICENSE-2.0
7210
+ *
7211
+ * Unless required by applicable law or agreed to in writing, software
7212
+ * distributed under the License is distributed on an "AS IS" BASIS,
7213
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7214
+ * See the License for the specific language governing permissions and
7215
+ * limitations under the License.
7216
+ */
7217
+ /**
7218
+ * Check to make sure the appropriate number of arguments are provided for a public function.
7219
+ * Throws an error if it fails.
7220
+ *
7221
+ * @param fnName The function name
7222
+ * @param minCount The minimum number of arguments to allow for the function call
7223
+ * @param maxCount The maximum number of argument to allow for the function call
7224
+ * @param argCount The actual number of arguments provided.
7225
+ */
7226
+ const validateArgCount = function (fnName, minCount, maxCount, argCount) {
7227
+ let argError;
7228
+ if (argCount < minCount) {
7229
+ argError = 'at least ' + minCount;
7230
+ }
7231
+ else if (argCount > maxCount) {
7232
+ argError = maxCount === 0 ? 'none' : 'no more than ' + maxCount;
7233
+ }
7234
+ if (argError) {
7235
+ const error = fnName +
7236
+ ' failed: Was called with ' +
7237
+ argCount +
7238
+ (argCount === 1 ? ' argument.' : ' arguments.') +
7239
+ ' Expects ' +
7240
+ argError +
7241
+ '.';
7242
+ throw new Error(error);
7243
+ }
7244
+ };
7245
+ /**
7246
+ * Generates a string to prefix an error message about failed argument validation
7247
+ *
7248
+ * @param fnName The function name
7249
+ * @param argName The name of the argument
7250
+ * @return The prefix to add to the error thrown for validation.
7251
+ */
7252
+ function errorPrefix(fnName, argName) {
7253
+ return `${fnName} failed: ${argName} argument `;
7254
+ }
7255
+ /**
7256
+ * @param fnName
7257
+ * @param argumentNumber
7258
+ * @param namespace
7259
+ * @param optional
7260
+ */
7261
+ function validateNamespace(fnName, namespace, optional) {
7262
+ if (optional && !namespace) {
7263
+ return;
7264
+ }
7265
+ if (typeof namespace !== 'string') {
7266
+ //TODO: I should do more validation here. We only allow certain chars in namespaces.
7267
+ throw new Error(errorPrefix(fnName, 'namespace') + 'must be a valid firebase namespace.');
7268
+ }
7269
+ }
7270
+ function validateCallback(fnName, argumentName,
7271
+ // eslint-disable-next-line @typescript-eslint/ban-types
7272
+ callback, optional) {
7273
+ if (optional && !callback) {
7274
+ return;
7275
+ }
7276
+ if (typeof callback !== 'function') {
7277
+ throw new Error(errorPrefix(fnName, argumentName) + 'must be a valid function.');
7278
+ }
7279
+ }
7280
+ function validateContextObject(fnName, argumentName, context, optional) {
7281
+ if (optional && !context) {
7282
+ return;
7283
+ }
7284
+ if (typeof context !== 'object' || context === null) {
7285
+ throw new Error(errorPrefix(fnName, argumentName) + 'must be a valid context object.');
7286
+ }
7287
+ }
7288
+
7289
+ /**
7290
+ * @license
7291
+ * Copyright 2017 Google LLC
7292
+ *
7293
+ * Licensed under the Apache License, Version 2.0 (the "License");
7294
+ * you may not use this file except in compliance with the License.
7295
+ * You may obtain a copy of the License at
7296
+ *
7297
+ * http://www.apache.org/licenses/LICENSE-2.0
7298
+ *
7299
+ * Unless required by applicable law or agreed to in writing, software
7300
+ * distributed under the License is distributed on an "AS IS" BASIS,
7301
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7302
+ * See the License for the specific language governing permissions and
7303
+ * limitations under the License.
7304
+ */
7305
+ // Code originally came from goog.crypt.stringToUtf8ByteArray, but for some reason they
7306
+ // automatically replaced '\r\n' with '\n', and they didn't handle surrogate pairs,
7307
+ // so it's been modified.
7308
+ // Note that not all Unicode characters appear as single characters in JavaScript strings.
7309
+ // fromCharCode returns the UTF-16 encoding of a character - so some Unicode characters
7310
+ // use 2 characters in Javascript. All 4-byte UTF-8 characters begin with a first
7311
+ // character in the range 0xD800 - 0xDBFF (the first character of a so-called surrogate
7312
+ // pair).
7313
+ // See http://www.ecma-international.org/ecma-262/5.1/#sec-15.1.3
7314
+ /**
7315
+ * @param {string} str
7316
+ * @return {Array}
7317
+ */
7318
+ const stringToByteArray = function (str) {
7319
+ const out = [];
7320
+ let p = 0;
7321
+ for (let i = 0; i < str.length; i++) {
7322
+ let c = str.charCodeAt(i);
7323
+ // Is this the lead surrogate in a surrogate pair?
7324
+ if (c >= 0xd800 && c <= 0xdbff) {
7325
+ const high = c - 0xd800; // the high 10 bits.
7326
+ i++;
7327
+ assert(i < str.length, 'Surrogate pair missing trail surrogate.');
7328
+ const low = str.charCodeAt(i) - 0xdc00; // the low 10 bits.
7329
+ c = 0x10000 + (high << 10) + low;
7330
+ }
7331
+ if (c < 128) {
7332
+ out[p++] = c;
7333
+ }
7334
+ else if (c < 2048) {
7335
+ out[p++] = (c >> 6) | 192;
7336
+ out[p++] = (c & 63) | 128;
7337
+ }
7338
+ else if (c < 65536) {
7339
+ out[p++] = (c >> 12) | 224;
7340
+ out[p++] = ((c >> 6) & 63) | 128;
7341
+ out[p++] = (c & 63) | 128;
7342
+ }
7343
+ else {
7344
+ out[p++] = (c >> 18) | 240;
7345
+ out[p++] = ((c >> 12) & 63) | 128;
7346
+ out[p++] = ((c >> 6) & 63) | 128;
7347
+ out[p++] = (c & 63) | 128;
7348
+ }
7349
+ }
6764
7350
  return out;
6765
7351
  };
6766
7352
  /**
@@ -6790,6 +7376,143 @@ const stringLength = function (str) {
6790
7376
  return p;
6791
7377
  };
6792
7378
 
7379
+ /**
7380
+ * @license
7381
+ * Copyright 2022 Google LLC
7382
+ *
7383
+ * Licensed under the Apache License, Version 2.0 (the "License");
7384
+ * you may not use this file except in compliance with the License.
7385
+ * You may obtain a copy of the License at
7386
+ *
7387
+ * http://www.apache.org/licenses/LICENSE-2.0
7388
+ *
7389
+ * Unless required by applicable law or agreed to in writing, software
7390
+ * distributed under the License is distributed on an "AS IS" BASIS,
7391
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7392
+ * See the License for the specific language governing permissions and
7393
+ * limitations under the License.
7394
+ */
7395
+ /**
7396
+ * Copied from https://stackoverflow.com/a/2117523
7397
+ * Generates a new uuid.
7398
+ * @public
7399
+ */
7400
+ const uuidv4 = function () {
7401
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
7402
+ const r = (Math.random() * 16) | 0, v = c === 'x' ? r : (r & 0x3) | 0x8;
7403
+ return v.toString(16);
7404
+ });
7405
+ };
7406
+
7407
+ /**
7408
+ * @license
7409
+ * Copyright 2019 Google LLC
7410
+ *
7411
+ * Licensed under the Apache License, Version 2.0 (the "License");
7412
+ * you may not use this file except in compliance with the License.
7413
+ * You may obtain a copy of the License at
7414
+ *
7415
+ * http://www.apache.org/licenses/LICENSE-2.0
7416
+ *
7417
+ * Unless required by applicable law or agreed to in writing, software
7418
+ * distributed under the License is distributed on an "AS IS" BASIS,
7419
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7420
+ * See the License for the specific language governing permissions and
7421
+ * limitations under the License.
7422
+ */
7423
+ /**
7424
+ * The amount of milliseconds to exponentially increase.
7425
+ */
7426
+ const DEFAULT_INTERVAL_MILLIS = 1000;
7427
+ /**
7428
+ * The factor to backoff by.
7429
+ * Should be a number greater than 1.
7430
+ */
7431
+ const DEFAULT_BACKOFF_FACTOR = 2;
7432
+ /**
7433
+ * The maximum milliseconds to increase to.
7434
+ *
7435
+ * <p>Visible for testing
7436
+ */
7437
+ const MAX_VALUE_MILLIS = 4 * 60 * 60 * 1000; // Four hours, like iOS and Android.
7438
+ /**
7439
+ * The percentage of backoff time to randomize by.
7440
+ * See
7441
+ * http://go/safe-client-behavior#step-1-determine-the-appropriate-retry-interval-to-handle-spike-traffic
7442
+ * for context.
7443
+ *
7444
+ * <p>Visible for testing
7445
+ */
7446
+ const RANDOM_FACTOR = 0.5;
7447
+ /**
7448
+ * Based on the backoff method from
7449
+ * https://github.com/google/closure-library/blob/master/closure/goog/math/exponentialbackoff.js.
7450
+ * Extracted here so we don't need to pass metadata and a stateful ExponentialBackoff object around.
7451
+ */
7452
+ function calculateBackoffMillis(backoffCount, intervalMillis = DEFAULT_INTERVAL_MILLIS, backoffFactor = DEFAULT_BACKOFF_FACTOR) {
7453
+ // Calculates an exponentially increasing value.
7454
+ // Deviation: calculates value from count and a constant interval, so we only need to save value
7455
+ // and count to restore state.
7456
+ const currBaseValue = intervalMillis * Math.pow(backoffFactor, backoffCount);
7457
+ // A random "fuzz" to avoid waves of retries.
7458
+ // Deviation: randomFactor is required.
7459
+ const randomWait = Math.round(
7460
+ // A fraction of the backoff value to add/subtract.
7461
+ // Deviation: changes multiplication order to improve readability.
7462
+ RANDOM_FACTOR *
7463
+ currBaseValue *
7464
+ // A random float (rounded to int by Math.round above) in the range [-1, 1]. Determines
7465
+ // if we add or subtract.
7466
+ (Math.random() - 0.5) *
7467
+ 2);
7468
+ // Limits backoff to max to avoid effectively permanent backoff.
7469
+ return Math.min(MAX_VALUE_MILLIS, currBaseValue + randomWait);
7470
+ }
7471
+
7472
+ /**
7473
+ * @license
7474
+ * Copyright 2020 Google LLC
7475
+ *
7476
+ * Licensed under the Apache License, Version 2.0 (the "License");
7477
+ * you may not use this file except in compliance with the License.
7478
+ * You may obtain a copy of the License at
7479
+ *
7480
+ * http://www.apache.org/licenses/LICENSE-2.0
7481
+ *
7482
+ * Unless required by applicable law or agreed to in writing, software
7483
+ * distributed under the License is distributed on an "AS IS" BASIS,
7484
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7485
+ * See the License for the specific language governing permissions and
7486
+ * limitations under the License.
7487
+ */
7488
+ /**
7489
+ * Provide English ordinal letters after a number
7490
+ */
7491
+ function ordinal(i) {
7492
+ if (!Number.isFinite(i)) {
7493
+ return `${i}`;
7494
+ }
7495
+ return i + indicator(i);
7496
+ }
7497
+ function indicator(i) {
7498
+ i = Math.abs(i);
7499
+ const cent = i % 100;
7500
+ if (cent >= 10 && cent <= 20) {
7501
+ return 'th';
7502
+ }
7503
+ const dec = i % 10;
7504
+ if (dec === 1) {
7505
+ return 'st';
7506
+ }
7507
+ if (dec === 2) {
7508
+ return 'nd';
7509
+ }
7510
+ if (dec === 3) {
7511
+ return 'rd';
7512
+ }
7513
+ return 'th';
7514
+ }
7515
+
6793
7516
  /**
6794
7517
  * @license
6795
7518
  * Copyright 2021 Google LLC
@@ -7236,6 +7959,10 @@ class ComponentContainer {
7236
7959
  * See the License for the specific language governing permissions and
7237
7960
  * limitations under the License.
7238
7961
  */
7962
+ /**
7963
+ * A container for all of the Logger instances
7964
+ */
7965
+ const instances = [];
7239
7966
  /**
7240
7967
  * The JS SDK supports 5 log levels and also allows a user the ability to
7241
7968
  * silence the logs altogether.
@@ -7321,6 +8048,10 @@ class Logger {
7321
8048
  * The optional, additional, user-defined log handler for the Logger instance.
7322
8049
  */
7323
8050
  this._userLogHandler = null;
8051
+ /**
8052
+ * Capture the current instance for later use
8053
+ */
8054
+ instances.push(this);
7324
8055
  }
7325
8056
  get logLevel() {
7326
8057
  return this._logLevel;
@@ -7374,26 +8105,79 @@ class Logger {
7374
8105
  this._userLogHandler && this._userLogHandler(this, LogLevel.ERROR, ...args);
7375
8106
  this._logHandler(this, LogLevel.ERROR, ...args);
7376
8107
  }
7377
- }
7378
-
7379
- const instanceOfAny = (object, constructors) => constructors.some((c) => object instanceof c);
7380
-
7381
- let idbProxyableTypes;
7382
- let cursorAdvanceMethods;
7383
- // This is a function to prevent it throwing up in node environments.
7384
- function getIdbProxyableTypes() {
7385
- return (idbProxyableTypes ||
7386
- (idbProxyableTypes = [
7387
- IDBDatabase,
7388
- IDBObjectStore,
7389
- IDBIndex,
7390
- IDBCursor,
7391
- IDBTransaction,
7392
- ]));
7393
- }
7394
- // This is a function to prevent it throwing up in node environments.
7395
- function getCursorAdvanceMethods() {
7396
- return (cursorAdvanceMethods ||
8108
+ }
8109
+ function setLogLevel$1(level) {
8110
+ instances.forEach(inst => {
8111
+ inst.setLogLevel(level);
8112
+ });
8113
+ }
8114
+ function setUserLogHandler(logCallback, options) {
8115
+ for (const instance of instances) {
8116
+ let customLogLevel = null;
8117
+ if (options && options.level) {
8118
+ customLogLevel = levelStringToEnum[options.level];
8119
+ }
8120
+ if (logCallback === null) {
8121
+ instance.userLogHandler = null;
8122
+ }
8123
+ else {
8124
+ instance.userLogHandler = (instance, level, ...args) => {
8125
+ const message = args
8126
+ .map(arg => {
8127
+ if (arg == null) {
8128
+ return null;
8129
+ }
8130
+ else if (typeof arg === 'string') {
8131
+ return arg;
8132
+ }
8133
+ else if (typeof arg === 'number' || typeof arg === 'boolean') {
8134
+ return arg.toString();
8135
+ }
8136
+ else if (arg instanceof Error) {
8137
+ return arg.message;
8138
+ }
8139
+ else {
8140
+ try {
8141
+ return JSON.stringify(arg);
8142
+ }
8143
+ catch (ignored) {
8144
+ return null;
8145
+ }
8146
+ }
8147
+ })
8148
+ .filter(arg => arg)
8149
+ .join(' ');
8150
+ if (level >= (customLogLevel !== null && customLogLevel !== void 0 ? customLogLevel : instance.logLevel)) {
8151
+ logCallback({
8152
+ level: LogLevel[level].toLowerCase(),
8153
+ message,
8154
+ args,
8155
+ type: instance.name
8156
+ });
8157
+ }
8158
+ };
8159
+ }
8160
+ }
8161
+ }
8162
+
8163
+ const instanceOfAny = (object, constructors) => constructors.some((c) => object instanceof c);
8164
+
8165
+ let idbProxyableTypes;
8166
+ let cursorAdvanceMethods;
8167
+ // This is a function to prevent it throwing up in node environments.
8168
+ function getIdbProxyableTypes() {
8169
+ return (idbProxyableTypes ||
8170
+ (idbProxyableTypes = [
8171
+ IDBDatabase,
8172
+ IDBObjectStore,
8173
+ IDBIndex,
8174
+ IDBCursor,
8175
+ IDBTransaction,
8176
+ ]));
8177
+ }
8178
+ // This is a function to prevent it throwing up in node environments.
8179
+ function getCursorAdvanceMethods() {
8180
+ return (cursorAdvanceMethods ||
7397
8181
  (cursorAdvanceMethods = [
7398
8182
  IDBCursor.prototype.advance,
7399
8183
  IDBCursor.prototype.continue,
@@ -7591,6 +8375,20 @@ function openDB(name, version, { blocked, upgrade, blocking, terminated } = {})
7591
8375
  .catch(() => { });
7592
8376
  return openPromise;
7593
8377
  }
8378
+ /**
8379
+ * Delete a database.
8380
+ *
8381
+ * @param name Name of the database.
8382
+ */
8383
+ function deleteDB(name, { blocked } = {}) {
8384
+ const request = indexedDB.deleteDatabase(name);
8385
+ if (blocked) {
8386
+ request.addEventListener('blocked', (event) => blocked(
8387
+ // Casting due to https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1405
8388
+ event.oldVersion, event));
8389
+ }
8390
+ return wrap(request).then(() => undefined);
8391
+ }
7594
8392
 
7595
8393
  const readMethods = ['get', 'getKey', 'getAll', 'getAllKeys', 'count'];
7596
8394
  const writeMethods = ['put', 'add', 'delete', 'clear'];
@@ -7851,6 +8649,13 @@ function _addComponent(app, component) {
7851
8649
  logger$1.debug(`Component ${component.name} failed to register with FirebaseApp ${app.name}`, e);
7852
8650
  }
7853
8651
  }
8652
+ /**
8653
+ *
8654
+ * @internal
8655
+ */
8656
+ function _addOrOverwriteComponent(app, component) {
8657
+ app.container.addOrOverwriteComponent(component);
8658
+ }
7854
8659
  /**
7855
8660
  *
7856
8661
  * @param component - the component to register
@@ -7889,6 +8694,25 @@ function _getProvider(app, name) {
7889
8694
  }
7890
8695
  return app.container.getProvider(name);
7891
8696
  }
8697
+ /**
8698
+ *
8699
+ * @param app - FirebaseApp instance
8700
+ * @param name - service name
8701
+ * @param instanceIdentifier - service instance identifier in case the service supports multiple instances
8702
+ *
8703
+ * @internal
8704
+ */
8705
+ function _removeServiceInstance(app, name, instanceIdentifier = DEFAULT_ENTRY_NAME) {
8706
+ _getProvider(app, name).clearInstance(instanceIdentifier);
8707
+ }
8708
+ /**
8709
+ * Test only
8710
+ *
8711
+ * @internal
8712
+ */
8713
+ function _clearComponents() {
8714
+ _components.clear();
8715
+ }
7892
8716
 
7893
8717
  /**
7894
8718
  * @license
@@ -8087,6 +8911,40 @@ function getApp(name = DEFAULT_ENTRY_NAME) {
8087
8911
  }
8088
8912
  return app;
8089
8913
  }
8914
+ /**
8915
+ * A (read-only) array of all initialized apps.
8916
+ * @public
8917
+ */
8918
+ function getApps() {
8919
+ return Array.from(_apps.values());
8920
+ }
8921
+ /**
8922
+ * Renders this app unusable and frees the resources of all associated
8923
+ * services.
8924
+ *
8925
+ * @example
8926
+ * ```javascript
8927
+ * deleteApp(app)
8928
+ * .then(function() {
8929
+ * console.log("App deleted successfully");
8930
+ * })
8931
+ * .catch(function(error) {
8932
+ * console.log("Error deleting app:", error);
8933
+ * });
8934
+ * ```
8935
+ *
8936
+ * @public
8937
+ */
8938
+ async function deleteApp(app) {
8939
+ const name = app.name;
8940
+ if (_apps.has(name)) {
8941
+ _apps.delete(name);
8942
+ await Promise.all(app.container
8943
+ .getProviders()
8944
+ .map(provider => provider.delete()));
8945
+ app.isDeleted = true;
8946
+ }
8947
+ }
8090
8948
  /**
8091
8949
  * Registers a library's name and version for platform logging purposes.
8092
8950
  * @param library - Name of 1p or 3p library (e.g. firestore, angularfire)
@@ -8123,6 +8981,31 @@ function registerVersion(libraryKeyOrName, version, variant) {
8123
8981
  }
8124
8982
  _registerComponent(new Component(`${library}-version`, () => ({ library, version }), "VERSION" /* ComponentType.VERSION */));
8125
8983
  }
8984
+ /**
8985
+ * Sets log handler for all Firebase SDKs.
8986
+ * @param logCallback - An optional custom log handler that executes user code whenever
8987
+ * the Firebase SDK makes a logging call.
8988
+ *
8989
+ * @public
8990
+ */
8991
+ function onLog(logCallback, options) {
8992
+ if (logCallback !== null && typeof logCallback !== 'function') {
8993
+ throw ERROR_FACTORY.create("invalid-log-argument" /* AppError.INVALID_LOG_ARGUMENT */);
8994
+ }
8995
+ setUserLogHandler(logCallback, options);
8996
+ }
8997
+ /**
8998
+ * Sets log level for all Firebase SDKs.
8999
+ *
9000
+ * All of the log types above the current log level are captured (i.e. if
9001
+ * you set the log level to `info`, errors are logged, but `debug` and
9002
+ * `verbose` logs are not).
9003
+ *
9004
+ * @public
9005
+ */
9006
+ function setLogLevel(logLevel) {
9007
+ setLogLevel$1(logLevel);
9008
+ }
8126
9009
 
8127
9010
  /**
8128
9011
  * @license
@@ -8832,7 +9715,7 @@ const isInvalidJSONNumber = function (data) {
8832
9715
  data === Number.NEGATIVE_INFINITY));
8833
9716
  };
8834
9717
  const executeWhenDOMReady = function (fn) {
8835
- if (document.readyState === 'complete') {
9718
+ if (isNodeSdk() || document.readyState === 'complete') {
8836
9719
  fn();
8837
9720
  }
8838
9721
  else {
@@ -9844,7 +10727,10 @@ class BrowserPollConnection {
9844
10727
  }
9845
10728
  // Static method, use string literal so it can be accessed in a generic way
9846
10729
  static isAvailable() {
9847
- if (BrowserPollConnection.forceAllow_) {
10730
+ if (isNodeSdk()) {
10731
+ return false;
10732
+ }
10733
+ else if (BrowserPollConnection.forceAllow_) {
9848
10734
  return true;
9849
10735
  }
9850
10736
  else {
@@ -9930,6 +10816,9 @@ class BrowserPollConnection {
9930
10816
  * trigger XHR requests in some browsers (everything but Opera basically).
9931
10817
  */
9932
10818
  addDisconnectPingFrame(id, pw) {
10819
+ if (isNodeSdk()) {
10820
+ return;
10821
+ }
9933
10822
  this.myDisconnFrame = document.createElement('iframe');
9934
10823
  const urlParams = {};
9935
10824
  urlParams[FIREBASE_LONGPOLL_DISCONN_FRAME_REQUEST_PARAM] = 't';
@@ -9976,7 +10865,7 @@ class FirebaseIFrameScriptHolder {
9976
10865
  // This gets set to false when we're "closing down" the connection (e.g. we're switching transports but there's still
9977
10866
  // incoming data from the server that we're waiting for).
9978
10867
  this.sendNewPolls = true;
9979
- {
10868
+ if (!isNodeSdk()) {
9980
10869
  //Each script holder registers a couple of uniquely named callbacks with the window. These are called from the
9981
10870
  //iframes where we put the long-polling script tags. We have two callbacks:
9982
10871
  // 1) Command Callback - Triggered for control issues, like starting a connection.
@@ -10010,6 +10899,10 @@ class FirebaseIFrameScriptHolder {
10010
10899
  log(e);
10011
10900
  }
10012
10901
  }
10902
+ else {
10903
+ this.commandCB = commandCB;
10904
+ this.onMessageCB = onMessageCB;
10905
+ }
10013
10906
  }
10014
10907
  /**
10015
10908
  * Each browser has its own funny way to handle iframes. Here we mush them all together into one object that I can
@@ -10203,7 +11096,11 @@ class FirebaseIFrameScriptHolder {
10203
11096
  * @param loadCB - A callback to be triggered once the script has loaded.
10204
11097
  */
10205
11098
  addTag(url, loadCB) {
10206
- {
11099
+ if (isNodeSdk()) {
11100
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
11101
+ this.doNodeLongPoll(url, loadCB);
11102
+ }
11103
+ else {
10207
11104
  setTimeout(() => {
10208
11105
  try {
10209
11106
  // if we're already closed, don't add this poll
@@ -10308,7 +11205,8 @@ class WebSocketConnection {
10308
11205
  static connectionURL_(repoInfo, transportSessionId, lastSessionId, appCheckToken, applicationId) {
10309
11206
  const urlParams = {};
10310
11207
  urlParams[VERSION_PARAM] = PROTOCOL_VERSION;
10311
- if (typeof location !== 'undefined' &&
11208
+ if (!isNodeSdk() &&
11209
+ typeof location !== 'undefined' &&
10312
11210
  location.hostname &&
10313
11211
  FORGE_DOMAIN_RE.test(location.hostname)) {
10314
11212
  urlParams[REFERER_PARAM] = FORGE_REF;
@@ -10340,6 +11238,35 @@ class WebSocketConnection {
10340
11238
  PersistentStorage.set('previous_websocket_failure', true);
10341
11239
  try {
10342
11240
  let options;
11241
+ if (isNodeSdk()) {
11242
+ const device = this.nodeAdmin ? 'AdminNode' : 'Node';
11243
+ // UA Format: Firebase/<wire_protocol>/<sdk_version>/<platform>/<device>
11244
+ options = {
11245
+ headers: {
11246
+ 'User-Agent': `Firebase/${PROTOCOL_VERSION}/${SDK_VERSION}/${process.platform}/${device}`,
11247
+ 'X-Firebase-GMPID': this.applicationId || ''
11248
+ }
11249
+ };
11250
+ // If using Node with admin creds, AppCheck-related checks are unnecessary.
11251
+ // Note that we send the credentials here even if they aren't admin credentials, which is
11252
+ // not a problem.
11253
+ // Note that this header is just used to bypass appcheck, and the token should still be sent
11254
+ // through the websocket connection once it is established.
11255
+ if (this.authToken) {
11256
+ options.headers['Authorization'] = `Bearer ${this.authToken}`;
11257
+ }
11258
+ if (this.appCheckToken) {
11259
+ options.headers['X-Firebase-AppCheck'] = this.appCheckToken;
11260
+ }
11261
+ // Plumb appropriate http_proxy environment variable into faye-websocket if it exists.
11262
+ const env = process['env'];
11263
+ const proxy = this.connURL.indexOf('wss://') === 0
11264
+ ? env['HTTPS_PROXY'] || env['https_proxy']
11265
+ : env['HTTP_PROXY'] || env['http_proxy'];
11266
+ if (proxy) {
11267
+ options['proxy'] = { origin: proxy };
11268
+ }
11269
+ }
10343
11270
  this.mySock = new WebSocketImpl(this.connURL, [], options);
10344
11271
  }
10345
11272
  catch (e) {
@@ -12414,6 +13341,14 @@ class PersistentConnection extends ServerActions {
12414
13341
  sendConnectStats_() {
12415
13342
  const stats = {};
12416
13343
  let clientName = 'js';
13344
+ if (isNodeSdk()) {
13345
+ if (this.repoInfo_.nodeAdmin) {
13346
+ clientName = 'admin_node';
13347
+ }
13348
+ else {
13349
+ clientName = 'node';
13350
+ }
13351
+ }
12417
13352
  stats['sdk.' + clientName + '.' + SDK_VERSION.replace(/\./g, '-')] = 1;
12418
13353
  if (isMobileCordova()) {
12419
13354
  stats['framework.cordova'] = 1;
@@ -15009,6 +15944,81 @@ function queryParamsGetNodeFilter(queryParams) {
15009
15944
  return new RangedFilter(queryParams);
15010
15945
  }
15011
15946
  }
15947
+ function queryParamsLimitToFirst(queryParams, newLimit) {
15948
+ const newParams = queryParams.copy();
15949
+ newParams.limitSet_ = true;
15950
+ newParams.limit_ = newLimit;
15951
+ newParams.viewFrom_ = "l" /* WIRE_PROTOCOL_CONSTANTS.VIEW_FROM_LEFT */;
15952
+ return newParams;
15953
+ }
15954
+ function queryParamsLimitToLast(queryParams, newLimit) {
15955
+ const newParams = queryParams.copy();
15956
+ newParams.limitSet_ = true;
15957
+ newParams.limit_ = newLimit;
15958
+ newParams.viewFrom_ = "r" /* WIRE_PROTOCOL_CONSTANTS.VIEW_FROM_RIGHT */;
15959
+ return newParams;
15960
+ }
15961
+ function queryParamsStartAt(queryParams, indexValue, key) {
15962
+ const newParams = queryParams.copy();
15963
+ newParams.startSet_ = true;
15964
+ if (indexValue === undefined) {
15965
+ indexValue = null;
15966
+ }
15967
+ newParams.indexStartValue_ = indexValue;
15968
+ if (key != null) {
15969
+ newParams.startNameSet_ = true;
15970
+ newParams.indexStartName_ = key;
15971
+ }
15972
+ else {
15973
+ newParams.startNameSet_ = false;
15974
+ newParams.indexStartName_ = '';
15975
+ }
15976
+ return newParams;
15977
+ }
15978
+ function queryParamsStartAfter(queryParams, indexValue, key) {
15979
+ let params;
15980
+ if (queryParams.index_ === KEY_INDEX || !!key) {
15981
+ params = queryParamsStartAt(queryParams, indexValue, key);
15982
+ }
15983
+ else {
15984
+ params = queryParamsStartAt(queryParams, indexValue, MAX_NAME);
15985
+ }
15986
+ params.startAfterSet_ = true;
15987
+ return params;
15988
+ }
15989
+ function queryParamsEndAt(queryParams, indexValue, key) {
15990
+ const newParams = queryParams.copy();
15991
+ newParams.endSet_ = true;
15992
+ if (indexValue === undefined) {
15993
+ indexValue = null;
15994
+ }
15995
+ newParams.indexEndValue_ = indexValue;
15996
+ if (key !== undefined) {
15997
+ newParams.endNameSet_ = true;
15998
+ newParams.indexEndName_ = key;
15999
+ }
16000
+ else {
16001
+ newParams.endNameSet_ = false;
16002
+ newParams.indexEndName_ = '';
16003
+ }
16004
+ return newParams;
16005
+ }
16006
+ function queryParamsEndBefore(queryParams, indexValue, key) {
16007
+ let params;
16008
+ if (queryParams.index_ === KEY_INDEX || !!key) {
16009
+ params = queryParamsEndAt(queryParams, indexValue, key);
16010
+ }
16011
+ else {
16012
+ params = queryParamsEndAt(queryParams, indexValue, MIN_NAME);
16013
+ }
16014
+ params.endBeforeSet_ = true;
16015
+ return params;
16016
+ }
16017
+ function queryParamsOrderBy(queryParams, index) {
16018
+ const newParams = queryParams.copy();
16019
+ newParams.index_ = index;
16020
+ return newParams;
16021
+ }
15012
16022
  /**
15013
16023
  * Returns a set of REST query string parameters representing this query.
15014
16024
  *
@@ -15356,6 +16366,49 @@ function sparseSnapshotTreeRemember(sparseSnapshotTree, path, data) {
15356
16366
  sparseSnapshotTreeRemember(child, path, data);
15357
16367
  }
15358
16368
  }
16369
+ /**
16370
+ * Purge the data at path from the cache.
16371
+ *
16372
+ * @param path - Path to look up snapshot for.
16373
+ * @returns True if this node should now be removed.
16374
+ */
16375
+ function sparseSnapshotTreeForget(sparseSnapshotTree, path) {
16376
+ if (pathIsEmpty(path)) {
16377
+ sparseSnapshotTree.value = null;
16378
+ sparseSnapshotTree.children.clear();
16379
+ return true;
16380
+ }
16381
+ else {
16382
+ if (sparseSnapshotTree.value !== null) {
16383
+ if (sparseSnapshotTree.value.isLeafNode()) {
16384
+ // We're trying to forget a node that doesn't exist
16385
+ return false;
16386
+ }
16387
+ else {
16388
+ const value = sparseSnapshotTree.value;
16389
+ sparseSnapshotTree.value = null;
16390
+ value.forEachChild(PRIORITY_INDEX, (key, tree) => {
16391
+ sparseSnapshotTreeRemember(sparseSnapshotTree, new Path(key), tree);
16392
+ });
16393
+ return sparseSnapshotTreeForget(sparseSnapshotTree, path);
16394
+ }
16395
+ }
16396
+ else if (sparseSnapshotTree.children.size > 0) {
16397
+ const childKey = pathGetFront(path);
16398
+ path = pathPopFront(path);
16399
+ if (sparseSnapshotTree.children.has(childKey)) {
16400
+ const safeToRemove = sparseSnapshotTreeForget(sparseSnapshotTree.children.get(childKey), path);
16401
+ if (safeToRemove) {
16402
+ sparseSnapshotTree.children.delete(childKey);
16403
+ }
16404
+ }
16405
+ return sparseSnapshotTree.children.size === 0;
16406
+ }
16407
+ else {
16408
+ return true;
16409
+ }
16410
+ }
16411
+ }
15359
16412
  /**
15360
16413
  * Recursively iterates through all of the stored tree and calls the
15361
16414
  * callback on each one.
@@ -17475,6 +18528,9 @@ class View {
17475
18528
  function viewGetServerCache(view) {
17476
18529
  return view.viewCache_.serverCache.getNode();
17477
18530
  }
18531
+ function viewGetCompleteNode(view) {
18532
+ return viewCacheGetCompleteEventSnap(view.viewCache_);
18533
+ }
17478
18534
  function viewGetCompleteServerCache(view, path) {
17479
18535
  const cache = viewCacheGetCompleteServerSnap(view.viewCache_);
17480
18536
  if (cache) {
@@ -18147,6 +19203,33 @@ function syncTreeCalcCompleteEventCache(syncTree, path, writeIdsToExclude) {
18147
19203
  });
18148
19204
  return writeTreeCalcCompleteEventCache(writeTree, path, serverCache, writeIdsToExclude, includeHiddenSets);
18149
19205
  }
19206
+ function syncTreeGetServerValue(syncTree, query) {
19207
+ const path = query._path;
19208
+ let serverCache = null;
19209
+ // Any covering writes will necessarily be at the root, so really all we need to find is the server cache.
19210
+ // Consider optimizing this once there's a better understanding of what actual behavior will be.
19211
+ syncTree.syncPointTree_.foreachOnPath(path, (pathToSyncPoint, sp) => {
19212
+ const relativePath = newRelativePath(pathToSyncPoint, path);
19213
+ serverCache =
19214
+ serverCache || syncPointGetCompleteServerCache(sp, relativePath);
19215
+ });
19216
+ let syncPoint = syncTree.syncPointTree_.get(path);
19217
+ if (!syncPoint) {
19218
+ syncPoint = new SyncPoint();
19219
+ syncTree.syncPointTree_ = syncTree.syncPointTree_.set(path, syncPoint);
19220
+ }
19221
+ else {
19222
+ serverCache =
19223
+ serverCache || syncPointGetCompleteServerCache(syncPoint, newEmptyPath());
19224
+ }
19225
+ const serverCacheComplete = serverCache != null;
19226
+ const serverCacheNode = serverCacheComplete
19227
+ ? new CacheNode(serverCache, true, false)
19228
+ : null;
19229
+ const writesCache = writeTreeChildWrites(syncTree.pendingWriteTree_, query._path);
19230
+ const view = syncPointGetView(syncPoint, query, writesCache, serverCacheComplete ? serverCacheNode.getNode() : ChildrenNode.EMPTY_NODE, serverCacheComplete);
19231
+ return viewGetCompleteNode(view);
19232
+ }
18150
19233
  /**
18151
19234
  * A helper method that visits all descendant and ancestor SyncPoints, applying the operation.
18152
19235
  *
@@ -18898,6 +19981,36 @@ const validateFirebaseMergeDataArg = function (fnName, data, path, optional) {
18898
19981
  });
18899
19982
  validateFirebaseMergePaths(errorPrefix$1, mergePaths);
18900
19983
  };
19984
+ const validatePriority = function (fnName, priority, optional) {
19985
+ if (optional && priority === undefined) {
19986
+ return;
19987
+ }
19988
+ if (isInvalidJSONNumber(priority)) {
19989
+ throw new Error(errorPrefix(fnName, 'priority') +
19990
+ 'is ' +
19991
+ priority.toString() +
19992
+ ', but must be a valid Firebase priority (a string, finite number, ' +
19993
+ 'server value, or null).');
19994
+ }
19995
+ // Special case to allow importing data with a .sv.
19996
+ if (!isValidPriority(priority)) {
19997
+ throw new Error(errorPrefix(fnName, 'priority') +
19998
+ 'must be a valid Firebase priority ' +
19999
+ '(a string, finite number, server value, or null).');
20000
+ }
20001
+ };
20002
+ const validateKey = function (fnName, argumentName, key, optional) {
20003
+ if (optional && key === undefined) {
20004
+ return;
20005
+ }
20006
+ if (!isValidKey(key)) {
20007
+ throw new Error(errorPrefix(fnName, argumentName) +
20008
+ 'was an invalid key = "' +
20009
+ key +
20010
+ '". Firebase keys must be non-empty strings and ' +
20011
+ 'can\'t contain ".", "#", "$", "/", "[", or "]").');
20012
+ }
20013
+ };
18901
20014
  /**
18902
20015
  * @internal
18903
20016
  */
@@ -19267,6 +20380,63 @@ function repoUpdateInfo(repo, pathString, value) {
19267
20380
  function repoGetNextWriteId(repo) {
19268
20381
  return repo.nextWriteId_++;
19269
20382
  }
20383
+ /**
20384
+ * The purpose of `getValue` is to return the latest known value
20385
+ * satisfying `query`.
20386
+ *
20387
+ * This method will first check for in-memory cached values
20388
+ * belonging to active listeners. If they are found, such values
20389
+ * are considered to be the most up-to-date.
20390
+ *
20391
+ * If the client is not connected, this method will wait until the
20392
+ * repo has established a connection and then request the value for `query`.
20393
+ * If the client is not able to retrieve the query result for another reason,
20394
+ * it reports an error.
20395
+ *
20396
+ * @param query - The query to surface a value for.
20397
+ */
20398
+ function repoGetValue(repo, query, eventRegistration) {
20399
+ // Only active queries are cached. There is no persisted cache.
20400
+ const cached = syncTreeGetServerValue(repo.serverSyncTree_, query);
20401
+ if (cached != null) {
20402
+ return Promise.resolve(cached);
20403
+ }
20404
+ return repo.server_.get(query).then(payload => {
20405
+ const node = nodeFromJSON(payload).withIndex(query._queryParams.getIndex());
20406
+ /**
20407
+ * Below we simulate the actions of an `onlyOnce` `onValue()` event where:
20408
+ * Add an event registration,
20409
+ * Update data at the path,
20410
+ * Raise any events,
20411
+ * Cleanup the SyncTree
20412
+ */
20413
+ syncTreeAddEventRegistration(repo.serverSyncTree_, query, eventRegistration, true);
20414
+ let events;
20415
+ if (query._queryParams.loadsAllData()) {
20416
+ events = syncTreeApplyServerOverwrite(repo.serverSyncTree_, query._path, node);
20417
+ }
20418
+ else {
20419
+ const tag = syncTreeTagForQuery(repo.serverSyncTree_, query);
20420
+ events = syncTreeApplyTaggedQueryOverwrite(repo.serverSyncTree_, query._path, node, tag);
20421
+ }
20422
+ /*
20423
+ * We need to raise events in the scenario where `get()` is called at a parent path, and
20424
+ * while the `get()` is pending, `onValue` is called at a child location. While get() is waiting
20425
+ * for the data, `onValue` will register a new event. Then, get() will come back, and update the syncTree
20426
+ * and its corresponding serverCache, including the child location where `onValue` is called. Then,
20427
+ * `onValue` will receive the event from the server, but look at the syncTree and see that the data received
20428
+ * from the server is already at the SyncPoint, and so the `onValue` callback will never get fired.
20429
+ * Calling `eventQueueRaiseEventsForChangedPath()` is the correct way to propagate the events and
20430
+ * ensure the corresponding child events will get fired.
20431
+ */
20432
+ eventQueueRaiseEventsForChangedPath(repo.eventQueue_, query._path, events);
20433
+ syncTreeRemoveEventRegistration(repo.serverSyncTree_, query, eventRegistration, null, true);
20434
+ return node;
20435
+ }, err => {
20436
+ repoLog(repo, 'get for query ' + stringify(query) + ' failed: ' + err);
20437
+ return Promise.reject(new Error(err));
20438
+ });
20439
+ }
19270
20440
  function repoSetWithPriority(repo, path, newVal, newPriority, onComplete) {
19271
20441
  repoLog(repo, 'set', {
19272
20442
  path: path.toString(),
@@ -19352,6 +20522,48 @@ function repoRunOnDisconnectEvents(repo) {
19352
20522
  repo.onDisconnect_ = newSparseSnapshotTree();
19353
20523
  eventQueueRaiseEventsForChangedPath(repo.eventQueue_, newEmptyPath(), events);
19354
20524
  }
20525
+ function repoOnDisconnectCancel(repo, path, onComplete) {
20526
+ repo.server_.onDisconnectCancel(path.toString(), (status, errorReason) => {
20527
+ if (status === 'ok') {
20528
+ sparseSnapshotTreeForget(repo.onDisconnect_, path);
20529
+ }
20530
+ repoCallOnCompleteCallback(repo, onComplete, status, errorReason);
20531
+ });
20532
+ }
20533
+ function repoOnDisconnectSet(repo, path, value, onComplete) {
20534
+ const newNode = nodeFromJSON(value);
20535
+ repo.server_.onDisconnectPut(path.toString(), newNode.val(/*export=*/ true), (status, errorReason) => {
20536
+ if (status === 'ok') {
20537
+ sparseSnapshotTreeRemember(repo.onDisconnect_, path, newNode);
20538
+ }
20539
+ repoCallOnCompleteCallback(repo, onComplete, status, errorReason);
20540
+ });
20541
+ }
20542
+ function repoOnDisconnectSetWithPriority(repo, path, value, priority, onComplete) {
20543
+ const newNode = nodeFromJSON(value, priority);
20544
+ repo.server_.onDisconnectPut(path.toString(), newNode.val(/*export=*/ true), (status, errorReason) => {
20545
+ if (status === 'ok') {
20546
+ sparseSnapshotTreeRemember(repo.onDisconnect_, path, newNode);
20547
+ }
20548
+ repoCallOnCompleteCallback(repo, onComplete, status, errorReason);
20549
+ });
20550
+ }
20551
+ function repoOnDisconnectUpdate(repo, path, childrenToMerge, onComplete) {
20552
+ if (isEmpty(childrenToMerge)) {
20553
+ log("onDisconnect().update() called with empty data. Don't do anything.");
20554
+ repoCallOnCompleteCallback(repo, onComplete, 'ok', undefined);
20555
+ return;
20556
+ }
20557
+ repo.server_.onDisconnectMerge(path.toString(), childrenToMerge, (status, errorReason) => {
20558
+ if (status === 'ok') {
20559
+ each(childrenToMerge, (childName, childNode) => {
20560
+ const newChildNode = nodeFromJSON(childNode);
20561
+ sparseSnapshotTreeRemember(repo.onDisconnect_, pathChild(path, childName), newChildNode);
20562
+ });
20563
+ }
20564
+ repoCallOnCompleteCallback(repo, onComplete, status, errorReason);
20565
+ });
20566
+ }
19355
20567
  function repoAddEventCallbackForQuery(repo, query, eventRegistration) {
19356
20568
  let events;
19357
20569
  if (pathGetFront(query._path) === '.info') {
@@ -19379,6 +20591,11 @@ function repoInterrupt(repo) {
19379
20591
  repo.persistentConnection_.interrupt(INTERRUPT_REASON);
19380
20592
  }
19381
20593
  }
20594
+ function repoResume(repo) {
20595
+ if (repo.persistentConnection_) {
20596
+ repo.persistentConnection_.resume(INTERRUPT_REASON);
20597
+ }
20598
+ }
19382
20599
  function repoLog(repo, ...varArgs) {
19383
20600
  let prefix = '';
19384
20601
  if (repo.persistentConnection_) {
@@ -19406,6 +20623,92 @@ function repoCallOnCompleteCallback(repo, callback, status, errorReason) {
19406
20623
  });
19407
20624
  }
19408
20625
  }
20626
+ /**
20627
+ * Creates a new transaction, adds it to the transactions we're tracking, and
20628
+ * sends it to the server if possible.
20629
+ *
20630
+ * @param path - Path at which to do transaction.
20631
+ * @param transactionUpdate - Update callback.
20632
+ * @param onComplete - Completion callback.
20633
+ * @param unwatcher - Function that will be called when the transaction no longer
20634
+ * need data updates for `path`.
20635
+ * @param applyLocally - Whether or not to make intermediate results visible
20636
+ */
20637
+ function repoStartTransaction(repo, path, transactionUpdate, onComplete, unwatcher, applyLocally) {
20638
+ repoLog(repo, 'transaction on ' + path);
20639
+ // Initialize transaction.
20640
+ const transaction = {
20641
+ path,
20642
+ update: transactionUpdate,
20643
+ onComplete,
20644
+ // One of TransactionStatus enums.
20645
+ status: null,
20646
+ // Used when combining transactions at different locations to figure out
20647
+ // which one goes first.
20648
+ order: LUIDGenerator(),
20649
+ // Whether to raise local events for this transaction.
20650
+ applyLocally,
20651
+ // Count of how many times we've retried the transaction.
20652
+ retryCount: 0,
20653
+ // Function to call to clean up our .on() listener.
20654
+ unwatcher,
20655
+ // Stores why a transaction was aborted.
20656
+ abortReason: null,
20657
+ currentWriteId: null,
20658
+ currentInputSnapshot: null,
20659
+ currentOutputSnapshotRaw: null,
20660
+ currentOutputSnapshotResolved: null
20661
+ };
20662
+ // Run transaction initially.
20663
+ const currentState = repoGetLatestState(repo, path, undefined);
20664
+ transaction.currentInputSnapshot = currentState;
20665
+ const newVal = transaction.update(currentState.val());
20666
+ if (newVal === undefined) {
20667
+ // Abort transaction.
20668
+ transaction.unwatcher();
20669
+ transaction.currentOutputSnapshotRaw = null;
20670
+ transaction.currentOutputSnapshotResolved = null;
20671
+ if (transaction.onComplete) {
20672
+ transaction.onComplete(null, false, transaction.currentInputSnapshot);
20673
+ }
20674
+ }
20675
+ else {
20676
+ validateFirebaseData('transaction failed: Data returned ', newVal, transaction.path);
20677
+ // Mark as run and add to our queue.
20678
+ transaction.status = 0 /* TransactionStatus.RUN */;
20679
+ const queueNode = treeSubTree(repo.transactionQueueTree_, path);
20680
+ const nodeQueue = treeGetValue(queueNode) || [];
20681
+ nodeQueue.push(transaction);
20682
+ treeSetValue(queueNode, nodeQueue);
20683
+ // Update visibleData and raise events
20684
+ // Note: We intentionally raise events after updating all of our
20685
+ // transaction state, since the user could start new transactions from the
20686
+ // event callbacks.
20687
+ let priorityForNode;
20688
+ if (typeof newVal === 'object' &&
20689
+ newVal !== null &&
20690
+ contains(newVal, '.priority')) {
20691
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
20692
+ priorityForNode = safeGet(newVal, '.priority');
20693
+ assert(isValidPriority(priorityForNode), 'Invalid priority returned by transaction. ' +
20694
+ 'Priority must be a valid string, finite number, server value, or null.');
20695
+ }
20696
+ else {
20697
+ const currentNode = syncTreeCalcCompleteEventCache(repo.serverSyncTree_, path) ||
20698
+ ChildrenNode.EMPTY_NODE;
20699
+ priorityForNode = currentNode.getPriority().val();
20700
+ }
20701
+ const serverValues = repoGenerateServerValues(repo);
20702
+ const newNodeUnresolved = nodeFromJSON(newVal, priorityForNode);
20703
+ const newNode = resolveDeferredValueSnapshot(newNodeUnresolved, currentState, serverValues);
20704
+ transaction.currentOutputSnapshotRaw = newNodeUnresolved;
20705
+ transaction.currentOutputSnapshotResolved = newNode;
20706
+ transaction.currentWriteId = repoGetNextWriteId(repo);
20707
+ const events = syncTreeApplyUserOverwrite(repo.serverSyncTree_, path, newNode, transaction.currentWriteId, transaction.applyLocally);
20708
+ eventQueueRaiseEventsForChangedPath(repo.eventQueue_, path, events);
20709
+ repoSendReadyTransactions(repo, repo.transactionQueueTree_);
20710
+ }
20711
+ }
19409
20712
  /**
19410
20713
  * @param excludeSets - A specific set to exclude
19411
20714
  */
@@ -20123,7 +21426,7 @@ class CallbackContext {
20123
21426
 
20124
21427
  /**
20125
21428
  * @license
20126
- * Copyright 2020 Google LLC
21429
+ * Copyright 2021 Google LLC
20127
21430
  *
20128
21431
  * Licensed under the Apache License, Version 2.0 (the "License");
20129
21432
  * you may not use this file except in compliance with the License.
@@ -20138,11 +21441,149 @@ class CallbackContext {
20138
21441
  * limitations under the License.
20139
21442
  */
20140
21443
  /**
20141
- * @internal
21444
+ * The `onDisconnect` class allows you to write or clear data when your client
21445
+ * disconnects from the Database server. These updates occur whether your
21446
+ * client disconnects cleanly or not, so you can rely on them to clean up data
21447
+ * even if a connection is dropped or a client crashes.
21448
+ *
21449
+ * The `onDisconnect` class is most commonly used to manage presence in
21450
+ * applications where it is useful to detect how many clients are connected and
21451
+ * when other clients disconnect. See
21452
+ * {@link https://firebase.google.com/docs/database/web/offline-capabilities | Enabling Offline Capabilities in JavaScript}
21453
+ * for more information.
21454
+ *
21455
+ * To avoid problems when a connection is dropped before the requests can be
21456
+ * transferred to the Database server, these functions should be called before
21457
+ * writing any data.
21458
+ *
21459
+ * Note that `onDisconnect` operations are only triggered once. If you want an
21460
+ * operation to occur each time a disconnect occurs, you'll need to re-establish
21461
+ * the `onDisconnect` operations each time you reconnect.
20142
21462
  */
20143
- class QueryImpl {
20144
- /**
20145
- * @hideconstructor
21463
+ class OnDisconnect {
21464
+ /** @hideconstructor */
21465
+ constructor(_repo, _path) {
21466
+ this._repo = _repo;
21467
+ this._path = _path;
21468
+ }
21469
+ /**
21470
+ * Cancels all previously queued `onDisconnect()` set or update events for this
21471
+ * location and all children.
21472
+ *
21473
+ * If a write has been queued for this location via a `set()` or `update()` at a
21474
+ * parent location, the write at this location will be canceled, though writes
21475
+ * to sibling locations will still occur.
21476
+ *
21477
+ * @returns Resolves when synchronization to the server is complete.
21478
+ */
21479
+ cancel() {
21480
+ const deferred = new Deferred();
21481
+ repoOnDisconnectCancel(this._repo, this._path, deferred.wrapCallback(() => { }));
21482
+ return deferred.promise;
21483
+ }
21484
+ /**
21485
+ * Ensures the data at this location is deleted when the client is disconnected
21486
+ * (due to closing the browser, navigating to a new page, or network issues).
21487
+ *
21488
+ * @returns Resolves when synchronization to the server is complete.
21489
+ */
21490
+ remove() {
21491
+ validateWritablePath('OnDisconnect.remove', this._path);
21492
+ const deferred = new Deferred();
21493
+ repoOnDisconnectSet(this._repo, this._path, null, deferred.wrapCallback(() => { }));
21494
+ return deferred.promise;
21495
+ }
21496
+ /**
21497
+ * Ensures the data at this location is set to the specified value when the
21498
+ * client is disconnected (due to closing the browser, navigating to a new page,
21499
+ * or network issues).
21500
+ *
21501
+ * `set()` is especially useful for implementing "presence" systems, where a
21502
+ * value should be changed or cleared when a user disconnects so that they
21503
+ * appear "offline" to other users. See
21504
+ * {@link https://firebase.google.com/docs/database/web/offline-capabilities | Enabling Offline Capabilities in JavaScript}
21505
+ * for more information.
21506
+ *
21507
+ * Note that `onDisconnect` operations are only triggered once. If you want an
21508
+ * operation to occur each time a disconnect occurs, you'll need to re-establish
21509
+ * the `onDisconnect` operations each time.
21510
+ *
21511
+ * @param value - The value to be written to this location on disconnect (can
21512
+ * be an object, array, string, number, boolean, or null).
21513
+ * @returns Resolves when synchronization to the Database is complete.
21514
+ */
21515
+ set(value) {
21516
+ validateWritablePath('OnDisconnect.set', this._path);
21517
+ validateFirebaseDataArg('OnDisconnect.set', value, this._path, false);
21518
+ const deferred = new Deferred();
21519
+ repoOnDisconnectSet(this._repo, this._path, value, deferred.wrapCallback(() => { }));
21520
+ return deferred.promise;
21521
+ }
21522
+ /**
21523
+ * Ensures the data at this location is set to the specified value and priority
21524
+ * when the client is disconnected (due to closing the browser, navigating to a
21525
+ * new page, or network issues).
21526
+ *
21527
+ * @param value - The value to be written to this location on disconnect (can
21528
+ * be an object, array, string, number, boolean, or null).
21529
+ * @param priority - The priority to be written (string, number, or null).
21530
+ * @returns Resolves when synchronization to the Database is complete.
21531
+ */
21532
+ setWithPriority(value, priority) {
21533
+ validateWritablePath('OnDisconnect.setWithPriority', this._path);
21534
+ validateFirebaseDataArg('OnDisconnect.setWithPriority', value, this._path, false);
21535
+ validatePriority('OnDisconnect.setWithPriority', priority, false);
21536
+ const deferred = new Deferred();
21537
+ repoOnDisconnectSetWithPriority(this._repo, this._path, value, priority, deferred.wrapCallback(() => { }));
21538
+ return deferred.promise;
21539
+ }
21540
+ /**
21541
+ * Writes multiple values at this location when the client is disconnected (due
21542
+ * to closing the browser, navigating to a new page, or network issues).
21543
+ *
21544
+ * The `values` argument contains multiple property-value pairs that will be
21545
+ * written to the Database together. Each child property can either be a simple
21546
+ * property (for example, "name") or a relative path (for example, "name/first")
21547
+ * from the current location to the data to update.
21548
+ *
21549
+ * As opposed to the `set()` method, `update()` can be use to selectively update
21550
+ * only the referenced properties at the current location (instead of replacing
21551
+ * all the child properties at the current location).
21552
+ *
21553
+ * @param values - Object containing multiple values.
21554
+ * @returns Resolves when synchronization to the Database is complete.
21555
+ */
21556
+ update(values) {
21557
+ validateWritablePath('OnDisconnect.update', this._path);
21558
+ validateFirebaseMergeDataArg('OnDisconnect.update', values, this._path, false);
21559
+ const deferred = new Deferred();
21560
+ repoOnDisconnectUpdate(this._repo, this._path, values, deferred.wrapCallback(() => { }));
21561
+ return deferred.promise;
21562
+ }
21563
+ }
21564
+
21565
+ /**
21566
+ * @license
21567
+ * Copyright 2020 Google LLC
21568
+ *
21569
+ * Licensed under the Apache License, Version 2.0 (the "License");
21570
+ * you may not use this file except in compliance with the License.
21571
+ * You may obtain a copy of the License at
21572
+ *
21573
+ * http://www.apache.org/licenses/LICENSE-2.0
21574
+ *
21575
+ * Unless required by applicable law or agreed to in writing, software
21576
+ * distributed under the License is distributed on an "AS IS" BASIS,
21577
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21578
+ * See the License for the specific language governing permissions and
21579
+ * limitations under the License.
21580
+ */
21581
+ /**
21582
+ * @internal
21583
+ */
21584
+ class QueryImpl {
21585
+ /**
21586
+ * @hideconstructor
20146
21587
  */
20147
21588
  constructor(_repo, _path, _queryParams, _orderByCalled) {
20148
21589
  this._repo = _repo;
@@ -20189,6 +21630,80 @@ class QueryImpl {
20189
21630
  return this._repo.toString() + pathToUrlEncodedString(this._path);
20190
21631
  }
20191
21632
  }
21633
+ /**
21634
+ * Validates that no other order by call has been made
21635
+ */
21636
+ function validateNoPreviousOrderByCall(query, fnName) {
21637
+ if (query._orderByCalled === true) {
21638
+ throw new Error(fnName + ": You can't combine multiple orderBy calls.");
21639
+ }
21640
+ }
21641
+ /**
21642
+ * Validates start/end values for queries.
21643
+ */
21644
+ function validateQueryEndpoints(params) {
21645
+ let startNode = null;
21646
+ let endNode = null;
21647
+ if (params.hasStart()) {
21648
+ startNode = params.getIndexStartValue();
21649
+ }
21650
+ if (params.hasEnd()) {
21651
+ endNode = params.getIndexEndValue();
21652
+ }
21653
+ if (params.getIndex() === KEY_INDEX) {
21654
+ const tooManyArgsError = 'Query: When ordering by key, you may only pass one argument to ' +
21655
+ 'startAt(), endAt(), or equalTo().';
21656
+ const wrongArgTypeError = 'Query: When ordering by key, the argument passed to startAt(), startAfter(), ' +
21657
+ 'endAt(), endBefore(), or equalTo() must be a string.';
21658
+ if (params.hasStart()) {
21659
+ const startName = params.getIndexStartName();
21660
+ if (startName !== MIN_NAME) {
21661
+ throw new Error(tooManyArgsError);
21662
+ }
21663
+ else if (typeof startNode !== 'string') {
21664
+ throw new Error(wrongArgTypeError);
21665
+ }
21666
+ }
21667
+ if (params.hasEnd()) {
21668
+ const endName = params.getIndexEndName();
21669
+ if (endName !== MAX_NAME) {
21670
+ throw new Error(tooManyArgsError);
21671
+ }
21672
+ else if (typeof endNode !== 'string') {
21673
+ throw new Error(wrongArgTypeError);
21674
+ }
21675
+ }
21676
+ }
21677
+ else if (params.getIndex() === PRIORITY_INDEX) {
21678
+ if ((startNode != null && !isValidPriority(startNode)) ||
21679
+ (endNode != null && !isValidPriority(endNode))) {
21680
+ throw new Error('Query: When ordering by priority, the first argument passed to startAt(), ' +
21681
+ 'startAfter() endAt(), endBefore(), or equalTo() must be a valid priority value ' +
21682
+ '(null, a number, or a string).');
21683
+ }
21684
+ }
21685
+ else {
21686
+ assert(params.getIndex() instanceof PathIndex ||
21687
+ params.getIndex() === VALUE_INDEX, 'unknown index type.');
21688
+ if ((startNode != null && typeof startNode === 'object') ||
21689
+ (endNode != null && typeof endNode === 'object')) {
21690
+ throw new Error('Query: First argument passed to startAt(), startAfter(), endAt(), endBefore(), or ' +
21691
+ 'equalTo() cannot be an object.');
21692
+ }
21693
+ }
21694
+ }
21695
+ /**
21696
+ * Validates that limit* has been called with the correct combination of parameters
21697
+ */
21698
+ function validateLimit(params) {
21699
+ if (params.hasStart() &&
21700
+ params.hasEnd() &&
21701
+ params.hasLimit() &&
21702
+ !params.hasAnchoredLimit()) {
21703
+ throw new Error("Query: Can't combine startAt(), startAfter(), endAt(), endBefore(), and limit(). Use " +
21704
+ 'limitToFirst() or limitToLast() instead.');
21705
+ }
21706
+ }
20192
21707
  /**
20193
21708
  * @internal
20194
21709
  */
@@ -20406,6 +21921,40 @@ function ref(db, path) {
20406
21921
  db._checkNotDeleted('ref');
20407
21922
  return path !== undefined ? child(db._root, path) : db._root;
20408
21923
  }
21924
+ /**
21925
+ * Returns a `Reference` representing the location in the Database
21926
+ * corresponding to the provided Firebase URL.
21927
+ *
21928
+ * An exception is thrown if the URL is not a valid Firebase Database URL or it
21929
+ * has a different domain than the current `Database` instance.
21930
+ *
21931
+ * Note that all query parameters (`orderBy`, `limitToLast`, etc.) are ignored
21932
+ * and are not applied to the returned `Reference`.
21933
+ *
21934
+ * @param db - The database instance to obtain a reference for.
21935
+ * @param url - The Firebase URL at which the returned `Reference` will
21936
+ * point.
21937
+ * @returns A `Reference` pointing to the provided
21938
+ * Firebase URL.
21939
+ */
21940
+ function refFromURL(db, url) {
21941
+ db = getModularInstance(db);
21942
+ db._checkNotDeleted('refFromURL');
21943
+ const parsedURL = parseRepoInfo(url, db._repo.repoInfo_.nodeAdmin);
21944
+ validateUrl('refFromURL', parsedURL);
21945
+ const repoInfo = parsedURL.repoInfo;
21946
+ if (!db._repo.repoInfo_.isCustomHost() &&
21947
+ repoInfo.host !== db._repo.repoInfo_.host) {
21948
+ fatal('refFromURL' +
21949
+ ': Host name does not match the current database: ' +
21950
+ '(found ' +
21951
+ repoInfo.host +
21952
+ ' but expected ' +
21953
+ db._repo.repoInfo_.host +
21954
+ ')');
21955
+ }
21956
+ return ref(db, parsedURL.path.toString());
21957
+ }
20409
21958
  /**
20410
21959
  * Gets a `Reference` for the location at the specified relative path.
20411
21960
  *
@@ -20427,6 +21976,17 @@ function child(parent, path) {
20427
21976
  }
20428
21977
  return new ReferenceImpl(parent._repo, pathChild(parent._path, path));
20429
21978
  }
21979
+ /**
21980
+ * Returns an `OnDisconnect` object - see
21981
+ * {@link https://firebase.google.com/docs/database/web/offline-capabilities | Enabling Offline Capabilities in JavaScript}
21982
+ * for more information on how to use it.
21983
+ *
21984
+ * @param ref - The reference to add OnDisconnect triggers for.
21985
+ */
21986
+ function onDisconnect(ref) {
21987
+ ref = getModularInstance(ref);
21988
+ return new OnDisconnect(ref._repo, ref._path);
21989
+ }
20430
21990
  /**
20431
21991
  * Generates a new child location using a unique key and returns its
20432
21992
  * `Reference`.
@@ -20475,6 +22035,24 @@ function push(parent, value) {
20475
22035
  thennablePushRef.catch = promise.then.bind(promise, undefined);
20476
22036
  return thennablePushRef;
20477
22037
  }
22038
+ /**
22039
+ * Removes the data at this Database location.
22040
+ *
22041
+ * Any data at child locations will also be deleted.
22042
+ *
22043
+ * The effect of the remove will be visible immediately and the corresponding
22044
+ * event 'value' will be triggered. Synchronization of the remove to the
22045
+ * Firebase servers will also be started, and the returned Promise will resolve
22046
+ * when complete. If provided, the onComplete callback will be called
22047
+ * asynchronously after synchronization has finished.
22048
+ *
22049
+ * @param ref - The location to remove.
22050
+ * @returns Resolves when remove on server is complete.
22051
+ */
22052
+ function remove(ref) {
22053
+ validateWritablePath('remove', ref._path);
22054
+ return set(ref, null);
22055
+ }
20478
22056
  /**
20479
22057
  * Writes data to this Database location.
20480
22058
  *
@@ -20513,6 +22091,52 @@ function set(ref, value) {
20513
22091
  /*priority=*/ null, deferred.wrapCallback(() => { }));
20514
22092
  return deferred.promise;
20515
22093
  }
22094
+ /**
22095
+ * Sets a priority for the data at this Database location.
22096
+ *
22097
+ * Applications need not use priority but can order collections by
22098
+ * ordinary properties (see
22099
+ * {@link https://firebase.google.com/docs/database/web/lists-of-data#sorting_and_filtering_data | Sorting and filtering data}
22100
+ * ).
22101
+ *
22102
+ * @param ref - The location to write to.
22103
+ * @param priority - The priority to be written (string, number, or null).
22104
+ * @returns Resolves when write to server is complete.
22105
+ */
22106
+ function setPriority(ref, priority) {
22107
+ ref = getModularInstance(ref);
22108
+ validateWritablePath('setPriority', ref._path);
22109
+ validatePriority('setPriority', priority, false);
22110
+ const deferred = new Deferred();
22111
+ repoSetWithPriority(ref._repo, pathChild(ref._path, '.priority'), priority, null, deferred.wrapCallback(() => { }));
22112
+ return deferred.promise;
22113
+ }
22114
+ /**
22115
+ * Writes data the Database location. Like `set()` but also specifies the
22116
+ * priority for that data.
22117
+ *
22118
+ * Applications need not use priority but can order collections by
22119
+ * ordinary properties (see
22120
+ * {@link https://firebase.google.com/docs/database/web/lists-of-data#sorting_and_filtering_data | Sorting and filtering data}
22121
+ * ).
22122
+ *
22123
+ * @param ref - The location to write to.
22124
+ * @param value - The value to be written (string, number, boolean, object,
22125
+ * array, or null).
22126
+ * @param priority - The priority to be written (string, number, or null).
22127
+ * @returns Resolves when write to server is complete.
22128
+ */
22129
+ function setWithPriority(ref, value, priority) {
22130
+ validateWritablePath('setWithPriority', ref._path);
22131
+ validateFirebaseDataArg('setWithPriority', value, ref._path, false);
22132
+ validatePriority('setWithPriority', priority, false);
22133
+ if (ref.key === '.length' || ref.key === '.keys') {
22134
+ throw 'setWithPriority failed: ' + ref.key + ' is a read-only object.';
22135
+ }
22136
+ const deferred = new Deferred();
22137
+ repoSetWithPriority(ref._repo, ref._path, value, priority, deferred.wrapCallback(() => { }));
22138
+ return deferred.promise;
22139
+ }
20516
22140
  /**
20517
22141
  * Writes multiple values to the Database at once.
20518
22142
  *
@@ -20554,6 +22178,22 @@ function update(ref, values) {
20554
22178
  repoUpdate(ref._repo, ref._path, values, deferred.wrapCallback(() => { }));
20555
22179
  return deferred.promise;
20556
22180
  }
22181
+ /**
22182
+ * Gets the most up-to-date result for this query.
22183
+ *
22184
+ * @param query - The query to run.
22185
+ * @returns A `Promise` which resolves to the resulting DataSnapshot if a value is
22186
+ * available, or rejects if the client is unable to return a value (e.g., if the
22187
+ * server is unreachable and there is nothing cached).
22188
+ */
22189
+ function get(query) {
22190
+ query = getModularInstance(query);
22191
+ const callbackContext = new CallbackContext(() => { });
22192
+ const container = new ValueEventRegistration(callbackContext);
22193
+ return repoGetValue(query._repo, query, container).then(node => {
22194
+ return new DataSnapshot(node, new ReferenceImpl(query._repo, query._path), query._queryParams.getIndex());
22195
+ });
22196
+ }
20557
22197
  /**
20558
22198
  * Represents registration for 'value' events.
20559
22199
  */
@@ -20678,6 +22318,479 @@ function addEventListener(query, eventType, callback, cancelCallbackOrListenOpti
20678
22318
  function onValue(query, callback, cancelCallbackOrListenOptions, options) {
20679
22319
  return addEventListener(query, 'value', callback, cancelCallbackOrListenOptions, options);
20680
22320
  }
22321
+ function onChildAdded(query, callback, cancelCallbackOrListenOptions, options) {
22322
+ return addEventListener(query, 'child_added', callback, cancelCallbackOrListenOptions, options);
22323
+ }
22324
+ function onChildChanged(query, callback, cancelCallbackOrListenOptions, options) {
22325
+ return addEventListener(query, 'child_changed', callback, cancelCallbackOrListenOptions, options);
22326
+ }
22327
+ function onChildMoved(query, callback, cancelCallbackOrListenOptions, options) {
22328
+ return addEventListener(query, 'child_moved', callback, cancelCallbackOrListenOptions, options);
22329
+ }
22330
+ function onChildRemoved(query, callback, cancelCallbackOrListenOptions, options) {
22331
+ return addEventListener(query, 'child_removed', callback, cancelCallbackOrListenOptions, options);
22332
+ }
22333
+ /**
22334
+ * Detaches a callback previously attached with the corresponding `on*()` (`onValue`, `onChildAdded`) listener.
22335
+ * Note: This is not the recommended way to remove a listener. Instead, please use the returned callback function from
22336
+ * the respective `on*` callbacks.
22337
+ *
22338
+ * Detach a callback previously attached with `on*()`. Calling `off()` on a parent listener
22339
+ * will not automatically remove listeners registered on child nodes, `off()`
22340
+ * must also be called on any child listeners to remove the callback.
22341
+ *
22342
+ * If a callback is not specified, all callbacks for the specified eventType
22343
+ * will be removed. Similarly, if no eventType is specified, all callbacks
22344
+ * for the `Reference` will be removed.
22345
+ *
22346
+ * Individual listeners can also be removed by invoking their unsubscribe
22347
+ * callbacks.
22348
+ *
22349
+ * @param query - The query that the listener was registered with.
22350
+ * @param eventType - One of the following strings: "value", "child_added",
22351
+ * "child_changed", "child_removed", or "child_moved." If omitted, all callbacks
22352
+ * for the `Reference` will be removed.
22353
+ * @param callback - The callback function that was passed to `on()` or
22354
+ * `undefined` to remove all callbacks.
22355
+ */
22356
+ function off(query, eventType, callback) {
22357
+ let container = null;
22358
+ const expCallback = callback ? new CallbackContext(callback) : null;
22359
+ if (eventType === 'value') {
22360
+ container = new ValueEventRegistration(expCallback);
22361
+ }
22362
+ else if (eventType) {
22363
+ container = new ChildEventRegistration(eventType, expCallback);
22364
+ }
22365
+ repoRemoveEventCallbackForQuery(query._repo, query, container);
22366
+ }
22367
+ /**
22368
+ * A `QueryConstraint` is used to narrow the set of documents returned by a
22369
+ * Database query. `QueryConstraint`s are created by invoking {@link endAt},
22370
+ * {@link endBefore}, {@link startAt}, {@link startAfter}, {@link
22371
+ * limitToFirst}, {@link limitToLast}, {@link orderByChild},
22372
+ * {@link orderByChild}, {@link orderByKey} , {@link orderByPriority} ,
22373
+ * {@link orderByValue} or {@link equalTo} and
22374
+ * can then be passed to {@link query} to create a new query instance that
22375
+ * also contains this `QueryConstraint`.
22376
+ */
22377
+ class QueryConstraint {
22378
+ }
22379
+ class QueryEndAtConstraint extends QueryConstraint {
22380
+ constructor(_value, _key) {
22381
+ super();
22382
+ this._value = _value;
22383
+ this._key = _key;
22384
+ }
22385
+ _apply(query) {
22386
+ validateFirebaseDataArg('endAt', this._value, query._path, true);
22387
+ const newParams = queryParamsEndAt(query._queryParams, this._value, this._key);
22388
+ validateLimit(newParams);
22389
+ validateQueryEndpoints(newParams);
22390
+ if (query._queryParams.hasEnd()) {
22391
+ throw new Error('endAt: Starting point was already set (by another call to endAt, ' +
22392
+ 'endBefore or equalTo).');
22393
+ }
22394
+ return new QueryImpl(query._repo, query._path, newParams, query._orderByCalled);
22395
+ }
22396
+ }
22397
+ /**
22398
+ * Creates a `QueryConstraint` with the specified ending point.
22399
+ *
22400
+ * Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()`
22401
+ * allows you to choose arbitrary starting and ending points for your queries.
22402
+ *
22403
+ * The ending point is inclusive, so children with exactly the specified value
22404
+ * will be included in the query. The optional key argument can be used to
22405
+ * further limit the range of the query. If it is specified, then children that
22406
+ * have exactly the specified value must also have a key name less than or equal
22407
+ * to the specified key.
22408
+ *
22409
+ * You can read more about `endAt()` in
22410
+ * {@link https://firebase.google.com/docs/database/web/lists-of-data#filtering_data | Filtering data}.
22411
+ *
22412
+ * @param value - The value to end at. The argument type depends on which
22413
+ * `orderBy*()` function was used in this query. Specify a value that matches
22414
+ * the `orderBy*()` type. When used in combination with `orderByKey()`, the
22415
+ * value must be a string.
22416
+ * @param key - The child key to end at, among the children with the previously
22417
+ * specified priority. This argument is only allowed if ordering by child,
22418
+ * value, or priority.
22419
+ */
22420
+ function endAt(value, key) {
22421
+ validateKey('endAt', 'key', key, true);
22422
+ return new QueryEndAtConstraint(value, key);
22423
+ }
22424
+ class QueryEndBeforeConstraint extends QueryConstraint {
22425
+ constructor(_value, _key) {
22426
+ super();
22427
+ this._value = _value;
22428
+ this._key = _key;
22429
+ }
22430
+ _apply(query) {
22431
+ validateFirebaseDataArg('endBefore', this._value, query._path, false);
22432
+ const newParams = queryParamsEndBefore(query._queryParams, this._value, this._key);
22433
+ validateLimit(newParams);
22434
+ validateQueryEndpoints(newParams);
22435
+ if (query._queryParams.hasEnd()) {
22436
+ throw new Error('endBefore: Starting point was already set (by another call to endAt, ' +
22437
+ 'endBefore or equalTo).');
22438
+ }
22439
+ return new QueryImpl(query._repo, query._path, newParams, query._orderByCalled);
22440
+ }
22441
+ }
22442
+ /**
22443
+ * Creates a `QueryConstraint` with the specified ending point (exclusive).
22444
+ *
22445
+ * Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()`
22446
+ * allows you to choose arbitrary starting and ending points for your queries.
22447
+ *
22448
+ * The ending point is exclusive. If only a value is provided, children
22449
+ * with a value less than the specified value will be included in the query.
22450
+ * If a key is specified, then children must have a value less than or equal
22451
+ * to the specified value and a key name less than the specified key.
22452
+ *
22453
+ * @param value - The value to end before. The argument type depends on which
22454
+ * `orderBy*()` function was used in this query. Specify a value that matches
22455
+ * the `orderBy*()` type. When used in combination with `orderByKey()`, the
22456
+ * value must be a string.
22457
+ * @param key - The child key to end before, among the children with the
22458
+ * previously specified priority. This argument is only allowed if ordering by
22459
+ * child, value, or priority.
22460
+ */
22461
+ function endBefore(value, key) {
22462
+ validateKey('endBefore', 'key', key, true);
22463
+ return new QueryEndBeforeConstraint(value, key);
22464
+ }
22465
+ class QueryStartAtConstraint extends QueryConstraint {
22466
+ constructor(_value, _key) {
22467
+ super();
22468
+ this._value = _value;
22469
+ this._key = _key;
22470
+ }
22471
+ _apply(query) {
22472
+ validateFirebaseDataArg('startAt', this._value, query._path, true);
22473
+ const newParams = queryParamsStartAt(query._queryParams, this._value, this._key);
22474
+ validateLimit(newParams);
22475
+ validateQueryEndpoints(newParams);
22476
+ if (query._queryParams.hasStart()) {
22477
+ throw new Error('startAt: Starting point was already set (by another call to startAt, ' +
22478
+ 'startBefore or equalTo).');
22479
+ }
22480
+ return new QueryImpl(query._repo, query._path, newParams, query._orderByCalled);
22481
+ }
22482
+ }
22483
+ /**
22484
+ * Creates a `QueryConstraint` with the specified starting point.
22485
+ *
22486
+ * Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()`
22487
+ * allows you to choose arbitrary starting and ending points for your queries.
22488
+ *
22489
+ * The starting point is inclusive, so children with exactly the specified value
22490
+ * will be included in the query. The optional key argument can be used to
22491
+ * further limit the range of the query. If it is specified, then children that
22492
+ * have exactly the specified value must also have a key name greater than or
22493
+ * equal to the specified key.
22494
+ *
22495
+ * You can read more about `startAt()` in
22496
+ * {@link https://firebase.google.com/docs/database/web/lists-of-data#filtering_data | Filtering data}.
22497
+ *
22498
+ * @param value - The value to start at. The argument type depends on which
22499
+ * `orderBy*()` function was used in this query. Specify a value that matches
22500
+ * the `orderBy*()` type. When used in combination with `orderByKey()`, the
22501
+ * value must be a string.
22502
+ * @param key - The child key to start at. This argument is only allowed if
22503
+ * ordering by child, value, or priority.
22504
+ */
22505
+ function startAt(value = null, key) {
22506
+ validateKey('startAt', 'key', key, true);
22507
+ return new QueryStartAtConstraint(value, key);
22508
+ }
22509
+ class QueryStartAfterConstraint extends QueryConstraint {
22510
+ constructor(_value, _key) {
22511
+ super();
22512
+ this._value = _value;
22513
+ this._key = _key;
22514
+ }
22515
+ _apply(query) {
22516
+ validateFirebaseDataArg('startAfter', this._value, query._path, false);
22517
+ const newParams = queryParamsStartAfter(query._queryParams, this._value, this._key);
22518
+ validateLimit(newParams);
22519
+ validateQueryEndpoints(newParams);
22520
+ if (query._queryParams.hasStart()) {
22521
+ throw new Error('startAfter: Starting point was already set (by another call to startAt, ' +
22522
+ 'startAfter, or equalTo).');
22523
+ }
22524
+ return new QueryImpl(query._repo, query._path, newParams, query._orderByCalled);
22525
+ }
22526
+ }
22527
+ /**
22528
+ * Creates a `QueryConstraint` with the specified starting point (exclusive).
22529
+ *
22530
+ * Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()`
22531
+ * allows you to choose arbitrary starting and ending points for your queries.
22532
+ *
22533
+ * The starting point is exclusive. If only a value is provided, children
22534
+ * with a value greater than the specified value will be included in the query.
22535
+ * If a key is specified, then children must have a value greater than or equal
22536
+ * to the specified value and a a key name greater than the specified key.
22537
+ *
22538
+ * @param value - The value to start after. The argument type depends on which
22539
+ * `orderBy*()` function was used in this query. Specify a value that matches
22540
+ * the `orderBy*()` type. When used in combination with `orderByKey()`, the
22541
+ * value must be a string.
22542
+ * @param key - The child key to start after. This argument is only allowed if
22543
+ * ordering by child, value, or priority.
22544
+ */
22545
+ function startAfter(value, key) {
22546
+ validateKey('startAfter', 'key', key, true);
22547
+ return new QueryStartAfterConstraint(value, key);
22548
+ }
22549
+ class QueryLimitToFirstConstraint extends QueryConstraint {
22550
+ constructor(_limit) {
22551
+ super();
22552
+ this._limit = _limit;
22553
+ }
22554
+ _apply(query) {
22555
+ if (query._queryParams.hasLimit()) {
22556
+ throw new Error('limitToFirst: Limit was already set (by another call to limitToFirst ' +
22557
+ 'or limitToLast).');
22558
+ }
22559
+ return new QueryImpl(query._repo, query._path, queryParamsLimitToFirst(query._queryParams, this._limit), query._orderByCalled);
22560
+ }
22561
+ }
22562
+ /**
22563
+ * Creates a new `QueryConstraint` that if limited to the first specific number
22564
+ * of children.
22565
+ *
22566
+ * The `limitToFirst()` method is used to set a maximum number of children to be
22567
+ * synced for a given callback. If we set a limit of 100, we will initially only
22568
+ * receive up to 100 `child_added` events. If we have fewer than 100 messages
22569
+ * stored in our Database, a `child_added` event will fire for each message.
22570
+ * However, if we have over 100 messages, we will only receive a `child_added`
22571
+ * event for the first 100 ordered messages. As items change, we will receive
22572
+ * `child_removed` events for each item that drops out of the active list so
22573
+ * that the total number stays at 100.
22574
+ *
22575
+ * You can read more about `limitToFirst()` in
22576
+ * {@link https://firebase.google.com/docs/database/web/lists-of-data#filtering_data | Filtering data}.
22577
+ *
22578
+ * @param limit - The maximum number of nodes to include in this query.
22579
+ */
22580
+ function limitToFirst(limit) {
22581
+ if (typeof limit !== 'number' || Math.floor(limit) !== limit || limit <= 0) {
22582
+ throw new Error('limitToFirst: First argument must be a positive integer.');
22583
+ }
22584
+ return new QueryLimitToFirstConstraint(limit);
22585
+ }
22586
+ class QueryLimitToLastConstraint extends QueryConstraint {
22587
+ constructor(_limit) {
22588
+ super();
22589
+ this._limit = _limit;
22590
+ }
22591
+ _apply(query) {
22592
+ if (query._queryParams.hasLimit()) {
22593
+ throw new Error('limitToLast: Limit was already set (by another call to limitToFirst ' +
22594
+ 'or limitToLast).');
22595
+ }
22596
+ return new QueryImpl(query._repo, query._path, queryParamsLimitToLast(query._queryParams, this._limit), query._orderByCalled);
22597
+ }
22598
+ }
22599
+ /**
22600
+ * Creates a new `QueryConstraint` that is limited to return only the last
22601
+ * specified number of children.
22602
+ *
22603
+ * The `limitToLast()` method is used to set a maximum number of children to be
22604
+ * synced for a given callback. If we set a limit of 100, we will initially only
22605
+ * receive up to 100 `child_added` events. If we have fewer than 100 messages
22606
+ * stored in our Database, a `child_added` event will fire for each message.
22607
+ * However, if we have over 100 messages, we will only receive a `child_added`
22608
+ * event for the last 100 ordered messages. As items change, we will receive
22609
+ * `child_removed` events for each item that drops out of the active list so
22610
+ * that the total number stays at 100.
22611
+ *
22612
+ * You can read more about `limitToLast()` in
22613
+ * {@link https://firebase.google.com/docs/database/web/lists-of-data#filtering_data | Filtering data}.
22614
+ *
22615
+ * @param limit - The maximum number of nodes to include in this query.
22616
+ */
22617
+ function limitToLast(limit) {
22618
+ if (typeof limit !== 'number' || Math.floor(limit) !== limit || limit <= 0) {
22619
+ throw new Error('limitToLast: First argument must be a positive integer.');
22620
+ }
22621
+ return new QueryLimitToLastConstraint(limit);
22622
+ }
22623
+ class QueryOrderByChildConstraint extends QueryConstraint {
22624
+ constructor(_path) {
22625
+ super();
22626
+ this._path = _path;
22627
+ }
22628
+ _apply(query) {
22629
+ validateNoPreviousOrderByCall(query, 'orderByChild');
22630
+ const parsedPath = new Path(this._path);
22631
+ if (pathIsEmpty(parsedPath)) {
22632
+ throw new Error('orderByChild: cannot pass in empty path. Use orderByValue() instead.');
22633
+ }
22634
+ const index = new PathIndex(parsedPath);
22635
+ const newParams = queryParamsOrderBy(query._queryParams, index);
22636
+ validateQueryEndpoints(newParams);
22637
+ return new QueryImpl(query._repo, query._path, newParams,
22638
+ /*orderByCalled=*/ true);
22639
+ }
22640
+ }
22641
+ /**
22642
+ * Creates a new `QueryConstraint` that orders by the specified child key.
22643
+ *
22644
+ * Queries can only order by one key at a time. Calling `orderByChild()`
22645
+ * multiple times on the same query is an error.
22646
+ *
22647
+ * Firebase queries allow you to order your data by any child key on the fly.
22648
+ * However, if you know in advance what your indexes will be, you can define
22649
+ * them via the .indexOn rule in your Security Rules for better performance. See
22650
+ * the{@link https://firebase.google.com/docs/database/security/indexing-data}
22651
+ * rule for more information.
22652
+ *
22653
+ * You can read more about `orderByChild()` in
22654
+ * {@link https://firebase.google.com/docs/database/web/lists-of-data#sort_data | Sort data}.
22655
+ *
22656
+ * @param path - The path to order by.
22657
+ */
22658
+ function orderByChild(path) {
22659
+ if (path === '$key') {
22660
+ throw new Error('orderByChild: "$key" is invalid. Use orderByKey() instead.');
22661
+ }
22662
+ else if (path === '$priority') {
22663
+ throw new Error('orderByChild: "$priority" is invalid. Use orderByPriority() instead.');
22664
+ }
22665
+ else if (path === '$value') {
22666
+ throw new Error('orderByChild: "$value" is invalid. Use orderByValue() instead.');
22667
+ }
22668
+ validatePathString('orderByChild', 'path', path, false);
22669
+ return new QueryOrderByChildConstraint(path);
22670
+ }
22671
+ class QueryOrderByKeyConstraint extends QueryConstraint {
22672
+ _apply(query) {
22673
+ validateNoPreviousOrderByCall(query, 'orderByKey');
22674
+ const newParams = queryParamsOrderBy(query._queryParams, KEY_INDEX);
22675
+ validateQueryEndpoints(newParams);
22676
+ return new QueryImpl(query._repo, query._path, newParams,
22677
+ /*orderByCalled=*/ true);
22678
+ }
22679
+ }
22680
+ /**
22681
+ * Creates a new `QueryConstraint` that orders by the key.
22682
+ *
22683
+ * Sorts the results of a query by their (ascending) key values.
22684
+ *
22685
+ * You can read more about `orderByKey()` in
22686
+ * {@link https://firebase.google.com/docs/database/web/lists-of-data#sort_data | Sort data}.
22687
+ */
22688
+ function orderByKey() {
22689
+ return new QueryOrderByKeyConstraint();
22690
+ }
22691
+ class QueryOrderByPriorityConstraint extends QueryConstraint {
22692
+ _apply(query) {
22693
+ validateNoPreviousOrderByCall(query, 'orderByPriority');
22694
+ const newParams = queryParamsOrderBy(query._queryParams, PRIORITY_INDEX);
22695
+ validateQueryEndpoints(newParams);
22696
+ return new QueryImpl(query._repo, query._path, newParams,
22697
+ /*orderByCalled=*/ true);
22698
+ }
22699
+ }
22700
+ /**
22701
+ * Creates a new `QueryConstraint` that orders by priority.
22702
+ *
22703
+ * Applications need not use priority but can order collections by
22704
+ * ordinary properties (see
22705
+ * {@link https://firebase.google.com/docs/database/web/lists-of-data#sort_data | Sort data}
22706
+ * for alternatives to priority.
22707
+ */
22708
+ function orderByPriority() {
22709
+ return new QueryOrderByPriorityConstraint();
22710
+ }
22711
+ class QueryOrderByValueConstraint extends QueryConstraint {
22712
+ _apply(query) {
22713
+ validateNoPreviousOrderByCall(query, 'orderByValue');
22714
+ const newParams = queryParamsOrderBy(query._queryParams, VALUE_INDEX);
22715
+ validateQueryEndpoints(newParams);
22716
+ return new QueryImpl(query._repo, query._path, newParams,
22717
+ /*orderByCalled=*/ true);
22718
+ }
22719
+ }
22720
+ /**
22721
+ * Creates a new `QueryConstraint` that orders by value.
22722
+ *
22723
+ * If the children of a query are all scalar values (string, number, or
22724
+ * boolean), you can order the results by their (ascending) values.
22725
+ *
22726
+ * You can read more about `orderByValue()` in
22727
+ * {@link https://firebase.google.com/docs/database/web/lists-of-data#sort_data | Sort data}.
22728
+ */
22729
+ function orderByValue() {
22730
+ return new QueryOrderByValueConstraint();
22731
+ }
22732
+ class QueryEqualToValueConstraint extends QueryConstraint {
22733
+ constructor(_value, _key) {
22734
+ super();
22735
+ this._value = _value;
22736
+ this._key = _key;
22737
+ }
22738
+ _apply(query) {
22739
+ validateFirebaseDataArg('equalTo', this._value, query._path, false);
22740
+ if (query._queryParams.hasStart()) {
22741
+ throw new Error('equalTo: Starting point was already set (by another call to startAt/startAfter or ' +
22742
+ 'equalTo).');
22743
+ }
22744
+ if (query._queryParams.hasEnd()) {
22745
+ throw new Error('equalTo: Ending point was already set (by another call to endAt/endBefore or ' +
22746
+ 'equalTo).');
22747
+ }
22748
+ return new QueryEndAtConstraint(this._value, this._key)._apply(new QueryStartAtConstraint(this._value, this._key)._apply(query));
22749
+ }
22750
+ }
22751
+ /**
22752
+ * Creates a `QueryConstraint` that includes children that match the specified
22753
+ * value.
22754
+ *
22755
+ * Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()`
22756
+ * allows you to choose arbitrary starting and ending points for your queries.
22757
+ *
22758
+ * The optional key argument can be used to further limit the range of the
22759
+ * query. If it is specified, then children that have exactly the specified
22760
+ * value must also have exactly the specified key as their key name. This can be
22761
+ * used to filter result sets with many matches for the same value.
22762
+ *
22763
+ * You can read more about `equalTo()` in
22764
+ * {@link https://firebase.google.com/docs/database/web/lists-of-data#filtering_data | Filtering data}.
22765
+ *
22766
+ * @param value - The value to match for. The argument type depends on which
22767
+ * `orderBy*()` function was used in this query. Specify a value that matches
22768
+ * the `orderBy*()` type. When used in combination with `orderByKey()`, the
22769
+ * value must be a string.
22770
+ * @param key - The child key to start at, among the children with the
22771
+ * previously specified priority. This argument is only allowed if ordering by
22772
+ * child, value, or priority.
22773
+ */
22774
+ function equalTo(value, key) {
22775
+ validateKey('equalTo', 'key', key, true);
22776
+ return new QueryEqualToValueConstraint(value, key);
22777
+ }
22778
+ /**
22779
+ * Creates a new immutable instance of `Query` that is extended to also include
22780
+ * additional query constraints.
22781
+ *
22782
+ * @param query - The Query instance to use as a base for the new constraints.
22783
+ * @param queryConstraints - The list of `QueryConstraint`s to apply.
22784
+ * @throws if any of the provided query constraints cannot be combined with the
22785
+ * existing or new constraints.
22786
+ */
22787
+ function query(query, ...queryConstraints) {
22788
+ let queryImpl = getModularInstance(query);
22789
+ for (const constraint of queryConstraints) {
22790
+ queryImpl = constraint._apply(queryImpl);
22791
+ }
22792
+ return queryImpl;
22793
+ }
20681
22794
  /**
20682
22795
  * Define reference constructor in various modules
20683
22796
  *
@@ -20806,6 +22919,12 @@ function repoManagerCreateRepo(repoInfo, app, authTokenProvider, appCheckProvide
20806
22919
  appRepos[repoInfo.toURLString()] = repo;
20807
22920
  return repo;
20808
22921
  }
22922
+ /**
22923
+ * Forces us to use ReadonlyRestClient instead of PersistentConnection for new Repos.
22924
+ */
22925
+ function repoManagerForceRestClient(forceRestClient) {
22926
+ useRestClient = forceRestClient;
22927
+ }
20809
22928
  /**
20810
22929
  * Class representing a Firebase Realtime Database.
20811
22930
  */
@@ -20848,6 +22967,26 @@ class Database {
20848
22967
  }
20849
22968
  }
20850
22969
  }
22970
+ function checkTransportInit() {
22971
+ if (TransportManager.IS_TRANSPORT_INITIALIZED) {
22972
+ warn('Transport has already been initialized. Please call this function before calling ref or setting up a listener');
22973
+ }
22974
+ }
22975
+ /**
22976
+ * Force the use of websockets instead of longPolling.
22977
+ */
22978
+ function forceWebSockets() {
22979
+ checkTransportInit();
22980
+ BrowserPollConnection.forceDisallow();
22981
+ }
22982
+ /**
22983
+ * Force the use of longPolling instead of websockets. This will be ignored if websocket protocol is used in databaseURL.
22984
+ */
22985
+ function forceLongPolling() {
22986
+ checkTransportInit();
22987
+ WebSocketConnection.forceDisallow();
22988
+ BrowserPollConnection.forceAllow();
22989
+ }
20851
22990
  /**
20852
22991
  * Returns the instance of the Realtime Database SDK that is associated
20853
22992
  * with the provided {@link @firebase/app#FirebaseApp}. Initializes a new instance with
@@ -20906,6 +23045,51 @@ function connectDatabaseEmulator(db, host, port, options = {}) {
20906
23045
  // Modify the repo to apply emulator settings
20907
23046
  repoManagerApplyEmulatorSettings(repo, host, port, tokenProvider);
20908
23047
  }
23048
+ /**
23049
+ * Disconnects from the server (all Database operations will be completed
23050
+ * offline).
23051
+ *
23052
+ * The client automatically maintains a persistent connection to the Database
23053
+ * server, which will remain active indefinitely and reconnect when
23054
+ * disconnected. However, the `goOffline()` and `goOnline()` methods may be used
23055
+ * to control the client connection in cases where a persistent connection is
23056
+ * undesirable.
23057
+ *
23058
+ * While offline, the client will no longer receive data updates from the
23059
+ * Database. However, all Database operations performed locally will continue to
23060
+ * immediately fire events, allowing your application to continue behaving
23061
+ * normally. Additionally, each operation performed locally will automatically
23062
+ * be queued and retried upon reconnection to the Database server.
23063
+ *
23064
+ * To reconnect to the Database and begin receiving remote events, see
23065
+ * `goOnline()`.
23066
+ *
23067
+ * @param db - The instance to disconnect.
23068
+ */
23069
+ function goOffline(db) {
23070
+ db = getModularInstance(db);
23071
+ db._checkNotDeleted('goOffline');
23072
+ repoInterrupt(db._repo);
23073
+ }
23074
+ /**
23075
+ * Reconnects to the server and synchronizes the offline Database state
23076
+ * with the server state.
23077
+ *
23078
+ * This method should be used after disabling the active connection with
23079
+ * `goOffline()`. Once reconnected, the client will transmit the proper data
23080
+ * and fire the appropriate events so that your client "catches up"
23081
+ * automatically.
23082
+ *
23083
+ * @param db - The instance to reconnect.
23084
+ */
23085
+ function goOnline(db) {
23086
+ db = getModularInstance(db);
23087
+ db._checkNotDeleted('goOnline');
23088
+ repoResume(db._repo);
23089
+ }
23090
+ function enableLogging(logger, persistent) {
23091
+ enableLogging$1(logger, persistent);
23092
+ }
20909
23093
 
20910
23094
  /**
20911
23095
  * @license
@@ -20935,6 +23119,164 @@ function registerDatabase(variant) {
20935
23119
  // BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation
20936
23120
  registerVersion(name, version, 'esm2017');
20937
23121
  }
23122
+
23123
+ /**
23124
+ * @license
23125
+ * Copyright 2020 Google LLC
23126
+ *
23127
+ * Licensed under the Apache License, Version 2.0 (the "License");
23128
+ * you may not use this file except in compliance with the License.
23129
+ * You may obtain a copy of the License at
23130
+ *
23131
+ * http://www.apache.org/licenses/LICENSE-2.0
23132
+ *
23133
+ * Unless required by applicable law or agreed to in writing, software
23134
+ * distributed under the License is distributed on an "AS IS" BASIS,
23135
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23136
+ * See the License for the specific language governing permissions and
23137
+ * limitations under the License.
23138
+ */
23139
+ const SERVER_TIMESTAMP = {
23140
+ '.sv': 'timestamp'
23141
+ };
23142
+ /**
23143
+ * Returns a placeholder value for auto-populating the current timestamp (time
23144
+ * since the Unix epoch, in milliseconds) as determined by the Firebase
23145
+ * servers.
23146
+ */
23147
+ function serverTimestamp() {
23148
+ return SERVER_TIMESTAMP;
23149
+ }
23150
+ /**
23151
+ * Returns a placeholder value that can be used to atomically increment the
23152
+ * current database value by the provided delta.
23153
+ *
23154
+ * @param delta - the amount to modify the current value atomically.
23155
+ * @returns A placeholder value for modifying data atomically server-side.
23156
+ */
23157
+ function increment(delta) {
23158
+ return {
23159
+ '.sv': {
23160
+ 'increment': delta
23161
+ }
23162
+ };
23163
+ }
23164
+
23165
+ /**
23166
+ * @license
23167
+ * Copyright 2020 Google LLC
23168
+ *
23169
+ * Licensed under the Apache License, Version 2.0 (the "License");
23170
+ * you may not use this file except in compliance with the License.
23171
+ * You may obtain a copy of the License at
23172
+ *
23173
+ * http://www.apache.org/licenses/LICENSE-2.0
23174
+ *
23175
+ * Unless required by applicable law or agreed to in writing, software
23176
+ * distributed under the License is distributed on an "AS IS" BASIS,
23177
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23178
+ * See the License for the specific language governing permissions and
23179
+ * limitations under the License.
23180
+ */
23181
+ /**
23182
+ * A type for the resolve value of {@link runTransaction}.
23183
+ */
23184
+ class TransactionResult {
23185
+ /** @hideconstructor */
23186
+ constructor(
23187
+ /** Whether the transaction was successfully committed. */
23188
+ committed,
23189
+ /** The resulting data snapshot. */
23190
+ snapshot) {
23191
+ this.committed = committed;
23192
+ this.snapshot = snapshot;
23193
+ }
23194
+ /** Returns a JSON-serializable representation of this object. */
23195
+ toJSON() {
23196
+ return { committed: this.committed, snapshot: this.snapshot.toJSON() };
23197
+ }
23198
+ }
23199
+ /**
23200
+ * Atomically modifies the data at this location.
23201
+ *
23202
+ * Atomically modify the data at this location. Unlike a normal `set()`, which
23203
+ * just overwrites the data regardless of its previous value, `runTransaction()` is
23204
+ * used to modify the existing value to a new value, ensuring there are no
23205
+ * conflicts with other clients writing to the same location at the same time.
23206
+ *
23207
+ * To accomplish this, you pass `runTransaction()` an update function which is
23208
+ * used to transform the current value into a new value. If another client
23209
+ * writes to the location before your new value is successfully written, your
23210
+ * update function will be called again with the new current value, and the
23211
+ * write will be retried. This will happen repeatedly until your write succeeds
23212
+ * without conflict or you abort the transaction by not returning a value from
23213
+ * your update function.
23214
+ *
23215
+ * Note: Modifying data with `set()` will cancel any pending transactions at
23216
+ * that location, so extreme care should be taken if mixing `set()` and
23217
+ * `runTransaction()` to update the same data.
23218
+ *
23219
+ * Note: When using transactions with Security and Firebase Rules in place, be
23220
+ * aware that a client needs `.read` access in addition to `.write` access in
23221
+ * order to perform a transaction. This is because the client-side nature of
23222
+ * transactions requires the client to read the data in order to transactionally
23223
+ * update it.
23224
+ *
23225
+ * @param ref - The location to atomically modify.
23226
+ * @param transactionUpdate - A developer-supplied function which will be passed
23227
+ * the current data stored at this location (as a JavaScript object). The
23228
+ * function should return the new value it would like written (as a JavaScript
23229
+ * object). If `undefined` is returned (i.e. you return with no arguments) the
23230
+ * transaction will be aborted and the data at this location will not be
23231
+ * modified.
23232
+ * @param options - An options object to configure transactions.
23233
+ * @returns A `Promise` that can optionally be used instead of the `onComplete`
23234
+ * callback to handle success and failure.
23235
+ */
23236
+ function runTransaction(ref,
23237
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
23238
+ transactionUpdate, options) {
23239
+ var _a;
23240
+ ref = getModularInstance(ref);
23241
+ validateWritablePath('Reference.transaction', ref._path);
23242
+ if (ref.key === '.length' || ref.key === '.keys') {
23243
+ throw ('Reference.transaction failed: ' + ref.key + ' is a read-only object.');
23244
+ }
23245
+ const applyLocally = (_a = options === null || options === void 0 ? void 0 : options.applyLocally) !== null && _a !== void 0 ? _a : true;
23246
+ const deferred = new Deferred();
23247
+ const promiseComplete = (error, committed, node) => {
23248
+ let dataSnapshot = null;
23249
+ if (error) {
23250
+ deferred.reject(error);
23251
+ }
23252
+ else {
23253
+ dataSnapshot = new DataSnapshot(node, new ReferenceImpl(ref._repo, ref._path), PRIORITY_INDEX);
23254
+ deferred.resolve(new TransactionResult(committed, dataSnapshot));
23255
+ }
23256
+ };
23257
+ // Add a watch to make sure we get server updates.
23258
+ const unwatcher = onValue(ref, () => { });
23259
+ repoStartTransaction(ref._repo, ref._path, transactionUpdate, promiseComplete, unwatcher, applyLocally);
23260
+ return deferred.promise;
23261
+ }
23262
+
23263
+ /**
23264
+ * @license
23265
+ * Copyright 2017 Google LLC
23266
+ *
23267
+ * Licensed under the Apache License, Version 2.0 (the "License");
23268
+ * you may not use this file except in compliance with the License.
23269
+ * You may obtain a copy of the License at
23270
+ *
23271
+ * http://www.apache.org/licenses/LICENSE-2.0
23272
+ *
23273
+ * Unless required by applicable law or agreed to in writing, software
23274
+ * distributed under the License is distributed on an "AS IS" BASIS,
23275
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23276
+ * See the License for the specific language governing permissions and
23277
+ * limitations under the License.
23278
+ */
23279
+ PersistentConnection;
20938
23280
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
20939
23281
  PersistentConnection.prototype.simpleListen = function (pathString, onComplete) {
20940
23282
  this.sendRequest('q', { p: pathString }, onComplete);
@@ -20943,6 +23285,31 @@ PersistentConnection.prototype.simpleListen = function (pathString, onComplete)
20943
23285
  PersistentConnection.prototype.echo = function (data, onEcho) {
20944
23286
  this.sendRequest('echo', { d: data }, onEcho);
20945
23287
  };
23288
+ // RealTimeConnection properties that we use in tests.
23289
+ Connection;
23290
+ /**
23291
+ * @internal
23292
+ */
23293
+ const hijackHash = function (newHash) {
23294
+ const oldPut = PersistentConnection.prototype.put;
23295
+ PersistentConnection.prototype.put = function (pathString, data, onComplete, hash) {
23296
+ if (hash !== undefined) {
23297
+ hash = newHash();
23298
+ }
23299
+ oldPut.call(this, pathString, data, onComplete, hash);
23300
+ };
23301
+ return function () {
23302
+ PersistentConnection.prototype.put = oldPut;
23303
+ };
23304
+ };
23305
+ RepoInfo;
23306
+ /**
23307
+ * Forces the RepoManager to create Repos that use ReadonlyRestClient instead of PersistentConnection.
23308
+ * @internal
23309
+ */
23310
+ const forceRestClient = function (forceRestClient) {
23311
+ repoManagerForceRestClient(forceRestClient);
23312
+ };
20946
23313
 
20947
23314
  /**
20948
23315
  * Firebase Realtime Database
@@ -20952,7 +23319,7 @@ PersistentConnection.prototype.echo = function (data, onEcho) {
20952
23319
  registerDatabase();
20953
23320
 
20954
23321
  var dayjs_min = createCommonjsModule(function (module, exports) {
20955
- !function(t,e){module.exports=e();}(commonjsGlobal,(function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",f="month",h="quarter",c="year",d="date",$="Invalid Date",l=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_")},m=function(t,e,n){var r=String(t);return !r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},g={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return (e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return -t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,f),s=n-i<0,u=e.clone().add(r+(s?-1:1),f);return +(-(r+(n-i)/(s?i-u:u-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return {M:f,y:c,w:o,d:a,D:d,h:u,m:s,s:i,ms:r,Q:h}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},D="en",v={};v[D]=M;var p=function(t){return t instanceof _},S=function(t,e,n){var r;if(!t)return D;if("string"==typeof t)v[t]&&(r=t),e&&(v[t]=e,r=t);else {var i=t.name;v[i]=t,r=i;}return !n&&r&&(D=r),r||!n&&D},w=function(t,e){if(p(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},O=g;O.l=S,O.i=p,O.w=function(t,e){return w(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=S(t.locale,null,!0),this.parse(t);}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(O.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match(l);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.$x=t.x||{},this.init();},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds();},m.$utils=function(){return O},m.isValid=function(){return !(this.$d.toString()===$)},m.isSame=function(t,e){var n=w(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return w(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<w(t)},m.$g=function(t,e,n){return O.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var n=this,r=!!O.u(e)||e,h=O.p(t),$=function(t,e){var i=O.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?i:i.endOf(a)},l=function(t,e){return O.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},y=this.$W,M=this.$M,m=this.$D,g="set"+(this.$u?"UTC":"");switch(h){case c:return r?$(1,0):$(31,11);case f:return r?$(1,M):$(0,M+1);case o:var D=this.$locale().weekStart||0,v=(y<D?y+7:y)-D;return $(r?m-v:m+(6-v),M);case a:case d:return l(g+"Hours",0);case u:return l(g+"Minutes",1);case s:return l(g+"Seconds",2);case i:return l(g+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,!1)},m.$set=function(t,e){var n,o=O.p(t),h="set"+(this.$u?"UTC":""),$=(n={},n[a]=h+"Date",n[d]=h+"Date",n[f]=h+"Month",n[c]=h+"FullYear",n[u]=h+"Hours",n[s]=h+"Minutes",n[i]=h+"Seconds",n[r]=h+"Milliseconds",n)[o],l=o===a?this.$D+(e-this.$W):e;if(o===f||o===c){var y=this.clone().set(d,1);y.$d[$](l),y.init(),this.$d=y.set(d,Math.min(this.$D,y.daysInMonth())).$d;}else $&&this.$d[$](l);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[O.p(t)]()},m.add=function(r,h){var d,$=this;r=Number(r);var l=O.p(h),y=function(t){var e=w($);return O.w(e.date(e.date()+Math.round(t*r)),$)};if(l===f)return this.set(f,this.$M+r);if(l===c)return this.set(c,this.$y+r);if(l===a)return y(1);if(l===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[l]||1,m=this.$d.getTime()+r*M;return O.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||$;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=O.z(this),s=this.$H,u=this.$m,a=this.$M,o=n.weekdays,f=n.months,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].substr(0,s)},c=function(t){return O.s(s%12||12,t,"0")},d=n.meridiem||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r},l={YY:String(this.$y).slice(-2),YYYY:this.$y,M:a+1,MM:O.s(a+1,2,"0"),MMM:h(n.monthsShort,a,f,3),MMMM:h(f,a),D:this.$D,DD:O.s(this.$D,2,"0"),d:String(this.$W),dd:h(n.weekdaysMin,this.$W,o,2),ddd:h(n.weekdaysShort,this.$W,o,3),dddd:o[this.$W],H:String(s),HH:O.s(s,2,"0"),h:c(1),hh:c(2),a:d(s,u,!0),A:d(s,u,!1),m:String(u),mm:O.s(u,2,"0"),s:String(this.$s),ss:O.s(this.$s,2,"0"),SSS:O.s(this.$ms,3,"0"),Z:i};return r.replace(y,(function(t,e){return e||l[t]||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,$){var l,y=O.p(d),M=w(r),m=(M.utcOffset()-this.utcOffset())*e,g=this-M,D=O.m(this,M);return D=(l={},l[c]=D/12,l[f]=D,l[h]=D/3,l[o]=(g-m)/6048e5,l[a]=(g-m)/864e5,l[u]=g/n,l[s]=g/e,l[i]=g/t,l)[y]||g,$?D:O.a(D)},m.daysInMonth=function(){return this.endOf(f).$D},m.$locale=function(){return v[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=S(t,e,!0);return r&&(n.$L=r),n},m.clone=function(){return O.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},M}(),b=_.prototype;return w.prototype=b,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",f],["$y",c],["$D",d]].forEach((function(t){b[t[1]]=function(e){return this.$g(e,t[0],t[1])};})),w.extend=function(t,e){return t.$i||(t(e,_,w),t.$i=!0),w},w.locale=S,w.isDayjs=p,w.unix=function(t){return w(1e3*t)},w.en=v[D],w.Ls=v,w.p={},w}));
23322
+ !function(t,e){"object"=='object'&&"undefined"!='object'?module.exports=e():"function"==typeof undefined&&undefined.amd?undefined(e):(t="undefined"!=typeof globalThis?globalThis:t||self).dayjs=e();}(commonjsGlobal,(function(){"use strict";var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",f="month",h="quarter",c="year",d="date",$="Invalid Date",l=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_")},m=function(t,e,n){var r=String(t);return !r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},g={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return (e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return -t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,f),s=n-i<0,u=e.clone().add(r+(s?-1:1),f);return +(-(r+(n-i)/(s?i-u:u-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return {M:f,y:c,w:o,d:a,D:d,h:u,m:s,s:i,ms:r,Q:h}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},D="en",v={};v[D]=M;var p=function(t){return t instanceof _},S=function(t,e,n){var r;if(!t)return D;if("string"==typeof t)v[t]&&(r=t),e&&(v[t]=e,r=t);else {var i=t.name;v[i]=t,r=i;}return !n&&r&&(D=r),r||!n&&D},w=function(t,e){if(p(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},O=g;O.l=S,O.i=p,O.w=function(t,e){return w(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=S(t.locale,null,!0),this.parse(t);}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(O.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match(l);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.$x=t.x||{},this.init();},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds();},m.$utils=function(){return O},m.isValid=function(){return !(this.$d.toString()===$)},m.isSame=function(t,e){var n=w(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return w(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<w(t)},m.$g=function(t,e,n){return O.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var n=this,r=!!O.u(e)||e,h=O.p(t),$=function(t,e){var i=O.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?i:i.endOf(a)},l=function(t,e){return O.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},y=this.$W,M=this.$M,m=this.$D,g="set"+(this.$u?"UTC":"");switch(h){case c:return r?$(1,0):$(31,11);case f:return r?$(1,M):$(0,M+1);case o:var D=this.$locale().weekStart||0,v=(y<D?y+7:y)-D;return $(r?m-v:m+(6-v),M);case a:case d:return l(g+"Hours",0);case u:return l(g+"Minutes",1);case s:return l(g+"Seconds",2);case i:return l(g+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,!1)},m.$set=function(t,e){var n,o=O.p(t),h="set"+(this.$u?"UTC":""),$=(n={},n[a]=h+"Date",n[d]=h+"Date",n[f]=h+"Month",n[c]=h+"FullYear",n[u]=h+"Hours",n[s]=h+"Minutes",n[i]=h+"Seconds",n[r]=h+"Milliseconds",n)[o],l=o===a?this.$D+(e-this.$W):e;if(o===f||o===c){var y=this.clone().set(d,1);y.$d[$](l),y.init(),this.$d=y.set(d,Math.min(this.$D,y.daysInMonth())).$d;}else $&&this.$d[$](l);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[O.p(t)]()},m.add=function(r,h){var d,$=this;r=Number(r);var l=O.p(h),y=function(t){var e=w($);return O.w(e.date(e.date()+Math.round(t*r)),$)};if(l===f)return this.set(f,this.$M+r);if(l===c)return this.set(c,this.$y+r);if(l===a)return y(1);if(l===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[l]||1,m=this.$d.getTime()+r*M;return O.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||$;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=O.z(this),s=this.$H,u=this.$m,a=this.$M,o=n.weekdays,f=n.months,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].substr(0,s)},c=function(t){return O.s(s%12||12,t,"0")},d=n.meridiem||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r},l={YY:String(this.$y).slice(-2),YYYY:this.$y,M:a+1,MM:O.s(a+1,2,"0"),MMM:h(n.monthsShort,a,f,3),MMMM:h(f,a),D:this.$D,DD:O.s(this.$D,2,"0"),d:String(this.$W),dd:h(n.weekdaysMin,this.$W,o,2),ddd:h(n.weekdaysShort,this.$W,o,3),dddd:o[this.$W],H:String(s),HH:O.s(s,2,"0"),h:c(1),hh:c(2),a:d(s,u,!0),A:d(s,u,!1),m:String(u),mm:O.s(u,2,"0"),s:String(this.$s),ss:O.s(this.$s,2,"0"),SSS:O.s(this.$ms,3,"0"),Z:i};return r.replace(y,(function(t,e){return e||l[t]||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,$){var l,y=O.p(d),M=w(r),m=(M.utcOffset()-this.utcOffset())*e,g=this-M,D=O.m(this,M);return D=(l={},l[c]=D/12,l[f]=D,l[h]=D/3,l[o]=(g-m)/6048e5,l[a]=(g-m)/864e5,l[u]=g/n,l[s]=g/e,l[i]=g/t,l)[y]||g,$?D:O.a(D)},m.daysInMonth=function(){return this.endOf(f).$D},m.$locale=function(){return v[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=S(t,e,!0);return r&&(n.$L=r),n},m.clone=function(){return O.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},M}(),b=_.prototype;return w.prototype=b,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",f],["$y",c],["$D",d]].forEach((function(t){b[t[1]]=function(e){return this.$g(e,t[0],t[1])};})),w.extend=function(t,e){return t.$i||(t(e,_,w),t.$i=!0),w},w.locale=S,w.isDayjs=p,w.unix=function(t){return w(1e3*t)},w.en=v[D],w.Ls=v,w.p={},w}));
20956
23323
  });
20957
23324
 
20958
23325
  function createService(blob) {
@@ -21153,6 +23520,8 @@ function createReviewPhoto(blob) {
21153
23520
  imageUrlThumb: blob.full_image_url_thumb,
21154
23521
  };
21155
23522
  }
23523
+ class Review {
23524
+ }
21156
23525
  function createReview(blob) {
21157
23526
  const reviewPhotos = blob.review_photo || [];
21158
23527
  const [createdDay, createdTime] = String(blob.create_date).split(' ');
@@ -21184,7 +23553,7 @@ function createChatMessage(blob) {
21184
23553
  message: blob.message,
21185
23554
  timestamp: blob.timestamp,
21186
23555
  unRead: blob.unRead,
21187
- senderId: blob.senderId,
23556
+ senderId: Number(blob.senderId),
21188
23557
  };
21189
23558
  }
21190
23559
  class ChatRoom {
@@ -21443,7 +23812,7 @@ class HttpService {
21443
23812
  const roomMessagesRef = ref(this.firebaseDatabase, `${firebaseMessagesNode}/${roomId}`);
21444
23813
  const updates = {};
21445
23814
  roomMessages.forEach(message => {
21446
- const nestedMessage = __rest(message, ["uid"]);
23815
+ const { uid } = message, nestedMessage = __rest(message, ["uid"]);
21447
23816
  updates[`${message.uid}`] = Object.assign(Object.assign({}, nestedMessage), { unRead: 0 });
21448
23817
  });
21449
23818
  return update(roomMessagesRef, updates);