pyric-tools 0.1.0-alpha.7

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 (1052) hide show
  1. package/README.md +125 -0
  2. package/dist/auth/domains/handler.d.ts +6 -0
  3. package/dist/auth/domains/handler.d.ts.map +1 -0
  4. package/dist/auth/domains/handler.js +75 -0
  5. package/dist/auth/domains/handler.js.map +1 -0
  6. package/dist/auth/domains/spec.d.ts +25 -0
  7. package/dist/auth/domains/spec.d.ts.map +1 -0
  8. package/dist/auth/domains/spec.js +6 -0
  9. package/dist/auth/domains/spec.js.map +1 -0
  10. package/dist/auth/index.d.ts +34 -0
  11. package/dist/auth/index.d.ts.map +1 -0
  12. package/dist/auth/index.js +30 -0
  13. package/dist/auth/index.js.map +1 -0
  14. package/dist/auth/mapper.d.ts +5 -0
  15. package/dist/auth/mapper.d.ts.map +1 -0
  16. package/dist/auth/mapper.js +49 -0
  17. package/dist/auth/mapper.js.map +1 -0
  18. package/dist/auth/provider/handler.d.ts +9 -0
  19. package/dist/auth/provider/handler.d.ts.map +1 -0
  20. package/dist/auth/provider/handler.js +128 -0
  21. package/dist/auth/provider/handler.js.map +1 -0
  22. package/dist/auth/provider/spec.d.ts +29 -0
  23. package/dist/auth/provider/spec.d.ts.map +1 -0
  24. package/dist/auth/provider/spec.js +12 -0
  25. package/dist/auth/provider/spec.js.map +1 -0
  26. package/dist/auth/resolver.d.ts +16 -0
  27. package/dist/auth/resolver.d.ts.map +1 -0
  28. package/dist/auth/resolver.js +32 -0
  29. package/dist/auth/resolver.js.map +1 -0
  30. package/dist/auth/tools.d.ts +23 -0
  31. package/dist/auth/tools.d.ts.map +1 -0
  32. package/dist/auth/tools.js +71 -0
  33. package/dist/auth/tools.js.map +1 -0
  34. package/dist/auth/types.d.ts +37 -0
  35. package/dist/auth/types.d.ts.map +1 -0
  36. package/dist/auth/types.js +17 -0
  37. package/dist/auth/types.js.map +1 -0
  38. package/dist/bridge/client/bridge.d.ts +133 -0
  39. package/dist/bridge/client/bridge.d.ts.map +1 -0
  40. package/dist/bridge/client/bridge.js +430 -0
  41. package/dist/bridge/client/bridge.js.map +1 -0
  42. package/dist/bridge/client/dispatch.d.ts +49 -0
  43. package/dist/bridge/client/dispatch.d.ts.map +1 -0
  44. package/dist/bridge/client/dispatch.js +103 -0
  45. package/dist/bridge/client/dispatch.js.map +1 -0
  46. package/dist/bridge/client.d.ts +24 -0
  47. package/dist/bridge/client.d.ts.map +1 -0
  48. package/dist/bridge/client.js +26 -0
  49. package/dist/bridge/client.js.map +1 -0
  50. package/dist/bridge/protocol.d.ts +228 -0
  51. package/dist/bridge/protocol.d.ts.map +1 -0
  52. package/dist/bridge/protocol.js +131 -0
  53. package/dist/bridge/protocol.js.map +1 -0
  54. package/dist/bridge/server/audit.d.ts +19 -0
  55. package/dist/bridge/server/audit.d.ts.map +1 -0
  56. package/dist/bridge/server/audit.js +46 -0
  57. package/dist/bridge/server/audit.js.map +1 -0
  58. package/dist/bridge/server/bridge.d.ts +165 -0
  59. package/dist/bridge/server/bridge.d.ts.map +1 -0
  60. package/dist/bridge/server/bridge.js +410 -0
  61. package/dist/bridge/server/bridge.js.map +1 -0
  62. package/dist/bridge/server/confirm-policy.d.ts +56 -0
  63. package/dist/bridge/server/confirm-policy.d.ts.map +1 -0
  64. package/dist/bridge/server/confirm-policy.js +107 -0
  65. package/dist/bridge/server/confirm-policy.js.map +1 -0
  66. package/dist/bridge/server/confirm-prompt.d.ts +73 -0
  67. package/dist/bridge/server/confirm-prompt.d.ts.map +1 -0
  68. package/dist/bridge/server/confirm-prompt.js +199 -0
  69. package/dist/bridge/server/confirm-prompt.js.map +1 -0
  70. package/dist/bridge/server/confirm.d.ts +92 -0
  71. package/dist/bridge/server/confirm.d.ts.map +1 -0
  72. package/dist/bridge/server/confirm.js +210 -0
  73. package/dist/bridge/server/confirm.js.map +1 -0
  74. package/dist/bridge/server/headless.d.ts +36 -0
  75. package/dist/bridge/server/headless.d.ts.map +1 -0
  76. package/dist/bridge/server/headless.js +132 -0
  77. package/dist/bridge/server/headless.js.map +1 -0
  78. package/dist/bridge/server/json-schema-to-zod.d.ts +37 -0
  79. package/dist/bridge/server/json-schema-to-zod.d.ts.map +1 -0
  80. package/dist/bridge/server/json-schema-to-zod.js +93 -0
  81. package/dist/bridge/server/json-schema-to-zod.js.map +1 -0
  82. package/dist/bridge/server/local-bridge.d.ts +33 -0
  83. package/dist/bridge/server/local-bridge.d.ts.map +1 -0
  84. package/dist/bridge/server/local-bridge.js +42 -0
  85. package/dist/bridge/server/local-bridge.js.map +1 -0
  86. package/dist/bridge/server/logger.d.ts +28 -0
  87. package/dist/bridge/server/logger.d.ts.map +1 -0
  88. package/dist/bridge/server/logger.js +42 -0
  89. package/dist/bridge/server/logger.js.map +1 -0
  90. package/dist/bridge/server/mcp.d.ts +33 -0
  91. package/dist/bridge/server/mcp.d.ts.map +1 -0
  92. package/dist/bridge/server/mcp.js +159 -0
  93. package/dist/bridge/server/mcp.js.map +1 -0
  94. package/dist/bridge/server/peer.d.ts +39 -0
  95. package/dist/bridge/server/peer.d.ts.map +1 -0
  96. package/dist/bridge/server/peer.js +189 -0
  97. package/dist/bridge/server/peer.js.map +1 -0
  98. package/dist/bridge/server/standalone.d.ts +102 -0
  99. package/dist/bridge/server/standalone.d.ts.map +1 -0
  100. package/dist/bridge/server/standalone.js +352 -0
  101. package/dist/bridge/server/standalone.js.map +1 -0
  102. package/dist/bridge/server/tool-metadata.d.ts +38 -0
  103. package/dist/bridge/server/tool-metadata.d.ts.map +1 -0
  104. package/dist/bridge/server/tool-metadata.js +79 -0
  105. package/dist/bridge/server/tool-metadata.js.map +1 -0
  106. package/dist/bridge/server.d.ts +25 -0
  107. package/dist/bridge/server.d.ts.map +1 -0
  108. package/dist/bridge/server.js +23 -0
  109. package/dist/bridge/server.js.map +1 -0
  110. package/dist/cli/auth.d.ts +37 -0
  111. package/dist/cli/auth.d.ts.map +1 -0
  112. package/dist/cli/auth.js +119 -0
  113. package/dist/cli/auth.js.map +1 -0
  114. package/dist/cli/database-rules.d.ts +25 -0
  115. package/dist/cli/database-rules.d.ts.map +1 -0
  116. package/dist/cli/database-rules.js +215 -0
  117. package/dist/cli/database-rules.js.map +1 -0
  118. package/dist/cli/deploy-progress.d.ts +35 -0
  119. package/dist/cli/deploy-progress.d.ts.map +1 -0
  120. package/dist/cli/deploy-progress.js +69 -0
  121. package/dist/cli/deploy-progress.js.map +1 -0
  122. package/dist/cli/deploy.d.ts +81 -0
  123. package/dist/cli/deploy.d.ts.map +1 -0
  124. package/dist/cli/deploy.js +413 -0
  125. package/dist/cli/deploy.js.map +1 -0
  126. package/dist/cli/dev-runner.d.ts +112 -0
  127. package/dist/cli/dev-runner.d.ts.map +1 -0
  128. package/dist/cli/dev-runner.js +227 -0
  129. package/dist/cli/dev-runner.js.map +1 -0
  130. package/dist/cli/discover.d.ts +47 -0
  131. package/dist/cli/discover.d.ts.map +1 -0
  132. package/dist/cli/discover.js +77 -0
  133. package/dist/cli/discover.js.map +1 -0
  134. package/dist/cli/firebase-json.d.ts +66 -0
  135. package/dist/cli/firebase-json.d.ts.map +1 -0
  136. package/dist/cli/firebase-json.js +60 -0
  137. package/dist/cli/firebase-json.js.map +1 -0
  138. package/dist/cli/index.d.ts +55 -0
  139. package/dist/cli/index.d.ts.map +1 -0
  140. package/dist/cli/index.js +500 -0
  141. package/dist/cli/index.js.map +1 -0
  142. package/dist/cli/init-templates.d.ts +37 -0
  143. package/dist/cli/init-templates.d.ts.map +1 -0
  144. package/dist/cli/init-templates.js +638 -0
  145. package/dist/cli/init-templates.js.map +1 -0
  146. package/dist/cli/init.d.ts +124 -0
  147. package/dist/cli/init.d.ts.map +1 -0
  148. package/dist/cli/init.js +423 -0
  149. package/dist/cli/init.js.map +1 -0
  150. package/dist/cli/login.d.ts +18 -0
  151. package/dist/cli/login.d.ts.map +1 -0
  152. package/dist/cli/login.js +59 -0
  153. package/dist/cli/login.js.map +1 -0
  154. package/dist/cli/mcp-proxy.d.ts +10 -0
  155. package/dist/cli/mcp-proxy.d.ts.map +1 -0
  156. package/dist/cli/mcp-proxy.js +126 -0
  157. package/dist/cli/mcp-proxy.js.map +1 -0
  158. package/dist/cli/parse-args.d.ts +20 -0
  159. package/dist/cli/parse-args.d.ts.map +1 -0
  160. package/dist/cli/parse-args.js +69 -0
  161. package/dist/cli/parse-args.js.map +1 -0
  162. package/dist/cli/rules.d.ts +40 -0
  163. package/dist/cli/rules.d.ts.map +1 -0
  164. package/dist/cli/rules.js +162 -0
  165. package/dist/cli/rules.js.map +1 -0
  166. package/dist/cli/scope.d.ts +38 -0
  167. package/dist/cli/scope.d.ts.map +1 -0
  168. package/dist/cli/scope.js +63 -0
  169. package/dist/cli/scope.js.map +1 -0
  170. package/dist/cli/serve.d.ts +122 -0
  171. package/dist/cli/serve.d.ts.map +1 -0
  172. package/dist/cli/serve.js +685 -0
  173. package/dist/cli/serve.js.map +1 -0
  174. package/dist/cli/snapshot.d.ts +22 -0
  175. package/dist/cli/snapshot.d.ts.map +1 -0
  176. package/dist/cli/snapshot.js +139 -0
  177. package/dist/cli/snapshot.js.map +1 -0
  178. package/dist/cli/verify.d.ts +23 -0
  179. package/dist/cli/verify.d.ts.map +1 -0
  180. package/dist/cli/verify.js +349 -0
  181. package/dist/cli/verify.js.map +1 -0
  182. package/dist/credentials/core/authorize.d.ts +22 -0
  183. package/dist/credentials/core/authorize.d.ts.map +1 -0
  184. package/dist/credentials/core/authorize.js +39 -0
  185. package/dist/credentials/core/authorize.js.map +1 -0
  186. package/dist/credentials/core/client.d.ts +14 -0
  187. package/dist/credentials/core/client.d.ts.map +1 -0
  188. package/dist/credentials/core/client.js +13 -0
  189. package/dist/credentials/core/client.js.map +1 -0
  190. package/dist/credentials/core/exchange.d.ts +24 -0
  191. package/dist/credentials/core/exchange.d.ts.map +1 -0
  192. package/dist/credentials/core/exchange.js +46 -0
  193. package/dist/credentials/core/exchange.js.map +1 -0
  194. package/dist/credentials/core/flow.d.ts +15 -0
  195. package/dist/credentials/core/flow.d.ts.map +1 -0
  196. package/dist/credentials/core/flow.js +40 -0
  197. package/dist/credentials/core/flow.js.map +1 -0
  198. package/dist/credentials/core/from-user-credential.d.ts +3 -0
  199. package/dist/credentials/core/from-user-credential.d.ts.map +1 -0
  200. package/dist/credentials/core/from-user-credential.js +19 -0
  201. package/dist/credentials/core/from-user-credential.js.map +1 -0
  202. package/dist/credentials/core/scopes.d.ts +26 -0
  203. package/dist/credentials/core/scopes.d.ts.map +1 -0
  204. package/dist/credentials/core/scopes.js +32 -0
  205. package/dist/credentials/core/scopes.js.map +1 -0
  206. package/dist/credentials/core/types.d.ts +72 -0
  207. package/dist/credentials/core/types.d.ts.map +1 -0
  208. package/dist/credentials/core/types.js +2 -0
  209. package/dist/credentials/core/types.js.map +1 -0
  210. package/dist/credentials/index.d.ts +14 -0
  211. package/dist/credentials/index.d.ts.map +1 -0
  212. package/dist/credentials/index.js +13 -0
  213. package/dist/credentials/index.js.map +1 -0
  214. package/dist/credentials/node/ensure-scope.d.ts +29 -0
  215. package/dist/credentials/node/ensure-scope.d.ts.map +1 -0
  216. package/dist/credentials/node/ensure-scope.js +42 -0
  217. package/dist/credentials/node/ensure-scope.js.map +1 -0
  218. package/dist/credentials/node/file-store.d.ts +4 -0
  219. package/dist/credentials/node/file-store.d.ts.map +1 -0
  220. package/dist/credentials/node/file-store.js +52 -0
  221. package/dist/credentials/node/file-store.js.map +1 -0
  222. package/dist/credentials/node/from-adc.d.ts +10 -0
  223. package/dist/credentials/node/from-adc.d.ts.map +1 -0
  224. package/dist/credentials/node/from-adc.js +60 -0
  225. package/dist/credentials/node/from-adc.js.map +1 -0
  226. package/dist/credentials/node/index.d.ts +10 -0
  227. package/dist/credentials/node/index.d.ts.map +1 -0
  228. package/dist/credentials/node/index.js +10 -0
  229. package/dist/credentials/node/index.js.map +1 -0
  230. package/dist/credentials/node/loopback-authorizer.d.ts +12 -0
  231. package/dist/credentials/node/loopback-authorizer.d.ts.map +1 -0
  232. package/dist/credentials/node/loopback-authorizer.js +61 -0
  233. package/dist/credentials/node/loopback-authorizer.js.map +1 -0
  234. package/dist/credentials/node/resolve-local-token.d.ts +20 -0
  235. package/dist/credentials/node/resolve-local-token.d.ts.map +1 -0
  236. package/dist/credentials/node/resolve-local-token.js +97 -0
  237. package/dist/credentials/node/resolve-local-token.js.map +1 -0
  238. package/dist/credentials/server/bff.d.ts +44 -0
  239. package/dist/credentials/server/bff.d.ts.map +1 -0
  240. package/dist/credentials/server/bff.js +43 -0
  241. package/dist/credentials/server/bff.js.map +1 -0
  242. package/dist/deploy/api-enablement.d.ts +45 -0
  243. package/dist/deploy/api-enablement.d.ts.map +1 -0
  244. package/dist/deploy/api-enablement.js +125 -0
  245. package/dist/deploy/api-enablement.js.map +1 -0
  246. package/dist/deploy/firestore/databases.d.ts +41 -0
  247. package/dist/deploy/firestore/databases.d.ts.map +1 -0
  248. package/dist/deploy/firestore/databases.js +63 -0
  249. package/dist/deploy/firestore/databases.js.map +1 -0
  250. package/dist/deploy/firestore/indexes.d.ts +120 -0
  251. package/dist/deploy/firestore/indexes.d.ts.map +1 -0
  252. package/dist/deploy/firestore/indexes.js +243 -0
  253. package/dist/deploy/firestore/indexes.js.map +1 -0
  254. package/dist/deploy/firestore/recipes.d.ts +21 -0
  255. package/dist/deploy/firestore/recipes.d.ts.map +1 -0
  256. package/dist/deploy/firestore/recipes.js +34 -0
  257. package/dist/deploy/firestore/recipes.js.map +1 -0
  258. package/dist/deploy/firestore/rules.d.ts +76 -0
  259. package/dist/deploy/firestore/rules.d.ts.map +1 -0
  260. package/dist/deploy/firestore/rules.js +180 -0
  261. package/dist/deploy/firestore/rules.js.map +1 -0
  262. package/dist/deploy/from-admin-app.d.ts +20 -0
  263. package/dist/deploy/from-admin-app.d.ts.map +1 -0
  264. package/dist/deploy/from-admin-app.js +18 -0
  265. package/dist/deploy/from-admin-app.js.map +1 -0
  266. package/dist/deploy/from-service-account.d.ts +29 -0
  267. package/dist/deploy/from-service-account.d.ts.map +1 -0
  268. package/dist/deploy/from-service-account.js +115 -0
  269. package/dist/deploy/from-service-account.js.map +1 -0
  270. package/dist/deploy/functions/bundle.d.ts +37 -0
  271. package/dist/deploy/functions/bundle.d.ts.map +1 -0
  272. package/dist/deploy/functions/bundle.js +181 -0
  273. package/dist/deploy/functions/bundle.js.map +1 -0
  274. package/dist/deploy/functions/core.d.ts +18 -0
  275. package/dist/deploy/functions/core.d.ts.map +1 -0
  276. package/dist/deploy/functions/core.js +211 -0
  277. package/dist/deploy/functions/core.js.map +1 -0
  278. package/dist/deploy/functions/iam.d.ts +17 -0
  279. package/dist/deploy/functions/iam.d.ts.map +1 -0
  280. package/dist/deploy/functions/iam.js +40 -0
  281. package/dist/deploy/functions/iam.js.map +1 -0
  282. package/dist/deploy/functions/operation.d.ts +39 -0
  283. package/dist/deploy/functions/operation.d.ts.map +1 -0
  284. package/dist/deploy/functions/operation.js +37 -0
  285. package/dist/deploy/functions/operation.js.map +1 -0
  286. package/dist/deploy/functions/spec.d.ts +69 -0
  287. package/dist/deploy/functions/spec.d.ts.map +1 -0
  288. package/dist/deploy/functions/spec.js +7 -0
  289. package/dist/deploy/functions/spec.js.map +1 -0
  290. package/dist/deploy/functions/types.d.ts +50 -0
  291. package/dist/deploy/functions/types.d.ts.map +1 -0
  292. package/dist/deploy/functions/types.js +3 -0
  293. package/dist/deploy/functions/types.js.map +1 -0
  294. package/dist/deploy/hosting/channels.d.ts +93 -0
  295. package/dist/deploy/hosting/channels.d.ts.map +1 -0
  296. package/dist/deploy/hosting/channels.js +134 -0
  297. package/dist/deploy/hosting/channels.js.map +1 -0
  298. package/dist/deploy/hosting/config.d.ts +28 -0
  299. package/dist/deploy/hosting/config.d.ts.map +1 -0
  300. package/dist/deploy/hosting/config.js +261 -0
  301. package/dist/deploy/hosting/config.js.map +1 -0
  302. package/dist/deploy/hosting/core.d.ts +38 -0
  303. package/dist/deploy/hosting/core.d.ts.map +1 -0
  304. package/dist/deploy/hosting/core.js +311 -0
  305. package/dist/deploy/hosting/core.js.map +1 -0
  306. package/dist/deploy/hosting/gzip.d.ts +11 -0
  307. package/dist/deploy/hosting/gzip.d.ts.map +1 -0
  308. package/dist/deploy/hosting/gzip.js +20 -0
  309. package/dist/deploy/hosting/gzip.js.map +1 -0
  310. package/dist/deploy/hosting/hash.d.ts +6 -0
  311. package/dist/deploy/hosting/hash.d.ts.map +1 -0
  312. package/dist/deploy/hosting/hash.js +17 -0
  313. package/dist/deploy/hosting/hash.js.map +1 -0
  314. package/dist/deploy/hosting/sites.d.ts +77 -0
  315. package/dist/deploy/hosting/sites.d.ts.map +1 -0
  316. package/dist/deploy/hosting/sites.js +73 -0
  317. package/dist/deploy/hosting/sites.js.map +1 -0
  318. package/dist/deploy/hosting/spec.d.ts +140 -0
  319. package/dist/deploy/hosting/spec.d.ts.map +1 -0
  320. package/dist/deploy/hosting/spec.js +8 -0
  321. package/dist/deploy/hosting/spec.js.map +1 -0
  322. package/dist/deploy/hosting/types.d.ts +71 -0
  323. package/dist/deploy/hosting/types.d.ts.map +1 -0
  324. package/dist/deploy/hosting/types.js +3 -0
  325. package/dist/deploy/hosting/types.js.map +1 -0
  326. package/dist/deploy/hosting/walk.d.ts +31 -0
  327. package/dist/deploy/hosting/walk.d.ts.map +1 -0
  328. package/dist/deploy/hosting/walk.js +167 -0
  329. package/dist/deploy/hosting/walk.js.map +1 -0
  330. package/dist/deploy/index.d.ts +51 -0
  331. package/dist/deploy/index.d.ts.map +1 -0
  332. package/dist/deploy/index.js +50 -0
  333. package/dist/deploy/index.js.map +1 -0
  334. package/dist/deploy/memoize-ttl.d.ts +58 -0
  335. package/dist/deploy/memoize-ttl.d.ts.map +1 -0
  336. package/dist/deploy/memoize-ttl.js +88 -0
  337. package/dist/deploy/memoize-ttl.js.map +1 -0
  338. package/dist/deploy/namespaces.d.ts +119 -0
  339. package/dist/deploy/namespaces.d.ts.map +1 -0
  340. package/dist/deploy/namespaces.js +192 -0
  341. package/dist/deploy/namespaces.js.map +1 -0
  342. package/dist/deploy/preflight.d.ts +119 -0
  343. package/dist/deploy/preflight.d.ts.map +1 -0
  344. package/dist/deploy/preflight.js +440 -0
  345. package/dist/deploy/preflight.js.map +1 -0
  346. package/dist/deploy/provider.d.ts +130 -0
  347. package/dist/deploy/provider.d.ts.map +1 -0
  348. package/dist/deploy/provider.js +21 -0
  349. package/dist/deploy/provider.js.map +1 -0
  350. package/dist/deploy/providers/database.d.ts +8 -0
  351. package/dist/deploy/providers/database.d.ts.map +1 -0
  352. package/dist/deploy/providers/database.js +37 -0
  353. package/dist/deploy/providers/database.js.map +1 -0
  354. package/dist/deploy/providers/firestore.d.ts +11 -0
  355. package/dist/deploy/providers/firestore.d.ts.map +1 -0
  356. package/dist/deploy/providers/firestore.js +43 -0
  357. package/dist/deploy/providers/firestore.js.map +1 -0
  358. package/dist/deploy/providers/functions.d.ts +9 -0
  359. package/dist/deploy/providers/functions.d.ts.map +1 -0
  360. package/dist/deploy/providers/functions.js +49 -0
  361. package/dist/deploy/providers/functions.js.map +1 -0
  362. package/dist/deploy/providers/hosting.d.ts +13 -0
  363. package/dist/deploy/providers/hosting.d.ts.map +1 -0
  364. package/dist/deploy/providers/hosting.js +149 -0
  365. package/dist/deploy/providers/hosting.js.map +1 -0
  366. package/dist/deploy/providers/storage.d.ts +9 -0
  367. package/dist/deploy/providers/storage.d.ts.map +1 -0
  368. package/dist/deploy/providers/storage.js +46 -0
  369. package/dist/deploy/providers/storage.js.map +1 -0
  370. package/dist/deploy/registry.d.ts +17 -0
  371. package/dist/deploy/registry.d.ts.map +1 -0
  372. package/dist/deploy/registry.js +15 -0
  373. package/dist/deploy/registry.js.map +1 -0
  374. package/dist/deploy/rtdb/rules.d.ts +21 -0
  375. package/dist/deploy/rtdb/rules.d.ts.map +1 -0
  376. package/dist/deploy/rtdb/rules.js +104 -0
  377. package/dist/deploy/rtdb/rules.js.map +1 -0
  378. package/dist/deploy/scope.d.ts +81 -0
  379. package/dist/deploy/scope.d.ts.map +1 -0
  380. package/dist/deploy/scope.js +44 -0
  381. package/dist/deploy/scope.js.map +1 -0
  382. package/dist/deploy/tools.d.ts +55 -0
  383. package/dist/deploy/tools.d.ts.map +1 -0
  384. package/dist/deploy/tools.js +329 -0
  385. package/dist/deploy/tools.js.map +1 -0
  386. package/dist/deploy/with-resolved-scope.d.ts +31 -0
  387. package/dist/deploy/with-resolved-scope.d.ts.map +1 -0
  388. package/dist/deploy/with-resolved-scope.js +73 -0
  389. package/dist/deploy/with-resolved-scope.js.map +1 -0
  390. package/dist/discover/concurrency.d.ts +42 -0
  391. package/dist/discover/concurrency.d.ts.map +1 -0
  392. package/dist/discover/concurrency.js +113 -0
  393. package/dist/discover/concurrency.js.map +1 -0
  394. package/dist/discover/crawler-adapter.d.ts +49 -0
  395. package/dist/discover/crawler-adapter.d.ts.map +1 -0
  396. package/dist/discover/crawler-adapter.js +92 -0
  397. package/dist/discover/crawler-adapter.js.map +1 -0
  398. package/dist/discover/crawler.d.ts +333 -0
  399. package/dist/discover/crawler.d.ts.map +1 -0
  400. package/dist/discover/crawler.js +764 -0
  401. package/dist/discover/crawler.js.map +1 -0
  402. package/dist/discover/findCollectionGroup.d.ts +80 -0
  403. package/dist/discover/findCollectionGroup.d.ts.map +1 -0
  404. package/dist/discover/findCollectionGroup.js +81 -0
  405. package/dist/discover/findCollectionGroup.js.map +1 -0
  406. package/dist/discover/index.d.ts +15 -0
  407. package/dist/discover/index.d.ts.map +1 -0
  408. package/dist/discover/index.js +24 -0
  409. package/dist/discover/index.js.map +1 -0
  410. package/dist/discover/merge.d.ts +108 -0
  411. package/dist/discover/merge.d.ts.map +1 -0
  412. package/dist/discover/merge.js +394 -0
  413. package/dist/discover/merge.js.map +1 -0
  414. package/dist/discover/rest-crawler-firestore.d.ts +51 -0
  415. package/dist/discover/rest-crawler-firestore.d.ts.map +1 -0
  416. package/dist/discover/rest-crawler-firestore.js +154 -0
  417. package/dist/discover/rest-crawler-firestore.js.map +1 -0
  418. package/dist/discover/session.d.ts +116 -0
  419. package/dist/discover/session.d.ts.map +1 -0
  420. package/dist/discover/session.js +331 -0
  421. package/dist/discover/session.js.map +1 -0
  422. package/dist/discover/tools.d.ts +59 -0
  423. package/dist/discover/tools.d.ts.map +1 -0
  424. package/dist/discover/tools.js +115 -0
  425. package/dist/discover/tools.js.map +1 -0
  426. package/dist/discover/types.d.ts +191 -0
  427. package/dist/discover/types.d.ts.map +1 -0
  428. package/dist/discover/types.js +12 -0
  429. package/dist/discover/types.js.map +1 -0
  430. package/dist/discover/wire.d.ts +81 -0
  431. package/dist/discover/wire.d.ts.map +1 -0
  432. package/dist/discover/wire.js +308 -0
  433. package/dist/discover/wire.js.map +1 -0
  434. package/dist/pkg-version.d.ts +2 -0
  435. package/dist/pkg-version.d.ts.map +1 -0
  436. package/dist/pkg-version.js +47 -0
  437. package/dist/pkg-version.js.map +1 -0
  438. package/dist/register/esm-exports.d.ts +26 -0
  439. package/dist/register/esm-exports.d.ts.map +1 -0
  440. package/dist/register/esm-exports.js +61 -0
  441. package/dist/register/esm-exports.js.map +1 -0
  442. package/dist/register/exempt.d.ts +11 -0
  443. package/dist/register/exempt.d.ts.map +1 -0
  444. package/dist/register/exempt.js +74 -0
  445. package/dist/register/exempt.js.map +1 -0
  446. package/dist/register/hooks.d.ts +13 -0
  447. package/dist/register/hooks.d.ts.map +1 -0
  448. package/dist/register/hooks.js +15 -0
  449. package/dist/register/hooks.js.map +1 -0
  450. package/dist/register/index.d.ts +5 -0
  451. package/dist/register/index.d.ts.map +1 -0
  452. package/dist/register/index.js +126 -0
  453. package/dist/register/index.js.map +1 -0
  454. package/dist/register/mapping.d.ts +17 -0
  455. package/dist/register/mapping.d.ts.map +1 -0
  456. package/dist/register/mapping.js +31 -0
  457. package/dist/register/mapping.js.map +1 -0
  458. package/dist/registry/admin-deps.d.ts +17 -0
  459. package/dist/registry/admin-deps.d.ts.map +1 -0
  460. package/dist/registry/admin-deps.js +68 -0
  461. package/dist/registry/admin-deps.js.map +1 -0
  462. package/dist/registry/compose.d.ts +68 -0
  463. package/dist/registry/compose.d.ts.map +1 -0
  464. package/dist/registry/compose.js +113 -0
  465. package/dist/registry/compose.js.map +1 -0
  466. package/dist/registry/index.d.ts +11 -0
  467. package/dist/registry/index.d.ts.map +1 -0
  468. package/dist/registry/index.js +11 -0
  469. package/dist/registry/index.js.map +1 -0
  470. package/dist/remote/index.d.ts +232 -0
  471. package/dist/remote/index.d.ts.map +1 -0
  472. package/dist/remote/index.js +719 -0
  473. package/dist/remote/index.js.map +1 -0
  474. package/dist/rtdb/rules-json.d.ts +8 -0
  475. package/dist/rtdb/rules-json.d.ts.map +1 -0
  476. package/dist/rtdb/rules-json.js +17 -0
  477. package/dist/rtdb/rules-json.js.map +1 -0
  478. package/dist/serve/bridge-mount.d.ts +38 -0
  479. package/dist/serve/bridge-mount.d.ts.map +1 -0
  480. package/dist/serve/bridge-mount.js +162 -0
  481. package/dist/serve/bridge-mount.js.map +1 -0
  482. package/dist/serve/bundler.d.ts +134 -0
  483. package/dist/serve/bundler.d.ts.map +1 -0
  484. package/dist/serve/bundler.js +452 -0
  485. package/dist/serve/bundler.js.map +1 -0
  486. package/dist/serve/capture-store.d.ts +27 -0
  487. package/dist/serve/capture-store.d.ts.map +1 -0
  488. package/dist/serve/capture-store.js +47 -0
  489. package/dist/serve/capture-store.js.map +1 -0
  490. package/dist/serve/discovery.d.ts +71 -0
  491. package/dist/serve/discovery.d.ts.map +1 -0
  492. package/dist/serve/discovery.js +158 -0
  493. package/dist/serve/discovery.js.map +1 -0
  494. package/dist/serve/docs-ui/_astro/_slug_.BsN3bPok.css +1 -0
  495. package/dist/serve/docs-ui/docs/_rhythm/index.html +99 -0
  496. package/dist/serve/docs-ui/docs/_rhythm.md +101 -0
  497. package/dist/serve/docs-ui/docs/index.html +1 -0
  498. package/dist/serve/docs-ui/docs/index.json +9914 -0
  499. package/dist/serve/docs-ui/docs/pyric-admin-firestore/index.html +38 -0
  500. package/dist/serve/docs-ui/docs/pyric-admin-firestore-explanation-error-translation/index.html +57 -0
  501. package/dist/serve/docs-ui/docs/pyric-admin-firestore-explanation-error-translation.md +87 -0
  502. package/dist/serve/docs-ui/docs/pyric-admin-firestore-explanation-per-call-delegate/index.html +58 -0
  503. package/dist/serve/docs-ui/docs/pyric-admin-firestore-explanation-per-call-delegate.md +86 -0
  504. package/dist/serve/docs-ui/docs/pyric-admin-firestore-explanation-why-mirror-admin-shape/index.html +59 -0
  505. package/dist/serve/docs-ui/docs/pyric-admin-firestore-explanation-why-mirror-admin-shape.md +82 -0
  506. package/dist/serve/docs-ui/docs/pyric-admin-firestore-how-to-run-a-transaction/index.html +53 -0
  507. package/dist/serve/docs-ui/docs/pyric-admin-firestore-how-to-run-a-transaction.md +70 -0
  508. package/dist/serve/docs-ui/docs/pyric-admin-firestore-how-to-seed-and-set-rules/index.html +62 -0
  509. package/dist/serve/docs-ui/docs/pyric-admin-firestore-how-to-seed-and-set-rules.md +86 -0
  510. package/dist/serve/docs-ui/docs/pyric-admin-firestore-how-to-translate-denials/index.html +80 -0
  511. package/dist/serve/docs-ui/docs/pyric-admin-firestore-how-to-translate-denials.md +92 -0
  512. package/dist/serve/docs-ui/docs/pyric-admin-firestore-how-to-use-onsnapshot/index.html +57 -0
  513. package/dist/serve/docs-ui/docs/pyric-admin-firestore-how-to-use-onsnapshot.md +78 -0
  514. package/dist/serve/docs-ui/docs/pyric-admin-firestore-how-to-write-a-batch/index.html +50 -0
  515. package/dist/serve/docs-ui/docs/pyric-admin-firestore-how-to-write-a-batch.md +67 -0
  516. package/dist/serve/docs-ui/docs/pyric-admin-firestore-reference-api/index.html +53 -0
  517. package/dist/serve/docs-ui/docs/pyric-admin-firestore-reference-api.md +73 -0
  518. package/dist/serve/docs-ui/docs/pyric-admin-firestore-reference-onsnapshot/index.html +68 -0
  519. package/dist/serve/docs-ui/docs/pyric-admin-firestore-reference-onsnapshot.md +75 -0
  520. package/dist/serve/docs-ui/docs/pyric-admin-firestore-reference-re-exported-types/index.html +76 -0
  521. package/dist/serve/docs-ui/docs/pyric-admin-firestore-reference-re-exported-types.md +95 -0
  522. package/dist/serve/docs-ui/docs/pyric-admin-firestore-reference-sandbox-firestore/index.html +40 -0
  523. package/dist/serve/docs-ui/docs/pyric-admin-firestore-reference-sandbox-firestore.md +73 -0
  524. package/dist/serve/docs-ui/docs/pyric-admin-firestore-tutorials-01-first-admin-session/index.html +118 -0
  525. package/dist/serve/docs-ui/docs/pyric-admin-firestore-tutorials-01-first-admin-session.md +146 -0
  526. package/dist/serve/docs-ui/docs/pyric-admin-firestore.md +49 -0
  527. package/dist/serve/docs-ui/docs/pyric-auth/index.html +64 -0
  528. package/dist/serve/docs-ui/docs/pyric-auth-compat/index.html +874 -0
  529. package/dist/serve/docs-ui/docs/pyric-auth-compat.md +265 -0
  530. package/dist/serve/docs-ui/docs/pyric-auth-reference-api/index.html +112 -0
  531. package/dist/serve/docs-ui/docs/pyric-auth-reference-api.md +129 -0
  532. package/dist/serve/docs-ui/docs/pyric-auth-reference-feature-matrix/index.html +781 -0
  533. package/dist/serve/docs-ui/docs/pyric-auth-reference-feature-matrix.md +198 -0
  534. package/dist/serve/docs-ui/docs/pyric-auth-reference-sandbox-test-driver/index.html +80 -0
  535. package/dist/serve/docs-ui/docs/pyric-auth-reference-sandbox-test-driver.md +107 -0
  536. package/dist/serve/docs-ui/docs/pyric-auth.md +84 -0
  537. package/dist/serve/docs-ui/docs/pyric-database/index.html +36 -0
  538. package/dist/serve/docs-ui/docs/pyric-database-compat/index.html +2428 -0
  539. package/dist/serve/docs-ui/docs/pyric-database-compat.md +850 -0
  540. package/dist/serve/docs-ui/docs/pyric-database-explanation-rules-authoring-and-deploy-are-separate/index.html +23 -0
  541. package/dist/serve/docs-ui/docs/pyric-database-explanation-rules-authoring-and-deploy-are-separate.md +29 -0
  542. package/dist/serve/docs-ui/docs/pyric-database-reference-rules-tooling/index.html +263 -0
  543. package/dist/serve/docs-ui/docs/pyric-database-reference-rules-tooling.md +288 -0
  544. package/dist/serve/docs-ui/docs/pyric-database-tutorials-01-author-rtdb-rules-with-constraints/index.html +116 -0
  545. package/dist/serve/docs-ui/docs/pyric-database-tutorials-01-author-rtdb-rules-with-constraints.md +142 -0
  546. package/dist/serve/docs-ui/docs/pyric-database.md +18 -0
  547. package/dist/serve/docs-ui/docs/pyric-firestore/index.html +54 -0
  548. package/dist/serve/docs-ui/docs/pyric-firestore-compat/index.html +1345 -0
  549. package/dist/serve/docs-ui/docs/pyric-firestore-compat.md +366 -0
  550. package/dist/serve/docs-ui/docs/pyric-firestore-explanation-rules-tooling-is-separate/index.html +79 -0
  551. package/dist/serve/docs-ui/docs/pyric-firestore-explanation-rules-tooling-is-separate.md +62 -0
  552. package/dist/serve/docs-ui/docs/pyric-firestore-explanation-target-symbol-opacity/index.html +59 -0
  553. package/dist/serve/docs-ui/docs/pyric-firestore-explanation-target-symbol-opacity.md +85 -0
  554. package/dist/serve/docs-ui/docs/pyric-firestore-explanation-two-backends-one-surface/index.html +61 -0
  555. package/dist/serve/docs-ui/docs/pyric-firestore-explanation-two-backends-one-surface.md +87 -0
  556. package/dist/serve/docs-ui/docs/pyric-firestore-how-to-build-queries/index.html +105 -0
  557. package/dist/serve/docs-ui/docs/pyric-firestore-how-to-build-queries.md +138 -0
  558. package/dist/serve/docs-ui/docs/pyric-firestore-how-to-migrate-from-firebase-firestore/index.html +65 -0
  559. package/dist/serve/docs-ui/docs/pyric-firestore-how-to-migrate-from-firebase-firestore.md +93 -0
  560. package/dist/serve/docs-ui/docs/pyric-firestore-how-to-pick-a-backend/index.html +112 -0
  561. package/dist/serve/docs-ui/docs/pyric-firestore-how-to-pick-a-backend.md +100 -0
  562. package/dist/serve/docs-ui/docs/pyric-firestore-how-to-run-a-transaction/index.html +42 -0
  563. package/dist/serve/docs-ui/docs/pyric-firestore-how-to-run-a-transaction.md +55 -0
  564. package/dist/serve/docs-ui/docs/pyric-firestore-how-to-use-onsnapshot/index.html +61 -0
  565. package/dist/serve/docs-ui/docs/pyric-firestore-how-to-use-onsnapshot.md +83 -0
  566. package/dist/serve/docs-ui/docs/pyric-firestore-how-to-use-sandbox-ops/index.html +52 -0
  567. package/dist/serve/docs-ui/docs/pyric-firestore-how-to-use-sandbox-ops.md +73 -0
  568. package/dist/serve/docs-ui/docs/pyric-firestore-reference-api/index.html +132 -0
  569. package/dist/serve/docs-ui/docs/pyric-firestore-reference-api.md +160 -0
  570. package/dist/serve/docs-ui/docs/pyric-firestore-reference-feature-matrix/index.html +793 -0
  571. package/dist/serve/docs-ui/docs/pyric-firestore-reference-feature-matrix.md +239 -0
  572. package/dist/serve/docs-ui/docs/pyric-firestore-reference-getfirestore/index.html +55 -0
  573. package/dist/serve/docs-ui/docs/pyric-firestore-reference-getfirestore.md +76 -0
  574. package/dist/serve/docs-ui/docs/pyric-firestore-reference-query-constraints/index.html +78 -0
  575. package/dist/serve/docs-ui/docs/pyric-firestore-reference-query-constraints.md +115 -0
  576. package/dist/serve/docs-ui/docs/pyric-firestore-reference-sandbox-ops/index.html +53 -0
  577. package/dist/serve/docs-ui/docs/pyric-firestore-reference-sandbox-ops.md +76 -0
  578. package/dist/serve/docs-ui/docs/pyric-firestore-reference-tool-factories/index.html +51 -0
  579. package/dist/serve/docs-ui/docs/pyric-firestore-reference-tool-factories.md +65 -0
  580. package/dist/serve/docs-ui/docs/pyric-firestore-tutorials-01-write-a-sandbox-demo/index.html +127 -0
  581. package/dist/serve/docs-ui/docs/pyric-firestore-tutorials-01-write-a-sandbox-demo.md +157 -0
  582. package/dist/serve/docs-ui/docs/pyric-firestore-tutorials-02-swap-to-prod-backend/index.html +85 -0
  583. package/dist/serve/docs-ui/docs/pyric-firestore-tutorials-02-swap-to-prod-backend.md +122 -0
  584. package/dist/serve/docs-ui/docs/pyric-firestore.md +69 -0
  585. package/dist/serve/docs-ui/docs/pyric-rules/index.html +93 -0
  586. package/dist/serve/docs-ui/docs/pyric-rules-explanation-agent-failure-modes/index.html +50 -0
  587. package/dist/serve/docs-ui/docs/pyric-rules-explanation-agent-failure-modes.md +74 -0
  588. package/dist/serve/docs-ui/docs/pyric-rules-explanation-lint-vs-validate-vs-simulate-vs-test/index.html +79 -0
  589. package/dist/serve/docs-ui/docs/pyric-rules-explanation-lint-vs-validate-vs-simulate-vs-test.md +69 -0
  590. package/dist/serve/docs-ui/docs/pyric-rules-explanation-runtime-budget-and-shared-gates/index.html +67 -0
  591. package/dist/serve/docs-ui/docs/pyric-rules-explanation-runtime-budget-and-shared-gates.md +71 -0
  592. package/dist/serve/docs-ui/docs/pyric-rules-explanation-sentinel-expression-engine/index.html +49 -0
  593. package/dist/serve/docs-ui/docs/pyric-rules-explanation-sentinel-expression-engine.md +70 -0
  594. package/dist/serve/docs-ui/docs/pyric-rules-explanation-simulator-vs-rules-test-api/index.html +96 -0
  595. package/dist/serve/docs-ui/docs/pyric-rules-explanation-simulator-vs-rules-test-api.md +76 -0
  596. package/dist/serve/docs-ui/docs/pyric-rules-explanation-the-2-plus-modules-extension/index.html +58 -0
  597. package/dist/serve/docs-ui/docs/pyric-rules-explanation-the-2-plus-modules-extension.md +75 -0
  598. package/dist/serve/docs-ui/docs/pyric-rules-explanation-value-wrappers-design/index.html +62 -0
  599. package/dist/serve/docs-ui/docs/pyric-rules-explanation-value-wrappers-design.md +80 -0
  600. package/dist/serve/docs-ui/docs/pyric-rules-explanation-why-this-package-exists/index.html +34 -0
  601. package/dist/serve/docs-ui/docs/pyric-rules-explanation-why-this-package-exists.md +43 -0
  602. package/dist/serve/docs-ui/docs/pyric-rules-how-to-compare-rulesets-for-weakening/index.html +54 -0
  603. package/dist/serve/docs-ui/docs/pyric-rules-how-to-compare-rulesets-for-weakening.md +69 -0
  604. package/dist/serve/docs-ui/docs/pyric-rules-how-to-inspect-rules-via-the-ast/index.html +89 -0
  605. package/dist/serve/docs-ui/docs/pyric-rules-how-to-inspect-rules-via-the-ast.md +113 -0
  606. package/dist/serve/docs-ui/docs/pyric-rules-how-to-lint-rules-source/index.html +50 -0
  607. package/dist/serve/docs-ui/docs/pyric-rules-how-to-lint-rules-source.md +73 -0
  608. package/dist/serve/docs-ui/docs/pyric-rules-how-to-pin-request-time/index.html +47 -0
  609. package/dist/serve/docs-ui/docs/pyric-rules-how-to-pin-request-time.md +58 -0
  610. package/dist/serve/docs-ui/docs/pyric-rules-how-to-register-tools-with-an-agent/index.html +61 -0
  611. package/dist/serve/docs-ui/docs/pyric-rules-how-to-register-tools-with-an-agent.md +78 -0
  612. package/dist/serve/docs-ui/docs/pyric-rules-how-to-resolve-module-imports/index.html +92 -0
  613. package/dist/serve/docs-ui/docs/pyric-rules-how-to-resolve-module-imports.md +93 -0
  614. package/dist/serve/docs-ui/docs/pyric-rules-how-to-simulate-rules-locally/index.html +89 -0
  615. package/dist/serve/docs-ui/docs/pyric-rules-how-to-simulate-rules-locally.md +117 -0
  616. package/dist/serve/docs-ui/docs/pyric-rules-how-to-test-rules-against-firebase/index.html +70 -0
  617. package/dist/serve/docs-ui/docs/pyric-rules-how-to-test-rules-against-firebase.md +93 -0
  618. package/dist/serve/docs-ui/docs/pyric-rules-reference-api/index.html +129 -0
  619. package/dist/serve/docs-ui/docs/pyric-rules-reference-api.md +176 -0
  620. package/dist/serve/docs-ui/docs/pyric-rules-reference-ast/index.html +85 -0
  621. package/dist/serve/docs-ui/docs/pyric-rules-reference-ast.md +105 -0
  622. package/dist/serve/docs-ui/docs/pyric-rules-reference-errors/index.html +63 -0
  623. package/dist/serve/docs-ui/docs/pyric-rules-reference-errors.md +89 -0
  624. package/dist/serve/docs-ui/docs/pyric-rules-reference-lint-rules/index.html +148 -0
  625. package/dist/serve/docs-ui/docs/pyric-rules-reference-lint-rules.md +159 -0
  626. package/dist/serve/docs-ui/docs/pyric-rules-reference-simulator-context/index.html +66 -0
  627. package/dist/serve/docs-ui/docs/pyric-rules-reference-simulator-context.md +98 -0
  628. package/dist/serve/docs-ui/docs/pyric-rules-reference-stdlib-modules/index.html +239 -0
  629. package/dist/serve/docs-ui/docs/pyric-rules-reference-stdlib-modules.md +135 -0
  630. package/dist/serve/docs-ui/docs/pyric-rules-reference-test-case-schema/index.html +93 -0
  631. package/dist/serve/docs-ui/docs/pyric-rules-reference-test-case-schema.md +109 -0
  632. package/dist/serve/docs-ui/docs/pyric-rules-reference-validator-findings/index.html +86 -0
  633. package/dist/serve/docs-ui/docs/pyric-rules-reference-validator-findings.md +113 -0
  634. package/dist/serve/docs-ui/docs/pyric-rules-reference-value-wrappers/index.html +101 -0
  635. package/dist/serve/docs-ui/docs/pyric-rules-reference-value-wrappers.md +134 -0
  636. package/dist/serve/docs-ui/docs/pyric-rules-tutorials-01-lint-your-first-rules-file/index.html +107 -0
  637. package/dist/serve/docs-ui/docs/pyric-rules-tutorials-01-lint-your-first-rules-file.md +142 -0
  638. package/dist/serve/docs-ui/docs/pyric-rules-tutorials-02-write-a-test-suite-for-your-rules/index.html +151 -0
  639. package/dist/serve/docs-ui/docs/pyric-rules-tutorials-02-write-a-test-suite-for-your-rules.md +194 -0
  640. package/dist/serve/docs-ui/docs/pyric-rules.md +88 -0
  641. package/dist/serve/docs-ui/docs/pyric-sandbox/index.html +67 -0
  642. package/dist/serve/docs-ui/docs/pyric-sandbox-explanation-every-op-is-a-request/index.html +141 -0
  643. package/dist/serve/docs-ui/docs/pyric-sandbox-explanation-every-op-is-a-request.md +157 -0
  644. package/dist/serve/docs-ui/docs/pyric-sandbox-explanation-identity-is-a-context/index.html +66 -0
  645. package/dist/serve/docs-ui/docs/pyric-sandbox-explanation-identity-is-a-context.md +98 -0
  646. package/dist/serve/docs-ui/docs/pyric-sandbox-explanation-internal-adapter-protocol/index.html +71 -0
  647. package/dist/serve/docs-ui/docs/pyric-sandbox-explanation-internal-adapter-protocol.md +105 -0
  648. package/dist/serve/docs-ui/docs/pyric-sandbox-explanation-listener-re-evaluation/index.html +56 -0
  649. package/dist/serve/docs-ui/docs/pyric-sandbox-explanation-listener-re-evaluation.md +80 -0
  650. package/dist/serve/docs-ui/docs/pyric-sandbox-explanation-local-backend-vs-firestore-offline/index.html +64 -0
  651. package/dist/serve/docs-ui/docs/pyric-sandbox-explanation-local-backend-vs-firestore-offline.md +56 -0
  652. package/dist/serve/docs-ui/docs/pyric-sandbox-explanation-why-adapters-are-siblings/index.html +88 -0
  653. package/dist/serve/docs-ui/docs/pyric-sandbox-explanation-why-adapters-are-siblings.md +87 -0
  654. package/dist/serve/docs-ui/docs/pyric-sandbox-explanation-why-this-package-exists/index.html +69 -0
  655. package/dist/serve/docs-ui/docs/pyric-sandbox-explanation-why-this-package-exists.md +57 -0
  656. package/dist/serve/docs-ui/docs/pyric-sandbox-how-to-multiple-isolated-sandboxes/index.html +63 -0
  657. package/dist/serve/docs-ui/docs/pyric-sandbox-how-to-multiple-isolated-sandboxes.md +83 -0
  658. package/dist/serve/docs-ui/docs/pyric-sandbox-how-to-observe-events/index.html +159 -0
  659. package/dist/serve/docs-ui/docs/pyric-sandbox-how-to-observe-events.md +154 -0
  660. package/dist/serve/docs-ui/docs/pyric-sandbox-how-to-pick-an-adapter/index.html +79 -0
  661. package/dist/serve/docs-ui/docs/pyric-sandbox-how-to-pick-an-adapter.md +69 -0
  662. package/dist/serve/docs-ui/docs/pyric-sandbox-how-to-replay-events/index.html +89 -0
  663. package/dist/serve/docs-ui/docs/pyric-sandbox-how-to-replay-events.md +87 -0
  664. package/dist/serve/docs-ui/docs/pyric-sandbox-how-to-reset-between-tests/index.html +68 -0
  665. package/dist/serve/docs-ui/docs/pyric-sandbox-how-to-reset-between-tests.md +86 -0
  666. package/dist/serve/docs-ui/docs/pyric-sandbox-how-to-seed-data-and-rules/index.html +91 -0
  667. package/dist/serve/docs-ui/docs/pyric-sandbox-how-to-seed-data-and-rules.md +112 -0
  668. package/dist/serve/docs-ui/docs/pyric-sandbox-how-to-switch-users/index.html +50 -0
  669. package/dist/serve/docs-ui/docs/pyric-sandbox-how-to-switch-users.md +70 -0
  670. package/dist/serve/docs-ui/docs/pyric-sandbox-how-to-use-admin-reads/index.html +54 -0
  671. package/dist/serve/docs-ui/docs/pyric-sandbox-how-to-use-admin-reads.md +73 -0
  672. package/dist/serve/docs-ui/docs/pyric-sandbox-reference-api/index.html +77 -0
  673. package/dist/serve/docs-ui/docs/pyric-sandbox-reference-api.md +117 -0
  674. package/dist/serve/docs-ui/docs/pyric-sandbox-reference-divergences/index.html +125 -0
  675. package/dist/serve/docs-ui/docs/pyric-sandbox-reference-divergences.md +137 -0
  676. package/dist/serve/docs-ui/docs/pyric-sandbox-reference-error-codes/index.html +110 -0
  677. package/dist/serve/docs-ui/docs/pyric-sandbox-reference-error-codes.md +114 -0
  678. package/dist/serve/docs-ui/docs/pyric-sandbox-reference-internal-protocol/index.html +72 -0
  679. package/dist/serve/docs-ui/docs/pyric-sandbox-reference-internal-protocol.md +99 -0
  680. package/dist/serve/docs-ui/docs/pyric-sandbox-reference-sandbox-and-context/index.html +90 -0
  681. package/dist/serve/docs-ui/docs/pyric-sandbox-reference-sandbox-and-context.md +128 -0
  682. package/dist/serve/docs-ui/docs/pyric-sandbox-reference-sandbox-event/index.html +146 -0
  683. package/dist/serve/docs-ui/docs/pyric-sandbox-reference-sandbox-event.md +188 -0
  684. package/dist/serve/docs-ui/docs/pyric-sandbox-reference-snapshot-and-admin/index.html +53 -0
  685. package/dist/serve/docs-ui/docs/pyric-sandbox-reference-snapshot-and-admin.md +77 -0
  686. package/dist/serve/docs-ui/docs/pyric-sandbox-tutorials-01-your-first-sandbox-session/index.html +115 -0
  687. package/dist/serve/docs-ui/docs/pyric-sandbox-tutorials-01-your-first-sandbox-session.md +154 -0
  688. package/dist/serve/docs-ui/docs/pyric-sandbox-tutorials-02-use-the-sandbox-in-a-test-harness/index.html +191 -0
  689. package/dist/serve/docs-ui/docs/pyric-sandbox-tutorials-02-use-the-sandbox-in-a-test-harness.md +222 -0
  690. package/dist/serve/docs-ui/docs/pyric-sandbox-tutorials-03-build-a-traffic-monitor/index.html +163 -0
  691. package/dist/serve/docs-ui/docs/pyric-sandbox-tutorials-03-build-a-traffic-monitor.md +192 -0
  692. package/dist/serve/docs-ui/docs/pyric-sandbox.md +63 -0
  693. package/dist/serve/docs-ui/docs/pyric-storage/index.html +65 -0
  694. package/dist/serve/docs-ui/docs/pyric-storage-compat/index.html +1076 -0
  695. package/dist/serve/docs-ui/docs/pyric-storage-compat.md +337 -0
  696. package/dist/serve/docs-ui/docs/pyric-storage-explanation-implementation-scope/index.html +63 -0
  697. package/dist/serve/docs-ui/docs/pyric-storage-explanation-implementation-scope.md +104 -0
  698. package/dist/serve/docs-ui/docs/pyric-storage-explanation-session-archive-use-case/index.html +58 -0
  699. package/dist/serve/docs-ui/docs/pyric-storage-explanation-session-archive-use-case.md +80 -0
  700. package/dist/serve/docs-ui/docs/pyric-storage-explanation-why-indexeddb/index.html +50 -0
  701. package/dist/serve/docs-ui/docs/pyric-storage-explanation-why-indexeddb.md +82 -0
  702. package/dist/serve/docs-ui/docs/pyric-storage-how-to-enforce-rules/index.html +104 -0
  703. package/dist/serve/docs-ui/docs/pyric-storage-how-to-enforce-rules.md +111 -0
  704. package/dist/serve/docs-ui/docs/pyric-storage-how-to-list-and-delete/index.html +53 -0
  705. package/dist/serve/docs-ui/docs/pyric-storage-how-to-list-and-delete.md +76 -0
  706. package/dist/serve/docs-ui/docs/pyric-storage-how-to-round-trip-metadata/index.html +77 -0
  707. package/dist/serve/docs-ui/docs/pyric-storage-how-to-round-trip-metadata.md +100 -0
  708. package/dist/serve/docs-ui/docs/pyric-storage-how-to-switch-backends/index.html +65 -0
  709. package/dist/serve/docs-ui/docs/pyric-storage-how-to-switch-backends.md +82 -0
  710. package/dist/serve/docs-ui/docs/pyric-storage-how-to-test-rule-expressions/index.html +70 -0
  711. package/dist/serve/docs-ui/docs/pyric-storage-how-to-test-rule-expressions.md +82 -0
  712. package/dist/serve/docs-ui/docs/pyric-storage-reference-api/index.html +92 -0
  713. package/dist/serve/docs-ui/docs/pyric-storage-reference-api.md +152 -0
  714. package/dist/serve/docs-ui/docs/pyric-storage-reference-error-codes/index.html +46 -0
  715. package/dist/serve/docs-ui/docs/pyric-storage-reference-error-codes.md +66 -0
  716. package/dist/serve/docs-ui/docs/pyric-storage-reference-rules-subset/index.html +73 -0
  717. package/dist/serve/docs-ui/docs/pyric-storage-reference-rules-subset.md +90 -0
  718. package/dist/serve/docs-ui/docs/pyric-storage-reference-storage-options/index.html +45 -0
  719. package/dist/serve/docs-ui/docs/pyric-storage-reference-storage-options.md +65 -0
  720. package/dist/serve/docs-ui/docs/pyric-storage-tutorials-01-upload-and-download/index.html +114 -0
  721. package/dist/serve/docs-ui/docs/pyric-storage-tutorials-01-upload-and-download.md +141 -0
  722. package/dist/serve/docs-ui/docs/pyric-storage.md +63 -0
  723. package/dist/serve/docs-ui/docs/pyric-tools/index.html +45 -0
  724. package/dist/serve/docs-ui/docs/pyric-tools-bridge/index.html +71 -0
  725. package/dist/serve/docs-ui/docs/pyric-tools-bridge.md +90 -0
  726. package/dist/serve/docs-ui/docs/pyric-tools-deploy/index.html +59 -0
  727. package/dist/serve/docs-ui/docs/pyric-tools-deploy-explanation-primitives-vs-orchestrators/index.html +63 -0
  728. package/dist/serve/docs-ui/docs/pyric-tools-deploy-explanation-primitives-vs-orchestrators.md +83 -0
  729. package/dist/serve/docs-ui/docs/pyric-tools-deploy-explanation-token-caching/index.html +47 -0
  730. package/dist/serve/docs-ui/docs/pyric-tools-deploy-explanation-token-caching.md +70 -0
  731. package/dist/serve/docs-ui/docs/pyric-tools-deploy-explanation-why-no-firebase-cli/index.html +36 -0
  732. package/dist/serve/docs-ui/docs/pyric-tools-deploy-explanation-why-no-firebase-cli.md +50 -0
  733. package/dist/serve/docs-ui/docs/pyric-tools-deploy-explanation-why-this-package-exists/index.html +47 -0
  734. package/dist/serve/docs-ui/docs/pyric-tools-deploy-explanation-why-this-package-exists.md +60 -0
  735. package/dist/serve/docs-ui/docs/pyric-tools-deploy-how-to-build-projectscope-from-firebase-auth/index.html +55 -0
  736. package/dist/serve/docs-ui/docs/pyric-tools-deploy-how-to-build-projectscope-from-firebase-auth.md +68 -0
  737. package/dist/serve/docs-ui/docs/pyric-tools-deploy-how-to-build-projectscope-from-service-account/index.html +35 -0
  738. package/dist/serve/docs-ui/docs/pyric-tools-deploy-how-to-build-projectscope-from-service-account.md +52 -0
  739. package/dist/serve/docs-ui/docs/pyric-tools-deploy-how-to-bundle-and-deploy-a-function/index.html +81 -0
  740. package/dist/serve/docs-ui/docs/pyric-tools-deploy-how-to-bundle-and-deploy-a-function.md +98 -0
  741. package/dist/serve/docs-ui/docs/pyric-tools-deploy-how-to-deploy-firestore-indexes/index.html +71 -0
  742. package/dist/serve/docs-ui/docs/pyric-tools-deploy-how-to-deploy-firestore-indexes.md +91 -0
  743. package/dist/serve/docs-ui/docs/pyric-tools-deploy-how-to-deploy-firestore-rules/index.html +100 -0
  744. package/dist/serve/docs-ui/docs/pyric-tools-deploy-how-to-deploy-firestore-rules.md +105 -0
  745. package/dist/serve/docs-ui/docs/pyric-tools-deploy-how-to-deploy-hosting-rewrites/index.html +86 -0
  746. package/dist/serve/docs-ui/docs/pyric-tools-deploy-how-to-deploy-hosting-rewrites.md +92 -0
  747. package/dist/serve/docs-ui/docs/pyric-tools-deploy-how-to-deploy-realtime-database-rules/index.html +132 -0
  748. package/dist/serve/docs-ui/docs/pyric-tools-deploy-how-to-deploy-realtime-database-rules.md +165 -0
  749. package/dist/serve/docs-ui/docs/pyric-tools-deploy-how-to-deploy-to-a-preview-channel/index.html +46 -0
  750. package/dist/serve/docs-ui/docs/pyric-tools-deploy-how-to-deploy-to-a-preview-channel.md +62 -0
  751. package/dist/serve/docs-ui/docs/pyric-tools-deploy-how-to-handle-errors-and-outcomes/index.html +75 -0
  752. package/dist/serve/docs-ui/docs/pyric-tools-deploy-how-to-handle-errors-and-outcomes.md +94 -0
  753. package/dist/serve/docs-ui/docs/pyric-tools-deploy-how-to-provision-a-firestore-database/index.html +48 -0
  754. package/dist/serve/docs-ui/docs/pyric-tools-deploy-how-to-provision-a-firestore-database.md +65 -0
  755. package/dist/serve/docs-ui/docs/pyric-tools-deploy-how-to-register-tools-with-an-agent/index.html +65 -0
  756. package/dist/serve/docs-ui/docs/pyric-tools-deploy-how-to-register-tools-with-an-agent.md +82 -0
  757. package/dist/serve/docs-ui/docs/pyric-tools-deploy-reference-api/index.html +155 -0
  758. package/dist/serve/docs-ui/docs/pyric-tools-deploy-reference-api.md +190 -0
  759. package/dist/serve/docs-ui/docs/pyric-tools-deploy-reference-cli-agent-io/index.html +84 -0
  760. package/dist/serve/docs-ui/docs/pyric-tools-deploy-reference-cli-agent-io.md +66 -0
  761. package/dist/serve/docs-ui/docs/pyric-tools-deploy-reference-error-codes/index.html +71 -0
  762. package/dist/serve/docs-ui/docs/pyric-tools-deploy-reference-error-codes.md +102 -0
  763. package/dist/serve/docs-ui/docs/pyric-tools-deploy-reference-firestore-namespace/index.html +138 -0
  764. package/dist/serve/docs-ui/docs/pyric-tools-deploy-reference-firestore-namespace.md +175 -0
  765. package/dist/serve/docs-ui/docs/pyric-tools-deploy-reference-functions-namespace/index.html +105 -0
  766. package/dist/serve/docs-ui/docs/pyric-tools-deploy-reference-functions-namespace.md +133 -0
  767. package/dist/serve/docs-ui/docs/pyric-tools-deploy-reference-hosting-config/index.html +194 -0
  768. package/dist/serve/docs-ui/docs/pyric-tools-deploy-reference-hosting-config.md +95 -0
  769. package/dist/serve/docs-ui/docs/pyric-tools-deploy-reference-hosting-namespace/index.html +99 -0
  770. package/dist/serve/docs-ui/docs/pyric-tools-deploy-reference-hosting-namespace.md +126 -0
  771. package/dist/serve/docs-ui/docs/pyric-tools-deploy-reference-rtdb-namespace/index.html +110 -0
  772. package/dist/serve/docs-ui/docs/pyric-tools-deploy-reference-rtdb-namespace.md +133 -0
  773. package/dist/serve/docs-ui/docs/pyric-tools-deploy-reference-scope-and-outcome/index.html +68 -0
  774. package/dist/serve/docs-ui/docs/pyric-tools-deploy-reference-scope-and-outcome.md +88 -0
  775. package/dist/serve/docs-ui/docs/pyric-tools-deploy-reference-tool-factories/index.html +160 -0
  776. package/dist/serve/docs-ui/docs/pyric-tools-deploy-reference-tool-factories.md +104 -0
  777. package/dist/serve/docs-ui/docs/pyric-tools-deploy-tutorials-01-deploy-a-cloud-function/index.html +88 -0
  778. package/dist/serve/docs-ui/docs/pyric-tools-deploy-tutorials-01-deploy-a-cloud-function.md +119 -0
  779. package/dist/serve/docs-ui/docs/pyric-tools-deploy.md +52 -0
  780. package/dist/serve/docs-ui/docs/pyric-tools-how-to-build-a-standalone-binary/index.html +92 -0
  781. package/dist/serve/docs-ui/docs/pyric-tools-how-to-build-a-standalone-binary.md +95 -0
  782. package/dist/serve/docs-ui/docs/pyric-tools-how-to-configure-auth-providers-and-domains/index.html +101 -0
  783. package/dist/serve/docs-ui/docs/pyric-tools-how-to-configure-auth-providers-and-domains.md +126 -0
  784. package/dist/serve/docs-ui/docs/pyric-tools-how-to-discover-a-schema-from-firestore/index.html +95 -0
  785. package/dist/serve/docs-ui/docs/pyric-tools-how-to-discover-a-schema-from-firestore.md +119 -0
  786. package/dist/serve/docs-ui/docs/pyric-tools-how-to-promote-sandbox-state-to-a-fixture/index.html +52 -0
  787. package/dist/serve/docs-ui/docs/pyric-tools-how-to-promote-sandbox-state-to-a-fixture.md +83 -0
  788. package/dist/serve/docs-ui/docs/pyric-tools-how-to-serve-persistence-and-multi-tab/index.html +232 -0
  789. package/dist/serve/docs-ui/docs/pyric-tools-how-to-serve-persistence-and-multi-tab.md +178 -0
  790. package/dist/serve/docs-ui/docs/pyric-tools-how-to-use-the-vite-plugin/index.html +340 -0
  791. package/dist/serve/docs-ui/docs/pyric-tools-how-to-use-the-vite-plugin.md +288 -0
  792. package/dist/serve/docs-ui/docs/pyric-tools-how-to-verify-against-a-captured-session/index.html +128 -0
  793. package/dist/serve/docs-ui/docs/pyric-tools-how-to-verify-against-a-captured-session.md +173 -0
  794. package/dist/serve/docs-ui/docs/pyric-tools-reference-cli/index.html +433 -0
  795. package/dist/serve/docs-ui/docs/pyric-tools-reference-cli.md +252 -0
  796. package/dist/serve/docs-ui/docs/pyric-tools-reference-verify/index.html +81 -0
  797. package/dist/serve/docs-ui/docs/pyric-tools-reference-verify.md +98 -0
  798. package/dist/serve/docs-ui/docs/pyric-tools-tutorials-getting-started/index.html +92 -0
  799. package/dist/serve/docs-ui/docs/pyric-tools-tutorials-getting-started.md +117 -0
  800. package/dist/serve/docs-ui/docs/pyric-tools-tutorials-server-adoption/index.html +221 -0
  801. package/dist/serve/docs-ui/docs/pyric-tools-tutorials-server-adoption.md +239 -0
  802. package/dist/serve/docs-ui/docs/pyric-tools-tutorials-wire-claude-code/index.html +205 -0
  803. package/dist/serve/docs-ui/docs/pyric-tools-tutorials-wire-claude-code.md +250 -0
  804. package/dist/serve/docs-ui/docs/pyric-tools.md +47 -0
  805. package/dist/serve/docs-ui/docs/ui/index.html +76 -0
  806. package/dist/serve/docs-ui/docs/ui-auth-authsigninhelper/index.html +194 -0
  807. package/dist/serve/docs-ui/docs/ui-auth-authsigninhelper.md +108 -0
  808. package/dist/serve/docs-ui/docs/ui-auth-authusers/index.html +258 -0
  809. package/dist/serve/docs-ui/docs/ui-auth-authusers.md +174 -0
  810. package/dist/serve/docs-ui/docs/ui-firestore-collectionlist/index.html +92 -0
  811. package/dist/serve/docs-ui/docs/ui-firestore-collectionlist.md +71 -0
  812. package/dist/serve/docs-ui/docs/ui-firestore-deletewithconfirm/index.html +128 -0
  813. package/dist/serve/docs-ui/docs/ui-firestore-deletewithconfirm.md +94 -0
  814. package/dist/serve/docs-ui/docs/ui-firestore-documenteditor/index.html +154 -0
  815. package/dist/serve/docs-ui/docs/ui-firestore-documenteditor.md +107 -0
  816. package/dist/serve/docs-ui/docs/ui-firestore-documentlist/index.html +132 -0
  817. package/dist/serve/docs-ui/docs/ui-firestore-documentlist.md +86 -0
  818. package/dist/serve/docs-ui/docs/ui-firestore-documentpreview/index.html +159 -0
  819. package/dist/serve/docs-ui/docs/ui-firestore-documentpreview.md +78 -0
  820. package/dist/serve/docs-ui/docs/ui-firestore-querybuilder/index.html +104 -0
  821. package/dist/serve/docs-ui/docs/ui-firestore-querybuilder.md +95 -0
  822. package/dist/serve/docs-ui/docs/ui-firestore-referencepicker/index.html +113 -0
  823. package/dist/serve/docs-ui/docs/ui-firestore-referencepicker.md +85 -0
  824. package/dist/serve/docs-ui/docs/ui-primitives-badge/index.html +56 -0
  825. package/dist/serve/docs-ui/docs/ui-primitives-badge.md +34 -0
  826. package/dist/serve/docs-ui/docs/ui-primitives-confirmdialog/index.html +140 -0
  827. package/dist/serve/docs-ui/docs/ui-primitives-confirmdialog.md +98 -0
  828. package/dist/serve/docs-ui/docs/ui-primitives-copybutton/index.html +58 -0
  829. package/dist/serve/docs-ui/docs/ui-primitives-copybutton.md +31 -0
  830. package/dist/serve/docs-ui/docs/ui-primitives-jsonview/index.html +58 -0
  831. package/dist/serve/docs-ui/docs/ui-primitives-jsonview.md +41 -0
  832. package/dist/serve/docs-ui/docs/ui-primitives-segmentedcontrol/index.html +70 -0
  833. package/dist/serve/docs-ui/docs/ui-primitives-segmentedcontrol.md +44 -0
  834. package/dist/serve/docs-ui/docs/ui-primitives-toast/index.html +87 -0
  835. package/dist/serve/docs-ui/docs/ui-primitives-toast.md +74 -0
  836. package/dist/serve/docs-ui/docs/ui-primitives-virtuallist/index.html +85 -0
  837. package/dist/serve/docs-ui/docs/ui-primitives-virtuallist.md +48 -0
  838. package/dist/serve/docs-ui/docs/ui-storage/index.html +154 -0
  839. package/dist/serve/docs-ui/docs/ui-storage-deleteselectionwithconfirm/index.html +127 -0
  840. package/dist/serve/docs-ui/docs/ui-storage-deleteselectionwithconfirm.md +83 -0
  841. package/dist/serve/docs-ui/docs/ui-storage-objectbrowser/index.html +137 -0
  842. package/dist/serve/docs-ui/docs/ui-storage-objectbrowser.md +84 -0
  843. package/dist/serve/docs-ui/docs/ui-storage-objectinspector/index.html +139 -0
  844. package/dist/serve/docs-ui/docs/ui-storage-objectinspector.md +87 -0
  845. package/dist/serve/docs-ui/docs/ui-storage-pathbreadcrumb/index.html +72 -0
  846. package/dist/serve/docs-ui/docs/ui-storage-pathbreadcrumb.md +51 -0
  847. package/dist/serve/docs-ui/docs/ui-storage-rules-aware-affordances/index.html +65 -0
  848. package/dist/serve/docs-ui/docs/ui-storage-rules-aware-affordances.md +53 -0
  849. package/dist/serve/docs-ui/docs/ui-storage-uploaddropzone/index.html +93 -0
  850. package/dist/serve/docs-ui/docs/ui-storage-uploaddropzone.md +72 -0
  851. package/dist/serve/docs-ui/docs/ui-storage-usestoragerulesgate/index.html +153 -0
  852. package/dist/serve/docs-ui/docs/ui-storage-usestoragerulesgate.md +105 -0
  853. package/dist/serve/docs-ui/docs/ui-storage.md +165 -0
  854. package/dist/serve/docs-ui/docs/ui-traffic/index.html +88 -0
  855. package/dist/serve/docs-ui/docs/ui-traffic-ruleheatmap/index.html +79 -0
  856. package/dist/serve/docs-ui/docs/ui-traffic-ruleheatmap.md +54 -0
  857. package/dist/serve/docs-ui/docs/ui-traffic-trafficdetail/index.html +78 -0
  858. package/dist/serve/docs-ui/docs/ui-traffic-trafficdetail.md +53 -0
  859. package/dist/serve/docs-ui/docs/ui-traffic-trafficlog/index.html +118 -0
  860. package/dist/serve/docs-ui/docs/ui-traffic-trafficlog.md +63 -0
  861. package/dist/serve/docs-ui/docs/ui-traffic-trafficstats/index.html +51 -0
  862. package/dist/serve/docs-ui/docs/ui-traffic-trafficstats.md +40 -0
  863. package/dist/serve/docs-ui/docs/ui-traffic.md +96 -0
  864. package/dist/serve/docs-ui/docs/ui.md +88 -0
  865. package/dist/serve/docs-ui/index.html +1 -0
  866. package/dist/serve/docs-ui/llms.txt +221 -0
  867. package/dist/serve/entries/app.d.ts +26 -0
  868. package/dist/serve/entries/app.d.ts.map +1 -0
  869. package/dist/serve/entries/app.js +51 -0
  870. package/dist/serve/entries/app.js.map +1 -0
  871. package/dist/serve/entries/auth-helper-core.d.ts +47 -0
  872. package/dist/serve/entries/auth-helper-core.d.ts.map +1 -0
  873. package/dist/serve/entries/auth-helper-core.js +121 -0
  874. package/dist/serve/entries/auth-helper-core.js.map +1 -0
  875. package/dist/serve/entries/auth-helper-dom.d.ts +14 -0
  876. package/dist/serve/entries/auth-helper-dom.d.ts.map +1 -0
  877. package/dist/serve/entries/auth-helper-dom.js +116 -0
  878. package/dist/serve/entries/auth-helper-dom.js.map +1 -0
  879. package/dist/serve/entries/auth.d.ts +62 -0
  880. package/dist/serve/entries/auth.d.ts.map +1 -0
  881. package/dist/serve/entries/auth.js +128 -0
  882. package/dist/serve/entries/auth.js.map +1 -0
  883. package/dist/serve/entries/bridge-url.d.ts +25 -0
  884. package/dist/serve/entries/bridge-url.d.ts.map +1 -0
  885. package/dist/serve/entries/bridge-url.js +30 -0
  886. package/dist/serve/entries/bridge-url.js.map +1 -0
  887. package/dist/serve/entries/database.d.ts +34 -0
  888. package/dist/serve/entries/database.d.ts.map +1 -0
  889. package/dist/serve/entries/database.js +42 -0
  890. package/dist/serve/entries/database.js.map +1 -0
  891. package/dist/serve/entries/firestore.d.ts +68 -0
  892. package/dist/serve/entries/firestore.d.ts.map +1 -0
  893. package/dist/serve/entries/firestore.js +115 -0
  894. package/dist/serve/entries/firestore.js.map +1 -0
  895. package/dist/serve/entries/init.d.ts +2 -0
  896. package/dist/serve/entries/init.d.ts.map +1 -0
  897. package/dist/serve/entries/init.js +14 -0
  898. package/dist/serve/entries/init.js.map +1 -0
  899. package/dist/serve/entries/keepalive.d.ts +20 -0
  900. package/dist/serve/entries/keepalive.d.ts.map +1 -0
  901. package/dist/serve/entries/keepalive.js +38 -0
  902. package/dist/serve/entries/keepalive.js.map +1 -0
  903. package/dist/serve/entries/runtime.d.ts +60 -0
  904. package/dist/serve/entries/runtime.d.ts.map +1 -0
  905. package/dist/serve/entries/runtime.js +555 -0
  906. package/dist/serve/entries/runtime.js.map +1 -0
  907. package/dist/serve/entries/session-store.d.ts +45 -0
  908. package/dist/serve/entries/session-store.d.ts.map +1 -0
  909. package/dist/serve/entries/session-store.js +71 -0
  910. package/dist/serve/entries/session-store.js.map +1 -0
  911. package/dist/serve/entries/storage.d.ts +23 -0
  912. package/dist/serve/entries/storage.d.ts.map +1 -0
  913. package/dist/serve/entries/storage.js +49 -0
  914. package/dist/serve/entries/storage.js.map +1 -0
  915. package/dist/serve/entries/tab-sync-wiring.d.ts +88 -0
  916. package/dist/serve/entries/tab-sync-wiring.d.ts.map +1 -0
  917. package/dist/serve/entries/tab-sync-wiring.js +217 -0
  918. package/dist/serve/entries/tab-sync-wiring.js.map +1 -0
  919. package/dist/serve/namespace.d.ts +93 -0
  920. package/dist/serve/namespace.d.ts.map +1 -0
  921. package/dist/serve/namespace.js +367 -0
  922. package/dist/serve/namespace.js.map +1 -0
  923. package/dist/serve/open-browser.d.ts +23 -0
  924. package/dist/serve/open-browser.d.ts.map +1 -0
  925. package/dist/serve/open-browser.js +58 -0
  926. package/dist/serve/open-browser.js.map +1 -0
  927. package/dist/serve/playground-ui/_astro/HomePage.BFOjZGZp.js +2 -0
  928. package/dist/serve/playground-ui/_astro/PlaygroundPage.3jki8il0.js +3300 -0
  929. package/dist/serve/playground-ui/_astro/PlaygroundPage.MhP_vFvK.css +32 -0
  930. package/dist/serve/playground-ui/_astro/TopBar.ChifCjLD.js +5025 -0
  931. package/dist/serve/playground-ui/_astro/client.D61DpmEZ.js +274 -0
  932. package/dist/serve/playground-ui/_astro/client.GCK88uRs.js +1 -0
  933. package/dist/serve/playground-ui/_astro/esbuild.BHljloGq.wasm +0 -0
  934. package/dist/serve/playground-ui/_astro/index.B9aLOeXL.js +29 -0
  935. package/dist/serve/playground-ui/_astro/index.BTKE7uRF.js +1227 -0
  936. package/dist/serve/playground-ui/_astro/index.BfCthstx.css +1 -0
  937. package/dist/serve/playground-ui/_astro/index.Mr0Dtjih.js +342 -0
  938. package/dist/serve/playground-ui/_astro/ort-wasm-simd-threaded.asyncify.DMmc6YqF.wasm +0 -0
  939. package/dist/serve/playground-ui/favicon.svg +4 -0
  940. package/dist/serve/playground-ui/index.html +2 -0
  941. package/dist/serve/playground-ui/playground/index.html +2 -0
  942. package/dist/serve/rules.d.ts +45 -0
  943. package/dist/serve/rules.d.ts.map +1 -0
  944. package/dist/serve/rules.js +139 -0
  945. package/dist/serve/rules.js.map +1 -0
  946. package/dist/serve/sandbox-marker.d.ts +9 -0
  947. package/dist/serve/sandbox-marker.d.ts.map +1 -0
  948. package/dist/serve/sandbox-marker.js +32 -0
  949. package/dist/serve/sandbox-marker.js.map +1 -0
  950. package/dist/serve/server.d.ts +135 -0
  951. package/dist/serve/server.d.ts.map +1 -0
  952. package/dist/serve/server.js +328 -0
  953. package/dist/serve/server.js.map +1 -0
  954. package/dist/serve/standalone-assets.d.ts +66 -0
  955. package/dist/serve/standalone-assets.d.ts.map +1 -0
  956. package/dist/serve/standalone-assets.js +144 -0
  957. package/dist/serve/standalone-assets.js.map +1 -0
  958. package/dist/serve/state-store.d.ts +45 -0
  959. package/dist/serve/state-store.d.ts.map +1 -0
  960. package/dist/serve/state-store.js +120 -0
  961. package/dist/serve/state-store.js.map +1 -0
  962. package/dist/serve/studio/disk-project-store.d.ts +9 -0
  963. package/dist/serve/studio/disk-project-store.d.ts.map +1 -0
  964. package/dist/serve/studio/disk-project-store.js +173 -0
  965. package/dist/serve/studio/disk-project-store.js.map +1 -0
  966. package/dist/serve/studio/disk-workspace.d.ts +14 -0
  967. package/dist/serve/studio/disk-workspace.d.ts.map +1 -0
  968. package/dist/serve/studio/disk-workspace.js +152 -0
  969. package/dist/serve/studio/disk-workspace.js.map +1 -0
  970. package/dist/serve/studio/index.d.ts +10 -0
  971. package/dist/serve/studio/index.d.ts.map +1 -0
  972. package/dist/serve/studio/index.js +9 -0
  973. package/dist/serve/studio/index.js.map +1 -0
  974. package/dist/serve/studio/routes.d.ts +40 -0
  975. package/dist/serve/studio/routes.d.ts.map +1 -0
  976. package/dist/serve/studio/routes.js +182 -0
  977. package/dist/serve/studio/routes.js.map +1 -0
  978. package/dist/serve/studio/store-types.d.ts +45 -0
  979. package/dist/serve/studio/store-types.d.ts.map +1 -0
  980. package/dist/serve/studio/store-types.js +11 -0
  981. package/dist/serve/studio/store-types.js.map +1 -0
  982. package/dist/serve/studio-ui/assets/RulesCodeEditor-Bncteb8z.js +23 -0
  983. package/dist/serve/studio-ui/assets/index-CmkJxFcG.js +4577 -0
  984. package/dist/serve/studio-ui/assets/index-DNK39P6C.css +1 -0
  985. package/dist/serve/studio-ui/assets/seed-Bab4ArXQ.js +2 -0
  986. package/dist/serve/studio-ui/index.html +32 -0
  987. package/dist/serve/studio-ui/pyric-logo.svg +76 -0
  988. package/dist/serve/vite-plugin.d.ts +57 -0
  989. package/dist/serve/vite-plugin.d.ts.map +1 -0
  990. package/dist/serve/vite-plugin.js +687 -0
  991. package/dist/serve/vite-plugin.js.map +1 -0
  992. package/dist/serve/worker/client.d.ts +668 -0
  993. package/dist/serve/worker/client.d.ts.map +1 -0
  994. package/dist/serve/worker/client.js +1635 -0
  995. package/dist/serve/worker/client.js.map +1 -0
  996. package/dist/serve/worker/entry.d.ts +40 -0
  997. package/dist/serve/worker/entry.d.ts.map +1 -0
  998. package/dist/serve/worker/entry.js +122 -0
  999. package/dist/serve/worker/entry.js.map +1 -0
  1000. package/dist/serve/worker/host-auth.d.ts +47 -0
  1001. package/dist/serve/worker/host-auth.d.ts.map +1 -0
  1002. package/dist/serve/worker/host-auth.js +434 -0
  1003. package/dist/serve/worker/host-auth.js.map +1 -0
  1004. package/dist/serve/worker/host-context.d.ts +180 -0
  1005. package/dist/serve/worker/host-context.d.ts.map +1 -0
  1006. package/dist/serve/worker/host-context.js +45 -0
  1007. package/dist/serve/worker/host-context.js.map +1 -0
  1008. package/dist/serve/worker/host-events.d.ts +21 -0
  1009. package/dist/serve/worker/host-events.d.ts.map +1 -0
  1010. package/dist/serve/worker/host-events.js +87 -0
  1011. package/dist/serve/worker/host-events.js.map +1 -0
  1012. package/dist/serve/worker/host.d.ts +81 -0
  1013. package/dist/serve/worker/host.d.ts.map +1 -0
  1014. package/dist/serve/worker/host.js +1605 -0
  1015. package/dist/serve/worker/host.js.map +1 -0
  1016. package/dist/serve/worker/index.d.ts +22 -0
  1017. package/dist/serve/worker/index.d.ts.map +1 -0
  1018. package/dist/serve/worker/index.js +61 -0
  1019. package/dist/serve/worker/index.js.map +1 -0
  1020. package/dist/serve/worker/protocol.d.ts +955 -0
  1021. package/dist/serve/worker/protocol.d.ts.map +1 -0
  1022. package/dist/serve/worker/protocol.js +197 -0
  1023. package/dist/serve/worker/protocol.js.map +1 -0
  1024. package/dist/serve/worker/serve-init.d.ts +192 -0
  1025. package/dist/serve/worker/serve-init.d.ts.map +1 -0
  1026. package/dist/serve/worker/serve-init.js +555 -0
  1027. package/dist/serve/worker/serve-init.js.map +1 -0
  1028. package/dist/serve/writer-lock.d.ts +32 -0
  1029. package/dist/serve/writer-lock.d.ts.map +1 -0
  1030. package/dist/serve/writer-lock.js +43 -0
  1031. package/dist/serve/writer-lock.js.map +1 -0
  1032. package/dist/verify/cases.d.ts +37 -0
  1033. package/dist/verify/cases.d.ts.map +1 -0
  1034. package/dist/verify/cases.js +173 -0
  1035. package/dist/verify/cases.js.map +1 -0
  1036. package/dist/verify/fixture.d.ts +79 -0
  1037. package/dist/verify/fixture.d.ts.map +1 -0
  1038. package/dist/verify/fixture.js +114 -0
  1039. package/dist/verify/fixture.js.map +1 -0
  1040. package/dist/verify/index.d.ts +102 -0
  1041. package/dist/verify/index.d.ts.map +1 -0
  1042. package/dist/verify/index.js +318 -0
  1043. package/dist/verify/index.js.map +1 -0
  1044. package/dist/verify/tools.d.ts +7 -0
  1045. package/dist/verify/tools.d.ts.map +1 -0
  1046. package/dist/verify/tools.js +83 -0
  1047. package/dist/verify/tools.js.map +1 -0
  1048. package/dist/vite.d.ts +12 -0
  1049. package/dist/vite.d.ts.map +1 -0
  1050. package/dist/vite.js +16 -0
  1051. package/dist/vite.js.map +1 -0
  1052. package/package.json +127 -0
@@ -0,0 +1,1227 @@
1
+ import{bB as Z,bE as W,bF as hn,cL as Si,cM as Ii,bH as lo,cN as co,bD as xt,bC as Pt,bG as Ti,cO as ki,cP as xe,cQ as uo,cR as _,Z as ho,$ as fo,a0 as Rs,cS as D,cT as qn,cU as ne,cV as je,cW as Ot,cX as _o,cY as po,cZ as mo,c_ as mt,c$ as Xt,X as go,d0 as yo,d1 as Jt,d2 as vo,d3 as Co,d4 as Eo,d5 as As,d6 as Ni,d7 as wo,L as Re,d8 as bo,d9 as Zt,da as So,db as Io,dc as To,V as ko,Q as xi,U as No,_ as xo,N as Ro,O as Ao,a1 as Po,a3 as It,a4 as Oo,dd as Do,de as Mo,df as Lo,a5 as Gn,a2 as Fo}from"./TopBar.ChifCjLD.js";import"./index.B9aLOeXL.js";const Wo=Z({code:W(),message:W()}),Uo=Z({code:W(),message:W()}),Bo=Z({raw:W(),valid:Si(),errors:hn(Wo),warnings:hn(Uo),referencedIdentifiers:hn(W())});Z({raw:W(),parsed:Bo});Z({service:lo("realtime-database"),databaseUrl:W().url(),rules:Ii()});const Vo=`RtdbExpr {
2
+ Expr = Ternary
3
+
4
+ Ternary
5
+ = Logical "?" Ternary ":" Ternary -- ternary
6
+ | Logical
7
+
8
+ Logical
9
+ = Logical "&&" Comparison -- and
10
+ | Logical "||" Comparison -- or
11
+ | Comparison
12
+
13
+ Comparison
14
+ = Comparison "===" Additive -- strictEq
15
+ | Comparison "!==" Additive -- strictNeq
16
+ | Comparison ">=" Additive -- gte
17
+ | Comparison "<=" Additive -- lte
18
+ | Comparison ">" Additive -- gt
19
+ | Comparison "<" Additive -- lt
20
+ | Comparison "==" Additive -- looseEq
21
+ | Comparison "!=" Additive -- looseNeq
22
+ | Additive
23
+
24
+ Additive
25
+ = Additive "+" Multiplicative -- add
26
+ | Additive "-" Multiplicative -- sub
27
+ | Multiplicative
28
+
29
+ Multiplicative
30
+ = Multiplicative "*" UnaryExpr -- mul
31
+ | Multiplicative "/" UnaryExpr -- div
32
+ | Multiplicative "%" UnaryExpr -- mod
33
+ | UnaryExpr
34
+
35
+ UnaryExpr
36
+ = "!" UnaryExpr -- not
37
+ | "-" UnaryExpr -- neg
38
+ | CallExpr
39
+
40
+ CallExpr
41
+ = CallExpr "." ident "(" ListOf<Expr, ","> ")" -- methodCall
42
+ | CallExpr "." ident -- memberAccess
43
+ | CallExpr "[" Expr "]" -- indexAccess
44
+ | Primary
45
+
46
+ Primary
47
+ = "(" Expr ")" -- paren
48
+ | Array
49
+ | literal
50
+ | ident
51
+
52
+ Array = "[" ListOf<Expr, ","> "]"
53
+
54
+ literal
55
+ = number
56
+ | string
57
+ | regex
58
+ | bool
59
+ | null
60
+
61
+ number
62
+ = digit+ "." digit+ -- float
63
+ | digit+ -- int
64
+
65
+ string
66
+ = "\\"" doubleStringChar* "\\"" -- double
67
+ | "'" singleStringChar* "'" -- single
68
+
69
+ doubleStringChar
70
+ = "\\\\" any -- escape
71
+ | ~"\\"" any -- char
72
+
73
+ singleStringChar
74
+ = "\\\\" any -- escape
75
+ | ~"'" any -- char
76
+
77
+ regex = "/" regexBody "/" regexFlags
78
+
79
+ regexBody = regexChar+
80
+
81
+ regexChar
82
+ = "\\\\" any -- escape
83
+ | ~("/" | "\\n") any -- char
84
+
85
+ regexFlags = alnum*
86
+
87
+ bool
88
+ = "true" ~identChar -- true
89
+ | "false" ~identChar -- false
90
+
91
+ null = "null" ~identChar
92
+
93
+ ident = "$"? identStart identChar*
94
+
95
+ identStart = letter | "_"
96
+
97
+ identChar = alnum | "_" | "$"
98
+ }
99
+ `,le=co(Vo),Ri=le.createSemantics();Ri.addOperation("identifiers",{_nonterminal(...n){return n.flatMap(e=>e.identifiers())},_iter(...n){return n.flatMap(e=>e.identifiers())},_terminal(){return[]},CallExpr_methodCall(n,e,t,s,i,r){return[...n.identifiers(),...i.asIteration().children.flatMap(o=>o.identifiers())]},CallExpr_memberAccess(n,e,t){return n.identifiers()},ident(n,e,t){return[this.sourceString]}});function jo(n){const e=n.trim(),t=le.match(e);if(t.failed())return{raw:n,valid:!1,errors:[{code:"PARSE_ERROR",message:t.message??"Parse failed"}],warnings:[],referencedIdentifiers:[]};const s=Ri(t).identifiers(),i=[...new Set(s)];return{raw:n,valid:!0,errors:[],warnings:[],referencedIdentifiers:i}}const qo={read:new Set(["auth","data","root","now"]),write:new Set(["auth","data","newData","root","now"]),validate:new Set(["auth","data","newData","root","now"])},Go=new Set(["val","exists","hasChild","hasChildren","isString","isNumber","isBoolean","child","parent","getPriority"]),$o=new Set(["matches","contains","beginsWith","endsWith","replace","toLowerCase","length"]),Ho=new Set([...Go,...$o]);let st=[],Rt="read",Ai=new Set;const Pi=le.createSemantics();Pi.addOperation("validate",{_nonterminal(...n){n.forEach(e=>e.validate())},_iter(...n){n.forEach(e=>e.validate())},_terminal(){},CallExpr_methodCall(n,e,t,s,i,r){n.validate();const o=t.sourceString;Ho.has(o)||st.push({code:"UNKNOWN_METHOD",message:`Unknown method '${o}'`}),i.asIteration().children.forEach(a=>a.validate())},CallExpr_memberAccess(n,e,t){n.validate()},CallExpr_indexAccess(n,e,t,s){n.validate(),t.validate()},ident(n,e,t){const s=this.sourceString;if(n.sourceString==="$")return;const r=qo[Rt];r&&(!r.has(s)&&!Ai.has(s)&&st.push({code:"UNKNOWN_IDENTIFIER",message:`Identifier '${s}' is not allowed in '${Rt}' context`}),s==="newData"&&Rt==="read"&&st.push({code:"NEWDATA_IN_READ",message:"'newData' is not available in 'read' context"}))}});function Ko(n,e,t=[]){const s=le.match(n.trim());return s.failed()?[]:(st=[],Rt=e,Ai=new Set(t.map(i=>i.startsWith("$")?i.slice(1):i)),Pi(s).validate(),[...st])}let Ee=[],En=!1,wn=!1,bn=!1;const Oi=le.createSemantics();Oi.addOperation("lint",{_nonterminal(...n){n.forEach(e=>e.lint())},_iter(...n){n.forEach(e=>e.lint())},_terminal(){},CallExpr_methodCall(n,e,t,s,i,r){n.lint(),i.asIteration().children.forEach(o=>o.lint()),t.sourceString==="child"&&n.sourceString==="data"&&(bn=!0)},ident(n,e,t){const s=this.sourceString;s==="data"&&(En=!0),s==="newData"&&(wn=!0)},bool_true(n){Ee.push({code:"HARDCODED_TRUE",message:"Rule expression is hardcoded to true"})},bool_false(n){Ee.push({code:"HARDCODED_FALSE",message:"Rule expression is hardcoded to false"})},Comparison_looseEq(n,e,t){Ee.push({code:"LOOSE_EQUALITY",message:"Use '===' instead of '=='"}),n.lint(),t.lint()},Comparison_looseNeq(n,e,t){Ee.push({code:"LOOSE_INEQUALITY",message:"Use '!==' instead of '!='"}),n.lint(),t.lint()}});function Yo(n,e="read"){const t=le.match(n.trim());return t.failed()?[]:(Ee=[],En=!1,wn=!1,bn=!1,Oi(t).lint(),e==="write"&&En&&!wn&&!bn&&Ee.push({code:"DATA_IN_WRITE",message:"Write rule references 'data' but not 'newData'; consider using 'newData' to check incoming data"}),[...Ee])}const Qo=new Set([".read",".write",".validate",".indexOn"]);function dn(n,e,t=[]){const s=jo(n),i=s.valid?Ko(n,e,t):s.errors,r=s.valid?Yo(n,e):[];return{raw:n,parsed:{...s,errors:i,warnings:r}}}function Di(n,e,t,s){const i=n[".read"],r=n[".write"],o=n[".validate"],a=n[".indexOn"],l=e.split("/").filter(Boolean)[0]??"",c=l!==""&&s!=null?l in s:!1,u={path:e,pathVariables:[...t],exists:c,children:[]};if(i!==void 0){const h=String(i);u.read=dn(h,"read",t)}if(r!==void 0){const h=String(r);u.write=dn(h,"write",t)}if(o!==void 0){const h=String(o);u.validate=dn(h,"validate",t)}a!==void 0&&(u.indexOn=Array.isArray(a)?a.map(String):[String(a)]);for(const h of Object.keys(n)){if(Qo.has(h))continue;const d=n[h];if(typeof d!="object"||d===null)continue;const f=e==="/"?`/${h}`:`${e}/${h}`,p=h.startsWith("$")?[...t,h]:[...t];u.children.push(Di(d,f,p,s))}return u}function fn(n){return n==="true"?!0:n==="false"?!1:n}function Mi(n){const e={};n.read&&(e[".read"]=fn(n.read.raw)),n.write&&(e[".write"]=fn(n.write.raw)),n.validate&&(e[".validate"]=fn(n.validate.raw)),n.indexOn&&(e[".indexOn"]=n.indexOn);for(const t of n.children){const s=t.path.split("/").filter(Boolean),i=s[s.length-1];e[i]=Mi(t)}return e}class zo{static mapToRulesJSON(e){if(!e.rules||typeof e.rules!="object"||!("path"in e.rules))throw new Error("Invalid rules IR: 'rules' field must be a valid RtdbNode object with a 'path' property");return{rules:Mi(e.rules)}}static mapToIR(e,t,s){if(!e||typeof e!="object")throw new Error("Invalid rules JSON: expected an object");const i=e;if(!("rules"in i))throw new Error('Invalid rules JSON: missing top-level "rules" key');const r=i.rules;if(typeof r!="object"||r===null)throw new Error('Invalid rules JSON: "rules" must be an object');const o=Di(r,"/",[],t);return{service:"realtime-database",databaseUrl:s,rules:o}}}const Xo=new Set(["__proto__","prototype","constructor"]);function Ps(n,e){return Xo.has(e)?null:typeof n=="string"?e==="length"?n.length:null:n===null||typeof n!="object"||!Object.hasOwn(n,e)?null:n[e]??null}let Le=class Sn{_value;_path;_root;constructor(e,t="/",s){this._value=e??null,this._path=t,this._root=s!==void 0?s:e}val(){return this._value}exists(){return this._value!==null&&this._value!==void 0}hasChild(e){return this.child(e).exists()}hasChildren(e){return Array.isArray(e)?e.every(t=>this.hasChild(String(t))):typeof this._value=="object"&&this._value!==null&&Object.keys(this._value).length>0}isString(){return typeof this._value=="string"}isNumber(){return typeof this._value=="number"}isBoolean(){return typeof this._value=="boolean"}child(e){const t=e.split("/").filter(r=>r.length>0);let s=this._value,i=this._path;for(const r of t){if(s==null||typeof s!="object"){s=null,i=`${i}/${r}`.replace(/\/+/g,"/");break}s=Object.hasOwn(s,r)?s[r]??null:null,i=`${i==="/"?"":i}/${r}`}return new Sn(s,i,this._root)}parent(){if(this._path==="/")return null;const e=this._path.split("/").filter(i=>i.length>0);e.pop();const t="/"+e.join("/"),s=new Sn(this._root,"/");return t==="/"?s:s.child(e.join("/"))}getPriority(){return null}};class Jo{value;constructor(e){this.value=e}matches(e){return(e instanceof RegExp?e:new RegExp(e)).test(this.value)}contains(e){return this.value.includes(e)}beginsWith(e){return this.value.startsWith(e)}endsWith(e){return this.value.endsWith(e)}replace(e,t){return this.value.replace(e,t)}toLowerCase(){return this.value.toLowerCase()}get length(){return this.value.length}}let ue={auth:null,data:new Le(null),newData:new Le(null),root:new Le(null),now:Date.now(),pathVariableBindings:{}};const Li=le.createSemantics();Li.addOperation("eval",{Expr(n){return n.eval()},Ternary_ternary(n,e,t,s,i){return n.eval()?t.eval():i.eval()},Ternary(n){return n.eval()},Logical_and(n,e,t){return n.eval()&&t.eval()},Logical_or(n,e,t){return n.eval()||t.eval()},Logical(n){return n.eval()},Comparison_strictEq(n,e,t){return n.eval()===t.eval()},Comparison_strictNeq(n,e,t){return n.eval()!==t.eval()},Comparison_gte(n,e,t){return n.eval()>=t.eval()},Comparison_lte(n,e,t){return n.eval()<=t.eval()},Comparison_gt(n,e,t){return n.eval()>t.eval()},Comparison_lt(n,e,t){return n.eval()<t.eval()},Comparison_looseEq(n,e,t){return n.eval()==t.eval()},Comparison_looseNeq(n,e,t){return n.eval()!=t.eval()},Comparison(n){return n.eval()},Additive_add(n,e,t){return n.eval()+t.eval()},Additive_sub(n,e,t){return n.eval()-t.eval()},Additive(n){return n.eval()},Multiplicative_mul(n,e,t){return n.eval()*t.eval()},Multiplicative_div(n,e,t){return n.eval()/t.eval()},Multiplicative_mod(n,e,t){return n.eval()%t.eval()},Multiplicative(n){return n.eval()},UnaryExpr_not(n,e){return!e.eval()},UnaryExpr_neg(n,e){return-e.eval()},UnaryExpr(n){return n.eval()},CallExpr_methodCall(n,e,t,s,i,r){const o=n.eval(),a=t.sourceString,l=i.asIteration().children.map(c=>c.eval());if(o instanceof Le)switch(a){case"val":return o.val();case"exists":return o.exists();case"hasChild":return o.hasChild(String(l[0]));case"hasChildren":return o.hasChildren(l.length>0?l[0]:void 0);case"isString":return o.isString();case"isNumber":return o.isNumber();case"isBoolean":return o.isBoolean();case"child":return o.child(String(l[0]));case"parent":return o.parent();case"getPriority":return o.getPriority();default:throw new Error(`Unknown DataSnapshot method: ${a}`)}if(typeof o=="string"){const c=new Jo(o);switch(a){case"matches":return c.matches(l[0]);case"contains":return c.contains(String(l[0]));case"beginsWith":return c.beginsWith(String(l[0]));case"endsWith":return c.endsWith(String(l[0]));case"replace":return c.replace(l[0],String(l[1]));case"toLowerCase":return c.toLowerCase();default:throw new Error(`Unknown string method: ${a}`)}}throw new Error(`Unknown method '${a}' for the given value.`)},CallExpr_memberAccess(n,e,t){const s=n.eval();return s==null?null:Ps(s,t.sourceString)},CallExpr_indexAccess(n,e,t,s){const i=n.eval(),r=t.eval();return i==null?null:Ps(i,String(r))},CallExpr(n){return n.eval()},Primary_paren(n,e,t){return e.eval()},Primary(n){return n.eval()},Array(n,e,t){return e.asIteration().children.map(s=>s.eval())},literal(n){return n.eval()},number_float(n,e,t){return parseFloat(this.sourceString)},number_int(n){return parseInt(this.sourceString,10)},number(n){return n.eval()},string_double(n,e,t){return JSON.parse(this.sourceString)},string_single(n,e,t){return e.children.map(s=>s.sourceString).join("")},string(n){return n.eval()},regex(n,e,t,s){return new RegExp(e.sourceString,s.sourceString)},bool_true(n){return!0},bool_false(n){return!1},bool(n){return n.eval()},null(n){return null},ident(n,e,t){const s=this.sourceString;if(s in ue.pathVariableBindings)return ue.pathVariableBindings[s];switch(s){case"auth":return ue.auth;case"data":return ue.data;case"newData":return ue.newData;case"root":return ue.root;case"now":return ue.now;default:return}}});function Fi(n,e){return ue=e,Li(n).eval()}const Zo=Z({operation:xe(["read","write","validate"]),path:W().min(1).startsWith("/"),auth:Ti([Z({uid:W(),token:Pt(xt())}),ki()]),mockData:Pt(xt()),newData:xt().optional()});xe(["IR_NOT_GENERATED","INVALID_INPUT","NO_MATCHING_RULE","EVALUATION_ERROR"]);Z({allowed:Si(),matchedPath:W(),matchedRule:W(),reason:W(),pathVariableBindings:Pt(W())});function ea(n){const e=n.val();return e===null||typeof e!="object"?[]:Object.keys(e)}function Wi(n,e,t){if(e.length===0)return{node:n,bindings:t};for(const s of n.children){const i=s.path.split("/").filter(Boolean);if(i.length===0)continue;const r=i[i.length-1],o=r.startsWith("$");if(o||e[0]===r){const a=o?{...t,[r]:e[0]}:{...t};return Wi(s,e.slice(1),a)}}return null}function In(n,e,t,s,i){if(!t.exists())return null;const r=n.validate;if(r&&r.parsed.valid){const o=le.match(r.raw.trim());if(!Fi(o,i(e,t,s)))return{node:n,rule:r,bindings:s}}for(const o of n.children){const a=o.path.split("/").filter(Boolean);if(a.length===0)continue;const l=a[a.length-1];if(l.startsWith("$"))for(const u of ea(t)){const h=In(o,e.child(u),t.child(u),{...s,[l]:u},i);if(h)return h}else{const u=In(o,e.child(l),t.child(l),s,i);if(u)return u}}return null}function Ui(n,e,t){const s=[{node:n,pathVariableBindings:{...t}}];if(e.length===0)return s;for(const i of n.children){const r=i.path.split("/").filter(Boolean);if(r.length===0)continue;const o=r[r.length-1],a=o.startsWith("$");if(a||e[0]===o){const l=a?{...t,[o]:e[0]}:{...t},c=Ui(i,e.slice(1),l);return s.push(...c),s}}return s}class ta{execute(e,t){if(!e)return{success:!1,error:{code:"IR_NOT_GENERATED",message:"Call generateIR() before simulate()",recoverable:!0}};const s=Zo.safeParse(t);if(!s.success)return{success:!1,error:{code:"INVALID_INPUT",message:s.error.message,recoverable:!0}};const{operation:i,path:r,auth:o,mockData:a,newData:l}=s.data;try{const c=r.split("/").filter(Boolean),u=e.rules,h=Ui(u,c,{}),d=new Le(a,"/"),f=d.child(r.slice(1)),p=new Le(l??null,r),g=(x,R,$)=>{const ie={};for(const[H,Q]of Object.entries($))ie[H]=Q,ie[H.slice(1)]=Q;return{auth:o?{uid:o.uid,token:o.token}:null,data:x,newData:R,root:d,now:Date.now(),pathVariableBindings:ie}};for(const x of h){const R=x.node[i];if(!R||!R.parsed.valid)continue;const $=le.match(R.raw.trim());if(Fi($,g(f,p,x.pathVariableBindings))){if(i==="write"){const H=Wi(u,c,{}),Q=H?In(H.node,f,p,H.bindings,g):null;if(Q)return{success:!0,data:{allowed:!1,matchedPath:Q.node.path,matchedRule:Q.rule.raw,reason:"Validation rule evaluated to false",pathVariableBindings:Q.bindings}}}return{success:!0,data:{allowed:!0,matchedPath:x.node.path,matchedRule:R.raw,reason:"Rule expression evaluated to true",pathVariableBindings:x.pathVariableBindings}}}}const b=h[h.length-1],A=b.node[i];return A?{success:!0,data:{allowed:!1,matchedPath:b.node.path,matchedRule:A.raw,reason:"Rule expression evaluated to false",pathVariableBindings:b.pathVariableBindings}}:{success:!1,error:{code:"NO_MATCHING_RULE",message:`No '${i}' rule found for path '${r}'`,recoverable:!0}}}catch(c){return{success:!1,error:{code:"EVALUATION_ERROR",message:c instanceof Error?c.message:String(c),recoverable:!1}}}}}xe(["CRAWL_FAILED","PERMISSION_DENIED"]);const Os="@firebase/database",Ds="1.1.3";/**
100
+ * @license
101
+ * Copyright 2019 Google LLC
102
+ *
103
+ * Licensed under the Apache License, Version 2.0 (the "License");
104
+ * you may not use this file except in compliance with the License.
105
+ * You may obtain a copy of the License at
106
+ *
107
+ * http://www.apache.org/licenses/LICENSE-2.0
108
+ *
109
+ * Unless required by applicable law or agreed to in writing, software
110
+ * distributed under the License is distributed on an "AS IS" BASIS,
111
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
112
+ * See the License for the specific language governing permissions and
113
+ * limitations under the License.
114
+ */let Bi="";function na(n){Bi=n}/**
115
+ * @license
116
+ * Copyright 2017 Google LLC
117
+ *
118
+ * Licensed under the Apache License, Version 2.0 (the "License");
119
+ * you may not use this file except in compliance with the License.
120
+ * You may obtain a copy of the License at
121
+ *
122
+ * http://www.apache.org/licenses/LICENSE-2.0
123
+ *
124
+ * Unless required by applicable law or agreed to in writing, software
125
+ * distributed under the License is distributed on an "AS IS" BASIS,
126
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
127
+ * See the License for the specific language governing permissions and
128
+ * limitations under the License.
129
+ */class sa{constructor(e){this.domStorage_=e,this.prefix_="firebase:"}set(e,t){t==null?this.domStorage_.removeItem(this.prefixedName_(e)):this.domStorage_.setItem(this.prefixedName_(e),D(t))}get(e){const t=this.domStorage_.getItem(this.prefixedName_(e));return t==null?null:qn(t)}remove(e){this.domStorage_.removeItem(this.prefixedName_(e))}prefixedName_(e){return this.prefix_+e}toString(){return this.domStorage_.toString()}}/**
130
+ * @license
131
+ * Copyright 2017 Google LLC
132
+ *
133
+ * Licensed under the Apache License, Version 2.0 (the "License");
134
+ * you may not use this file except in compliance with the License.
135
+ * You may obtain a copy of the License at
136
+ *
137
+ * http://www.apache.org/licenses/LICENSE-2.0
138
+ *
139
+ * Unless required by applicable law or agreed to in writing, software
140
+ * distributed under the License is distributed on an "AS IS" BASIS,
141
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
142
+ * See the License for the specific language governing permissions and
143
+ * limitations under the License.
144
+ */class ia{constructor(){this.cache_={},this.isInMemoryStorage=!0}set(e,t){t==null?delete this.cache_[e]:this.cache_[e]=t}get(e){return ne(this.cache_,e)?this.cache_[e]:null}remove(e){delete this.cache_[e]}}/**
145
+ * @license
146
+ * Copyright 2017 Google LLC
147
+ *
148
+ * Licensed under the Apache License, Version 2.0 (the "License");
149
+ * you may not use this file except in compliance with the License.
150
+ * You may obtain a copy of the License at
151
+ *
152
+ * http://www.apache.org/licenses/LICENSE-2.0
153
+ *
154
+ * Unless required by applicable law or agreed to in writing, software
155
+ * distributed under the License is distributed on an "AS IS" BASIS,
156
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
157
+ * See the License for the specific language governing permissions and
158
+ * limitations under the License.
159
+ */const Vi=function(n){try{if(typeof window<"u"&&typeof window[n]<"u"){const e=window[n];return e.setItem("firebase:sentinel","cache"),e.removeItem("firebase:sentinel"),new sa(e)}}catch{}return new ia},we=Vi("localStorage"),ra=Vi("sessionStorage");/**
160
+ * @license
161
+ * Copyright 2017 Google LLC
162
+ *
163
+ * Licensed under the Apache License, Version 2.0 (the "License");
164
+ * you may not use this file except in compliance with the License.
165
+ * You may obtain a copy of the License at
166
+ *
167
+ * http://www.apache.org/licenses/LICENSE-2.0
168
+ *
169
+ * Unless required by applicable law or agreed to in writing, software
170
+ * distributed under the License is distributed on an "AS IS" BASIS,
171
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
172
+ * See the License for the specific language governing permissions and
173
+ * limitations under the License.
174
+ */const Fe=new uo("@firebase/database"),oa=(function(){let n=1;return function(){return n++}})(),ji=function(n){const e=_o(n),t=new po;t.update(e);const s=t.digest();return mo.encodeByteArray(s)},gt=function(...n){let e="";for(let t=0;t<n.length;t++){const s=n[t];Array.isArray(s)||s&&typeof s=="object"&&typeof s.length=="number"?e+=gt.apply(null,s):typeof s=="object"?e+=D(s):e+=s,e+=" "}return e};let it=null,Ms=!0;const aa=function(n,e){_(!0,"Can't turn on custom loggers persistently."),Fe.logLevel=yo.VERBOSE,it=Fe.log.bind(Fe)},F=function(...n){if(Ms===!0&&(Ms=!1,it===null&&ra.get("logging_enabled")===!0&&aa()),it){const e=gt.apply(null,n);it(e)}},yt=function(n){return function(...e){F(n,...e)}},Tn=function(...n){const e="FIREBASE INTERNAL ERROR: "+gt(...n);Fe.error(e)},ae=function(...n){const e=`FIREBASE FATAL ERROR: ${gt(...n)}`;throw Fe.error(e),new Error(e)},V=function(...n){const e="FIREBASE WARNING: "+gt(...n);Fe.warn(e)},la=function(){typeof window<"u"&&window.location&&window.location.protocol&&window.location.protocol.indexOf("https:")!==-1&&V("Insecure Firebase access from a secure page. Please use https in calls to new Firebase().")},$n=function(n){return typeof n=="number"&&(n!==n||n===Number.POSITIVE_INFINITY||n===Number.NEGATIVE_INFINITY)},ca=function(n){if(document.readyState==="complete")n();else{let e=!1;const t=function(){if(!document.body){setTimeout(t,Math.floor(10));return}e||(e=!0,n())};document.addEventListener?(document.addEventListener("DOMContentLoaded",t,!1),window.addEventListener("load",t,!1)):document.attachEvent&&(document.attachEvent("onreadystatechange",()=>{document.readyState==="complete"&&t()}),window.attachEvent("onload",t))}},qe="[MIN_NAME]",be="[MAX_NAME]",Ae=function(n,e){if(n===e)return 0;if(n===qe||e===be)return-1;if(e===qe||n===be)return 1;{const t=Ls(n),s=Ls(e);return t!==null?s!==null?t-s===0?n.length-e.length:t-s:-1:s!==null?1:n<e?-1:1}},ua=function(n,e){return n===e?0:n<e?-1:1},Ze=function(n,e){if(e&&n in e)return e[n];throw new Error("Missing required key ("+n+") in object: "+D(e))},Hn=function(n){if(typeof n!="object"||n===null)return D(n);const e=[];for(const s in n)e.push(s);e.sort();let t="{";for(let s=0;s<e.length;s++)s!==0&&(t+=","),t+=D(e[s]),t+=":",t+=Hn(n[e[s]]);return t+="}",t},qi=function(n,e){const t=n.length;if(t<=e)return[n];const s=[];for(let i=0;i<t;i+=e)i+e>t?s.push(n.substring(i,t)):s.push(n.substring(i,i+e));return s};function U(n,e){for(const t in n)n.hasOwnProperty(t)&&e(t,n[t])}const Gi=function(n){_(!$n(n),"Invalid JSON number");const e=11,t=52,s=(1<<e-1)-1;let i,r,o,a,l;n===0?(r=0,o=0,i=1/n===-1/0?1:0):(i=n<0,n=Math.abs(n),n>=Math.pow(2,1-s)?(a=Math.min(Math.floor(Math.log(n)/Math.LN2),s),r=a+s,o=Math.round(n*Math.pow(2,t-a)-Math.pow(2,t))):(r=0,o=Math.round(n/Math.pow(2,1-s-t))));const c=[];for(l=t;l;l-=1)c.push(o%2?1:0),o=Math.floor(o/2);for(l=e;l;l-=1)c.push(r%2?1:0),r=Math.floor(r/2);c.push(i?1:0),c.reverse();const u=c.join("");let h="";for(l=0;l<64;l+=8){let d=parseInt(u.substr(l,8),2).toString(16);d.length===1&&(d="0"+d),h=h+d}return h.toLowerCase()},ha=function(){return!!(typeof window=="object"&&window.chrome&&window.chrome.extension&&!/^chrome/.test(window.location.href))},da=function(){return typeof Windows=="object"&&typeof Windows.UI=="object"};function fa(n,e){let t="Unknown Error";n==="too_big"?t="The data requested exceeds the maximum size that can be accessed with a single request.":n==="permission_denied"?t="Client doesn't have permission to access the desired data.":n==="unavailable"&&(t="The service is unavailable");const s=new Error(n+" at "+e._path.toString()+": "+t);return s.code=n.toUpperCase(),s}const _a=new RegExp("^-?(0*)\\d{1,10}$"),pa=-2147483648,ma=2147483647,Ls=function(n){if(_a.test(n)){const e=Number(n);if(e>=pa&&e<=ma)return e}return null},ze=function(n){try{n()}catch(e){setTimeout(()=>{const t=e.stack||"";throw V("Exception was thrown by user callback.",t),e},Math.floor(0))}},ga=function(){return(typeof window=="object"&&window.navigator&&window.navigator.userAgent||"").search(/googlebot|google webmaster tools|bingbot|yahoo! slurp|baiduspider|yandexbot|duckduckbot/i)>=0},rt=function(n,e){const t=setTimeout(n,e);return typeof t=="number"&&typeof Deno<"u"&&Deno.unrefTimer?Deno.unrefTimer(t):typeof t=="object"&&t.unref&&t.unref(),t};/**
175
+ * @license
176
+ * Copyright 2021 Google LLC
177
+ *
178
+ * Licensed under the Apache License, Version 2.0 (the "License");
179
+ * you may not use this file except in compliance with the License.
180
+ * You may obtain a copy of the License at
181
+ *
182
+ * http://www.apache.org/licenses/LICENSE-2.0
183
+ *
184
+ * Unless required by applicable law or agreed to in writing, software
185
+ * distributed under the License is distributed on an "AS IS" BASIS,
186
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
187
+ * See the License for the specific language governing permissions and
188
+ * limitations under the License.
189
+ */class ya{constructor(e,t){this.appCheckProvider=t,this.appName=e.name,go(e)&&e.settings.appCheckToken&&(this.serverAppAppCheckToken=e.settings.appCheckToken),this.appCheck=t?.getImmediate({optional:!0}),this.appCheck||t?.get().then(s=>this.appCheck=s)}getToken(e){if(this.serverAppAppCheckToken){if(e)throw new Error("Attempted reuse of `FirebaseServerApp.appCheckToken` after previous usage failed.");return Promise.resolve({token:this.serverAppAppCheckToken})}return this.appCheck?this.appCheck.getToken(e):new Promise((t,s)=>{setTimeout(()=>{this.appCheck?this.getToken(e).then(t,s):t(null)},0)})}addTokenChangeListener(e){this.appCheckProvider?.get().then(t=>t.addTokenListener(e))}notifyForInvalidToken(){V(`Provided AppCheck credentials for the app named "${this.appName}" are invalid. This usually indicates your app was not initialized correctly.`)}}/**
190
+ * @license
191
+ * Copyright 2017 Google LLC
192
+ *
193
+ * Licensed under the Apache License, Version 2.0 (the "License");
194
+ * you may not use this file except in compliance with the License.
195
+ * You may obtain a copy of the License at
196
+ *
197
+ * http://www.apache.org/licenses/LICENSE-2.0
198
+ *
199
+ * Unless required by applicable law or agreed to in writing, software
200
+ * distributed under the License is distributed on an "AS IS" BASIS,
201
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
202
+ * See the License for the specific language governing permissions and
203
+ * limitations under the License.
204
+ */class va{constructor(e,t,s){this.appName_=e,this.firebaseOptions_=t,this.authProvider_=s,this.auth_=null,this.auth_=s.getImmediate({optional:!0}),this.auth_||s.onInit(i=>this.auth_=i)}getToken(e){return this.auth_?this.auth_.getToken(e).catch(t=>t&&t.code==="auth/token-not-initialized"?(F("Got auth/token-not-initialized error. Treating as null token."),null):Promise.reject(t)):new Promise((t,s)=>{setTimeout(()=>{this.auth_?this.getToken(e).then(t,s):t(null)},0)})}addTokenChangeListener(e){this.auth_?this.auth_.addAuthTokenListener(e):this.authProvider_.get().then(t=>t.addAuthTokenListener(e))}removeTokenChangeListener(e){this.authProvider_.get().then(t=>t.removeAuthTokenListener(e))}notifyForInvalidToken(){let e='Provided authentication credentials for the app named "'+this.appName_+'" are invalid. This usually indicates your app was not initialized correctly. ';"credential"in this.firebaseOptions_?e+='Make sure the "credential" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':"serviceAccount"in this.firebaseOptions_?e+='Make sure the "serviceAccount" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':e+='Make sure the "apiKey" and "databaseURL" properties provided to initializeApp() match the values provided for your app at https://console.firebase.google.com/.',V(e)}}class At{constructor(e){this.accessToken=e}getToken(e){return Promise.resolve({accessToken:this.accessToken})}addTokenChangeListener(e){e(this.accessToken)}removeTokenChangeListener(e){}notifyForInvalidToken(){}}At.OWNER="owner";/**
205
+ * @license
206
+ * Copyright 2017 Google LLC
207
+ *
208
+ * Licensed under the Apache License, Version 2.0 (the "License");
209
+ * you may not use this file except in compliance with the License.
210
+ * You may obtain a copy of the License at
211
+ *
212
+ * http://www.apache.org/licenses/LICENSE-2.0
213
+ *
214
+ * Unless required by applicable law or agreed to in writing, software
215
+ * distributed under the License is distributed on an "AS IS" BASIS,
216
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
217
+ * See the License for the specific language governing permissions and
218
+ * limitations under the License.
219
+ */const Kn="5",$i="v",Hi="s",Ki="r",Yi="f",Qi=/(console\.firebase|firebase-console-\w+\.corp|firebase\.corp)\.google\.com/,zi="ls",Xi="p",kn="ac",Ji="websocket",Zi="long_polling";/**
220
+ * @license
221
+ * Copyright 2017 Google LLC
222
+ *
223
+ * Licensed under the Apache License, Version 2.0 (the "License");
224
+ * you may not use this file except in compliance with the License.
225
+ * You may obtain a copy of the License at
226
+ *
227
+ * http://www.apache.org/licenses/LICENSE-2.0
228
+ *
229
+ * Unless required by applicable law or agreed to in writing, software
230
+ * distributed under the License is distributed on an "AS IS" BASIS,
231
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
232
+ * See the License for the specific language governing permissions and
233
+ * limitations under the License.
234
+ */class er{constructor(e,t,s,i,r=!1,o="",a=!1,l=!1,c=null){this.secure=t,this.namespace=s,this.webSocketOnly=i,this.nodeAdmin=r,this.persistenceKey=o,this.includeNamespaceInQueryParams=a,this.isUsingEmulator=l,this.emulatorOptions=c,this._host=e.toLowerCase(),this._domain=this._host.substr(this._host.indexOf(".")+1),this.internalHost=we.get("host:"+e)||this._host}isCacheableHost(){return this.internalHost.substr(0,2)==="s-"}isCustomHost(){return this._domain!=="firebaseio.com"&&this._domain!=="firebaseio-demo.com"}get host(){return this._host}set host(e){e!==this.internalHost&&(this.internalHost=e,this.isCacheableHost()&&we.set("host:"+this._host,this.internalHost))}toString(){let e=this.toURLString();return this.persistenceKey&&(e+="<"+this.persistenceKey+">"),e}toURLString(){const e=this.secure?"https://":"http://",t=this.includeNamespaceInQueryParams?`?ns=${this.namespace}`:"";return`${e}${this.host}/${t}`}}function Ca(n){return n.host!==n.internalHost||n.isCustomHost()||n.includeNamespaceInQueryParams}function tr(n,e,t){_(typeof e=="string","typeof type must == string"),_(typeof t=="object","typeof params must == object");let s;if(e===Ji)s=(n.secure?"wss://":"ws://")+n.internalHost+"/.ws?";else if(e===Zi)s=(n.secure?"https://":"http://")+n.internalHost+"/.lp?";else throw new Error("Unknown connection type: "+e);Ca(n)&&(t.ns=n.namespace);const i=[];return U(t,(r,o)=>{i.push(r+"="+o)}),s+i.join("&")}/**
235
+ * @license
236
+ * Copyright 2017 Google LLC
237
+ *
238
+ * Licensed under the Apache License, Version 2.0 (the "License");
239
+ * you may not use this file except in compliance with the License.
240
+ * You may obtain a copy of the License at
241
+ *
242
+ * http://www.apache.org/licenses/LICENSE-2.0
243
+ *
244
+ * Unless required by applicable law or agreed to in writing, software
245
+ * distributed under the License is distributed on an "AS IS" BASIS,
246
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
247
+ * See the License for the specific language governing permissions and
248
+ * limitations under the License.
249
+ */class Ea{constructor(){this.counters_={}}incrementCounter(e,t=1){ne(this.counters_,e)||(this.counters_[e]=0),this.counters_[e]+=t}get(){return bo(this.counters_)}}/**
250
+ * @license
251
+ * Copyright 2017 Google LLC
252
+ *
253
+ * Licensed under the Apache License, Version 2.0 (the "License");
254
+ * you may not use this file except in compliance with the License.
255
+ * You may obtain a copy of the License at
256
+ *
257
+ * http://www.apache.org/licenses/LICENSE-2.0
258
+ *
259
+ * Unless required by applicable law or agreed to in writing, software
260
+ * distributed under the License is distributed on an "AS IS" BASIS,
261
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
262
+ * See the License for the specific language governing permissions and
263
+ * limitations under the License.
264
+ */const _n={},pn={};function Yn(n){const e=n.toString();return _n[e]||(_n[e]=new Ea),_n[e]}function wa(n,e){const t=n.toString();return pn[t]||(pn[t]=e()),pn[t]}/**
265
+ * @license
266
+ * Copyright 2017 Google LLC
267
+ *
268
+ * Licensed under the Apache License, Version 2.0 (the "License");
269
+ * you may not use this file except in compliance with the License.
270
+ * You may obtain a copy of the License at
271
+ *
272
+ * http://www.apache.org/licenses/LICENSE-2.0
273
+ *
274
+ * Unless required by applicable law or agreed to in writing, software
275
+ * distributed under the License is distributed on an "AS IS" BASIS,
276
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
277
+ * See the License for the specific language governing permissions and
278
+ * limitations under the License.
279
+ */class ba{constructor(e){this.onMessage_=e,this.pendingResponses=[],this.currentResponseNum=0,this.closeAfterResponse=-1,this.onClose=null}closeAfter(e,t){this.closeAfterResponse=e,this.onClose=t,this.closeAfterResponse<this.currentResponseNum&&(this.onClose(),this.onClose=null)}handleResponse(e,t){for(this.pendingResponses[e]=t;this.pendingResponses[this.currentResponseNum];){const s=this.pendingResponses[this.currentResponseNum];delete this.pendingResponses[this.currentResponseNum];for(let i=0;i<s.length;++i)s[i]&&ze(()=>{this.onMessage_(s[i])});if(this.currentResponseNum===this.closeAfterResponse){this.onClose&&(this.onClose(),this.onClose=null);break}this.currentResponseNum++}}}/**
280
+ * @license
281
+ * Copyright 2017 Google LLC
282
+ *
283
+ * Licensed under the Apache License, Version 2.0 (the "License");
284
+ * you may not use this file except in compliance with the License.
285
+ * You may obtain a copy of the License at
286
+ *
287
+ * http://www.apache.org/licenses/LICENSE-2.0
288
+ *
289
+ * Unless required by applicable law or agreed to in writing, software
290
+ * distributed under the License is distributed on an "AS IS" BASIS,
291
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
292
+ * See the License for the specific language governing permissions and
293
+ * limitations under the License.
294
+ */const Fs="start",Sa="close",Ia="pLPCommand",Ta="pRTLPCB",nr="id",sr="pw",ir="ser",ka="cb",Na="seg",xa="ts",Ra="d",Aa="dframe",rr=1870,or=30,Pa=rr-or,Oa=25e3,Da=3e4;class Me{constructor(e,t,s,i,r,o,a){this.connId=e,this.repoInfo=t,this.applicationId=s,this.appCheckToken=i,this.authToken=r,this.transportSessionId=o,this.lastSessionId=a,this.bytesSent=0,this.bytesReceived=0,this.everConnected_=!1,this.log_=yt(e),this.stats_=Yn(t),this.urlFn=l=>(this.appCheckToken&&(l[kn]=this.appCheckToken),tr(t,Zi,l))}open(e,t){this.curSegmentNum=0,this.onDisconnect_=t,this.myPacketOrderer=new ba(e),this.isClosed_=!1,this.connectTimeoutTimer_=setTimeout(()=>{this.log_("Timed out trying to connect."),this.onClosed_(),this.connectTimeoutTimer_=null},Math.floor(Da)),ca(()=>{if(this.isClosed_)return;this.scriptTagHolder=new Qn((...r)=>{const[o,a,l,c,u]=r;if(this.incrementIncomingBytes_(r),!!this.scriptTagHolder)if(this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null),this.everConnected_=!0,o===Fs)this.id=a,this.password=l;else if(o===Sa)a?(this.scriptTagHolder.sendNewPolls=!1,this.myPacketOrderer.closeAfter(a,()=>{this.onClosed_()})):this.onClosed_();else throw new Error("Unrecognized command received: "+o)},(...r)=>{const[o,a]=r;this.incrementIncomingBytes_(r),this.myPacketOrderer.handleResponse(o,a)},()=>{this.onClosed_()},this.urlFn);const s={};s[Fs]="t",s[ir]=Math.floor(Math.random()*1e8),this.scriptTagHolder.uniqueCallbackIdentifier&&(s[ka]=this.scriptTagHolder.uniqueCallbackIdentifier),s[$i]=Kn,this.transportSessionId&&(s[Hi]=this.transportSessionId),this.lastSessionId&&(s[zi]=this.lastSessionId),this.applicationId&&(s[Xi]=this.applicationId),this.appCheckToken&&(s[kn]=this.appCheckToken),typeof location<"u"&&location.hostname&&Qi.test(location.hostname)&&(s[Ki]=Yi);const i=this.urlFn(s);this.log_("Connecting via long-poll to "+i),this.scriptTagHolder.addTag(i,()=>{})})}start(){this.scriptTagHolder.startLongPoll(this.id,this.password),this.addDisconnectPingFrame(this.id,this.password)}static forceAllow(){Me.forceAllow_=!0}static forceDisallow(){Me.forceDisallow_=!0}static isAvailable(){return Me.forceAllow_?!0:!Me.forceDisallow_&&typeof document<"u"&&document.createElement!=null&&!ha()&&!da()}markConnectionHealthy(){}shutdown_(){this.isClosed_=!0,this.scriptTagHolder&&(this.scriptTagHolder.close(),this.scriptTagHolder=null),this.myDisconnFrame&&(document.body.removeChild(this.myDisconnFrame),this.myDisconnFrame=null),this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null)}onClosed_(){this.isClosed_||(this.log_("Longpoll is closing itself"),this.shutdown_(),this.onDisconnect_&&(this.onDisconnect_(this.everConnected_),this.onDisconnect_=null))}close(){this.isClosed_||(this.log_("Longpoll is being closed."),this.shutdown_())}send(e){const t=D(e);this.bytesSent+=t.length,this.stats_.incrementCounter("bytes_sent",t.length);const s=So(t),i=qi(s,Pa);for(let r=0;r<i.length;r++)this.scriptTagHolder.enqueueSegment(this.curSegmentNum,i.length,i[r]),this.curSegmentNum++}addDisconnectPingFrame(e,t){this.myDisconnFrame=document.createElement("iframe");const s={};s[Aa]="t",s[nr]=e,s[sr]=t,this.myDisconnFrame.src=this.urlFn(s),this.myDisconnFrame.style.display="none",document.body.appendChild(this.myDisconnFrame)}incrementIncomingBytes_(e){const t=D(e).length;this.bytesReceived+=t,this.stats_.incrementCounter("bytes_received",t)}}class Qn{constructor(e,t,s,i){this.onDisconnect=s,this.urlFn=i,this.outstandingRequests=new Set,this.pendingSegs=[],this.currentSerial=Math.floor(Math.random()*1e8),this.sendNewPolls=!0;{this.uniqueCallbackIdentifier=oa(),window[Ia+this.uniqueCallbackIdentifier]=e,window[Ta+this.uniqueCallbackIdentifier]=t,this.myIFrame=Qn.createIFrame_();let r="";this.myIFrame.src&&this.myIFrame.src.substr(0,11)==="javascript:"&&(r='<script>document.domain="'+document.domain+'";<\/script>');const o="<html><body>"+r+"</body></html>";try{this.myIFrame.doc.open(),this.myIFrame.doc.write(o),this.myIFrame.doc.close()}catch(a){F("frame writing exception"),a.stack&&F(a.stack),F(a)}}}static createIFrame_(){const e=document.createElement("iframe");if(e.style.display="none",document.body){document.body.appendChild(e);try{e.contentWindow.document||F("No IE domain setting required")}catch{const s=document.domain;e.src="javascript:void((function(){document.open();document.domain='"+s+"';document.close();})())"}}else throw"Document body has not initialized. Wait to initialize Firebase until after the document is ready.";return e.contentDocument?e.doc=e.contentDocument:e.contentWindow?e.doc=e.contentWindow.document:e.document&&(e.doc=e.document),e}close(){this.alive=!1,this.myIFrame&&(this.myIFrame.doc.body.textContent="",setTimeout(()=>{this.myIFrame!==null&&(document.body.removeChild(this.myIFrame),this.myIFrame=null)},Math.floor(0)));const e=this.onDisconnect;e&&(this.onDisconnect=null,e())}startLongPoll(e,t){for(this.myID=e,this.myPW=t,this.alive=!0;this.newRequest_(););}newRequest_(){if(this.alive&&this.sendNewPolls&&this.outstandingRequests.size<(this.pendingSegs.length>0?2:1)){this.currentSerial++;const e={};e[nr]=this.myID,e[sr]=this.myPW,e[ir]=this.currentSerial;let t=this.urlFn(e),s="",i=0;for(;this.pendingSegs.length>0&&this.pendingSegs[0].d.length+or+s.length<=rr;){const o=this.pendingSegs.shift();s=s+"&"+Na+i+"="+o.seg+"&"+xa+i+"="+o.ts+"&"+Ra+i+"="+o.d,i++}return t=t+s,this.addLongPollTag_(t,this.currentSerial),!0}else return!1}enqueueSegment(e,t,s){this.pendingSegs.push({seg:e,ts:t,d:s}),this.alive&&this.newRequest_()}addLongPollTag_(e,t){this.outstandingRequests.add(t);const s=()=>{this.outstandingRequests.delete(t),this.newRequest_()},i=setTimeout(s,Math.floor(Oa)),r=()=>{clearTimeout(i),s()};this.addTag(e,r)}addTag(e,t){setTimeout(()=>{try{if(!this.sendNewPolls)return;const s=this.myIFrame.doc.createElement("script");s.type="text/javascript",s.async=!0,s.src=e,s.onload=s.onreadystatechange=function(){const i=s.readyState;(!i||i==="loaded"||i==="complete")&&(s.onload=s.onreadystatechange=null,s.parentNode&&s.parentNode.removeChild(s),t())},s.onerror=()=>{F("Long-poll script failed to load: "+e),this.sendNewPolls=!1,this.close()},this.myIFrame.doc.body.appendChild(s)}catch{}},Math.floor(1))}}/**
295
+ * @license
296
+ * Copyright 2017 Google LLC
297
+ *
298
+ * Licensed under the Apache License, Version 2.0 (the "License");
299
+ * you may not use this file except in compliance with the License.
300
+ * You may obtain a copy of the License at
301
+ *
302
+ * http://www.apache.org/licenses/LICENSE-2.0
303
+ *
304
+ * Unless required by applicable law or agreed to in writing, software
305
+ * distributed under the License is distributed on an "AS IS" BASIS,
306
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
307
+ * See the License for the specific language governing permissions and
308
+ * limitations under the License.
309
+ */const Ma=16384,La=45e3;let Dt=null;typeof MozWebSocket<"u"?Dt=MozWebSocket:typeof WebSocket<"u"&&(Dt=WebSocket);class z{constructor(e,t,s,i,r,o,a){this.connId=e,this.applicationId=s,this.appCheckToken=i,this.authToken=r,this.keepaliveTimer=null,this.frames=null,this.totalFrames=0,this.bytesSent=0,this.bytesReceived=0,this.log_=yt(this.connId),this.stats_=Yn(t),this.connURL=z.connectionURL_(t,o,a,i,s),this.nodeAdmin=t.nodeAdmin}static connectionURL_(e,t,s,i,r){const o={};return o[$i]=Kn,typeof location<"u"&&location.hostname&&Qi.test(location.hostname)&&(o[Ki]=Yi),t&&(o[Hi]=t),s&&(o[zi]=s),i&&(o[kn]=i),r&&(o[Xi]=r),tr(e,Ji,o)}open(e,t){this.onDisconnect=t,this.onMessage=e,this.log_("Websocket connecting to "+this.connURL),this.everConnected_=!1,we.set("previous_websocket_failure",!0);try{let s;Io(),this.mySock=new Dt(this.connURL,[],s)}catch(s){this.log_("Error instantiating WebSocket.");const i=s.message||s.data;i&&this.log_(i),this.onClosed_();return}this.mySock.onopen=()=>{this.log_("Websocket connected."),this.everConnected_=!0},this.mySock.onclose=()=>{this.log_("Websocket connection was disconnected."),this.mySock=null,this.onClosed_()},this.mySock.onmessage=s=>{this.handleIncomingFrame(s)},this.mySock.onerror=s=>{this.log_("WebSocket error. Closing connection.");const i=s.message||s.data;i&&this.log_(i),this.onClosed_()}}start(){}static forceDisallow(){z.forceDisallow_=!0}static isAvailable(){let e=!1;if(typeof navigator<"u"&&navigator.userAgent){const t=/Android ([0-9]{0,}\.[0-9]{0,})/,s=navigator.userAgent.match(t);s&&s.length>1&&parseFloat(s[1])<4.4&&(e=!0)}return!e&&Dt!==null&&!z.forceDisallow_}static previouslyFailed(){return we.isInMemoryStorage||we.get("previous_websocket_failure")===!0}markConnectionHealthy(){we.remove("previous_websocket_failure")}appendFrame_(e){if(this.frames.push(e),this.frames.length===this.totalFrames){const t=this.frames.join("");this.frames=null;const s=qn(t);this.onMessage(s)}}handleNewFrameCount_(e){this.totalFrames=e,this.frames=[]}extractFrameCount_(e){if(_(this.frames===null,"We already have a frame buffer"),e.length<=6){const t=Number(e);if(!isNaN(t))return this.handleNewFrameCount_(t),null}return this.handleNewFrameCount_(1),e}handleIncomingFrame(e){if(this.mySock===null)return;const t=e.data;if(this.bytesReceived+=t.length,this.stats_.incrementCounter("bytes_received",t.length),this.resetKeepAlive(),this.frames!==null)this.appendFrame_(t);else{const s=this.extractFrameCount_(t);s!==null&&this.appendFrame_(s)}}send(e){this.resetKeepAlive();const t=D(e);this.bytesSent+=t.length,this.stats_.incrementCounter("bytes_sent",t.length);const s=qi(t,Ma);s.length>1&&this.sendString_(String(s.length));for(let i=0;i<s.length;i++)this.sendString_(s[i])}shutdown_(){this.isClosed_=!0,this.keepaliveTimer&&(clearInterval(this.keepaliveTimer),this.keepaliveTimer=null),this.mySock&&(this.mySock.close(),this.mySock=null)}onClosed_(){this.isClosed_||(this.log_("WebSocket is closing itself"),this.shutdown_(),this.onDisconnect&&(this.onDisconnect(this.everConnected_),this.onDisconnect=null))}close(){this.isClosed_||(this.log_("WebSocket is being closed"),this.shutdown_())}resetKeepAlive(){clearInterval(this.keepaliveTimer),this.keepaliveTimer=setInterval(()=>{this.mySock&&this.sendString_("0"),this.resetKeepAlive()},Math.floor(La))}sendString_(e){try{this.mySock.send(e)}catch(t){this.log_("Exception thrown from WebSocket.send():",t.message||t.data,"Closing connection."),setTimeout(this.onClosed_.bind(this),0)}}}z.responsesRequiredToBeHealthy=2;z.healthyTimeout=3e4;/**
310
+ * @license
311
+ * Copyright 2017 Google LLC
312
+ *
313
+ * Licensed under the Apache License, Version 2.0 (the "License");
314
+ * you may not use this file except in compliance with the License.
315
+ * You may obtain a copy of the License at
316
+ *
317
+ * http://www.apache.org/licenses/LICENSE-2.0
318
+ *
319
+ * Unless required by applicable law or agreed to in writing, software
320
+ * distributed under the License is distributed on an "AS IS" BASIS,
321
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
322
+ * See the License for the specific language governing permissions and
323
+ * limitations under the License.
324
+ */class ct{static get ALL_TRANSPORTS(){return[Me,z]}static get IS_TRANSPORT_INITIALIZED(){return this.globalTransportInitialized_}constructor(e){this.initTransports_(e)}initTransports_(e){const t=z&&z.isAvailable();let s=t&&!z.previouslyFailed();if(e.webSocketOnly&&(t||V("wss:// URL used, but browser isn't known to support websockets. Trying anyway."),s=!0),s)this.transports_=[z];else{const i=this.transports_=[];for(const r of ct.ALL_TRANSPORTS)r&&r.isAvailable()&&i.push(r);ct.globalTransportInitialized_=!0}}initialTransport(){if(this.transports_.length>0)return this.transports_[0];throw new Error("No transports available")}upgradeTransport(){return this.transports_.length>1?this.transports_[1]:null}}ct.globalTransportInitialized_=!1;/**
325
+ * @license
326
+ * Copyright 2017 Google LLC
327
+ *
328
+ * Licensed under the Apache License, Version 2.0 (the "License");
329
+ * you may not use this file except in compliance with the License.
330
+ * You may obtain a copy of the License at
331
+ *
332
+ * http://www.apache.org/licenses/LICENSE-2.0
333
+ *
334
+ * Unless required by applicable law or agreed to in writing, software
335
+ * distributed under the License is distributed on an "AS IS" BASIS,
336
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
337
+ * See the License for the specific language governing permissions and
338
+ * limitations under the License.
339
+ */const Fa=6e4,Wa=5e3,Ua=10*1024,Ba=100*1024,mn="t",Ws="d",Va="s",Us="r",ja="e",Bs="o",Vs="a",js="n",qs="p",qa="h";class Ga{constructor(e,t,s,i,r,o,a,l,c,u){this.id=e,this.repoInfo_=t,this.applicationId_=s,this.appCheckToken_=i,this.authToken_=r,this.onMessage_=o,this.onReady_=a,this.onDisconnect_=l,this.onKill_=c,this.lastSessionId=u,this.connectionCount=0,this.pendingDataMessages=[],this.state_=0,this.log_=yt("c:"+this.id+":"),this.transportManager_=new ct(t),this.log_("Connection created"),this.start_()}start_(){const e=this.transportManager_.initialTransport();this.conn_=new e(this.nextTransportId_(),this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,null,this.lastSessionId),this.primaryResponsesRequired_=e.responsesRequiredToBeHealthy||0;const t=this.connReceiver_(this.conn_),s=this.disconnReceiver_(this.conn_);this.tx_=this.conn_,this.rx_=this.conn_,this.secondaryConn_=null,this.isHealthy_=!1,setTimeout(()=>{this.conn_&&this.conn_.open(t,s)},Math.floor(0));const i=e.healthyTimeout||0;i>0&&(this.healthyTimeout_=rt(()=>{this.healthyTimeout_=null,this.isHealthy_||(this.conn_&&this.conn_.bytesReceived>Ba?(this.log_("Connection exceeded healthy timeout but has received "+this.conn_.bytesReceived+" bytes. Marking connection healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()):this.conn_&&this.conn_.bytesSent>Ua?this.log_("Connection exceeded healthy timeout but has sent "+this.conn_.bytesSent+" bytes. Leaving connection alive."):(this.log_("Closing unhealthy connection after timeout."),this.close()))},Math.floor(i)))}nextTransportId_(){return"c:"+this.id+":"+this.connectionCount++}disconnReceiver_(e){return t=>{e===this.conn_?this.onConnectionLost_(t):e===this.secondaryConn_?(this.log_("Secondary connection lost."),this.onSecondaryConnectionLost_()):this.log_("closing an old connection")}}connReceiver_(e){return t=>{this.state_!==2&&(e===this.rx_?this.onPrimaryMessageReceived_(t):e===this.secondaryConn_?this.onSecondaryMessageReceived_(t):this.log_("message on old connection"))}}sendRequest(e){const t={t:"d",d:e};this.sendData_(t)}tryCleanupConnection(){this.tx_===this.secondaryConn_&&this.rx_===this.secondaryConn_&&(this.log_("cleaning up and promoting a connection: "+this.secondaryConn_.connId),this.conn_=this.secondaryConn_,this.secondaryConn_=null)}onSecondaryControl_(e){if(mn in e){const t=e[mn];t===Vs?this.upgradeIfSecondaryHealthy_():t===Us?(this.log_("Got a reset on secondary, closing it"),this.secondaryConn_.close(),(this.tx_===this.secondaryConn_||this.rx_===this.secondaryConn_)&&this.close()):t===Bs&&(this.log_("got pong on secondary."),this.secondaryResponsesRequired_--,this.upgradeIfSecondaryHealthy_())}}onSecondaryMessageReceived_(e){const t=Ze("t",e),s=Ze("d",e);if(t==="c")this.onSecondaryControl_(s);else if(t==="d")this.pendingDataMessages.push(s);else throw new Error("Unknown protocol layer: "+t)}upgradeIfSecondaryHealthy_(){this.secondaryResponsesRequired_<=0?(this.log_("Secondary connection is healthy."),this.isHealthy_=!0,this.secondaryConn_.markConnectionHealthy(),this.proceedWithUpgrade_()):(this.log_("sending ping on secondary."),this.secondaryConn_.send({t:"c",d:{t:qs,d:{}}}))}proceedWithUpgrade_(){this.secondaryConn_.start(),this.log_("sending client ack on secondary"),this.secondaryConn_.send({t:"c",d:{t:Vs,d:{}}}),this.log_("Ending transmission on primary"),this.conn_.send({t:"c",d:{t:js,d:{}}}),this.tx_=this.secondaryConn_,this.tryCleanupConnection()}onPrimaryMessageReceived_(e){const t=Ze("t",e),s=Ze("d",e);t==="c"?this.onControl_(s):t==="d"&&this.onDataMessage_(s)}onDataMessage_(e){this.onPrimaryResponse_(),this.onMessage_(e)}onPrimaryResponse_(){this.isHealthy_||(this.primaryResponsesRequired_--,this.primaryResponsesRequired_<=0&&(this.log_("Primary connection is healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()))}onControl_(e){const t=Ze(mn,e);if(Ws in e){const s=e[Ws];if(t===qa){const i={...s};this.repoInfo_.isUsingEmulator&&(i.h=this.repoInfo_.host),this.onHandshake_(i)}else if(t===js){this.log_("recvd end transmission on primary"),this.rx_=this.secondaryConn_;for(let i=0;i<this.pendingDataMessages.length;++i)this.onDataMessage_(this.pendingDataMessages[i]);this.pendingDataMessages=[],this.tryCleanupConnection()}else t===Va?this.onConnectionShutdown_(s):t===Us?this.onReset_(s):t===ja?Tn("Server Error: "+s):t===Bs?(this.log_("got pong on primary."),this.onPrimaryResponse_(),this.sendPingOnPrimaryIfNecessary_()):Tn("Unknown control packet command: "+t)}}onHandshake_(e){const t=e.ts,s=e.v,i=e.h;this.sessionId=e.s,this.repoInfo_.host=i,this.state_===0&&(this.conn_.start(),this.onConnectionEstablished_(this.conn_,t),Kn!==s&&V("Protocol version mismatch detected"),this.tryStartUpgrade_())}tryStartUpgrade_(){const e=this.transportManager_.upgradeTransport();e&&this.startUpgrade_(e)}startUpgrade_(e){this.secondaryConn_=new e(this.nextTransportId_(),this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,this.sessionId),this.secondaryResponsesRequired_=e.responsesRequiredToBeHealthy||0;const t=this.connReceiver_(this.secondaryConn_),s=this.disconnReceiver_(this.secondaryConn_);this.secondaryConn_.open(t,s),rt(()=>{this.secondaryConn_&&(this.log_("Timed out trying to upgrade."),this.secondaryConn_.close())},Math.floor(Fa))}onReset_(e){this.log_("Reset packet received. New host: "+e),this.repoInfo_.host=e,this.state_===1?this.close():(this.closeConnections_(),this.start_())}onConnectionEstablished_(e,t){this.log_("Realtime connection established."),this.conn_=e,this.state_=1,this.onReady_&&(this.onReady_(t,this.sessionId),this.onReady_=null),this.primaryResponsesRequired_===0?(this.log_("Primary connection is healthy."),this.isHealthy_=!0):rt(()=>{this.sendPingOnPrimaryIfNecessary_()},Math.floor(Wa))}sendPingOnPrimaryIfNecessary_(){!this.isHealthy_&&this.state_===1&&(this.log_("sending ping on primary."),this.sendData_({t:"c",d:{t:qs,d:{}}}))}onSecondaryConnectionLost_(){const e=this.secondaryConn_;this.secondaryConn_=null,(this.tx_===e||this.rx_===e)&&this.close()}onConnectionLost_(e){this.conn_=null,!e&&this.state_===0?(this.log_("Realtime connection failed."),this.repoInfo_.isCacheableHost()&&(we.remove("host:"+this.repoInfo_.host),this.repoInfo_.internalHost=this.repoInfo_.host)):this.state_===1&&this.log_("Realtime connection lost."),this.close()}onConnectionShutdown_(e){this.log_("Connection shutdown command received. Shutting down..."),this.onKill_&&(this.onKill_(e),this.onKill_=null),this.onDisconnect_=null,this.close()}sendData_(e){if(this.state_!==1)throw"Connection is not connected";this.tx_.send(e)}close(){this.state_!==2&&(this.log_("Closing realtime connection."),this.state_=2,this.closeConnections_(),this.onDisconnect_&&(this.onDisconnect_(),this.onDisconnect_=null))}closeConnections_(){this.log_("Shutting down all connections"),this.conn_&&(this.conn_.close(),this.conn_=null),this.secondaryConn_&&(this.secondaryConn_.close(),this.secondaryConn_=null),this.healthyTimeout_&&(clearTimeout(this.healthyTimeout_),this.healthyTimeout_=null)}}/**
340
+ * @license
341
+ * Copyright 2017 Google LLC
342
+ *
343
+ * Licensed under the Apache License, Version 2.0 (the "License");
344
+ * you may not use this file except in compliance with the License.
345
+ * You may obtain a copy of the License at
346
+ *
347
+ * http://www.apache.org/licenses/LICENSE-2.0
348
+ *
349
+ * Unless required by applicable law or agreed to in writing, software
350
+ * distributed under the License is distributed on an "AS IS" BASIS,
351
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
352
+ * See the License for the specific language governing permissions and
353
+ * limitations under the License.
354
+ */class ar{put(e,t,s,i){}merge(e,t,s,i){}refreshAuthToken(e){}refreshAppCheckToken(e){}onDisconnectPut(e,t,s){}onDisconnectMerge(e,t,s){}onDisconnectCancel(e,t){}reportStats(e){}}/**
355
+ * @license
356
+ * Copyright 2017 Google LLC
357
+ *
358
+ * Licensed under the Apache License, Version 2.0 (the "License");
359
+ * you may not use this file except in compliance with the License.
360
+ * You may obtain a copy of the License at
361
+ *
362
+ * http://www.apache.org/licenses/LICENSE-2.0
363
+ *
364
+ * Unless required by applicable law or agreed to in writing, software
365
+ * distributed under the License is distributed on an "AS IS" BASIS,
366
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
367
+ * See the License for the specific language governing permissions and
368
+ * limitations under the License.
369
+ */class lr{constructor(e){this.allowedEvents_=e,this.listeners_={},_(Array.isArray(e)&&e.length>0,"Requires a non-empty array")}trigger(e,...t){if(Array.isArray(this.listeners_[e])){const s=[...this.listeners_[e]];for(let i=0;i<s.length;i++)s[i].callback.apply(s[i].context,t)}}on(e,t,s){this.validateEventType_(e),this.listeners_[e]=this.listeners_[e]||[],this.listeners_[e].push({callback:t,context:s});const i=this.getInitialEvent(e);i&&t.apply(s,i)}off(e,t,s){this.validateEventType_(e);const i=this.listeners_[e]||[];for(let r=0;r<i.length;r++)if(i[r].callback===t&&(!s||s===i[r].context)){i.splice(r,1);return}}validateEventType_(e){_(this.allowedEvents_.find(t=>t===e),"Unknown event: "+e)}}/**
370
+ * @license
371
+ * Copyright 2017 Google LLC
372
+ *
373
+ * Licensed under the Apache License, Version 2.0 (the "License");
374
+ * you may not use this file except in compliance with the License.
375
+ * You may obtain a copy of the License at
376
+ *
377
+ * http://www.apache.org/licenses/LICENSE-2.0
378
+ *
379
+ * Unless required by applicable law or agreed to in writing, software
380
+ * distributed under the License is distributed on an "AS IS" BASIS,
381
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
382
+ * See the License for the specific language governing permissions and
383
+ * limitations under the License.
384
+ */class Mt extends lr{static getInstance(){return new Mt}constructor(){super(["online"]),this.online_=!0,typeof window<"u"&&typeof window.addEventListener<"u"&&!Ni()&&(window.addEventListener("online",()=>{this.online_||(this.online_=!0,this.trigger("online",!0))},!1),window.addEventListener("offline",()=>{this.online_&&(this.online_=!1,this.trigger("online",!1))},!1))}getInitialEvent(e){return _(e==="online","Unknown event type: "+e),[this.online_]}currentlyOnline(){return this.online_}}/**
385
+ * @license
386
+ * Copyright 2017 Google LLC
387
+ *
388
+ * Licensed under the Apache License, Version 2.0 (the "License");
389
+ * you may not use this file except in compliance with the License.
390
+ * You may obtain a copy of the License at
391
+ *
392
+ * http://www.apache.org/licenses/LICENSE-2.0
393
+ *
394
+ * Unless required by applicable law or agreed to in writing, software
395
+ * distributed under the License is distributed on an "AS IS" BASIS,
396
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
397
+ * See the License for the specific language governing permissions and
398
+ * limitations under the License.
399
+ */const Gs=32,$s=768;class S{constructor(e,t){if(t===void 0){this.pieces_=e.split("/");let s=0;for(let i=0;i<this.pieces_.length;i++)this.pieces_[i].length>0&&(this.pieces_[s]=this.pieces_[i],s++);this.pieces_.length=s,this.pieceNum_=0}else this.pieces_=e,this.pieceNum_=t}toString(){let e="";for(let t=this.pieceNum_;t<this.pieces_.length;t++)this.pieces_[t]!==""&&(e+="/"+this.pieces_[t]);return e||"/"}}function w(){return new S("")}function y(n){return n.pieceNum_>=n.pieces_.length?null:n.pieces_[n.pieceNum_]}function pe(n){return n.pieces_.length-n.pieceNum_}function T(n){let e=n.pieceNum_;return e<n.pieces_.length&&e++,new S(n.pieces_,e)}function zn(n){return n.pieceNum_<n.pieces_.length?n.pieces_[n.pieces_.length-1]:null}function $a(n){let e="";for(let t=n.pieceNum_;t<n.pieces_.length;t++)n.pieces_[t]!==""&&(e+="/"+encodeURIComponent(String(n.pieces_[t])));return e||"/"}function ut(n,e=0){return n.pieces_.slice(n.pieceNum_+e)}function cr(n){if(n.pieceNum_>=n.pieces_.length)return null;const e=[];for(let t=n.pieceNum_;t<n.pieces_.length-1;t++)e.push(n.pieces_[t]);return new S(e,0)}function k(n,e){const t=[];for(let s=n.pieceNum_;s<n.pieces_.length;s++)t.push(n.pieces_[s]);if(e instanceof S)for(let s=e.pieceNum_;s<e.pieces_.length;s++)t.push(e.pieces_[s]);else{const s=e.split("/");for(let i=0;i<s.length;i++)s[i].length>0&&t.push(s[i])}return new S(t,0)}function C(n){return n.pieceNum_>=n.pieces_.length}function B(n,e){const t=y(n),s=y(e);if(t===null)return e;if(t===s)return B(T(n),T(e));throw new Error("INTERNAL ERROR: innerPath ("+e+") is not within outerPath ("+n+")")}function Ha(n,e){const t=ut(n,0),s=ut(e,0);for(let i=0;i<t.length&&i<s.length;i++){const r=Ae(t[i],s[i]);if(r!==0)return r}return t.length===s.length?0:t.length<s.length?-1:1}function Xn(n,e){if(pe(n)!==pe(e))return!1;for(let t=n.pieceNum_,s=e.pieceNum_;t<=n.pieces_.length;t++,s++)if(n.pieces_[t]!==e.pieces_[s])return!1;return!0}function K(n,e){let t=n.pieceNum_,s=e.pieceNum_;if(pe(n)>pe(e))return!1;for(;t<n.pieces_.length;){if(n.pieces_[t]!==e.pieces_[s])return!1;++t,++s}return!0}class Ka{constructor(e,t){this.errorPrefix_=t,this.parts_=ut(e,0),this.byteLength_=Math.max(1,this.parts_.length);for(let s=0;s<this.parts_.length;s++)this.byteLength_+=Zt(this.parts_[s]);ur(this)}}function Ya(n,e){n.parts_.length>0&&(n.byteLength_+=1),n.parts_.push(e),n.byteLength_+=Zt(e),ur(n)}function Qa(n){const e=n.parts_.pop();n.byteLength_-=Zt(e),n.parts_.length>0&&(n.byteLength_-=1)}function ur(n){if(n.byteLength_>$s)throw new Error(n.errorPrefix_+"has a key path longer than "+$s+" bytes ("+n.byteLength_+").");if(n.parts_.length>Gs)throw new Error(n.errorPrefix_+"path specified exceeds the maximum depth that can be written ("+Gs+") or object contains a cycle "+Ce(n))}function Ce(n){return n.parts_.length===0?"":"in property '"+n.parts_.join(".")+"'"}/**
400
+ * @license
401
+ * Copyright 2017 Google LLC
402
+ *
403
+ * Licensed under the Apache License, Version 2.0 (the "License");
404
+ * you may not use this file except in compliance with the License.
405
+ * You may obtain a copy of the License at
406
+ *
407
+ * http://www.apache.org/licenses/LICENSE-2.0
408
+ *
409
+ * Unless required by applicable law or agreed to in writing, software
410
+ * distributed under the License is distributed on an "AS IS" BASIS,
411
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
412
+ * See the License for the specific language governing permissions and
413
+ * limitations under the License.
414
+ */class Jn extends lr{static getInstance(){return new Jn}constructor(){super(["visible"]);let e,t;typeof document<"u"&&typeof document.addEventListener<"u"&&(typeof document.hidden<"u"?(t="visibilitychange",e="hidden"):typeof document.mozHidden<"u"?(t="mozvisibilitychange",e="mozHidden"):typeof document.msHidden<"u"?(t="msvisibilitychange",e="msHidden"):typeof document.webkitHidden<"u"&&(t="webkitvisibilitychange",e="webkitHidden")),this.visible_=!0,t&&document.addEventListener(t,()=>{const s=!document[e];s!==this.visible_&&(this.visible_=s,this.trigger("visible",s))},!1)}getInitialEvent(e){return _(e==="visible","Unknown event type: "+e),[this.visible_]}}/**
415
+ * @license
416
+ * Copyright 2017 Google LLC
417
+ *
418
+ * Licensed under the Apache License, Version 2.0 (the "License");
419
+ * you may not use this file except in compliance with the License.
420
+ * You may obtain a copy of the License at
421
+ *
422
+ * http://www.apache.org/licenses/LICENSE-2.0
423
+ *
424
+ * Unless required by applicable law or agreed to in writing, software
425
+ * distributed under the License is distributed on an "AS IS" BASIS,
426
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
427
+ * See the License for the specific language governing permissions and
428
+ * limitations under the License.
429
+ */const et=1e3,za=300*1e3,Hs=30*1e3,Xa=1.3,Ja=3e4,Za="server_kill",Ks=3;class oe extends ar{constructor(e,t,s,i,r,o,a,l){if(super(),this.repoInfo_=e,this.applicationId_=t,this.onDataUpdate_=s,this.onConnectStatus_=i,this.onServerInfoUpdate_=r,this.authTokenProvider_=o,this.appCheckTokenProvider_=a,this.authOverride_=l,this.id=oe.nextPersistentConnectionId_++,this.log_=yt("p:"+this.id+":"),this.interruptReasons_={},this.listens=new Map,this.outstandingPuts_=[],this.outstandingGets_=[],this.outstandingPutCount_=0,this.outstandingGetCount_=0,this.onDisconnectRequestQueue_=[],this.connected_=!1,this.reconnectDelay_=et,this.maxReconnectDelay_=za,this.securityDebugCallback_=null,this.lastSessionId=null,this.establishConnectionTimer_=null,this.visible_=!1,this.requestCBHash_={},this.requestNumber_=0,this.realtime_=null,this.authToken_=null,this.appCheckToken_=null,this.forceTokenRefresh_=!1,this.invalidAuthTokenCount_=0,this.invalidAppCheckTokenCount_=0,this.firstConnection_=!0,this.lastConnectionAttemptTime_=null,this.lastConnectionEstablishedTime_=null,l)throw new Error("Auth override specified in options, but not supported on non Node.js platforms");Jn.getInstance().on("visible",this.onVisible_,this),e.host.indexOf("fblocal")===-1&&Mt.getInstance().on("online",this.onOnline_,this)}sendRequest(e,t,s){const i=++this.requestNumber_,r={r:i,a:e,b:t};this.log_(D(r)),_(this.connected_,"sendRequest call when we're not connected not allowed."),this.realtime_.sendRequest(r),s&&(this.requestCBHash_[i]=s)}get(e){this.initConnection_();const t=new Jt,i={action:"g",request:{p:e._path.toString(),q:e._queryObject},onComplete:o=>{const a=o.d;o.s==="ok"?t.resolve(a):t.reject(a)}};this.outstandingGets_.push(i),this.outstandingGetCount_++;const r=this.outstandingGets_.length-1;return this.connected_&&this.sendGet_(r),t.promise}listen(e,t,s,i){this.initConnection_();const r=e._queryIdentifier,o=e._path.toString();this.log_("Listen called for "+o+" "+r),this.listens.has(o)||this.listens.set(o,new Map),_(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"listen() called for non-default but complete query"),_(!this.listens.get(o).has(r),"listen() called twice for same path/queryId.");const a={onComplete:i,hashFn:t,query:e,tag:s};this.listens.get(o).set(r,a),this.connected_&&this.sendListen_(a)}sendGet_(e){const t=this.outstandingGets_[e];this.sendRequest("g",t.request,s=>{delete this.outstandingGets_[e],this.outstandingGetCount_--,this.outstandingGetCount_===0&&(this.outstandingGets_=[]),t.onComplete&&t.onComplete(s)})}sendListen_(e){const t=e.query,s=t._path.toString(),i=t._queryIdentifier;this.log_("Listen on "+s+" for "+i);const r={p:s},o="q";e.tag&&(r.q=t._queryObject,r.t=e.tag),r.h=e.hashFn(),this.sendRequest(o,r,a=>{const l=a.d,c=a.s;oe.warnOnListenWarnings_(l,t),(this.listens.get(s)&&this.listens.get(s).get(i))===e&&(this.log_("listen response",a),c!=="ok"&&this.removeListen_(s,i),e.onComplete&&e.onComplete(c,l))})}static warnOnListenWarnings_(e,t){if(e&&typeof e=="object"&&ne(e,"w")){const s=je(e,"w");if(Array.isArray(s)&&~s.indexOf("no_index")){const i='".indexOn": "'+t._queryParams.getIndex().toString()+'"',r=t._path.toString();V(`Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding ${i} at ${r} to your security rules for better performance.`)}}}refreshAuthToken(e){this.authToken_=e,this.log_("Auth token refreshed"),this.authToken_?this.tryAuth():this.connected_&&this.sendRequest("unauth",{},()=>{}),this.reduceReconnectDelayIfAdminCredential_(e)}reduceReconnectDelayIfAdminCredential_(e){(e&&e.length===40||Co(e))&&(this.log_("Admin auth credential detected. Reducing max reconnect time."),this.maxReconnectDelay_=Hs)}refreshAppCheckToken(e){this.appCheckToken_=e,this.log_("App check token refreshed"),this.appCheckToken_?this.tryAppCheck():this.connected_&&this.sendRequest("unappeck",{},()=>{})}tryAuth(){if(this.connected_&&this.authToken_){const e=this.authToken_,t=Eo(e)?"auth":"gauth",s={cred:e};this.authOverride_===null?s.noauth=!0:typeof this.authOverride_=="object"&&(s.authvar=this.authOverride_),this.sendRequest(t,s,i=>{const r=i.s,o=i.d||"error";this.authToken_===e&&(r==="ok"?this.invalidAuthTokenCount_=0:this.onAuthRevoked_(r,o))})}}tryAppCheck(){this.connected_&&this.appCheckToken_&&this.sendRequest("appcheck",{token:this.appCheckToken_},e=>{const t=e.s,s=e.d||"error";t==="ok"?this.invalidAppCheckTokenCount_=0:this.onAppCheckRevoked_(t,s)})}unlisten(e,t){const s=e._path.toString(),i=e._queryIdentifier;this.log_("Unlisten called for "+s+" "+i),_(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"unlisten() called for non-default but complete query"),this.removeListen_(s,i)&&this.connected_&&this.sendUnlisten_(s,i,e._queryObject,t)}sendUnlisten_(e,t,s,i){this.log_("Unlisten on "+e+" for "+t);const r={p:e},o="n";i&&(r.q=s,r.t=i),this.sendRequest(o,r)}onDisconnectPut(e,t,s){this.initConnection_(),this.connected_?this.sendOnDisconnect_("o",e,t,s):this.onDisconnectRequestQueue_.push({pathString:e,action:"o",data:t,onComplete:s})}onDisconnectMerge(e,t,s){this.initConnection_(),this.connected_?this.sendOnDisconnect_("om",e,t,s):this.onDisconnectRequestQueue_.push({pathString:e,action:"om",data:t,onComplete:s})}onDisconnectCancel(e,t){this.initConnection_(),this.connected_?this.sendOnDisconnect_("oc",e,null,t):this.onDisconnectRequestQueue_.push({pathString:e,action:"oc",data:null,onComplete:t})}sendOnDisconnect_(e,t,s,i){const r={p:t,d:s};this.log_("onDisconnect "+e,r),this.sendRequest(e,r,o=>{i&&setTimeout(()=>{i(o.s,o.d)},Math.floor(0))})}put(e,t,s,i){this.putInternal("p",e,t,s,i)}merge(e,t,s,i){this.putInternal("m",e,t,s,i)}putInternal(e,t,s,i,r){this.initConnection_();const o={p:t,d:s};r!==void 0&&(o.h=r),this.outstandingPuts_.push({action:e,request:o,onComplete:i}),this.outstandingPutCount_++;const a=this.outstandingPuts_.length-1;this.connected_?this.sendPut_(a):this.log_("Buffering put: "+t)}sendPut_(e){const t=this.outstandingPuts_[e].action,s=this.outstandingPuts_[e].request,i=this.outstandingPuts_[e].onComplete;this.outstandingPuts_[e].queued=this.connected_,this.sendRequest(t,s,r=>{this.log_(t+" response",r),delete this.outstandingPuts_[e],this.outstandingPutCount_--,this.outstandingPutCount_===0&&(this.outstandingPuts_=[]),i&&i(r.s,r.d)})}reportStats(e){if(this.connected_){const t={c:e};this.log_("reportStats",t),this.sendRequest("s",t,s=>{if(s.s!=="ok"){const r=s.d;this.log_("reportStats","Error sending stats: "+r)}})}}onDataMessage_(e){if("r"in e){this.log_("from server: "+D(e));const t=e.r,s=this.requestCBHash_[t];s&&(delete this.requestCBHash_[t],s(e.b))}else{if("error"in e)throw"A server-side error has occurred: "+e.error;"a"in e&&this.onDataPush_(e.a,e.b)}}onDataPush_(e,t){this.log_("handleServerMessage",e,t),e==="d"?this.onDataUpdate_(t.p,t.d,!1,t.t):e==="m"?this.onDataUpdate_(t.p,t.d,!0,t.t):e==="c"?this.onListenRevoked_(t.p,t.q):e==="ac"?this.onAuthRevoked_(t.s,t.d):e==="apc"?this.onAppCheckRevoked_(t.s,t.d):e==="sd"?this.onSecurityDebugPacket_(t):Tn("Unrecognized action received from server: "+D(e)+`
430
+ Are you using the latest client?`)}onReady_(e,t){this.log_("connection ready"),this.connected_=!0,this.lastConnectionEstablishedTime_=new Date().getTime(),this.handleTimestamp_(e),this.lastSessionId=t,this.firstConnection_&&this.sendConnectStats_(),this.restoreState_(),this.firstConnection_=!1,this.onConnectStatus_(!0)}scheduleConnect_(e){_(!this.realtime_,"Scheduling a connect when we're already connected/ing?"),this.establishConnectionTimer_&&clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=setTimeout(()=>{this.establishConnectionTimer_=null,this.establishConnection_()},Math.floor(e))}initConnection_(){!this.realtime_&&this.firstConnection_&&this.scheduleConnect_(0)}onVisible_(e){e&&!this.visible_&&this.reconnectDelay_===this.maxReconnectDelay_&&(this.log_("Window became visible. Reducing delay."),this.reconnectDelay_=et,this.realtime_||this.scheduleConnect_(0)),this.visible_=e}onOnline_(e){e?(this.log_("Browser went online."),this.reconnectDelay_=et,this.realtime_||this.scheduleConnect_(0)):(this.log_("Browser went offline. Killing connection."),this.realtime_&&this.realtime_.close())}onRealtimeDisconnect_(){if(this.log_("data client disconnected"),this.connected_=!1,this.realtime_=null,this.cancelSentTransactions_(),this.requestCBHash_={},this.shouldReconnect_()){this.visible_?this.lastConnectionEstablishedTime_&&(new Date().getTime()-this.lastConnectionEstablishedTime_>Ja&&(this.reconnectDelay_=et),this.lastConnectionEstablishedTime_=null):(this.log_("Window isn't visible. Delaying reconnect."),this.reconnectDelay_=this.maxReconnectDelay_,this.lastConnectionAttemptTime_=new Date().getTime());const e=Math.max(0,new Date().getTime()-this.lastConnectionAttemptTime_);let t=Math.max(0,this.reconnectDelay_-e);t=Math.random()*t,this.log_("Trying to reconnect in "+t+"ms"),this.scheduleConnect_(t),this.reconnectDelay_=Math.min(this.maxReconnectDelay_,this.reconnectDelay_*Xa)}this.onConnectStatus_(!1)}async establishConnection_(){if(this.shouldReconnect_()){this.log_("Making a connection attempt"),this.lastConnectionAttemptTime_=new Date().getTime(),this.lastConnectionEstablishedTime_=null;const e=this.onDataMessage_.bind(this),t=this.onReady_.bind(this),s=this.onRealtimeDisconnect_.bind(this),i=this.id+":"+oe.nextConnectionId_++,r=this.lastSessionId;let o=!1,a=null;const l=function(){a?a.close():(o=!0,s())},c=function(h){_(a,"sendRequest call when we're not connected not allowed."),a.sendRequest(h)};this.realtime_={close:l,sendRequest:c};const u=this.forceTokenRefresh_;this.forceTokenRefresh_=!1;try{const[h,d]=await Promise.all([this.authTokenProvider_.getToken(u),this.appCheckTokenProvider_.getToken(u)]);o?F("getToken() completed but was canceled"):(F("getToken() completed. Creating connection."),this.authToken_=h&&h.accessToken,this.appCheckToken_=d&&d.token,a=new Ga(i,this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,e,t,s,f=>{V(f+" ("+this.repoInfo_.toString()+")"),this.interrupt(Za)},r))}catch(h){this.log_("Failed to get token: "+h),o||(this.repoInfo_.nodeAdmin&&V(h),l())}}}interrupt(e){F("Interrupting connection for reason: "+e),this.interruptReasons_[e]=!0,this.realtime_?this.realtime_.close():(this.establishConnectionTimer_&&(clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=null),this.connected_&&this.onRealtimeDisconnect_())}resume(e){F("Resuming connection for reason: "+e),delete this.interruptReasons_[e],As(this.interruptReasons_)&&(this.reconnectDelay_=et,this.realtime_||this.scheduleConnect_(0))}handleTimestamp_(e){const t=e-new Date().getTime();this.onServerInfoUpdate_({serverTimeOffset:t})}cancelSentTransactions_(){for(let e=0;e<this.outstandingPuts_.length;e++){const t=this.outstandingPuts_[e];t&&"h"in t.request&&t.queued&&(t.onComplete&&t.onComplete("disconnect"),delete this.outstandingPuts_[e],this.outstandingPutCount_--)}this.outstandingPutCount_===0&&(this.outstandingPuts_=[])}onListenRevoked_(e,t){let s;t?s=t.map(r=>Hn(r)).join("$"):s="default";const i=this.removeListen_(e,s);i&&i.onComplete&&i.onComplete("permission_denied")}removeListen_(e,t){const s=new S(e).toString();let i;if(this.listens.has(s)){const r=this.listens.get(s);i=r.get(t),r.delete(t),r.size===0&&this.listens.delete(s)}else i=void 0;return i}onAuthRevoked_(e,t){F("Auth token revoked: "+e+"/"+t),this.authToken_=null,this.forceTokenRefresh_=!0,this.realtime_.close(),(e==="invalid_token"||e==="permission_denied")&&(this.invalidAuthTokenCount_++,this.invalidAuthTokenCount_>=Ks&&(this.reconnectDelay_=Hs,this.authTokenProvider_.notifyForInvalidToken()))}onAppCheckRevoked_(e,t){F("App check token revoked: "+e+"/"+t),this.appCheckToken_=null,this.forceTokenRefresh_=!0,(e==="invalid_token"||e==="permission_denied")&&(this.invalidAppCheckTokenCount_++,this.invalidAppCheckTokenCount_>=Ks&&this.appCheckTokenProvider_.notifyForInvalidToken())}onSecurityDebugPacket_(e){this.securityDebugCallback_?this.securityDebugCallback_(e):"msg"in e&&console.log("FIREBASE: "+e.msg.replace(`
431
+ `,`
432
+ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of this.listens.values())for(const t of e.values())this.sendListen_(t);for(let e=0;e<this.outstandingPuts_.length;e++)this.outstandingPuts_[e]&&this.sendPut_(e);for(;this.onDisconnectRequestQueue_.length;){const e=this.onDisconnectRequestQueue_.shift();this.sendOnDisconnect_(e.action,e.pathString,e.data,e.onComplete)}for(let e=0;e<this.outstandingGets_.length;e++)this.outstandingGets_[e]&&this.sendGet_(e)}sendConnectStats_(){const e={};let t="js";e["sdk."+t+"."+Bi.replace(/\./g,"-")]=1,Ni()?e["framework.cordova"]=1:wo()&&(e["framework.reactnative"]=1),this.reportStats(e)}shouldReconnect_(){const e=Mt.getInstance().currentlyOnline();return As(this.interruptReasons_)&&e}}oe.nextPersistentConnectionId_=0;oe.nextConnectionId_=0;/**
433
+ * @license
434
+ * Copyright 2017 Google LLC
435
+ *
436
+ * Licensed under the Apache License, Version 2.0 (the "License");
437
+ * you may not use this file except in compliance with the License.
438
+ * You may obtain a copy of the License at
439
+ *
440
+ * http://www.apache.org/licenses/LICENSE-2.0
441
+ *
442
+ * Unless required by applicable law or agreed to in writing, software
443
+ * distributed under the License is distributed on an "AS IS" BASIS,
444
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
445
+ * See the License for the specific language governing permissions and
446
+ * limitations under the License.
447
+ */class v{constructor(e,t){this.name=e,this.node=t}static Wrap(e,t){return new v(e,t)}}/**
448
+ * @license
449
+ * Copyright 2017 Google LLC
450
+ *
451
+ * Licensed under the Apache License, Version 2.0 (the "License");
452
+ * you may not use this file except in compliance with the License.
453
+ * You may obtain a copy of the License at
454
+ *
455
+ * http://www.apache.org/licenses/LICENSE-2.0
456
+ *
457
+ * Unless required by applicable law or agreed to in writing, software
458
+ * distributed under the License is distributed on an "AS IS" BASIS,
459
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
460
+ * See the License for the specific language governing permissions and
461
+ * limitations under the License.
462
+ */class en{getCompare(){return this.compare.bind(this)}indexedValueChanged(e,t){const s=new v(qe,e),i=new v(qe,t);return this.compare(s,i)!==0}minPost(){return v.MIN}}/**
463
+ * @license
464
+ * Copyright 2017 Google LLC
465
+ *
466
+ * Licensed under the Apache License, Version 2.0 (the "License");
467
+ * you may not use this file except in compliance with the License.
468
+ * You may obtain a copy of the License at
469
+ *
470
+ * http://www.apache.org/licenses/LICENSE-2.0
471
+ *
472
+ * Unless required by applicable law or agreed to in writing, software
473
+ * distributed under the License is distributed on an "AS IS" BASIS,
474
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
475
+ * See the License for the specific language governing permissions and
476
+ * limitations under the License.
477
+ */let Tt;class hr extends en{static get __EMPTY_NODE(){return Tt}static set __EMPTY_NODE(e){Tt=e}compare(e,t){return Ae(e.name,t.name)}isDefinedOn(e){throw mt("KeyIndex.isDefinedOn not expected to be called.")}indexedValueChanged(e,t){return!1}minPost(){return v.MIN}maxPost(){return new v(be,Tt)}makePost(e,t){return _(typeof e=="string","KeyIndex indexValue must always be a string."),new v(e,Tt)}toString(){return".key"}}const We=new hr;/**
478
+ * @license
479
+ * Copyright 2017 Google LLC
480
+ *
481
+ * Licensed under the Apache License, Version 2.0 (the "License");
482
+ * you may not use this file except in compliance with the License.
483
+ * You may obtain a copy of the License at
484
+ *
485
+ * http://www.apache.org/licenses/LICENSE-2.0
486
+ *
487
+ * Unless required by applicable law or agreed to in writing, software
488
+ * distributed under the License is distributed on an "AS IS" BASIS,
489
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
490
+ * See the License for the specific language governing permissions and
491
+ * limitations under the License.
492
+ */class kt{constructor(e,t,s,i,r=null){this.isReverse_=i,this.resultGenerator_=r,this.nodeStack_=[];let o=1;for(;!e.isEmpty();)if(e=e,o=t?s(e.key,t):1,i&&(o*=-1),o<0)this.isReverse_?e=e.left:e=e.right;else if(o===0){this.nodeStack_.push(e);break}else this.nodeStack_.push(e),this.isReverse_?e=e.right:e=e.left}getNext(){if(this.nodeStack_.length===0)return null;let e=this.nodeStack_.pop(),t;if(this.resultGenerator_?t=this.resultGenerator_(e.key,e.value):t={key:e.key,value:e.value},this.isReverse_)for(e=e.left;!e.isEmpty();)this.nodeStack_.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack_.push(e),e=e.left;return t}hasNext(){return this.nodeStack_.length>0}peek(){if(this.nodeStack_.length===0)return null;const e=this.nodeStack_[this.nodeStack_.length-1];return this.resultGenerator_?this.resultGenerator_(e.key,e.value):{key:e.key,value:e.value}}}class L{constructor(e,t,s,i,r){this.key=e,this.value=t,this.color=s??L.RED,this.left=i??G.EMPTY_NODE,this.right=r??G.EMPTY_NODE}copy(e,t,s,i,r){return new L(e??this.key,t??this.value,s??this.color,i??this.left,r??this.right)}count(){return this.left.count()+1+this.right.count()}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||!!e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}min_(){return this.left.isEmpty()?this:this.left.min_()}minKey(){return this.min_().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(e,t,s){let i=this;const r=s(e,i.key);return r<0?i=i.copy(null,null,null,i.left.insert(e,t,s),null):r===0?i=i.copy(null,t,null,null,null):i=i.copy(null,null,null,null,i.right.insert(e,t,s)),i.fixUp_()}removeMin_(){if(this.left.isEmpty())return G.EMPTY_NODE;let e=this;return!e.left.isRed_()&&!e.left.left.isRed_()&&(e=e.moveRedLeft_()),e=e.copy(null,null,null,e.left.removeMin_(),null),e.fixUp_()}remove(e,t){let s,i;if(s=this,t(e,s.key)<0)!s.left.isEmpty()&&!s.left.isRed_()&&!s.left.left.isRed_()&&(s=s.moveRedLeft_()),s=s.copy(null,null,null,s.left.remove(e,t),null);else{if(s.left.isRed_()&&(s=s.rotateRight_()),!s.right.isEmpty()&&!s.right.isRed_()&&!s.right.left.isRed_()&&(s=s.moveRedRight_()),t(e,s.key)===0){if(s.right.isEmpty())return G.EMPTY_NODE;i=s.right.min_(),s=s.copy(i.key,i.value,null,null,s.right.removeMin_())}s=s.copy(null,null,null,null,s.right.remove(e,t))}return s.fixUp_()}isRed_(){return this.color}fixUp_(){let e=this;return e.right.isRed_()&&!e.left.isRed_()&&(e=e.rotateLeft_()),e.left.isRed_()&&e.left.left.isRed_()&&(e=e.rotateRight_()),e.left.isRed_()&&e.right.isRed_()&&(e=e.colorFlip_()),e}moveRedLeft_(){let e=this.colorFlip_();return e.right.left.isRed_()&&(e=e.copy(null,null,null,null,e.right.rotateRight_()),e=e.rotateLeft_(),e=e.colorFlip_()),e}moveRedRight_(){let e=this.colorFlip_();return e.left.left.isRed_()&&(e=e.rotateRight_(),e=e.colorFlip_()),e}rotateLeft_(){const e=this.copy(null,null,L.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight_(){const e=this.copy(null,null,L.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip_(){const e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}checkMaxDepth_(){const e=this.check_();return Math.pow(2,e)<=this.count()+1}check_(){if(this.isRed_()&&this.left.isRed_())throw new Error("Red node has red child("+this.key+","+this.value+")");if(this.right.isRed_())throw new Error("Right child of ("+this.key+","+this.value+") is red");const e=this.left.check_();if(e!==this.right.check_())throw new Error("Black depths differ");return e+(this.isRed_()?0:1)}}L.RED=!0;L.BLACK=!1;class el{copy(e,t,s,i,r){return this}insert(e,t,s){return new L(e,t,null)}remove(e,t){return this}count(){return 0}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}check_(){return 0}isRed_(){return!1}}class G{constructor(e,t=G.EMPTY_NODE){this.comparator_=e,this.root_=t}insert(e,t){return new G(this.comparator_,this.root_.insert(e,t,this.comparator_).copy(null,null,L.BLACK,null,null))}remove(e){return new G(this.comparator_,this.root_.remove(e,this.comparator_).copy(null,null,L.BLACK,null,null))}get(e){let t,s=this.root_;for(;!s.isEmpty();){if(t=this.comparator_(e,s.key),t===0)return s.value;t<0?s=s.left:t>0&&(s=s.right)}return null}getPredecessorKey(e){let t,s=this.root_,i=null;for(;!s.isEmpty();)if(t=this.comparator_(e,s.key),t===0){if(s.left.isEmpty())return i?i.key:null;for(s=s.left;!s.right.isEmpty();)s=s.right;return s.key}else t<0?s=s.left:t>0&&(i=s,s=s.right);throw new Error("Attempted to find predecessor key for a nonexistent key. What gives?")}isEmpty(){return this.root_.isEmpty()}count(){return this.root_.count()}minKey(){return this.root_.minKey()}maxKey(){return this.root_.maxKey()}inorderTraversal(e){return this.root_.inorderTraversal(e)}reverseTraversal(e){return this.root_.reverseTraversal(e)}getIterator(e){return new kt(this.root_,null,this.comparator_,!1,e)}getIteratorFrom(e,t){return new kt(this.root_,e,this.comparator_,!1,t)}getReverseIteratorFrom(e,t){return new kt(this.root_,e,this.comparator_,!0,t)}getReverseIterator(e){return new kt(this.root_,null,this.comparator_,!0,e)}}G.EMPTY_NODE=new el;/**
493
+ * @license
494
+ * Copyright 2017 Google LLC
495
+ *
496
+ * Licensed under the Apache License, Version 2.0 (the "License");
497
+ * you may not use this file except in compliance with the License.
498
+ * You may obtain a copy of the License at
499
+ *
500
+ * http://www.apache.org/licenses/LICENSE-2.0
501
+ *
502
+ * Unless required by applicable law or agreed to in writing, software
503
+ * distributed under the License is distributed on an "AS IS" BASIS,
504
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
505
+ * See the License for the specific language governing permissions and
506
+ * limitations under the License.
507
+ */function tl(n,e){return Ae(n.name,e.name)}function Zn(n,e){return Ae(n,e)}/**
508
+ * @license
509
+ * Copyright 2017 Google LLC
510
+ *
511
+ * Licensed under the Apache License, Version 2.0 (the "License");
512
+ * you may not use this file except in compliance with the License.
513
+ * You may obtain a copy of the License at
514
+ *
515
+ * http://www.apache.org/licenses/LICENSE-2.0
516
+ *
517
+ * Unless required by applicable law or agreed to in writing, software
518
+ * distributed under the License is distributed on an "AS IS" BASIS,
519
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
520
+ * See the License for the specific language governing permissions and
521
+ * limitations under the License.
522
+ */let Nn;function nl(n){Nn=n}const dr=function(n){return typeof n=="number"?"number:"+Gi(n):"string:"+n},fr=function(n){if(n.isLeafNode()){const e=n.val();_(typeof e=="string"||typeof e=="number"||typeof e=="object"&&ne(e,".sv"),"Priority must be a string or number.")}else _(n===Nn||n.isEmpty(),"priority of unexpected type.");_(n===Nn||n.getPriority().isEmpty(),"Priority nodes can't have a priority of their own.")};/**
523
+ * @license
524
+ * Copyright 2017 Google LLC
525
+ *
526
+ * Licensed under the Apache License, Version 2.0 (the "License");
527
+ * you may not use this file except in compliance with the License.
528
+ * You may obtain a copy of the License at
529
+ *
530
+ * http://www.apache.org/licenses/LICENSE-2.0
531
+ *
532
+ * Unless required by applicable law or agreed to in writing, software
533
+ * distributed under the License is distributed on an "AS IS" BASIS,
534
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
535
+ * See the License for the specific language governing permissions and
536
+ * limitations under the License.
537
+ */let Ys;class M{static set __childrenNodeConstructor(e){Ys=e}static get __childrenNodeConstructor(){return Ys}constructor(e,t=M.__childrenNodeConstructor.EMPTY_NODE){this.value_=e,this.priorityNode_=t,this.lazyHash_=null,_(this.value_!==void 0&&this.value_!==null,"LeafNode shouldn't be created with null/undefined value."),fr(this.priorityNode_)}isLeafNode(){return!0}getPriority(){return this.priorityNode_}updatePriority(e){return new M(this.value_,e)}getImmediateChild(e){return e===".priority"?this.priorityNode_:M.__childrenNodeConstructor.EMPTY_NODE}getChild(e){return C(e)?this:y(e)===".priority"?this.priorityNode_:M.__childrenNodeConstructor.EMPTY_NODE}hasChild(){return!1}getPredecessorChildName(e,t){return null}updateImmediateChild(e,t){return e===".priority"?this.updatePriority(t):t.isEmpty()&&e!==".priority"?this:M.__childrenNodeConstructor.EMPTY_NODE.updateImmediateChild(e,t).updatePriority(this.priorityNode_)}updateChild(e,t){const s=y(e);return s===null?t:t.isEmpty()&&s!==".priority"?this:(_(s!==".priority"||pe(e)===1,".priority must be the last token in a path"),this.updateImmediateChild(s,M.__childrenNodeConstructor.EMPTY_NODE.updateChild(T(e),t)))}isEmpty(){return!1}numChildren(){return 0}forEachChild(e,t){return!1}val(e){return e&&!this.getPriority().isEmpty()?{".value":this.getValue(),".priority":this.getPriority().val()}:this.getValue()}hash(){if(this.lazyHash_===null){let e="";this.priorityNode_.isEmpty()||(e+="priority:"+dr(this.priorityNode_.val())+":");const t=typeof this.value_;e+=t+":",t==="number"?e+=Gi(this.value_):e+=this.value_,this.lazyHash_=ji(e)}return this.lazyHash_}getValue(){return this.value_}compareTo(e){return e===M.__childrenNodeConstructor.EMPTY_NODE?1:e instanceof M.__childrenNodeConstructor?-1:(_(e.isLeafNode(),"Unknown node type"),this.compareToLeafNode_(e))}compareToLeafNode_(e){const t=typeof e.value_,s=typeof this.value_,i=M.VALUE_TYPE_ORDER.indexOf(t),r=M.VALUE_TYPE_ORDER.indexOf(s);return _(i>=0,"Unknown leaf type: "+t),_(r>=0,"Unknown leaf type: "+s),i===r?s==="object"?0:this.value_<e.value_?-1:this.value_===e.value_?0:1:r-i}withIndex(){return this}isIndexed(){return!0}equals(e){if(e===this)return!0;if(e.isLeafNode()){const t=e;return this.value_===t.value_&&this.priorityNode_.equals(t.priorityNode_)}else return!1}}M.VALUE_TYPE_ORDER=["object","boolean","number","string"];/**
538
+ * @license
539
+ * Copyright 2017 Google LLC
540
+ *
541
+ * Licensed under the Apache License, Version 2.0 (the "License");
542
+ * you may not use this file except in compliance with the License.
543
+ * You may obtain a copy of the License at
544
+ *
545
+ * http://www.apache.org/licenses/LICENSE-2.0
546
+ *
547
+ * Unless required by applicable law or agreed to in writing, software
548
+ * distributed under the License is distributed on an "AS IS" BASIS,
549
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
550
+ * See the License for the specific language governing permissions and
551
+ * limitations under the License.
552
+ */let _r,pr;function sl(n){_r=n}function il(n){pr=n}class rl extends en{compare(e,t){const s=e.node.getPriority(),i=t.node.getPriority(),r=s.compareTo(i);return r===0?Ae(e.name,t.name):r}isDefinedOn(e){return!e.getPriority().isEmpty()}indexedValueChanged(e,t){return!e.getPriority().equals(t.getPriority())}minPost(){return v.MIN}maxPost(){return new v(be,new M("[PRIORITY-POST]",pr))}makePost(e,t){const s=_r(e);return new v(t,new M("[PRIORITY-POST]",s))}toString(){return".priority"}}const N=new rl;/**
553
+ * @license
554
+ * Copyright 2017 Google LLC
555
+ *
556
+ * Licensed under the Apache License, Version 2.0 (the "License");
557
+ * you may not use this file except in compliance with the License.
558
+ * You may obtain a copy of the License at
559
+ *
560
+ * http://www.apache.org/licenses/LICENSE-2.0
561
+ *
562
+ * Unless required by applicable law or agreed to in writing, software
563
+ * distributed under the License is distributed on an "AS IS" BASIS,
564
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
565
+ * See the License for the specific language governing permissions and
566
+ * limitations under the License.
567
+ */const ol=Math.log(2);class al{constructor(e){const t=r=>parseInt(Math.log(r)/ol,10),s=r=>parseInt(Array(r+1).join("1"),2);this.count=t(e+1),this.current_=this.count-1;const i=s(this.count);this.bits_=e+1&i}nextBitIsOne(){const e=!(this.bits_&1<<this.current_);return this.current_--,e}}const Lt=function(n,e,t,s){n.sort(e);const i=function(l,c){const u=c-l;let h,d;if(u===0)return null;if(u===1)return h=n[l],d=t?t(h):h,new L(d,h.node,L.BLACK,null,null);{const f=parseInt(u/2,10)+l,p=i(l,f),g=i(f+1,c);return h=n[f],d=t?t(h):h,new L(d,h.node,L.BLACK,p,g)}},r=function(l){let c=null,u=null,h=n.length;const d=function(p,g){const b=h-p,A=h;h-=p;const x=i(b+1,A),R=n[b],$=t?t(R):R;f(new L($,R.node,g,null,x))},f=function(p){c?(c.left=p,c=p):(u=p,c=p)};for(let p=0;p<l.count;++p){const g=l.nextBitIsOne(),b=Math.pow(2,l.count-(p+1));g?d(b,L.BLACK):(d(b,L.BLACK),d(b,L.RED))}return u},o=new al(n.length),a=r(o);return new G(s||e,a)};/**
568
+ * @license
569
+ * Copyright 2017 Google LLC
570
+ *
571
+ * Licensed under the Apache License, Version 2.0 (the "License");
572
+ * you may not use this file except in compliance with the License.
573
+ * You may obtain a copy of the License at
574
+ *
575
+ * http://www.apache.org/licenses/LICENSE-2.0
576
+ *
577
+ * Unless required by applicable law or agreed to in writing, software
578
+ * distributed under the License is distributed on an "AS IS" BASIS,
579
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
580
+ * See the License for the specific language governing permissions and
581
+ * limitations under the License.
582
+ */let gn;const Oe={};class re{static get Default(){return _(Oe&&N,"ChildrenNode.ts has not been loaded"),gn=gn||new re({".priority":Oe},{".priority":N}),gn}constructor(e,t){this.indexes_=e,this.indexSet_=t}get(e){const t=je(this.indexes_,e);if(!t)throw new Error("No index defined for "+e);return t instanceof G?t:null}hasIndex(e){return ne(this.indexSet_,e.toString())}addIndex(e,t){_(e!==We,"KeyIndex always exists and isn't meant to be added to the IndexMap.");const s=[];let i=!1;const r=t.getIterator(v.Wrap);let o=r.getNext();for(;o;)i=i||e.isDefinedOn(o.node),s.push(o),o=r.getNext();let a;i?a=Lt(s,e.getCompare()):a=Oe;const l=e.toString(),c={...this.indexSet_};c[l]=e;const u={...this.indexes_};return u[l]=a,new re(u,c)}addToIndexes(e,t){const s=Ot(this.indexes_,(i,r)=>{const o=je(this.indexSet_,r);if(_(o,"Missing index implementation for "+r),i===Oe)if(o.isDefinedOn(e.node)){const a=[],l=t.getIterator(v.Wrap);let c=l.getNext();for(;c;)c.name!==e.name&&a.push(c),c=l.getNext();return a.push(e),Lt(a,o.getCompare())}else return Oe;else{const a=t.get(e.name);let l=i;return a&&(l=l.remove(new v(e.name,a))),l.insert(e,e.node)}});return new re(s,this.indexSet_)}removeFromIndexes(e,t){const s=Ot(this.indexes_,i=>{if(i===Oe)return i;{const r=t.get(e.name);return r?i.remove(new v(e.name,r)):i}});return new re(s,this.indexSet_)}}/**
583
+ * @license
584
+ * Copyright 2017 Google LLC
585
+ *
586
+ * Licensed under the Apache License, Version 2.0 (the "License");
587
+ * you may not use this file except in compliance with the License.
588
+ * You may obtain a copy of the License at
589
+ *
590
+ * http://www.apache.org/licenses/LICENSE-2.0
591
+ *
592
+ * Unless required by applicable law or agreed to in writing, software
593
+ * distributed under the License is distributed on an "AS IS" BASIS,
594
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
595
+ * See the License for the specific language governing permissions and
596
+ * limitations under the License.
597
+ */let tt;class m{static get EMPTY_NODE(){return tt||(tt=new m(new G(Zn),null,re.Default))}constructor(e,t,s){this.children_=e,this.priorityNode_=t,this.indexMap_=s,this.lazyHash_=null,this.priorityNode_&&fr(this.priorityNode_),this.children_.isEmpty()&&_(!this.priorityNode_||this.priorityNode_.isEmpty(),"An empty node cannot have a priority")}isLeafNode(){return!1}getPriority(){return this.priorityNode_||tt}updatePriority(e){return this.children_.isEmpty()?this:new m(this.children_,e,this.indexMap_)}getImmediateChild(e){if(e===".priority")return this.getPriority();{const t=this.children_.get(e);return t===null?tt:t}}getChild(e){const t=y(e);return t===null?this:this.getImmediateChild(t).getChild(T(e))}hasChild(e){return this.children_.get(e)!==null}updateImmediateChild(e,t){if(_(t,"We should always be passing snapshot nodes"),e===".priority")return this.updatePriority(t);{const s=new v(e,t);let i,r;t.isEmpty()?(i=this.children_.remove(e),r=this.indexMap_.removeFromIndexes(s,this.children_)):(i=this.children_.insert(e,t),r=this.indexMap_.addToIndexes(s,this.children_));const o=i.isEmpty()?tt:this.priorityNode_;return new m(i,o,r)}}updateChild(e,t){const s=y(e);if(s===null)return t;{_(y(e)!==".priority"||pe(e)===1,".priority must be the last token in a path");const i=this.getImmediateChild(s).updateChild(T(e),t);return this.updateImmediateChild(s,i)}}isEmpty(){return this.children_.isEmpty()}numChildren(){return this.children_.count()}val(e){if(this.isEmpty())return null;const t={};let s=0,i=0,r=!0;if(this.forEachChild(N,(o,a)=>{t[o]=a.val(e),s++,r&&m.INTEGER_REGEXP_.test(o)?i=Math.max(i,Number(o)):r=!1}),!e&&r&&i<2*s){const o=[];for(const a in t)o[a]=t[a];return o}else return e&&!this.getPriority().isEmpty()&&(t[".priority"]=this.getPriority().val()),t}hash(){if(this.lazyHash_===null){let e="";this.getPriority().isEmpty()||(e+="priority:"+dr(this.getPriority().val())+":"),this.forEachChild(N,(t,s)=>{const i=s.hash();i!==""&&(e+=":"+t+":"+i)}),this.lazyHash_=e===""?"":ji(e)}return this.lazyHash_}getPredecessorChildName(e,t,s){const i=this.resolveIndex_(s);if(i){const r=i.getPredecessorKey(new v(e,t));return r?r.name:null}else return this.children_.getPredecessorKey(e)}getFirstChildName(e){const t=this.resolveIndex_(e);if(t){const s=t.minKey();return s&&s.name}else return this.children_.minKey()}getFirstChild(e){const t=this.getFirstChildName(e);return t?new v(t,this.children_.get(t)):null}getLastChildName(e){const t=this.resolveIndex_(e);if(t){const s=t.maxKey();return s&&s.name}else return this.children_.maxKey()}getLastChild(e){const t=this.getLastChildName(e);return t?new v(t,this.children_.get(t)):null}forEachChild(e,t){const s=this.resolveIndex_(e);return s?s.inorderTraversal(i=>t(i.name,i.node)):this.children_.inorderTraversal(t)}getIterator(e){return this.getIteratorFrom(e.minPost(),e)}getIteratorFrom(e,t){const s=this.resolveIndex_(t);if(s)return s.getIteratorFrom(e,i=>i);{const i=this.children_.getIteratorFrom(e.name,v.Wrap);let r=i.peek();for(;r!=null&&t.compare(r,e)<0;)i.getNext(),r=i.peek();return i}}getReverseIterator(e){return this.getReverseIteratorFrom(e.maxPost(),e)}getReverseIteratorFrom(e,t){const s=this.resolveIndex_(t);if(s)return s.getReverseIteratorFrom(e,i=>i);{const i=this.children_.getReverseIteratorFrom(e.name,v.Wrap);let r=i.peek();for(;r!=null&&t.compare(r,e)>0;)i.getNext(),r=i.peek();return i}}compareTo(e){return this.isEmpty()?e.isEmpty()?0:-1:e.isLeafNode()||e.isEmpty()?1:e===vt?-1:0}withIndex(e){if(e===We||this.indexMap_.hasIndex(e))return this;{const t=this.indexMap_.addIndex(e,this.children_);return new m(this.children_,this.priorityNode_,t)}}isIndexed(e){return e===We||this.indexMap_.hasIndex(e)}equals(e){if(e===this)return!0;if(e.isLeafNode())return!1;{const t=e;if(this.getPriority().equals(t.getPriority()))if(this.children_.count()===t.children_.count()){const s=this.getIterator(N),i=t.getIterator(N);let r=s.getNext(),o=i.getNext();for(;r&&o;){if(r.name!==o.name||!r.node.equals(o.node))return!1;r=s.getNext(),o=i.getNext()}return r===null&&o===null}else return!1;else return!1}}resolveIndex_(e){return e===We?null:this.indexMap_.get(e.toString())}}m.INTEGER_REGEXP_=/^(0|[1-9]\d*)$/;class ll extends m{constructor(){super(new G(Zn),m.EMPTY_NODE,re.Default)}compareTo(e){return e===this?0:1}equals(e){return e===this}getPriority(){return this}getImmediateChild(e){return m.EMPTY_NODE}isEmpty(){return!1}}const vt=new ll;Object.defineProperties(v,{MIN:{value:new v(qe,m.EMPTY_NODE)},MAX:{value:new v(be,vt)}});hr.__EMPTY_NODE=m.EMPTY_NODE;M.__childrenNodeConstructor=m;nl(vt);il(vt);/**
598
+ * @license
599
+ * Copyright 2017 Google LLC
600
+ *
601
+ * Licensed under the Apache License, Version 2.0 (the "License");
602
+ * you may not use this file except in compliance with the License.
603
+ * You may obtain a copy of the License at
604
+ *
605
+ * http://www.apache.org/licenses/LICENSE-2.0
606
+ *
607
+ * Unless required by applicable law or agreed to in writing, software
608
+ * distributed under the License is distributed on an "AS IS" BASIS,
609
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
610
+ * See the License for the specific language governing permissions and
611
+ * limitations under the License.
612
+ */const cl=!0;function O(n,e=null){if(n===null)return m.EMPTY_NODE;if(typeof n=="object"&&".priority"in n&&(e=n[".priority"]),_(e===null||typeof e=="string"||typeof e=="number"||typeof e=="object"&&".sv"in e,"Invalid priority type found: "+typeof e),typeof n=="object"&&".value"in n&&n[".value"]!==null&&(n=n[".value"]),typeof n!="object"||".sv"in n){const t=n;return new M(t,O(e))}if(!(n instanceof Array)&&cl){const t=[];let s=!1;if(U(n,(o,a)=>{if(o.substring(0,1)!=="."){const l=O(a);l.isEmpty()||(s=s||!l.getPriority().isEmpty(),t.push(new v(o,l)))}}),t.length===0)return m.EMPTY_NODE;const r=Lt(t,tl,o=>o.name,Zn);if(s){const o=Lt(t,N.getCompare());return new m(r,O(e),new re({".priority":o},{".priority":N}))}else return new m(r,O(e),re.Default)}else{let t=m.EMPTY_NODE;return U(n,(s,i)=>{if(ne(n,s)&&s.substring(0,1)!=="."){const r=O(i);(r.isLeafNode()||!r.isEmpty())&&(t=t.updateImmediateChild(s,r))}}),t.updatePriority(O(e))}}sl(O);/**
613
+ * @license
614
+ * Copyright 2017 Google LLC
615
+ *
616
+ * Licensed under the Apache License, Version 2.0 (the "License");
617
+ * you may not use this file except in compliance with the License.
618
+ * You may obtain a copy of the License at
619
+ *
620
+ * http://www.apache.org/licenses/LICENSE-2.0
621
+ *
622
+ * Unless required by applicable law or agreed to in writing, software
623
+ * distributed under the License is distributed on an "AS IS" BASIS,
624
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
625
+ * See the License for the specific language governing permissions and
626
+ * limitations under the License.
627
+ */class ul extends en{constructor(e){super(),this.indexPath_=e,_(!C(e)&&y(e)!==".priority","Can't create PathIndex with empty path or .priority key")}extractChild(e){return e.getChild(this.indexPath_)}isDefinedOn(e){return!e.getChild(this.indexPath_).isEmpty()}compare(e,t){const s=this.extractChild(e.node),i=this.extractChild(t.node),r=s.compareTo(i);return r===0?Ae(e.name,t.name):r}makePost(e,t){const s=O(e),i=m.EMPTY_NODE.updateChild(this.indexPath_,s);return new v(t,i)}maxPost(){const e=m.EMPTY_NODE.updateChild(this.indexPath_,vt);return new v(be,e)}toString(){return ut(this.indexPath_,0).join("/")}}/**
628
+ * @license
629
+ * Copyright 2017 Google LLC
630
+ *
631
+ * Licensed under the Apache License, Version 2.0 (the "License");
632
+ * you may not use this file except in compliance with the License.
633
+ * You may obtain a copy of the License at
634
+ *
635
+ * http://www.apache.org/licenses/LICENSE-2.0
636
+ *
637
+ * Unless required by applicable law or agreed to in writing, software
638
+ * distributed under the License is distributed on an "AS IS" BASIS,
639
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
640
+ * See the License for the specific language governing permissions and
641
+ * limitations under the License.
642
+ */class hl extends en{compare(e,t){const s=e.node.compareTo(t.node);return s===0?Ae(e.name,t.name):s}isDefinedOn(e){return!0}indexedValueChanged(e,t){return!e.equals(t)}minPost(){return v.MIN}maxPost(){return v.MAX}makePost(e,t){const s=O(e);return new v(t,s)}toString(){return".value"}}const dl=new hl;/**
643
+ * @license
644
+ * Copyright 2017 Google LLC
645
+ *
646
+ * Licensed under the Apache License, Version 2.0 (the "License");
647
+ * you may not use this file except in compliance with the License.
648
+ * You may obtain a copy of the License at
649
+ *
650
+ * http://www.apache.org/licenses/LICENSE-2.0
651
+ *
652
+ * Unless required by applicable law or agreed to in writing, software
653
+ * distributed under the License is distributed on an "AS IS" BASIS,
654
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
655
+ * See the License for the specific language governing permissions and
656
+ * limitations under the License.
657
+ */function mr(n){return{type:"value",snapshotNode:n}}function Ge(n,e){return{type:"child_added",snapshotNode:e,childName:n}}function ht(n,e){return{type:"child_removed",snapshotNode:e,childName:n}}function dt(n,e,t){return{type:"child_changed",snapshotNode:e,childName:n,oldSnap:t}}function fl(n,e){return{type:"child_moved",snapshotNode:e,childName:n}}/**
658
+ * @license
659
+ * Copyright 2017 Google LLC
660
+ *
661
+ * Licensed under the Apache License, Version 2.0 (the "License");
662
+ * you may not use this file except in compliance with the License.
663
+ * You may obtain a copy of the License at
664
+ *
665
+ * http://www.apache.org/licenses/LICENSE-2.0
666
+ *
667
+ * Unless required by applicable law or agreed to in writing, software
668
+ * distributed under the License is distributed on an "AS IS" BASIS,
669
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
670
+ * See the License for the specific language governing permissions and
671
+ * limitations under the License.
672
+ */class es{constructor(e){this.index_=e}updateChild(e,t,s,i,r,o){_(e.isIndexed(this.index_),"A node must be indexed if only a child is updated");const a=e.getImmediateChild(t);return a.getChild(i).equals(s.getChild(i))&&a.isEmpty()===s.isEmpty()||(o!=null&&(s.isEmpty()?e.hasChild(t)?o.trackChildChange(ht(t,a)):_(e.isLeafNode(),"A child remove without an old child only makes sense on a leaf node"):a.isEmpty()?o.trackChildChange(Ge(t,s)):o.trackChildChange(dt(t,s,a))),e.isLeafNode()&&s.isEmpty())?e:e.updateImmediateChild(t,s).withIndex(this.index_)}updateFullNode(e,t,s){return s!=null&&(e.isLeafNode()||e.forEachChild(N,(i,r)=>{t.hasChild(i)||s.trackChildChange(ht(i,r))}),t.isLeafNode()||t.forEachChild(N,(i,r)=>{if(e.hasChild(i)){const o=e.getImmediateChild(i);o.equals(r)||s.trackChildChange(dt(i,r,o))}else s.trackChildChange(Ge(i,r))})),t.withIndex(this.index_)}updatePriority(e,t){return e.isEmpty()?m.EMPTY_NODE:e.updatePriority(t)}filtersNodes(){return!1}getIndexedFilter(){return this}getIndex(){return this.index_}}/**
673
+ * @license
674
+ * Copyright 2017 Google LLC
675
+ *
676
+ * Licensed under the Apache License, Version 2.0 (the "License");
677
+ * you may not use this file except in compliance with the License.
678
+ * You may obtain a copy of the License at
679
+ *
680
+ * http://www.apache.org/licenses/LICENSE-2.0
681
+ *
682
+ * Unless required by applicable law or agreed to in writing, software
683
+ * distributed under the License is distributed on an "AS IS" BASIS,
684
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
685
+ * See the License for the specific language governing permissions and
686
+ * limitations under the License.
687
+ */class ft{constructor(e){this.indexedFilter_=new es(e.getIndex()),this.index_=e.getIndex(),this.startPost_=ft.getStartPost_(e),this.endPost_=ft.getEndPost_(e),this.startIsInclusive_=!e.startAfterSet_,this.endIsInclusive_=!e.endBeforeSet_}getStartPost(){return this.startPost_}getEndPost(){return this.endPost_}matches(e){const t=this.startIsInclusive_?this.index_.compare(this.getStartPost(),e)<=0:this.index_.compare(this.getStartPost(),e)<0,s=this.endIsInclusive_?this.index_.compare(e,this.getEndPost())<=0:this.index_.compare(e,this.getEndPost())<0;return t&&s}updateChild(e,t,s,i,r,o){return this.matches(new v(t,s))||(s=m.EMPTY_NODE),this.indexedFilter_.updateChild(e,t,s,i,r,o)}updateFullNode(e,t,s){t.isLeafNode()&&(t=m.EMPTY_NODE);let i=t.withIndex(this.index_);i=i.updatePriority(m.EMPTY_NODE);const r=this;return t.forEachChild(N,(o,a)=>{r.matches(new v(o,a))||(i=i.updateImmediateChild(o,m.EMPTY_NODE))}),this.indexedFilter_.updateFullNode(e,i,s)}updatePriority(e,t){return e}filtersNodes(){return!0}getIndexedFilter(){return this.indexedFilter_}getIndex(){return this.index_}static getStartPost_(e){if(e.hasStart()){const t=e.getIndexStartName();return e.getIndex().makePost(e.getIndexStartValue(),t)}else return e.getIndex().minPost()}static getEndPost_(e){if(e.hasEnd()){const t=e.getIndexEndName();return e.getIndex().makePost(e.getIndexEndValue(),t)}else return e.getIndex().maxPost()}}/**
688
+ * @license
689
+ * Copyright 2017 Google LLC
690
+ *
691
+ * Licensed under the Apache License, Version 2.0 (the "License");
692
+ * you may not use this file except in compliance with the License.
693
+ * You may obtain a copy of the License at
694
+ *
695
+ * http://www.apache.org/licenses/LICENSE-2.0
696
+ *
697
+ * Unless required by applicable law or agreed to in writing, software
698
+ * distributed under the License is distributed on an "AS IS" BASIS,
699
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
700
+ * See the License for the specific language governing permissions and
701
+ * limitations under the License.
702
+ */class _l{constructor(e){this.withinDirectionalStart=t=>this.reverse_?this.withinEndPost(t):this.withinStartPost(t),this.withinDirectionalEnd=t=>this.reverse_?this.withinStartPost(t):this.withinEndPost(t),this.withinStartPost=t=>{const s=this.index_.compare(this.rangedFilter_.getStartPost(),t);return this.startIsInclusive_?s<=0:s<0},this.withinEndPost=t=>{const s=this.index_.compare(t,this.rangedFilter_.getEndPost());return this.endIsInclusive_?s<=0:s<0},this.rangedFilter_=new ft(e),this.index_=e.getIndex(),this.limit_=e.getLimit(),this.reverse_=!e.isViewFromLeft(),this.startIsInclusive_=!e.startAfterSet_,this.endIsInclusive_=!e.endBeforeSet_}updateChild(e,t,s,i,r,o){return this.rangedFilter_.matches(new v(t,s))||(s=m.EMPTY_NODE),e.getImmediateChild(t).equals(s)?e:e.numChildren()<this.limit_?this.rangedFilter_.getIndexedFilter().updateChild(e,t,s,i,r,o):this.fullLimitUpdateChild_(e,t,s,r,o)}updateFullNode(e,t,s){let i;if(t.isLeafNode()||t.isEmpty())i=m.EMPTY_NODE.withIndex(this.index_);else if(this.limit_*2<t.numChildren()&&t.isIndexed(this.index_)){i=m.EMPTY_NODE.withIndex(this.index_);let r;this.reverse_?r=t.getReverseIteratorFrom(this.rangedFilter_.getEndPost(),this.index_):r=t.getIteratorFrom(this.rangedFilter_.getStartPost(),this.index_);let o=0;for(;r.hasNext()&&o<this.limit_;){const a=r.getNext();if(this.withinDirectionalStart(a))if(this.withinDirectionalEnd(a))i=i.updateImmediateChild(a.name,a.node),o++;else break;else continue}}else{i=t.withIndex(this.index_),i=i.updatePriority(m.EMPTY_NODE);let r;this.reverse_?r=i.getReverseIterator(this.index_):r=i.getIterator(this.index_);let o=0;for(;r.hasNext();){const a=r.getNext();o<this.limit_&&this.withinDirectionalStart(a)&&this.withinDirectionalEnd(a)?o++:i=i.updateImmediateChild(a.name,m.EMPTY_NODE)}}return this.rangedFilter_.getIndexedFilter().updateFullNode(e,i,s)}updatePriority(e,t){return e}filtersNodes(){return!0}getIndexedFilter(){return this.rangedFilter_.getIndexedFilter()}getIndex(){return this.index_}fullLimitUpdateChild_(e,t,s,i,r){let o;if(this.reverse_){const h=this.index_.getCompare();o=(d,f)=>h(f,d)}else o=this.index_.getCompare();const a=e;_(a.numChildren()===this.limit_,"");const l=new v(t,s),c=this.reverse_?a.getFirstChild(this.index_):a.getLastChild(this.index_),u=this.rangedFilter_.matches(l);if(a.hasChild(t)){const h=a.getImmediateChild(t);let d=i.getChildAfterChild(this.index_,c,this.reverse_);for(;d!=null&&(d.name===t||a.hasChild(d.name));)d=i.getChildAfterChild(this.index_,d,this.reverse_);const f=d==null?1:o(d,l);if(u&&!s.isEmpty()&&f>=0)return r?.trackChildChange(dt(t,s,h)),a.updateImmediateChild(t,s);{r?.trackChildChange(ht(t,h));const g=a.updateImmediateChild(t,m.EMPTY_NODE);return d!=null&&this.rangedFilter_.matches(d)?(r?.trackChildChange(Ge(d.name,d.node)),g.updateImmediateChild(d.name,d.node)):g}}else return s.isEmpty()?e:u&&o(c,l)>=0?(r!=null&&(r.trackChildChange(ht(c.name,c.node)),r.trackChildChange(Ge(t,s))),a.updateImmediateChild(t,s).updateImmediateChild(c.name,m.EMPTY_NODE)):e}}/**
703
+ * @license
704
+ * Copyright 2017 Google LLC
705
+ *
706
+ * Licensed under the Apache License, Version 2.0 (the "License");
707
+ * you may not use this file except in compliance with the License.
708
+ * You may obtain a copy of the License at
709
+ *
710
+ * http://www.apache.org/licenses/LICENSE-2.0
711
+ *
712
+ * Unless required by applicable law or agreed to in writing, software
713
+ * distributed under the License is distributed on an "AS IS" BASIS,
714
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
715
+ * See the License for the specific language governing permissions and
716
+ * limitations under the License.
717
+ */class ts{constructor(){this.limitSet_=!1,this.startSet_=!1,this.startNameSet_=!1,this.startAfterSet_=!1,this.endSet_=!1,this.endNameSet_=!1,this.endBeforeSet_=!1,this.limit_=0,this.viewFrom_="",this.indexStartValue_=null,this.indexStartName_="",this.indexEndValue_=null,this.indexEndName_="",this.index_=N}hasStart(){return this.startSet_}isViewFromLeft(){return this.viewFrom_===""?this.startSet_:this.viewFrom_==="l"}getIndexStartValue(){return _(this.startSet_,"Only valid if start has been set"),this.indexStartValue_}getIndexStartName(){return _(this.startSet_,"Only valid if start has been set"),this.startNameSet_?this.indexStartName_:qe}hasEnd(){return this.endSet_}getIndexEndValue(){return _(this.endSet_,"Only valid if end has been set"),this.indexEndValue_}getIndexEndName(){return _(this.endSet_,"Only valid if end has been set"),this.endNameSet_?this.indexEndName_:be}hasLimit(){return this.limitSet_}hasAnchoredLimit(){return this.limitSet_&&this.viewFrom_!==""}getLimit(){return _(this.limitSet_,"Only valid if limit has been set"),this.limit_}getIndex(){return this.index_}loadsAllData(){return!(this.startSet_||this.endSet_||this.limitSet_)}isDefault(){return this.loadsAllData()&&this.index_===N}copy(){const e=new ts;return e.limitSet_=this.limitSet_,e.limit_=this.limit_,e.startSet_=this.startSet_,e.startAfterSet_=this.startAfterSet_,e.indexStartValue_=this.indexStartValue_,e.startNameSet_=this.startNameSet_,e.indexStartName_=this.indexStartName_,e.endSet_=this.endSet_,e.endBeforeSet_=this.endBeforeSet_,e.indexEndValue_=this.indexEndValue_,e.endNameSet_=this.endNameSet_,e.indexEndName_=this.indexEndName_,e.index_=this.index_,e.viewFrom_=this.viewFrom_,e}}function pl(n){return n.loadsAllData()?new es(n.getIndex()):n.hasLimit()?new _l(n):new ft(n)}function Qs(n){const e={};if(n.isDefault())return e;let t;if(n.index_===N?t="$priority":n.index_===dl?t="$value":n.index_===We?t="$key":(_(n.index_ instanceof ul,"Unrecognized index type!"),t=n.index_.toString()),e.orderBy=D(t),n.startSet_){const s=n.startAfterSet_?"startAfter":"startAt";e[s]=D(n.indexStartValue_),n.startNameSet_&&(e[s]+=","+D(n.indexStartName_))}if(n.endSet_){const s=n.endBeforeSet_?"endBefore":"endAt";e[s]=D(n.indexEndValue_),n.endNameSet_&&(e[s]+=","+D(n.indexEndName_))}return n.limitSet_&&(n.isViewFromLeft()?e.limitToFirst=n.limit_:e.limitToLast=n.limit_),e}function zs(n){const e={};if(n.startSet_&&(e.sp=n.indexStartValue_,n.startNameSet_&&(e.sn=n.indexStartName_),e.sin=!n.startAfterSet_),n.endSet_&&(e.ep=n.indexEndValue_,n.endNameSet_&&(e.en=n.indexEndName_),e.ein=!n.endBeforeSet_),n.limitSet_){e.l=n.limit_;let t=n.viewFrom_;t===""&&(n.isViewFromLeft()?t="l":t="r"),e.vf=t}return n.index_!==N&&(e.i=n.index_.toString()),e}/**
718
+ * @license
719
+ * Copyright 2017 Google LLC
720
+ *
721
+ * Licensed under the Apache License, Version 2.0 (the "License");
722
+ * you may not use this file except in compliance with the License.
723
+ * You may obtain a copy of the License at
724
+ *
725
+ * http://www.apache.org/licenses/LICENSE-2.0
726
+ *
727
+ * Unless required by applicable law or agreed to in writing, software
728
+ * distributed under the License is distributed on an "AS IS" BASIS,
729
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
730
+ * See the License for the specific language governing permissions and
731
+ * limitations under the License.
732
+ */class Ft extends ar{reportStats(e){throw new Error("Method not implemented.")}static getListenId_(e,t){return t!==void 0?"tag$"+t:(_(e._queryParams.isDefault(),"should have a tag if it's not a default query."),e._path.toString())}constructor(e,t,s,i){super(),this.repoInfo_=e,this.onDataUpdate_=t,this.authTokenProvider_=s,this.appCheckTokenProvider_=i,this.log_=yt("p:rest:"),this.listens_={}}listen(e,t,s,i){const r=e._path.toString();this.log_("Listen called for "+r+" "+e._queryIdentifier);const o=Ft.getListenId_(e,s),a={};this.listens_[o]=a;const l=Qs(e._queryParams);this.restRequest_(r+".json",l,(c,u)=>{let h=u;if(c===404&&(h=null,c=null),c===null&&this.onDataUpdate_(r,h,!1,s),je(this.listens_,o)===a){let d;c?c===401?d="permission_denied":d="rest_error:"+c:d="ok",i(d,null)}})}unlisten(e,t){const s=Ft.getListenId_(e,t);delete this.listens_[s]}get(e){const t=Qs(e._queryParams),s=e._path.toString(),i=new Jt;return this.restRequest_(s+".json",t,(r,o)=>{let a=o;r===404&&(a=null,r=null),r===null?(this.onDataUpdate_(s,a,!1,null),i.resolve(a)):i.reject(new Error(a))}),i.promise}refreshAuthToken(e){}restRequest_(e,t={},s){return t.format="export",Promise.all([this.authTokenProvider_.getToken(!1),this.appCheckTokenProvider_.getToken(!1)]).then(([i,r])=>{i&&i.accessToken&&(t.auth=i.accessToken),r&&r.token&&(t.ac=r.token);const o=(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host+e+"?ns="+this.repoInfo_.namespace+vo(t);this.log_("Sending REST request for "+o);const a=new XMLHttpRequest;a.onreadystatechange=()=>{if(s&&a.readyState===4){this.log_("REST Response for "+o+" received. status:",a.status,"response:",a.responseText);let l=null;if(a.status>=200&&a.status<300){try{l=qn(a.responseText)}catch{V("Failed to parse JSON response for "+o+": "+a.responseText)}s(null,l)}else a.status!==401&&a.status!==404&&V("Got unsuccessful REST response for "+o+" Status: "+a.status),s(a.status);s=null}},a.open("GET",o,!0),a.send()})}}/**
733
+ * @license
734
+ * Copyright 2017 Google LLC
735
+ *
736
+ * Licensed under the Apache License, Version 2.0 (the "License");
737
+ * you may not use this file except in compliance with the License.
738
+ * You may obtain a copy of the License at
739
+ *
740
+ * http://www.apache.org/licenses/LICENSE-2.0
741
+ *
742
+ * Unless required by applicable law or agreed to in writing, software
743
+ * distributed under the License is distributed on an "AS IS" BASIS,
744
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
745
+ * See the License for the specific language governing permissions and
746
+ * limitations under the License.
747
+ */class ml{constructor(){this.rootNode_=m.EMPTY_NODE}getNode(e){return this.rootNode_.getChild(e)}updateSnapshot(e,t){this.rootNode_=this.rootNode_.updateChild(e,t)}}/**
748
+ * @license
749
+ * Copyright 2017 Google LLC
750
+ *
751
+ * Licensed under the Apache License, Version 2.0 (the "License");
752
+ * you may not use this file except in compliance with the License.
753
+ * You may obtain a copy of the License at
754
+ *
755
+ * http://www.apache.org/licenses/LICENSE-2.0
756
+ *
757
+ * Unless required by applicable law or agreed to in writing, software
758
+ * distributed under the License is distributed on an "AS IS" BASIS,
759
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
760
+ * See the License for the specific language governing permissions and
761
+ * limitations under the License.
762
+ */function Wt(){return{value:null,children:new Map}}function gr(n,e,t){if(C(e))n.value=t,n.children.clear();else if(n.value!==null)n.value=n.value.updateChild(e,t);else{const s=y(e);n.children.has(s)||n.children.set(s,Wt());const i=n.children.get(s);e=T(e),gr(i,e,t)}}function xn(n,e,t){n.value!==null?t(e,n.value):gl(n,(s,i)=>{const r=new S(e.toString()+"/"+s);xn(i,r,t)})}function gl(n,e){n.children.forEach((t,s)=>{e(s,t)})}/**
763
+ * @license
764
+ * Copyright 2017 Google LLC
765
+ *
766
+ * Licensed under the Apache License, Version 2.0 (the "License");
767
+ * you may not use this file except in compliance with the License.
768
+ * You may obtain a copy of the License at
769
+ *
770
+ * http://www.apache.org/licenses/LICENSE-2.0
771
+ *
772
+ * Unless required by applicable law or agreed to in writing, software
773
+ * distributed under the License is distributed on an "AS IS" BASIS,
774
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
775
+ * See the License for the specific language governing permissions and
776
+ * limitations under the License.
777
+ */class yl{constructor(e){this.collection_=e,this.last_=null}get(){const e=this.collection_.get(),t={...e};return this.last_&&U(this.last_,(s,i)=>{t[s]=t[s]-i}),this.last_=e,t}}/**
778
+ * @license
779
+ * Copyright 2017 Google LLC
780
+ *
781
+ * Licensed under the Apache License, Version 2.0 (the "License");
782
+ * you may not use this file except in compliance with the License.
783
+ * You may obtain a copy of the License at
784
+ *
785
+ * http://www.apache.org/licenses/LICENSE-2.0
786
+ *
787
+ * Unless required by applicable law or agreed to in writing, software
788
+ * distributed under the License is distributed on an "AS IS" BASIS,
789
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
790
+ * See the License for the specific language governing permissions and
791
+ * limitations under the License.
792
+ */const Xs=10*1e3,vl=30*1e3,Cl=300*1e3;class El{constructor(e,t){this.server_=t,this.statsToReport_={},this.statsListener_=new yl(e);const s=Xs+(vl-Xs)*Math.random();rt(this.reportStats_.bind(this),Math.floor(s))}reportStats_(){const e=this.statsListener_.get(),t={};let s=!1;U(e,(i,r)=>{r>0&&ne(this.statsToReport_,i)&&(t[i]=r,s=!0)}),s&&this.server_.reportStats(t),rt(this.reportStats_.bind(this),Math.floor(Math.random()*2*Cl))}}/**
793
+ * @license
794
+ * Copyright 2017 Google LLC
795
+ *
796
+ * Licensed under the Apache License, Version 2.0 (the "License");
797
+ * you may not use this file except in compliance with the License.
798
+ * You may obtain a copy of the License at
799
+ *
800
+ * http://www.apache.org/licenses/LICENSE-2.0
801
+ *
802
+ * Unless required by applicable law or agreed to in writing, software
803
+ * distributed under the License is distributed on an "AS IS" BASIS,
804
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
805
+ * See the License for the specific language governing permissions and
806
+ * limitations under the License.
807
+ */var X;(function(n){n[n.OVERWRITE=0]="OVERWRITE",n[n.MERGE=1]="MERGE",n[n.ACK_USER_WRITE=2]="ACK_USER_WRITE",n[n.LISTEN_COMPLETE=3]="LISTEN_COMPLETE"})(X||(X={}));function ns(){return{fromUser:!0,fromServer:!1,queryId:null,tagged:!1}}function ss(){return{fromUser:!1,fromServer:!0,queryId:null,tagged:!1}}function is(n){return{fromUser:!1,fromServer:!0,queryId:n,tagged:!0}}/**
808
+ * @license
809
+ * Copyright 2017 Google LLC
810
+ *
811
+ * Licensed under the Apache License, Version 2.0 (the "License");
812
+ * you may not use this file except in compliance with the License.
813
+ * You may obtain a copy of the License at
814
+ *
815
+ * http://www.apache.org/licenses/LICENSE-2.0
816
+ *
817
+ * Unless required by applicable law or agreed to in writing, software
818
+ * distributed under the License is distributed on an "AS IS" BASIS,
819
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
820
+ * See the License for the specific language governing permissions and
821
+ * limitations under the License.
822
+ */class Ut{constructor(e,t,s){this.path=e,this.affectedTree=t,this.revert=s,this.type=X.ACK_USER_WRITE,this.source=ns()}operationForChild(e){if(C(this.path)){if(this.affectedTree.value!=null)return _(this.affectedTree.children.isEmpty(),"affectedTree should not have overlapping affected paths."),this;{const t=this.affectedTree.subtree(new S(e));return new Ut(w(),t,this.revert)}}else return _(y(this.path)===e,"operationForChild called for unrelated child."),new Ut(T(this.path),this.affectedTree,this.revert)}}/**
823
+ * @license
824
+ * Copyright 2017 Google LLC
825
+ *
826
+ * Licensed under the Apache License, Version 2.0 (the "License");
827
+ * you may not use this file except in compliance with the License.
828
+ * You may obtain a copy of the License at
829
+ *
830
+ * http://www.apache.org/licenses/LICENSE-2.0
831
+ *
832
+ * Unless required by applicable law or agreed to in writing, software
833
+ * distributed under the License is distributed on an "AS IS" BASIS,
834
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
835
+ * See the License for the specific language governing permissions and
836
+ * limitations under the License.
837
+ */class _t{constructor(e,t){this.source=e,this.path=t,this.type=X.LISTEN_COMPLETE}operationForChild(e){return C(this.path)?new _t(this.source,w()):new _t(this.source,T(this.path))}}/**
838
+ * @license
839
+ * Copyright 2017 Google LLC
840
+ *
841
+ * Licensed under the Apache License, Version 2.0 (the "License");
842
+ * you may not use this file except in compliance with the License.
843
+ * You may obtain a copy of the License at
844
+ *
845
+ * http://www.apache.org/licenses/LICENSE-2.0
846
+ *
847
+ * Unless required by applicable law or agreed to in writing, software
848
+ * distributed under the License is distributed on an "AS IS" BASIS,
849
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
850
+ * See the License for the specific language governing permissions and
851
+ * limitations under the License.
852
+ */class Se{constructor(e,t,s){this.source=e,this.path=t,this.snap=s,this.type=X.OVERWRITE}operationForChild(e){return C(this.path)?new Se(this.source,w(),this.snap.getImmediateChild(e)):new Se(this.source,T(this.path),this.snap)}}/**
853
+ * @license
854
+ * Copyright 2017 Google LLC
855
+ *
856
+ * Licensed under the Apache License, Version 2.0 (the "License");
857
+ * you may not use this file except in compliance with the License.
858
+ * You may obtain a copy of the License at
859
+ *
860
+ * http://www.apache.org/licenses/LICENSE-2.0
861
+ *
862
+ * Unless required by applicable law or agreed to in writing, software
863
+ * distributed under the License is distributed on an "AS IS" BASIS,
864
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
865
+ * See the License for the specific language governing permissions and
866
+ * limitations under the License.
867
+ */class $e{constructor(e,t,s){this.source=e,this.path=t,this.children=s,this.type=X.MERGE}operationForChild(e){if(C(this.path)){const t=this.children.subtree(new S(e));return t.isEmpty()?null:t.value?new Se(this.source,w(),t.value):new $e(this.source,w(),t)}else return _(y(this.path)===e,"Can't get a merge for a child not on the path of the operation"),new $e(this.source,T(this.path),this.children)}toString(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"}}/**
868
+ * @license
869
+ * Copyright 2017 Google LLC
870
+ *
871
+ * Licensed under the Apache License, Version 2.0 (the "License");
872
+ * you may not use this file except in compliance with the License.
873
+ * You may obtain a copy of the License at
874
+ *
875
+ * http://www.apache.org/licenses/LICENSE-2.0
876
+ *
877
+ * Unless required by applicable law or agreed to in writing, software
878
+ * distributed under the License is distributed on an "AS IS" BASIS,
879
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
880
+ * See the License for the specific language governing permissions and
881
+ * limitations under the License.
882
+ */class me{constructor(e,t,s){this.node_=e,this.fullyInitialized_=t,this.filtered_=s}isFullyInitialized(){return this.fullyInitialized_}isFiltered(){return this.filtered_}isCompleteForPath(e){if(C(e))return this.isFullyInitialized()&&!this.filtered_;const t=y(e);return this.isCompleteForChild(t)}isCompleteForChild(e){return this.isFullyInitialized()&&!this.filtered_||this.node_.hasChild(e)}getNode(){return this.node_}}/**
883
+ * @license
884
+ * Copyright 2017 Google LLC
885
+ *
886
+ * Licensed under the Apache License, Version 2.0 (the "License");
887
+ * you may not use this file except in compliance with the License.
888
+ * You may obtain a copy of the License at
889
+ *
890
+ * http://www.apache.org/licenses/LICENSE-2.0
891
+ *
892
+ * Unless required by applicable law or agreed to in writing, software
893
+ * distributed under the License is distributed on an "AS IS" BASIS,
894
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
895
+ * See the License for the specific language governing permissions and
896
+ * limitations under the License.
897
+ */class wl{constructor(e){this.query_=e,this.index_=this.query_._queryParams.getIndex()}}function bl(n,e,t,s){const i=[],r=[];return e.forEach(o=>{o.type==="child_changed"&&n.index_.indexedValueChanged(o.oldSnap,o.snapshotNode)&&r.push(fl(o.childName,o.snapshotNode))}),nt(n,i,"child_removed",e,s,t),nt(n,i,"child_added",e,s,t),nt(n,i,"child_moved",r,s,t),nt(n,i,"child_changed",e,s,t),nt(n,i,"value",e,s,t),i}function nt(n,e,t,s,i,r){const o=s.filter(a=>a.type===t);o.sort((a,l)=>Il(n,a,l)),o.forEach(a=>{const l=Sl(n,a,r);i.forEach(c=>{c.respondsTo(a.type)&&e.push(c.createEvent(l,n.query_))})})}function Sl(n,e,t){return e.type==="value"||e.type==="child_removed"||(e.prevName=t.getPredecessorChildName(e.childName,e.snapshotNode,n.index_)),e}function Il(n,e,t){if(e.childName==null||t.childName==null)throw mt("Should only compare child_ events.");const s=new v(e.childName,e.snapshotNode),i=new v(t.childName,t.snapshotNode);return n.index_.compare(s,i)}/**
898
+ * @license
899
+ * Copyright 2017 Google LLC
900
+ *
901
+ * Licensed under the Apache License, Version 2.0 (the "License");
902
+ * you may not use this file except in compliance with the License.
903
+ * You may obtain a copy of the License at
904
+ *
905
+ * http://www.apache.org/licenses/LICENSE-2.0
906
+ *
907
+ * Unless required by applicable law or agreed to in writing, software
908
+ * distributed under the License is distributed on an "AS IS" BASIS,
909
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
910
+ * See the License for the specific language governing permissions and
911
+ * limitations under the License.
912
+ */function tn(n,e){return{eventCache:n,serverCache:e}}function ot(n,e,t,s){return tn(new me(e,t,s),n.serverCache)}function yr(n,e,t,s){return tn(n.eventCache,new me(e,t,s))}function Bt(n){return n.eventCache.isFullyInitialized()?n.eventCache.getNode():null}function Ie(n){return n.serverCache.isFullyInitialized()?n.serverCache.getNode():null}/**
913
+ * @license
914
+ * Copyright 2017 Google LLC
915
+ *
916
+ * Licensed under the Apache License, Version 2.0 (the "License");
917
+ * you may not use this file except in compliance with the License.
918
+ * You may obtain a copy of the License at
919
+ *
920
+ * http://www.apache.org/licenses/LICENSE-2.0
921
+ *
922
+ * Unless required by applicable law or agreed to in writing, software
923
+ * distributed under the License is distributed on an "AS IS" BASIS,
924
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
925
+ * See the License for the specific language governing permissions and
926
+ * limitations under the License.
927
+ */let yn;const Tl=()=>(yn||(yn=new G(ua)),yn);class I{static fromObject(e){let t=new I(null);return U(e,(s,i)=>{t=t.set(new S(s),i)}),t}constructor(e,t=Tl()){this.value=e,this.children=t}isEmpty(){return this.value===null&&this.children.isEmpty()}findRootMostMatchingPathAndValue(e,t){if(this.value!=null&&t(this.value))return{path:w(),value:this.value};if(C(e))return null;{const s=y(e),i=this.children.get(s);if(i!==null){const r=i.findRootMostMatchingPathAndValue(T(e),t);return r!=null?{path:k(new S(s),r.path),value:r.value}:null}else return null}}findRootMostValueAndPath(e){return this.findRootMostMatchingPathAndValue(e,()=>!0)}subtree(e){if(C(e))return this;{const t=y(e),s=this.children.get(t);return s!==null?s.subtree(T(e)):new I(null)}}set(e,t){if(C(e))return new I(t,this.children);{const s=y(e),r=(this.children.get(s)||new I(null)).set(T(e),t),o=this.children.insert(s,r);return new I(this.value,o)}}remove(e){if(C(e))return this.children.isEmpty()?new I(null):new I(null,this.children);{const t=y(e),s=this.children.get(t);if(s){const i=s.remove(T(e));let r;return i.isEmpty()?r=this.children.remove(t):r=this.children.insert(t,i),this.value===null&&r.isEmpty()?new I(null):new I(this.value,r)}else return this}}get(e){if(C(e))return this.value;{const t=y(e),s=this.children.get(t);return s?s.get(T(e)):null}}setTree(e,t){if(C(e))return t;{const s=y(e),r=(this.children.get(s)||new I(null)).setTree(T(e),t);let o;return r.isEmpty()?o=this.children.remove(s):o=this.children.insert(s,r),new I(this.value,o)}}fold(e){return this.fold_(w(),e)}fold_(e,t){const s={};return this.children.inorderTraversal((i,r)=>{s[i]=r.fold_(k(e,i),t)}),t(e,this.value,s)}findOnPath(e,t){return this.findOnPath_(e,w(),t)}findOnPath_(e,t,s){const i=this.value?s(t,this.value):!1;if(i)return i;if(C(e))return null;{const r=y(e),o=this.children.get(r);return o?o.findOnPath_(T(e),k(t,r),s):null}}foreachOnPath(e,t){return this.foreachOnPath_(e,w(),t)}foreachOnPath_(e,t,s){if(C(e))return this;{this.value&&s(t,this.value);const i=y(e),r=this.children.get(i);return r?r.foreachOnPath_(T(e),k(t,i),s):new I(null)}}foreach(e){this.foreach_(w(),e)}foreach_(e,t){this.children.inorderTraversal((s,i)=>{i.foreach_(k(e,s),t)}),this.value&&t(e,this.value)}foreachChild(e){this.children.inorderTraversal((t,s)=>{s.value&&e(t,s.value)})}}/**
928
+ * @license
929
+ * Copyright 2017 Google LLC
930
+ *
931
+ * Licensed under the Apache License, Version 2.0 (the "License");
932
+ * you may not use this file except in compliance with the License.
933
+ * You may obtain a copy of the License at
934
+ *
935
+ * http://www.apache.org/licenses/LICENSE-2.0
936
+ *
937
+ * Unless required by applicable law or agreed to in writing, software
938
+ * distributed under the License is distributed on an "AS IS" BASIS,
939
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
940
+ * See the License for the specific language governing permissions and
941
+ * limitations under the License.
942
+ */class J{constructor(e){this.writeTree_=e}static empty(){return new J(new I(null))}}function at(n,e,t){if(C(e))return new J(new I(t));{const s=n.writeTree_.findRootMostValueAndPath(e);if(s!=null){const i=s.path;let r=s.value;const o=B(i,e);return r=r.updateChild(o,t),new J(n.writeTree_.set(i,r))}else{const i=new I(t),r=n.writeTree_.setTree(e,i);return new J(r)}}}function Rn(n,e,t){let s=n;return U(t,(i,r)=>{s=at(s,k(e,i),r)}),s}function Js(n,e){if(C(e))return J.empty();{const t=n.writeTree_.setTree(e,new I(null));return new J(t)}}function An(n,e){return Pe(n,e)!=null}function Pe(n,e){const t=n.writeTree_.findRootMostValueAndPath(e);return t!=null?n.writeTree_.get(t.path).getChild(B(t.path,e)):null}function Zs(n){const e=[],t=n.writeTree_.value;return t!=null?t.isLeafNode()||t.forEachChild(N,(s,i)=>{e.push(new v(s,i))}):n.writeTree_.children.inorderTraversal((s,i)=>{i.value!=null&&e.push(new v(s,i.value))}),e}function fe(n,e){if(C(e))return n;{const t=Pe(n,e);return t!=null?new J(new I(t)):new J(n.writeTree_.subtree(e))}}function Pn(n){return n.writeTree_.isEmpty()}function He(n,e){return vr(w(),n.writeTree_,e)}function vr(n,e,t){if(e.value!=null)return t.updateChild(n,e.value);{let s=null;return e.children.inorderTraversal((i,r)=>{i===".priority"?(_(r.value!==null,"Priority writes must always be leaf nodes"),s=r.value):t=vr(k(n,i),r,t)}),!t.getChild(n).isEmpty()&&s!==null&&(t=t.updateChild(k(n,".priority"),s)),t}}/**
943
+ * @license
944
+ * Copyright 2017 Google LLC
945
+ *
946
+ * Licensed under the Apache License, Version 2.0 (the "License");
947
+ * you may not use this file except in compliance with the License.
948
+ * You may obtain a copy of the License at
949
+ *
950
+ * http://www.apache.org/licenses/LICENSE-2.0
951
+ *
952
+ * Unless required by applicable law or agreed to in writing, software
953
+ * distributed under the License is distributed on an "AS IS" BASIS,
954
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
955
+ * See the License for the specific language governing permissions and
956
+ * limitations under the License.
957
+ */function nn(n,e){return br(e,n)}function kl(n,e,t,s,i){_(s>n.lastWriteId,"Stacking an older write on top of newer ones"),i===void 0&&(i=!0),n.allWrites.push({path:e,snap:t,writeId:s,visible:i}),i&&(n.visibleWrites=at(n.visibleWrites,e,t)),n.lastWriteId=s}function Nl(n,e,t,s){_(s>n.lastWriteId,"Stacking an older merge on top of newer ones"),n.allWrites.push({path:e,children:t,writeId:s,visible:!0}),n.visibleWrites=Rn(n.visibleWrites,e,t),n.lastWriteId=s}function xl(n,e){for(let t=0;t<n.allWrites.length;t++){const s=n.allWrites[t];if(s.writeId===e)return s}return null}function Rl(n,e){const t=n.allWrites.findIndex(a=>a.writeId===e);_(t>=0,"removeWrite called with nonexistent writeId.");const s=n.allWrites[t];n.allWrites.splice(t,1);let i=s.visible,r=!1,o=n.allWrites.length-1;for(;i&&o>=0;){const a=n.allWrites[o];a.visible&&(o>=t&&Al(a,s.path)?i=!1:K(s.path,a.path)&&(r=!0)),o--}if(i){if(r)return Pl(n),!0;if(s.snap)n.visibleWrites=Js(n.visibleWrites,s.path);else{const a=s.children;U(a,l=>{n.visibleWrites=Js(n.visibleWrites,k(s.path,l))})}return!0}else return!1}function Al(n,e){if(n.snap)return K(n.path,e);for(const t in n.children)if(n.children.hasOwnProperty(t)&&K(k(n.path,t),e))return!0;return!1}function Pl(n){n.visibleWrites=Cr(n.allWrites,Ol,w()),n.allWrites.length>0?n.lastWriteId=n.allWrites[n.allWrites.length-1].writeId:n.lastWriteId=-1}function Ol(n){return n.visible}function Cr(n,e,t){let s=J.empty();for(let i=0;i<n.length;++i){const r=n[i];if(e(r)){const o=r.path;let a;if(r.snap)K(t,o)?(a=B(t,o),s=at(s,a,r.snap)):K(o,t)&&(a=B(o,t),s=at(s,w(),r.snap.getChild(a)));else if(r.children){if(K(t,o))a=B(t,o),s=Rn(s,a,r.children);else if(K(o,t))if(a=B(o,t),C(a))s=Rn(s,w(),r.children);else{const l=je(r.children,y(a));if(l){const c=l.getChild(T(a));s=at(s,w(),c)}}}else throw mt("WriteRecord should have .snap or .children")}}return s}function Er(n,e,t,s,i){if(!s&&!i){const r=Pe(n.visibleWrites,e);if(r!=null)return r;{const o=fe(n.visibleWrites,e);if(Pn(o))return t;if(t==null&&!An(o,w()))return null;{const a=t||m.EMPTY_NODE;return He(o,a)}}}else{const r=fe(n.visibleWrites,e);if(!i&&Pn(r))return t;if(!i&&t==null&&!An(r,w()))return null;{const o=function(c){return(c.visible||i)&&(!s||!~s.indexOf(c.writeId))&&(K(c.path,e)||K(e,c.path))},a=Cr(n.allWrites,o,e),l=t||m.EMPTY_NODE;return He(a,l)}}}function Dl(n,e,t){let s=m.EMPTY_NODE;const i=Pe(n.visibleWrites,e);if(i)return i.isLeafNode()||i.forEachChild(N,(r,o)=>{s=s.updateImmediateChild(r,o)}),s;if(t){const r=fe(n.visibleWrites,e);return t.forEachChild(N,(o,a)=>{const l=He(fe(r,new S(o)),a);s=s.updateImmediateChild(o,l)}),Zs(r).forEach(o=>{s=s.updateImmediateChild(o.name,o.node)}),s}else{const r=fe(n.visibleWrites,e);return Zs(r).forEach(o=>{s=s.updateImmediateChild(o.name,o.node)}),s}}function Ml(n,e,t,s,i){_(s||i,"Either existingEventSnap or existingServerSnap must exist");const r=k(e,t);if(An(n.visibleWrites,r))return null;{const o=fe(n.visibleWrites,r);return Pn(o)?i.getChild(t):He(o,i.getChild(t))}}function Ll(n,e,t,s){const i=k(e,t),r=Pe(n.visibleWrites,i);if(r!=null)return r;if(s.isCompleteForChild(t)){const o=fe(n.visibleWrites,i);return He(o,s.getNode().getImmediateChild(t))}else return null}function Fl(n,e){return Pe(n.visibleWrites,e)}function Wl(n,e,t,s,i,r,o){let a;const l=fe(n.visibleWrites,e),c=Pe(l,w());if(c!=null)a=c;else if(t!=null)a=He(l,t);else return[];if(a=a.withIndex(o),!a.isEmpty()&&!a.isLeafNode()){const u=[],h=o.getCompare(),d=r?a.getReverseIteratorFrom(s,o):a.getIteratorFrom(s,o);let f=d.getNext();for(;f&&u.length<i;)h(f,s)!==0&&u.push(f),f=d.getNext();return u}else return[]}function Ul(){return{visibleWrites:J.empty(),allWrites:[],lastWriteId:-1}}function Vt(n,e,t,s){return Er(n.writeTree,n.treePath,e,t,s)}function rs(n,e){return Dl(n.writeTree,n.treePath,e)}function ei(n,e,t,s){return Ml(n.writeTree,n.treePath,e,t,s)}function jt(n,e){return Fl(n.writeTree,k(n.treePath,e))}function Bl(n,e,t,s,i,r){return Wl(n.writeTree,n.treePath,e,t,s,i,r)}function os(n,e,t){return Ll(n.writeTree,n.treePath,e,t)}function wr(n,e){return br(k(n.treePath,e),n.writeTree)}function br(n,e){return{treePath:n,writeTree:e}}/**
958
+ * @license
959
+ * Copyright 2017 Google LLC
960
+ *
961
+ * Licensed under the Apache License, Version 2.0 (the "License");
962
+ * you may not use this file except in compliance with the License.
963
+ * You may obtain a copy of the License at
964
+ *
965
+ * http://www.apache.org/licenses/LICENSE-2.0
966
+ *
967
+ * Unless required by applicable law or agreed to in writing, software
968
+ * distributed under the License is distributed on an "AS IS" BASIS,
969
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
970
+ * See the License for the specific language governing permissions and
971
+ * limitations under the License.
972
+ */class Vl{constructor(){this.changeMap=new Map}trackChildChange(e){const t=e.type,s=e.childName;_(t==="child_added"||t==="child_changed"||t==="child_removed","Only child changes supported for tracking"),_(s!==".priority","Only non-priority child changes can be tracked.");const i=this.changeMap.get(s);if(i){const r=i.type;if(t==="child_added"&&r==="child_removed")this.changeMap.set(s,dt(s,e.snapshotNode,i.snapshotNode));else if(t==="child_removed"&&r==="child_added")this.changeMap.delete(s);else if(t==="child_removed"&&r==="child_changed")this.changeMap.set(s,ht(s,i.oldSnap));else if(t==="child_changed"&&r==="child_added")this.changeMap.set(s,Ge(s,e.snapshotNode));else if(t==="child_changed"&&r==="child_changed")this.changeMap.set(s,dt(s,e.snapshotNode,i.oldSnap));else throw mt("Illegal combination of changes: "+e+" occurred after "+i)}else this.changeMap.set(s,e)}getChanges(){return Array.from(this.changeMap.values())}}/**
973
+ * @license
974
+ * Copyright 2017 Google LLC
975
+ *
976
+ * Licensed under the Apache License, Version 2.0 (the "License");
977
+ * you may not use this file except in compliance with the License.
978
+ * You may obtain a copy of the License at
979
+ *
980
+ * http://www.apache.org/licenses/LICENSE-2.0
981
+ *
982
+ * Unless required by applicable law or agreed to in writing, software
983
+ * distributed under the License is distributed on an "AS IS" BASIS,
984
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
985
+ * See the License for the specific language governing permissions and
986
+ * limitations under the License.
987
+ */class jl{getCompleteChild(e){return null}getChildAfterChild(e,t,s){return null}}const Sr=new jl;class as{constructor(e,t,s=null){this.writes_=e,this.viewCache_=t,this.optCompleteServerCache_=s}getCompleteChild(e){const t=this.viewCache_.eventCache;if(t.isCompleteForChild(e))return t.getNode().getImmediateChild(e);{const s=this.optCompleteServerCache_!=null?new me(this.optCompleteServerCache_,!0,!1):this.viewCache_.serverCache;return os(this.writes_,e,s)}}getChildAfterChild(e,t,s){const i=this.optCompleteServerCache_!=null?this.optCompleteServerCache_:Ie(this.viewCache_),r=Bl(this.writes_,i,t,1,s,e);return r.length===0?null:r[0]}}/**
988
+ * @license
989
+ * Copyright 2017 Google LLC
990
+ *
991
+ * Licensed under the Apache License, Version 2.0 (the "License");
992
+ * you may not use this file except in compliance with the License.
993
+ * You may obtain a copy of the License at
994
+ *
995
+ * http://www.apache.org/licenses/LICENSE-2.0
996
+ *
997
+ * Unless required by applicable law or agreed to in writing, software
998
+ * distributed under the License is distributed on an "AS IS" BASIS,
999
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1000
+ * See the License for the specific language governing permissions and
1001
+ * limitations under the License.
1002
+ */function ql(n){return{filter:n}}function Gl(n,e){_(e.eventCache.getNode().isIndexed(n.filter.getIndex()),"Event snap not indexed"),_(e.serverCache.getNode().isIndexed(n.filter.getIndex()),"Server snap not indexed")}function $l(n,e,t,s,i){const r=new Vl;let o,a;if(t.type===X.OVERWRITE){const c=t;c.source.fromUser?o=On(n,e,c.path,c.snap,s,i,r):(_(c.source.fromServer,"Unknown source."),a=c.source.tagged||e.serverCache.isFiltered()&&!C(c.path),o=qt(n,e,c.path,c.snap,s,i,a,r))}else if(t.type===X.MERGE){const c=t;c.source.fromUser?o=Kl(n,e,c.path,c.children,s,i,r):(_(c.source.fromServer,"Unknown source."),a=c.source.tagged||e.serverCache.isFiltered(),o=Dn(n,e,c.path,c.children,s,i,a,r))}else if(t.type===X.ACK_USER_WRITE){const c=t;c.revert?o=zl(n,e,c.path,s,i,r):o=Yl(n,e,c.path,c.affectedTree,s,i,r)}else if(t.type===X.LISTEN_COMPLETE)o=Ql(n,e,t.path,s,r);else throw mt("Unknown operation type: "+t.type);const l=r.getChanges();return Hl(e,o,l),{viewCache:o,changes:l}}function Hl(n,e,t){const s=e.eventCache;if(s.isFullyInitialized()){const i=s.getNode().isLeafNode()||s.getNode().isEmpty(),r=Bt(n);(t.length>0||!n.eventCache.isFullyInitialized()||i&&!s.getNode().equals(r)||!s.getNode().getPriority().equals(r.getPriority()))&&t.push(mr(Bt(e)))}}function Ir(n,e,t,s,i,r){const o=e.eventCache;if(jt(s,t)!=null)return e;{let a,l;if(C(t))if(_(e.serverCache.isFullyInitialized(),"If change path is empty, we must have complete server data"),e.serverCache.isFiltered()){const c=Ie(e),u=c instanceof m?c:m.EMPTY_NODE,h=rs(s,u);a=n.filter.updateFullNode(e.eventCache.getNode(),h,r)}else{const c=Vt(s,Ie(e));a=n.filter.updateFullNode(e.eventCache.getNode(),c,r)}else{const c=y(t);if(c===".priority"){_(pe(t)===1,"Can't have a priority with additional path components");const u=o.getNode();l=e.serverCache.getNode();const h=ei(s,t,u,l);h!=null?a=n.filter.updatePriority(u,h):a=o.getNode()}else{const u=T(t);let h;if(o.isCompleteForChild(c)){l=e.serverCache.getNode();const d=ei(s,t,o.getNode(),l);d!=null?h=o.getNode().getImmediateChild(c).updateChild(u,d):h=o.getNode().getImmediateChild(c)}else h=os(s,c,e.serverCache);h!=null?a=n.filter.updateChild(o.getNode(),c,h,u,i,r):a=o.getNode()}}return ot(e,a,o.isFullyInitialized()||C(t),n.filter.filtersNodes())}}function qt(n,e,t,s,i,r,o,a){const l=e.serverCache;let c;const u=o?n.filter:n.filter.getIndexedFilter();if(C(t))c=u.updateFullNode(l.getNode(),s,null);else if(u.filtersNodes()&&!l.isFiltered()){const f=l.getNode().updateChild(t,s);c=u.updateFullNode(l.getNode(),f,null)}else{const f=y(t);if(!l.isCompleteForPath(t)&&pe(t)>1)return e;const p=T(t),b=l.getNode().getImmediateChild(f).updateChild(p,s);f===".priority"?c=u.updatePriority(l.getNode(),b):c=u.updateChild(l.getNode(),f,b,p,Sr,null)}const h=yr(e,c,l.isFullyInitialized()||C(t),u.filtersNodes()),d=new as(i,h,r);return Ir(n,h,t,i,d,a)}function On(n,e,t,s,i,r,o){const a=e.eventCache;let l,c;const u=new as(i,e,r);if(C(t))c=n.filter.updateFullNode(e.eventCache.getNode(),s,o),l=ot(e,c,!0,n.filter.filtersNodes());else{const h=y(t);if(h===".priority")c=n.filter.updatePriority(e.eventCache.getNode(),s),l=ot(e,c,a.isFullyInitialized(),a.isFiltered());else{const d=T(t),f=a.getNode().getImmediateChild(h);let p;if(C(d))p=s;else{const g=u.getCompleteChild(h);g!=null?zn(d)===".priority"&&g.getChild(cr(d)).isEmpty()?p=g:p=g.updateChild(d,s):p=m.EMPTY_NODE}if(f.equals(p))l=e;else{const g=n.filter.updateChild(a.getNode(),h,p,d,u,o);l=ot(e,g,a.isFullyInitialized(),n.filter.filtersNodes())}}}return l}function ti(n,e){return n.eventCache.isCompleteForChild(e)}function Kl(n,e,t,s,i,r,o){let a=e;return s.foreach((l,c)=>{const u=k(t,l);ti(e,y(u))&&(a=On(n,a,u,c,i,r,o))}),s.foreach((l,c)=>{const u=k(t,l);ti(e,y(u))||(a=On(n,a,u,c,i,r,o))}),a}function ni(n,e,t){return t.foreach((s,i)=>{e=e.updateChild(s,i)}),e}function Dn(n,e,t,s,i,r,o,a){if(e.serverCache.getNode().isEmpty()&&!e.serverCache.isFullyInitialized())return e;let l=e,c;C(t)?c=s:c=new I(null).setTree(t,s);const u=e.serverCache.getNode();return c.children.inorderTraversal((h,d)=>{if(u.hasChild(h)){const f=e.serverCache.getNode().getImmediateChild(h),p=ni(n,f,d);l=qt(n,l,new S(h),p,i,r,o,a)}}),c.children.inorderTraversal((h,d)=>{const f=!e.serverCache.isCompleteForChild(h)&&d.value===null;if(!u.hasChild(h)&&!f){const p=e.serverCache.getNode().getImmediateChild(h),g=ni(n,p,d);l=qt(n,l,new S(h),g,i,r,o,a)}}),l}function Yl(n,e,t,s,i,r,o){if(jt(i,t)!=null)return e;const a=e.serverCache.isFiltered(),l=e.serverCache;if(s.value!=null){if(C(t)&&l.isFullyInitialized()||l.isCompleteForPath(t))return qt(n,e,t,l.getNode().getChild(t),i,r,a,o);if(C(t)){let c=new I(null);return l.getNode().forEachChild(We,(u,h)=>{c=c.set(new S(u),h)}),Dn(n,e,t,c,i,r,a,o)}else return e}else{let c=new I(null);return s.foreach((u,h)=>{const d=k(t,u);l.isCompleteForPath(d)&&(c=c.set(u,l.getNode().getChild(d)))}),Dn(n,e,t,c,i,r,a,o)}}function Ql(n,e,t,s,i){const r=e.serverCache,o=yr(e,r.getNode(),r.isFullyInitialized()||C(t),r.isFiltered());return Ir(n,o,t,s,Sr,i)}function zl(n,e,t,s,i,r){let o;if(jt(s,t)!=null)return e;{const a=new as(s,e,i),l=e.eventCache.getNode();let c;if(C(t)||y(t)===".priority"){let u;if(e.serverCache.isFullyInitialized())u=Vt(s,Ie(e));else{const h=e.serverCache.getNode();_(h instanceof m,"serverChildren would be complete if leaf node"),u=rs(s,h)}u=u,c=n.filter.updateFullNode(l,u,r)}else{const u=y(t);let h=os(s,u,e.serverCache);h==null&&e.serverCache.isCompleteForChild(u)&&(h=l.getImmediateChild(u)),h!=null?c=n.filter.updateChild(l,u,h,T(t),a,r):e.eventCache.getNode().hasChild(u)?c=n.filter.updateChild(l,u,m.EMPTY_NODE,T(t),a,r):c=l,c.isEmpty()&&e.serverCache.isFullyInitialized()&&(o=Vt(s,Ie(e)),o.isLeafNode()&&(c=n.filter.updateFullNode(c,o,r)))}return o=e.serverCache.isFullyInitialized()||jt(s,w())!=null,ot(e,c,o,n.filter.filtersNodes())}}/**
1003
+ * @license
1004
+ * Copyright 2017 Google LLC
1005
+ *
1006
+ * Licensed under the Apache License, Version 2.0 (the "License");
1007
+ * you may not use this file except in compliance with the License.
1008
+ * You may obtain a copy of the License at
1009
+ *
1010
+ * http://www.apache.org/licenses/LICENSE-2.0
1011
+ *
1012
+ * Unless required by applicable law or agreed to in writing, software
1013
+ * distributed under the License is distributed on an "AS IS" BASIS,
1014
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1015
+ * See the License for the specific language governing permissions and
1016
+ * limitations under the License.
1017
+ */class Xl{constructor(e,t){this.query_=e,this.eventRegistrations_=[];const s=this.query_._queryParams,i=new es(s.getIndex()),r=pl(s);this.processor_=ql(r);const o=t.serverCache,a=t.eventCache,l=i.updateFullNode(m.EMPTY_NODE,o.getNode(),null),c=r.updateFullNode(m.EMPTY_NODE,a.getNode(),null),u=new me(l,o.isFullyInitialized(),i.filtersNodes()),h=new me(c,a.isFullyInitialized(),r.filtersNodes());this.viewCache_=tn(h,u),this.eventGenerator_=new wl(this.query_)}get query(){return this.query_}}function Jl(n){return n.viewCache_.serverCache.getNode()}function Zl(n){return Bt(n.viewCache_)}function ec(n,e){const t=Ie(n.viewCache_);return t&&(n.query._queryParams.loadsAllData()||!C(e)&&!t.getImmediateChild(y(e)).isEmpty())?t.getChild(e):null}function si(n){return n.eventRegistrations_.length===0}function tc(n,e){n.eventRegistrations_.push(e)}function ii(n,e,t){const s=[];if(t){_(e==null,"A cancel should cancel all event registrations.");const i=n.query._path;n.eventRegistrations_.forEach(r=>{const o=r.createCancelEvent(t,i);o&&s.push(o)})}if(e){let i=[];for(let r=0;r<n.eventRegistrations_.length;++r){const o=n.eventRegistrations_[r];if(!o.matches(e))i.push(o);else if(e.hasAnyCallback()){i=i.concat(n.eventRegistrations_.slice(r+1));break}}n.eventRegistrations_=i}else n.eventRegistrations_=[];return s}function ri(n,e,t,s){e.type===X.MERGE&&e.source.queryId!==null&&(_(Ie(n.viewCache_),"We should always have a full cache before handling merges"),_(Bt(n.viewCache_),"Missing event cache, even though we have a server cache"));const i=n.viewCache_,r=$l(n.processor_,i,e,t,s);return Gl(n.processor_,r.viewCache),_(r.viewCache.serverCache.isFullyInitialized()||!i.serverCache.isFullyInitialized(),"Once a server snap is complete, it should never go back"),n.viewCache_=r.viewCache,Tr(n,r.changes,r.viewCache.eventCache.getNode(),null)}function nc(n,e){const t=n.viewCache_.eventCache,s=[];return t.getNode().isLeafNode()||t.getNode().forEachChild(N,(r,o)=>{s.push(Ge(r,o))}),t.isFullyInitialized()&&s.push(mr(t.getNode())),Tr(n,s,t.getNode(),e)}function Tr(n,e,t,s){const i=s?[s]:n.eventRegistrations_;return bl(n.eventGenerator_,e,t,i)}/**
1018
+ * @license
1019
+ * Copyright 2017 Google LLC
1020
+ *
1021
+ * Licensed under the Apache License, Version 2.0 (the "License");
1022
+ * you may not use this file except in compliance with the License.
1023
+ * You may obtain a copy of the License at
1024
+ *
1025
+ * http://www.apache.org/licenses/LICENSE-2.0
1026
+ *
1027
+ * Unless required by applicable law or agreed to in writing, software
1028
+ * distributed under the License is distributed on an "AS IS" BASIS,
1029
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1030
+ * See the License for the specific language governing permissions and
1031
+ * limitations under the License.
1032
+ */let Gt;class kr{constructor(){this.views=new Map}}function sc(n){_(!Gt,"__referenceConstructor has already been defined"),Gt=n}function ic(){return _(Gt,"Reference.ts has not been loaded"),Gt}function rc(n){return n.views.size===0}function ls(n,e,t,s){const i=e.source.queryId;if(i!==null){const r=n.views.get(i);return _(r!=null,"SyncTree gave us an op for an invalid query."),ri(r,e,t,s)}else{let r=[];for(const o of n.views.values())r=r.concat(ri(o,e,t,s));return r}}function Nr(n,e,t,s,i){const r=e._queryIdentifier,o=n.views.get(r);if(!o){let a=Vt(t,i?s:null),l=!1;a?l=!0:s instanceof m?(a=rs(t,s),l=!1):(a=m.EMPTY_NODE,l=!1);const c=tn(new me(a,l,!1),new me(s,i,!1));return new Xl(e,c)}return o}function oc(n,e,t,s,i,r){const o=Nr(n,e,s,i,r);return n.views.has(e._queryIdentifier)||n.views.set(e._queryIdentifier,o),tc(o,t),nc(o,t)}function ac(n,e,t,s){const i=e._queryIdentifier,r=[];let o=[];const a=ge(n);if(i==="default")for(const[l,c]of n.views.entries())o=o.concat(ii(c,t,s)),si(c)&&(n.views.delete(l),c.query._queryParams.loadsAllData()||r.push(c.query));else{const l=n.views.get(i);l&&(o=o.concat(ii(l,t,s)),si(l)&&(n.views.delete(i),l.query._queryParams.loadsAllData()||r.push(l.query)))}return a&&!ge(n)&&r.push(new(ic())(e._repo,e._path)),{removed:r,events:o}}function xr(n){const e=[];for(const t of n.views.values())t.query._queryParams.loadsAllData()||e.push(t);return e}function _e(n,e){let t=null;for(const s of n.views.values())t=t||ec(s,e);return t}function Rr(n,e){if(e._queryParams.loadsAllData())return sn(n);{const s=e._queryIdentifier;return n.views.get(s)}}function Ar(n,e){return Rr(n,e)!=null}function ge(n){return sn(n)!=null}function sn(n){for(const e of n.views.values())if(e.query._queryParams.loadsAllData())return e;return null}/**
1033
+ * @license
1034
+ * Copyright 2017 Google LLC
1035
+ *
1036
+ * Licensed under the Apache License, Version 2.0 (the "License");
1037
+ * you may not use this file except in compliance with the License.
1038
+ * You may obtain a copy of the License at
1039
+ *
1040
+ * http://www.apache.org/licenses/LICENSE-2.0
1041
+ *
1042
+ * Unless required by applicable law or agreed to in writing, software
1043
+ * distributed under the License is distributed on an "AS IS" BASIS,
1044
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1045
+ * See the License for the specific language governing permissions and
1046
+ * limitations under the License.
1047
+ */let $t;function lc(n){_(!$t,"__referenceConstructor has already been defined"),$t=n}function cc(){return _($t,"Reference.ts has not been loaded"),$t}let uc=1;class oi{constructor(e){this.listenProvider_=e,this.syncPointTree_=new I(null),this.pendingWriteTree_=Ul(),this.tagToQueryMap=new Map,this.queryToTagMap=new Map}}function Pr(n,e,t,s,i){return kl(n.pendingWriteTree_,e,t,s,i),i?Xe(n,new Se(ns(),e,t)):[]}function hc(n,e,t,s){Nl(n.pendingWriteTree_,e,t,s);const i=I.fromObject(t);return Xe(n,new $e(ns(),e,i))}function de(n,e,t=!1){const s=xl(n.pendingWriteTree_,e);if(Rl(n.pendingWriteTree_,e)){let r=new I(null);return s.snap!=null?r=r.set(w(),!0):U(s.children,o=>{r=r.set(new S(o),!0)}),Xe(n,new Ut(s.path,r,t))}else return[]}function Ct(n,e,t){return Xe(n,new Se(ss(),e,t))}function dc(n,e,t){const s=I.fromObject(t);return Xe(n,new $e(ss(),e,s))}function fc(n,e){return Xe(n,new _t(ss(),e))}function _c(n,e,t){const s=us(n,t);if(s){const i=hs(s),r=i.path,o=i.queryId,a=B(r,e),l=new _t(is(o),a);return ds(n,r,l)}else return[]}function Ht(n,e,t,s,i=!1){const r=e._path,o=n.syncPointTree_.get(r);let a=[];if(o&&(e._queryIdentifier==="default"||Ar(o,e))){const l=ac(o,e,t,s);rc(o)&&(n.syncPointTree_=n.syncPointTree_.remove(r));const c=l.removed;if(a=l.events,!i){const u=c.findIndex(d=>d._queryParams.loadsAllData())!==-1,h=n.syncPointTree_.findOnPath(r,(d,f)=>ge(f));if(u&&!h){const d=n.syncPointTree_.subtree(r);if(!d.isEmpty()){const f=gc(d);for(let p=0;p<f.length;++p){const g=f[p],b=g.query,A=Lr(n,g);n.listenProvider_.startListening(lt(b),pt(n,b),A.hashFn,A.onComplete)}}}!h&&c.length>0&&!s&&(u?n.listenProvider_.stopListening(lt(e),null):c.forEach(d=>{const f=n.queryToTagMap.get(rn(d));n.listenProvider_.stopListening(lt(d),f)}))}yc(n,c)}return a}function Or(n,e,t,s){const i=us(n,s);if(i!=null){const r=hs(i),o=r.path,a=r.queryId,l=B(o,e),c=new Se(is(a),l,t);return ds(n,o,c)}else return[]}function pc(n,e,t,s){const i=us(n,s);if(i){const r=hs(i),o=r.path,a=r.queryId,l=B(o,e),c=I.fromObject(t),u=new $e(is(a),l,c);return ds(n,o,u)}else return[]}function Mn(n,e,t,s=!1){const i=e._path;let r=null,o=!1;n.syncPointTree_.foreachOnPath(i,(d,f)=>{const p=B(d,i);r=r||_e(f,p),o=o||ge(f)});let a=n.syncPointTree_.get(i);a?(o=o||ge(a),r=r||_e(a,w())):(a=new kr,n.syncPointTree_=n.syncPointTree_.set(i,a));let l;r!=null?l=!0:(l=!1,r=m.EMPTY_NODE,n.syncPointTree_.subtree(i).foreachChild((f,p)=>{const g=_e(p,w());g&&(r=r.updateImmediateChild(f,g))}));const c=Ar(a,e);if(!c&&!e._queryParams.loadsAllData()){const d=rn(e);_(!n.queryToTagMap.has(d),"View does not exist, but we have a tag");const f=vc();n.queryToTagMap.set(d,f),n.tagToQueryMap.set(f,d)}const u=nn(n.pendingWriteTree_,i);let h=oc(a,e,t,u,r,l);if(!c&&!o&&!s){const d=Rr(a,e);h=h.concat(Cc(n,e,d))}return h}function cs(n,e,t){const i=n.pendingWriteTree_,r=n.syncPointTree_.findOnPath(e,(o,a)=>{const l=B(o,e),c=_e(a,l);if(c)return c});return Er(i,e,r,t,!0)}function mc(n,e){const t=e._path;let s=null;n.syncPointTree_.foreachOnPath(t,(c,u)=>{const h=B(c,t);s=s||_e(u,h)});let i=n.syncPointTree_.get(t);i?s=s||_e(i,w()):(i=new kr,n.syncPointTree_=n.syncPointTree_.set(t,i));const r=s!=null,o=r?new me(s,!0,!1):null,a=nn(n.pendingWriteTree_,e._path),l=Nr(i,e,a,r?o.getNode():m.EMPTY_NODE,r);return Zl(l)}function Xe(n,e){return Dr(e,n.syncPointTree_,null,nn(n.pendingWriteTree_,w()))}function Dr(n,e,t,s){if(C(n.path))return Mr(n,e,t,s);{const i=e.get(w());t==null&&i!=null&&(t=_e(i,w()));let r=[];const o=y(n.path),a=n.operationForChild(o),l=e.children.get(o);if(l&&a){const c=t?t.getImmediateChild(o):null,u=wr(s,o);r=r.concat(Dr(a,l,c,u))}return i&&(r=r.concat(ls(i,n,s,t))),r}}function Mr(n,e,t,s){const i=e.get(w());t==null&&i!=null&&(t=_e(i,w()));let r=[];return e.children.inorderTraversal((o,a)=>{const l=t?t.getImmediateChild(o):null,c=wr(s,o),u=n.operationForChild(o);u&&(r=r.concat(Mr(u,a,l,c)))}),i&&(r=r.concat(ls(i,n,s,t))),r}function Lr(n,e){const t=e.query,s=pt(n,t);return{hashFn:()=>(Jl(e)||m.EMPTY_NODE).hash(),onComplete:i=>{if(i==="ok")return s?_c(n,t._path,s):fc(n,t._path);{const r=fa(i,t);return Ht(n,t,null,r)}}}}function pt(n,e){const t=rn(e);return n.queryToTagMap.get(t)}function rn(n){return n._path.toString()+"$"+n._queryIdentifier}function us(n,e){return n.tagToQueryMap.get(e)}function hs(n){const e=n.indexOf("$");return _(e!==-1&&e<n.length-1,"Bad queryKey."),{queryId:n.substr(e+1),path:new S(n.substr(0,e))}}function ds(n,e,t){const s=n.syncPointTree_.get(e);_(s,"Missing sync point for query tag that we're tracking");const i=nn(n.pendingWriteTree_,e);return ls(s,t,i,null)}function gc(n){return n.fold((e,t,s)=>{if(t&&ge(t))return[sn(t)];{let i=[];return t&&(i=xr(t)),U(s,(r,o)=>{i=i.concat(o)}),i}})}function lt(n){return n._queryParams.loadsAllData()&&!n._queryParams.isDefault()?new(cc())(n._repo,n._path):n}function yc(n,e){for(let t=0;t<e.length;++t){const s=e[t];if(!s._queryParams.loadsAllData()){const i=rn(s),r=n.queryToTagMap.get(i);n.queryToTagMap.delete(i),n.tagToQueryMap.delete(r)}}}function vc(){return uc++}function Cc(n,e,t){const s=e._path,i=pt(n,e),r=Lr(n,t),o=n.listenProvider_.startListening(lt(e),i,r.hashFn,r.onComplete),a=n.syncPointTree_.subtree(s);if(i)_(!ge(a.value),"If we're adding a query, it shouldn't be shadowed");else{const l=a.fold((c,u,h)=>{if(!C(c)&&u&&ge(u))return[sn(u).query];{let d=[];return u&&(d=d.concat(xr(u).map(f=>f.query))),U(h,(f,p)=>{d=d.concat(p)}),d}});for(let c=0;c<l.length;++c){const u=l[c];n.listenProvider_.stopListening(lt(u),pt(n,u))}}return o}/**
1048
+ * @license
1049
+ * Copyright 2017 Google LLC
1050
+ *
1051
+ * Licensed under the Apache License, Version 2.0 (the "License");
1052
+ * you may not use this file except in compliance with the License.
1053
+ * You may obtain a copy of the License at
1054
+ *
1055
+ * http://www.apache.org/licenses/LICENSE-2.0
1056
+ *
1057
+ * Unless required by applicable law or agreed to in writing, software
1058
+ * distributed under the License is distributed on an "AS IS" BASIS,
1059
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1060
+ * See the License for the specific language governing permissions and
1061
+ * limitations under the License.
1062
+ */class fs{constructor(e){this.node_=e}getImmediateChild(e){const t=this.node_.getImmediateChild(e);return new fs(t)}node(){return this.node_}}class _s{constructor(e,t){this.syncTree_=e,this.path_=t}getImmediateChild(e){const t=k(this.path_,e);return new _s(this.syncTree_,t)}node(){return cs(this.syncTree_,this.path_)}}const Ec=function(n){return n=n||{},n.timestamp=n.timestamp||new Date().getTime(),n},ai=function(n,e,t){if(!n||typeof n!="object")return n;if(_(".sv"in n,"Unexpected leaf node or priority contents"),typeof n[".sv"]=="string")return wc(n[".sv"],e,t);if(typeof n[".sv"]=="object")return bc(n[".sv"],e);_(!1,"Unexpected server value: "+JSON.stringify(n,null,2))},wc=function(n,e,t){switch(n){case"timestamp":return t.timestamp;default:_(!1,"Unexpected server value: "+n)}},bc=function(n,e,t){n.hasOwnProperty("increment")||_(!1,"Unexpected server value: "+JSON.stringify(n,null,2));const s=n.increment;typeof s!="number"&&_(!1,"Unexpected increment value: "+s);const i=e.node();if(_(i!==null&&typeof i<"u","Expected ChildrenNode.EMPTY_NODE for nulls"),!i.isLeafNode())return s;const o=i.getValue();return typeof o!="number"?s:o+s},Fr=function(n,e,t,s){return ps(e,new _s(t,n),s)},Wr=function(n,e,t){return ps(n,new fs(e),t)};function ps(n,e,t){const s=n.getPriority().val(),i=ai(s,e.getImmediateChild(".priority"),t);let r;if(n.isLeafNode()){const o=n,a=ai(o.getValue(),e,t);return a!==o.getValue()||i!==o.getPriority().val()?new M(a,O(i)):n}else{const o=n;return r=o,i!==o.getPriority().val()&&(r=r.updatePriority(new M(i))),o.forEachChild(N,(a,l)=>{const c=ps(l,e.getImmediateChild(a),t);c!==l&&(r=r.updateImmediateChild(a,c))}),r}}/**
1063
+ * @license
1064
+ * Copyright 2017 Google LLC
1065
+ *
1066
+ * Licensed under the Apache License, Version 2.0 (the "License");
1067
+ * you may not use this file except in compliance with the License.
1068
+ * You may obtain a copy of the License at
1069
+ *
1070
+ * http://www.apache.org/licenses/LICENSE-2.0
1071
+ *
1072
+ * Unless required by applicable law or agreed to in writing, software
1073
+ * distributed under the License is distributed on an "AS IS" BASIS,
1074
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1075
+ * See the License for the specific language governing permissions and
1076
+ * limitations under the License.
1077
+ */class ms{constructor(e="",t=null,s={children:{},childCount:0}){this.name=e,this.parent=t,this.node=s}}function gs(n,e){let t=e instanceof S?e:new S(e),s=n,i=y(t);for(;i!==null;){const r=je(s.node.children,i)||{children:{},childCount:0};s=new ms(i,s,r),t=T(t),i=y(t)}return s}function Je(n){return n.node.value}function Ur(n,e){n.node.value=e,Ln(n)}function Br(n){return n.node.childCount>0}function Sc(n){return Je(n)===void 0&&!Br(n)}function on(n,e){U(n.node.children,(t,s)=>{e(new ms(t,n,s))})}function Vr(n,e,t,s){t&&e(n),on(n,i=>{Vr(i,e,!0)})}function Ic(n,e,t){let s=n.parent;for(;s!==null;){if(e(s))return!0;s=s.parent}return!1}function Et(n){return new S(n.parent===null?n.name:Et(n.parent)+"/"+n.name)}function Ln(n){n.parent!==null&&Tc(n.parent,n.name,n)}function Tc(n,e,t){const s=Sc(t),i=ne(n.node.children,e);s&&i?(delete n.node.children[e],n.node.childCount--,Ln(n)):!s&&!i&&(n.node.children[e]=t.node,n.node.childCount++,Ln(n))}/**
1078
+ * @license
1079
+ * Copyright 2017 Google LLC
1080
+ *
1081
+ * Licensed under the Apache License, Version 2.0 (the "License");
1082
+ * you may not use this file except in compliance with the License.
1083
+ * You may obtain a copy of the License at
1084
+ *
1085
+ * http://www.apache.org/licenses/LICENSE-2.0
1086
+ *
1087
+ * Unless required by applicable law or agreed to in writing, software
1088
+ * distributed under the License is distributed on an "AS IS" BASIS,
1089
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1090
+ * See the License for the specific language governing permissions and
1091
+ * limitations under the License.
1092
+ */const kc=/[\[\].#$\/\u0000-\u001F\u007F]/,Nc=/[\[\].#$\u0000-\u001F\u007F]/,vn=10*1024*1024,ys=function(n){return typeof n=="string"&&n.length!==0&&!kc.test(n)},jr=function(n){return typeof n=="string"&&n.length!==0&&!Nc.test(n)},xc=function(n){return n&&(n=n.replace(/^\/*\.info(\/|$)/,"/")),jr(n)},Rc=function(n){return n===null||typeof n=="string"||typeof n=="number"&&!$n(n)||n&&typeof n=="object"&&ne(n,".sv")},qr=function(n,e,t,s){s&&e===void 0||an(Xt(n,"value"),e,t)},an=function(n,e,t){const s=t instanceof S?new Ka(t,n):t;if(e===void 0)throw new Error(n+"contains undefined "+Ce(s));if(typeof e=="function")throw new Error(n+"contains a function "+Ce(s)+" with contents = "+e.toString());if($n(e))throw new Error(n+"contains "+e.toString()+" "+Ce(s));if(typeof e=="string"&&e.length>vn/3&&Zt(e)>vn)throw new Error(n+"contains a string greater than "+vn+" utf8 bytes "+Ce(s)+" ('"+e.substring(0,50)+"...')");if(e&&typeof e=="object"){let i=!1,r=!1;if(U(e,(o,a)=>{if(o===".value")i=!0;else if(o!==".priority"&&o!==".sv"&&(r=!0,!ys(o)))throw new Error(n+" contains an invalid key ("+o+") "+Ce(s)+`. Keys must be non-empty strings and can't contain ".", "#", "$", "/", "[", or "]"`);Ya(s,o),an(n,a,s),Qa(s)}),i&&r)throw new Error(n+' contains ".value" child '+Ce(s)+" in addition to actual children.")}},Ac=function(n,e){let t,s;for(t=0;t<e.length;t++){s=e[t];const r=ut(s);for(let o=0;o<r.length;o++)if(!(r[o]===".priority"&&o===r.length-1)){if(!ys(r[o]))throw new Error(n+"contains an invalid key ("+r[o]+") in path "+s.toString()+`. Keys must be non-empty strings and can't contain ".", "#", "$", "/", "[", or "]"`)}}e.sort(Ha);let i=null;for(t=0;t<e.length;t++){if(s=e[t],i!==null&&K(i,s))throw new Error(n+"contains a path "+i.toString()+" that is ancestor of another path "+s.toString());i=s}},Pc=function(n,e,t,s){const i=Xt(n,"values");if(!(e&&typeof e=="object")||Array.isArray(e))throw new Error(i+" must be an object containing the children to replace.");const r=[];U(e,(o,a)=>{const l=new S(o);if(an(i,a,k(t,l)),zn(l)===".priority"&&!Rc(a))throw new Error(i+"contains an invalid value for '"+l.toString()+"', which must be a valid Firebase priority (a string, finite number, server value, or null).");r.push(l)}),Ac(i,r)},Gr=function(n,e,t,s){if(!jr(t))throw new Error(Xt(n,e)+'was an invalid path = "'+t+`". Paths must be non-empty strings and can't contain ".", "#", "$", "[", or "]"`)},Oc=function(n,e,t,s){t&&(t=t.replace(/^\/*\.info(\/|$)/,"/")),Gr(n,e,t)},vs=function(n,e){if(y(e)===".info")throw new Error(n+" failed = Can't modify data under /.info/")},Dc=function(n,e){const t=e.path.toString();if(typeof e.repoInfo.host!="string"||e.repoInfo.host.length===0||!ys(e.repoInfo.namespace)&&e.repoInfo.host.split(":")[0]!=="localhost"||t.length!==0&&!xc(t))throw new Error(Xt(n,"url")+`must be a valid firebase URL and the path can't contain ".", "#", "$", "[", or "]".`)};/**
1093
+ * @license
1094
+ * Copyright 2017 Google LLC
1095
+ *
1096
+ * Licensed under the Apache License, Version 2.0 (the "License");
1097
+ * you may not use this file except in compliance with the License.
1098
+ * You may obtain a copy of the License at
1099
+ *
1100
+ * http://www.apache.org/licenses/LICENSE-2.0
1101
+ *
1102
+ * Unless required by applicable law or agreed to in writing, software
1103
+ * distributed under the License is distributed on an "AS IS" BASIS,
1104
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1105
+ * See the License for the specific language governing permissions and
1106
+ * limitations under the License.
1107
+ */class Mc{constructor(){this.eventLists_=[],this.recursionDepth_=0}}function ln(n,e){let t=null;for(let s=0;s<e.length;s++){const i=e[s],r=i.getPath();t!==null&&!Xn(r,t.path)&&(n.eventLists_.push(t),t=null),t===null&&(t={events:[],path:r}),t.events.push(i)}t&&n.eventLists_.push(t)}function $r(n,e,t){ln(n,t),Hr(n,s=>Xn(s,e))}function Y(n,e,t){ln(n,t),Hr(n,s=>K(s,e)||K(e,s))}function Hr(n,e){n.recursionDepth_++;let t=!0;for(let s=0;s<n.eventLists_.length;s++){const i=n.eventLists_[s];if(i){const r=i.path;e(r)?(Lc(n.eventLists_[s]),n.eventLists_[s]=null):t=!1}}t&&(n.eventLists_=[]),n.recursionDepth_--}function Lc(n){for(let e=0;e<n.events.length;e++){const t=n.events[e];if(t!==null){n.events[e]=null;const s=t.getEventRunner();it&&F("event: "+t.toString()),ze(s)}}}/**
1108
+ * @license
1109
+ * Copyright 2017 Google LLC
1110
+ *
1111
+ * Licensed under the Apache License, Version 2.0 (the "License");
1112
+ * you may not use this file except in compliance with the License.
1113
+ * You may obtain a copy of the License at
1114
+ *
1115
+ * http://www.apache.org/licenses/LICENSE-2.0
1116
+ *
1117
+ * Unless required by applicable law or agreed to in writing, software
1118
+ * distributed under the License is distributed on an "AS IS" BASIS,
1119
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1120
+ * See the License for the specific language governing permissions and
1121
+ * limitations under the License.
1122
+ */const Fc="repo_interrupt",Wc=25;class Uc{constructor(e,t,s,i){this.repoInfo_=e,this.forceRestClient_=t,this.authTokenProvider_=s,this.appCheckProvider_=i,this.dataUpdateCount=0,this.statsListener_=null,this.eventQueue_=new Mc,this.nextWriteId_=1,this.interceptServerDataCallback_=null,this.onDisconnect_=Wt(),this.transactionQueueTree_=new ms,this.persistentConnection_=null,this.key=this.repoInfo_.toURLString()}toString(){return(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host}}function Bc(n,e,t){if(n.stats_=Yn(n.repoInfo_),n.forceRestClient_||ga())n.server_=new Ft(n.repoInfo_,(s,i,r,o)=>{li(n,s,i,r,o)},n.authTokenProvider_,n.appCheckProvider_),setTimeout(()=>ci(n,!0),0);else{if(typeof t<"u"&&t!==null){if(typeof t!="object")throw new Error("Only objects are supported for option databaseAuthVariableOverride");try{D(t)}catch(s){throw new Error("Invalid authOverride provided: "+s)}}n.persistentConnection_=new oe(n.repoInfo_,e,(s,i,r,o)=>{li(n,s,i,r,o)},s=>{ci(n,s)},s=>{Vc(n,s)},n.authTokenProvider_,n.appCheckProvider_,t),n.server_=n.persistentConnection_}n.authTokenProvider_.addTokenChangeListener(s=>{n.server_.refreshAuthToken(s)}),n.appCheckProvider_.addTokenChangeListener(s=>{n.server_.refreshAppCheckToken(s.token)}),n.statsReporter_=wa(n.repoInfo_,()=>new El(n.stats_,n.server_)),n.infoData_=new ml,n.infoSyncTree_=new oi({startListening:(s,i,r,o)=>{let a=[];const l=n.infoData_.getNode(s._path);return l.isEmpty()||(a=Ct(n.infoSyncTree_,s._path,l),setTimeout(()=>{o("ok")},0)),a},stopListening:()=>{}}),Cs(n,"connected",!1),n.serverSyncTree_=new oi({startListening:(s,i,r,o)=>(n.server_.listen(s,r,i,(a,l)=>{const c=o(a,l);Y(n.eventQueue_,s._path,c)}),[]),stopListening:(s,i)=>{n.server_.unlisten(s,i)}})}function Kr(n){const t=n.infoData_.getNode(new S(".info/serverTimeOffset")).val()||0;return new Date().getTime()+t}function cn(n){return Ec({timestamp:Kr(n)})}function li(n,e,t,s,i){n.dataUpdateCount++;const r=new S(e);t=n.interceptServerDataCallback_?n.interceptServerDataCallback_(e,t):t;let o=[];if(i)if(s){const l=Ot(t,c=>O(c));o=pc(n.serverSyncTree_,r,l,i)}else{const l=O(t);o=Or(n.serverSyncTree_,r,l,i)}else if(s){const l=Ot(t,c=>O(c));o=dc(n.serverSyncTree_,r,l)}else{const l=O(t);o=Ct(n.serverSyncTree_,r,l)}let a=r;o.length>0&&(a=Ke(n,r)),Y(n.eventQueue_,a,o)}function ci(n,e){Cs(n,"connected",e),e===!1&&$c(n)}function Vc(n,e){U(e,(t,s)=>{Cs(n,t,s)})}function Cs(n,e,t){const s=new S("/.info/"+e),i=O(t);n.infoData_.updateSnapshot(s,i);const r=Ct(n.infoSyncTree_,s,i);Y(n.eventQueue_,s,r)}function Es(n){return n.nextWriteId_++}function jc(n,e,t){const s=mc(n.serverSyncTree_,e);return s!=null?Promise.resolve(s):n.server_.get(e).then(i=>{const r=O(i).withIndex(e._queryParams.getIndex());Mn(n.serverSyncTree_,e,t,!0);let o;if(e._queryParams.loadsAllData())o=Ct(n.serverSyncTree_,e._path,r);else{const a=pt(n.serverSyncTree_,e);o=Or(n.serverSyncTree_,e._path,r,a)}return Y(n.eventQueue_,e._path,o),Ht(n.serverSyncTree_,e,t,null,!0),r},i=>(wt(n,"get for query "+D(e)+" failed: "+i),Promise.reject(new Error(i))))}function qc(n,e,t,s,i){wt(n,"set",{path:e.toString(),value:t,priority:s});const r=cn(n),o=O(t,s),a=cs(n.serverSyncTree_,e),l=Wr(o,a,r),c=Es(n),u=Pr(n.serverSyncTree_,e,l,c,!0);ln(n.eventQueue_,u),n.server_.put(e.toString(),o.val(!0),(d,f)=>{const p=d==="ok";p||V("set at "+e+" failed: "+d);const g=de(n.serverSyncTree_,c,!p);Y(n.eventQueue_,e,g),Fn(n,i,d,f)});const h=bs(n,e);Ke(n,h),Y(n.eventQueue_,h,[])}function Gc(n,e,t,s){wt(n,"update",{path:e.toString(),value:t});let i=!0;const r=cn(n),o={};if(U(t,(a,l)=>{i=!1,o[a]=Fr(k(e,a),O(l),n.serverSyncTree_,r)}),i)F("update() called with empty data. Don't do anything."),Fn(n,s,"ok",void 0);else{const a=Es(n),l=hc(n.serverSyncTree_,e,o,a);ln(n.eventQueue_,l),n.server_.merge(e.toString(),t,(c,u)=>{const h=c==="ok";h||V("update at "+e+" failed: "+c);const d=de(n.serverSyncTree_,a,!h),f=d.length>0?Ke(n,e):e;Y(n.eventQueue_,f,d),Fn(n,s,c,u)}),U(t,c=>{const u=bs(n,k(e,c));Ke(n,u)}),Y(n.eventQueue_,e,[])}}function $c(n){wt(n,"onDisconnectEvents");const e=cn(n),t=Wt();xn(n.onDisconnect_,w(),(i,r)=>{const o=Fr(i,r,n.serverSyncTree_,e);gr(t,i,o)});let s=[];xn(t,w(),(i,r)=>{s=s.concat(Ct(n.serverSyncTree_,i,r));const o=bs(n,i);Ke(n,o)}),n.onDisconnect_=Wt(),Y(n.eventQueue_,w(),s)}function Hc(n,e,t){let s;y(e._path)===".info"?s=Mn(n.infoSyncTree_,e,t):s=Mn(n.serverSyncTree_,e,t),$r(n.eventQueue_,e._path,s)}function Yr(n,e,t){let s;y(e._path)===".info"?s=Ht(n.infoSyncTree_,e,t):s=Ht(n.serverSyncTree_,e,t),$r(n.eventQueue_,e._path,s)}function Kc(n){n.persistentConnection_&&n.persistentConnection_.interrupt(Fc)}function wt(n,...e){let t="";n.persistentConnection_&&(t=n.persistentConnection_.id+":"),F(t,...e)}function Fn(n,e,t,s){e&&ze(()=>{if(t==="ok")e(null);else{const i=(t||"error").toUpperCase();let r=i;s&&(r+=": "+s);const o=new Error(r);o.code=i,e(o)}})}function Qr(n,e,t){return cs(n.serverSyncTree_,e,t)||m.EMPTY_NODE}function ws(n,e=n.transactionQueueTree_){if(e||un(n,e),Je(e)){const t=Xr(n,e);_(t.length>0,"Sending zero length transaction queue"),t.every(i=>i.status===0)&&Yc(n,Et(e),t)}else Br(e)&&on(e,t=>{ws(n,t)})}function Yc(n,e,t){const s=t.map(c=>c.currentWriteId),i=Qr(n,e,s);let r=i;const o=i.hash();for(let c=0;c<t.length;c++){const u=t[c];_(u.status===0,"tryToSendTransactionQueue_: items in queue should all be run."),u.status=1,u.retryCount++;const h=B(e,u.path);r=r.updateChild(h,u.currentOutputSnapshotRaw)}const a=r.val(!0),l=e;n.server_.put(l.toString(),a,c=>{wt(n,"transaction put response",{path:l.toString(),status:c});let u=[];if(c==="ok"){const h=[];for(let d=0;d<t.length;d++)t[d].status=2,u=u.concat(de(n.serverSyncTree_,t[d].currentWriteId)),t[d].onComplete&&h.push(()=>t[d].onComplete(null,!0,t[d].currentOutputSnapshotResolved)),t[d].unwatcher();un(n,gs(n.transactionQueueTree_,e)),ws(n,n.transactionQueueTree_),Y(n.eventQueue_,e,u);for(let d=0;d<h.length;d++)ze(h[d])}else{if(c==="datastale")for(let h=0;h<t.length;h++)t[h].status===3?t[h].status=4:t[h].status=0;else{V("transaction at "+l.toString()+" failed: "+c);for(let h=0;h<t.length;h++)t[h].status=4,t[h].abortReason=c}Ke(n,e)}},o)}function Ke(n,e){const t=zr(n,e),s=Et(t),i=Xr(n,t);return Qc(n,i,s),s}function Qc(n,e,t){if(e.length===0)return;const s=[];let i=[];const o=e.filter(a=>a.status===0).map(a=>a.currentWriteId);for(let a=0;a<e.length;a++){const l=e[a],c=B(t,l.path);let u=!1,h;if(_(c!==null,"rerunTransactionsUnderNode_: relativePath should not be null."),l.status===4)u=!0,h=l.abortReason,i=i.concat(de(n.serverSyncTree_,l.currentWriteId,!0));else if(l.status===0)if(l.retryCount>=Wc)u=!0,h="maxretry",i=i.concat(de(n.serverSyncTree_,l.currentWriteId,!0));else{const d=Qr(n,l.path,o);l.currentInputSnapshot=d;const f=e[a].update(d.val());if(f!==void 0){an("transaction failed: Data returned ",f,l.path);let p=O(f);typeof f=="object"&&f!=null&&ne(f,".priority")||(p=p.updatePriority(d.getPriority()));const b=l.currentWriteId,A=cn(n),x=Wr(p,d,A);l.currentOutputSnapshotRaw=p,l.currentOutputSnapshotResolved=x,l.currentWriteId=Es(n),o.splice(o.indexOf(b),1),i=i.concat(Pr(n.serverSyncTree_,l.path,x,l.currentWriteId,l.applyLocally)),i=i.concat(de(n.serverSyncTree_,b,!0))}else u=!0,h="nodata",i=i.concat(de(n.serverSyncTree_,l.currentWriteId,!0))}Y(n.eventQueue_,t,i),i=[],u&&(e[a].status=2,(function(d){setTimeout(d,Math.floor(0))})(e[a].unwatcher),e[a].onComplete&&(h==="nodata"?s.push(()=>e[a].onComplete(null,!1,e[a].currentInputSnapshot)):s.push(()=>e[a].onComplete(new Error(h),!1,null))))}un(n,n.transactionQueueTree_);for(let a=0;a<s.length;a++)ze(s[a]);ws(n,n.transactionQueueTree_)}function zr(n,e){let t,s=n.transactionQueueTree_;for(t=y(e);t!==null&&Je(s)===void 0;)s=gs(s,t),e=T(e),t=y(e);return s}function Xr(n,e){const t=[];return Jr(n,e,t),t.sort((s,i)=>s.order-i.order),t}function Jr(n,e,t){const s=Je(e);if(s)for(let i=0;i<s.length;i++)t.push(s[i]);on(e,i=>{Jr(n,i,t)})}function un(n,e){const t=Je(e);if(t){let s=0;for(let i=0;i<t.length;i++)t[i].status!==2&&(t[s]=t[i],s++);t.length=s,Ur(e,t.length>0?t:void 0)}on(e,s=>{un(n,s)})}function bs(n,e){const t=Et(zr(n,e)),s=gs(n.transactionQueueTree_,e);return Ic(s,i=>{Cn(n,i)}),Cn(n,s),Vr(s,i=>{Cn(n,i)}),t}function Cn(n,e){const t=Je(e);if(t){const s=[];let i=[],r=-1;for(let o=0;o<t.length;o++)t[o].status===3||(t[o].status===1?(_(r===o-1,"All SENT items should be at beginning of queue."),r=o,t[o].status=3,t[o].abortReason="set"):(_(t[o].status===0,"Unexpected transaction status in abort"),t[o].unwatcher(),i=i.concat(de(n.serverSyncTree_,t[o].currentWriteId,!0)),t[o].onComplete&&s.push(t[o].onComplete.bind(null,new Error("set"),!1,null))));r===-1?Ur(e,void 0):t.length=r+1,Y(n.eventQueue_,Et(e),i);for(let o=0;o<s.length;o++)ze(s[o])}}/**
1123
+ * @license
1124
+ * Copyright 2017 Google LLC
1125
+ *
1126
+ * Licensed under the Apache License, Version 2.0 (the "License");
1127
+ * you may not use this file except in compliance with the License.
1128
+ * You may obtain a copy of the License at
1129
+ *
1130
+ * http://www.apache.org/licenses/LICENSE-2.0
1131
+ *
1132
+ * Unless required by applicable law or agreed to in writing, software
1133
+ * distributed under the License is distributed on an "AS IS" BASIS,
1134
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1135
+ * See the License for the specific language governing permissions and
1136
+ * limitations under the License.
1137
+ */function zc(n){let e="";const t=n.split("/");for(let s=0;s<t.length;s++)if(t[s].length>0){let i=t[s];try{i=decodeURIComponent(i.replace(/\+/g," "))}catch{}e+="/"+i}return e}function Xc(n){const e={};n.charAt(0)==="?"&&(n=n.substring(1));for(const t of n.split("&")){if(t.length===0)continue;const s=t.split("=");s.length===2?e[decodeURIComponent(s[0])]=decodeURIComponent(s[1]):V(`Invalid query segment '${t}' in query '${n}'`)}return e}const ui=function(n,e){const t=Jc(n),s=t.namespace;t.domain==="firebase.com"&&ae(t.host+" is no longer supported. Please use <YOUR FIREBASE>.firebaseio.com instead"),(!s||s==="undefined")&&t.domain!=="localhost"&&ae("Cannot parse Firebase url. Please use https://<YOUR FIREBASE>.firebaseio.com"),t.secure||la();const i=t.scheme==="ws"||t.scheme==="wss";return{repoInfo:new er(t.host,t.secure,s,i,e,"",s!==t.subdomain),path:new S(t.pathString)}},Jc=function(n){let e="",t="",s="",i="",r="",o=!0,a="https",l=443;if(typeof n=="string"){let c=n.indexOf("//");c>=0&&(a=n.substring(0,c-1),n=n.substring(c+2));let u=n.indexOf("/");u===-1&&(u=n.length);let h=n.indexOf("?");h===-1&&(h=n.length),e=n.substring(0,Math.min(u,h)),u<h&&(i=zc(n.substring(u,h)));const d=Xc(n.substring(Math.min(n.length,h)));c=e.indexOf(":"),c>=0?(o=a==="https"||a==="wss",l=parseInt(e.substring(c+1),10)):c=e.length;const f=e.slice(0,c);if(f.toLowerCase()==="localhost")t="localhost";else if(f.split(".").length<=2)t=f;else{const p=e.indexOf(".");s=e.substring(0,p).toLowerCase(),t=e.substring(p+1),r=s}"ns"in d&&(r=d.ns)}return{host:e,port:l,domain:t,subdomain:s,secure:o,scheme:a,pathString:i,namespace:r}};/**
1138
+ * @license
1139
+ * Copyright 2017 Google LLC
1140
+ *
1141
+ * Licensed under the Apache License, Version 2.0 (the "License");
1142
+ * you may not use this file except in compliance with the License.
1143
+ * You may obtain a copy of the License at
1144
+ *
1145
+ * http://www.apache.org/licenses/LICENSE-2.0
1146
+ *
1147
+ * Unless required by applicable law or agreed to in writing, software
1148
+ * distributed under the License is distributed on an "AS IS" BASIS,
1149
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1150
+ * See the License for the specific language governing permissions and
1151
+ * limitations under the License.
1152
+ */const hi="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz",Zc=(function(){let n=0;const e=[];return function(t){const s=t===n;n=t;let i;const r=new Array(8);for(i=7;i>=0;i--)r[i]=hi.charAt(t%64),t=Math.floor(t/64);_(t===0,"Cannot push at time == 0");let o=r.join("");if(s){for(i=11;i>=0&&e[i]===63;i--)e[i]=0;e[i]++}else for(i=0;i<12;i++)e[i]=Math.floor(Math.random()*64);for(i=0;i<12;i++)o+=hi.charAt(e[i]);return _(o.length===20,"nextPushId: Length should be 20."),o}})();/**
1153
+ * @license
1154
+ * Copyright 2017 Google LLC
1155
+ *
1156
+ * Licensed under the Apache License, Version 2.0 (the "License");
1157
+ * you may not use this file except in compliance with the License.
1158
+ * You may obtain a copy of the License at
1159
+ *
1160
+ * http://www.apache.org/licenses/LICENSE-2.0
1161
+ *
1162
+ * Unless required by applicable law or agreed to in writing, software
1163
+ * distributed under the License is distributed on an "AS IS" BASIS,
1164
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1165
+ * See the License for the specific language governing permissions and
1166
+ * limitations under the License.
1167
+ */class Zr{constructor(e,t,s,i){this.eventType=e,this.eventRegistration=t,this.snapshot=s,this.prevName=i}getPath(){const e=this.snapshot.ref;return this.eventType==="value"?e._path:e.parent._path}getEventType(){return this.eventType}getEventRunner(){return this.eventRegistration.getEventRunner(this)}toString(){return this.getPath().toString()+":"+this.eventType+":"+D(this.snapshot.exportVal())}}class eo{constructor(e,t,s){this.eventRegistration=e,this.error=t,this.path=s}getPath(){return this.path}getEventType(){return"cancel"}getEventRunner(){return this.eventRegistration.getEventRunner(this)}toString(){return this.path.toString()+":cancel"}}/**
1168
+ * @license
1169
+ * Copyright 2017 Google LLC
1170
+ *
1171
+ * Licensed under the Apache License, Version 2.0 (the "License");
1172
+ * you may not use this file except in compliance with the License.
1173
+ * You may obtain a copy of the License at
1174
+ *
1175
+ * http://www.apache.org/licenses/LICENSE-2.0
1176
+ *
1177
+ * Unless required by applicable law or agreed to in writing, software
1178
+ * distributed under the License is distributed on an "AS IS" BASIS,
1179
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1180
+ * See the License for the specific language governing permissions and
1181
+ * limitations under the License.
1182
+ */class Ss{constructor(e,t){this.snapshotCallback=e,this.cancelCallback=t}onValue(e,t){this.snapshotCallback.call(null,e,t)}onCancel(e){return _(this.hasCancelCallback,"Raising a cancel event on a listener with no cancel callback"),this.cancelCallback.call(null,e)}get hasCancelCallback(){return!!this.cancelCallback}matches(e){return this.snapshotCallback===e.snapshotCallback||this.snapshotCallback.userCallback!==void 0&&this.snapshotCallback.userCallback===e.snapshotCallback.userCallback&&this.snapshotCallback.context===e.snapshotCallback.context}}/**
1183
+ * @license
1184
+ * Copyright 2020 Google LLC
1185
+ *
1186
+ * Licensed under the Apache License, Version 2.0 (the "License");
1187
+ * you may not use this file except in compliance with the License.
1188
+ * You may obtain a copy of the License at
1189
+ *
1190
+ * http://www.apache.org/licenses/LICENSE-2.0
1191
+ *
1192
+ * Unless required by applicable law or agreed to in writing, software
1193
+ * distributed under the License is distributed on an "AS IS" BASIS,
1194
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1195
+ * See the License for the specific language governing permissions and
1196
+ * limitations under the License.
1197
+ */class Is{constructor(e,t,s,i){this._repo=e,this._path=t,this._queryParams=s,this._orderByCalled=i}get key(){return C(this._path)?null:zn(this._path)}get ref(){return new se(this._repo,this._path)}get _queryIdentifier(){const e=zs(this._queryParams),t=Hn(e);return t==="{}"?"default":t}get _queryObject(){return zs(this._queryParams)}isEqual(e){if(e=Re(e),!(e instanceof Is))return!1;const t=this._repo===e._repo,s=Xn(this._path,e._path),i=this._queryIdentifier===e._queryIdentifier;return t&&s&&i}toJSON(){return this.toString()}toString(){return this._repo.toString()+$a(this._path)}}class se extends Is{constructor(e,t){super(e,t,new ts,!1)}get parent(){const e=cr(this._path);return e===null?null:new se(this._repo,e)}get root(){let e=this;for(;e.parent!==null;)e=e.parent;return e}}class Ye{constructor(e,t,s){this._node=e,this.ref=t,this._index=s}get priority(){return this._node.getPriority().val()}get key(){return this.ref.key}get size(){return this._node.numChildren()}child(e){const t=new S(e),s=Te(this.ref,e);return new Ye(this._node.getChild(t),s,N)}exists(){return!this._node.isEmpty()}exportVal(){return this._node.val(!0)}forEach(e){return this._node.isLeafNode()?!1:!!this._node.forEachChild(this._index,(s,i)=>e(new Ye(i,Te(this.ref,s),N)))}hasChild(e){const t=new S(e);return!this._node.getChild(t).isEmpty()}hasChildren(){return this._node.isLeafNode()?!1:!this._node.isEmpty()}toJSON(){return this.exportVal()}val(){return this._node.val()}}function eu(n,e){return n=Re(n),n._checkNotDeleted("ref"),e!==void 0?Te(n._root,e):n._root}function Te(n,e){return n=Re(n),y(n._path)===null?Oc("child","path",e):Gr("child","path",e),new se(n._repo,k(n._path,e))}function di(n,e){n=Re(n),vs("push",n._path),qr("push",e,n._path,!0);const t=Kr(n._repo),s=Zc(t),i=Te(n,s),r=Te(n,s);let o;return e!=null?o=Ts(r,e).then(()=>r):o=Promise.resolve(r),i.then=o.then.bind(o),i.catch=o.then.bind(o,void 0),i}function tu(n){return vs("remove",n._path),Ts(n,null)}function Ts(n,e){n=Re(n),vs("set",n._path),qr("set",e,n._path,!1);const t=new Jt;return qc(n._repo,n._path,e,null,t.wrapCallback(()=>{})),t.promise}function nu(n,e){Pc("update",e,n._path);const t=new Jt;return Gc(n._repo,n._path,e,t.wrapCallback(()=>{})),t.promise}function fi(n){n=Re(n);const e=new Ss(()=>{}),t=new bt(e);return jc(n._repo,n,t).then(s=>new Ye(s,new se(n._repo,n._path),n._queryParams.getIndex()))}class bt{constructor(e){this.callbackContext=e}respondsTo(e){return e==="value"}createEvent(e,t){const s=t._queryParams.getIndex();return new Zr("value",this,new Ye(e.snapshotNode,new se(t._repo,t._path),s))}getEventRunner(e){return e.getEventType()==="cancel"?()=>this.callbackContext.onCancel(e.error):()=>this.callbackContext.onValue(e.snapshot,null)}createCancelEvent(e,t){return this.callbackContext.hasCancelCallback?new eo(this,e,t):null}matches(e){return e instanceof bt?!e.callbackContext||!this.callbackContext?!0:e.callbackContext.matches(this.callbackContext):!1}hasAnyCallback(){return this.callbackContext!==null}}class ks{constructor(e,t){this.eventType=e,this.callbackContext=t}respondsTo(e){let t=e==="children_added"?"child_added":e;return t=t==="children_removed"?"child_removed":t,this.eventType===t}createCancelEvent(e,t){return this.callbackContext.hasCancelCallback?new eo(this,e,t):null}createEvent(e,t){_(e.childName!=null,"Child events should have a childName.");const s=Te(new se(t._repo,t._path),e.childName),i=t._queryParams.getIndex();return new Zr(e.type,this,new Ye(e.snapshotNode,s,i),e.prevName)}getEventRunner(e){return e.getEventType()==="cancel"?()=>this.callbackContext.onCancel(e.error):()=>this.callbackContext.onValue(e.snapshot,e.prevName)}matches(e){return e instanceof ks?this.eventType===e.eventType&&(!this.callbackContext||!e.callbackContext||this.callbackContext.matches(e.callbackContext)):!1}hasAnyCallback(){return!!this.callbackContext}}function su(n,e,t,s,i){const r=new Ss(t,void 0),o=new bt(r);return Hc(n._repo,n,o),()=>Yr(n._repo,n,o)}function _i(n,e,t,s){return su(n,"value",e)}function iu(n,e,t){let s=null;const i=t?new Ss(t):null;e==="value"?s=new bt(i):e&&(s=new ks(e,i)),Yr(n._repo,n,s)}sc(se);lc(se);/**
1198
+ * @license
1199
+ * Copyright 2020 Google LLC
1200
+ *
1201
+ * Licensed under the Apache License, Version 2.0 (the "License");
1202
+ * you may not use this file except in compliance with the License.
1203
+ * You may obtain a copy of the License at
1204
+ *
1205
+ * http://www.apache.org/licenses/LICENSE-2.0
1206
+ *
1207
+ * Unless required by applicable law or agreed to in writing, software
1208
+ * distributed under the License is distributed on an "AS IS" BASIS,
1209
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1210
+ * See the License for the specific language governing permissions and
1211
+ * limitations under the License.
1212
+ */const ru="FIREBASE_DATABASE_EMULATOR_HOST",Wn={};let ou=!1;function au(n,e,t,s){const i=e.lastIndexOf(":"),r=e.substring(0,i),o=xi(r);n.repoInfo_=new er(e,o,n.repoInfo_.namespace,n.repoInfo_.webSocketOnly,n.repoInfo_.nodeAdmin,n.repoInfo_.persistenceKey,n.repoInfo_.includeNamespaceInQueryParams,!0,t),s&&(n.authTokenProvider_=s)}function lu(n,e,t,s,i){let r=s||n.options.databaseURL;r===void 0&&(n.options.projectId||ae("Can't determine Firebase Database URL. Be sure to include a Project ID when calling firebase.initializeApp()."),F("Using default host for project ",n.options.projectId),r=`${n.options.projectId}-default-rtdb.firebaseio.com`);let o=ui(r,i),a=o.repoInfo,l;typeof process<"u"&&(l={}[ru]),l?(r=`http://${l}?ns=${a.namespace}`,o=ui(r,i),a=o.repoInfo):o.repoInfo.secure;const c=new va(n.name,n.options,e);Dc("Invalid Firebase Database URL",o),C(o.path)||ae("Database URL must point to the root of a Firebase Database (not including a child path).");const u=uu(a,n,c,new ya(n,t));return new hu(u,n)}function cu(n,e){const t=Wn[e];(!t||t[n.key]!==n)&&ae(`Database ${e}(${n.repoInfo_}) has already been deleted.`),Kc(n),delete t[n.key]}function uu(n,e,t,s){let i=Wn[e.name];i||(i={},Wn[e.name]=i);let r=i[n.toURLString()];return r&&ae("Database initialized multiple times. Please make sure the format of the database URL matches with each database() call."),r=new Uc(n,ou,t,s),i[n.toURLString()]=r,r}class hu{constructor(e,t){this._repoInternal=e,this.app=t,this.type="database",this._instanceStarted=!1}get _repo(){return this._instanceStarted||(Bc(this._repoInternal,this.app.options.appId,this.app.options.databaseAuthVariableOverride),this._instanceStarted=!0),this._repoInternal}get _root(){return this._rootInternal||(this._rootInternal=new se(this._repo,w())),this._rootInternal}_delete(){return this._rootInternal!==null&&(cu(this._repo,this.app.name),this._repoInternal=null,this._rootInternal=null),Promise.resolve()}_checkNotDeleted(e){this._rootInternal===null&&ae("Cannot call "+e+" on a deleted database.")}}function du(n=Ao(),e){const t=xo(n,"database").getImmediate({identifier:e});if(!t._instanceStarted){const s=Ro("database");s&&to(t,...s)}return t}function to(n,e,t,s={}){n=Re(n),n._checkNotDeleted("useEmulator");const i=`${e}:${t}`,r=n._repoInternal;if(n._instanceStarted){if(i===n._repoInternal.repoInfo_.host&&To(s,r.repoInfo_.emulatorOptions))return;ae("connectDatabaseEmulator() cannot initialize or alter the emulator configuration after the database instance has started.")}let o;if(r.repoInfo_.nodeAdmin)s.mockUserToken&&ae('mockUserToken is not supported by the Admin SDK. For client access with mock users, please use the "firebase" package instead of "firebase-admin".'),o=new At(At.OWNER);else if(s.mockUserToken){const a=typeof s.mockUserToken=="string"?s.mockUserToken:ko(s.mockUserToken,n.app.options.projectId);o=new At(a)}xi(e)&&No(e),au(r,i,s,o)}/**
1213
+ * @license
1214
+ * Copyright 2021 Google LLC
1215
+ *
1216
+ * Licensed under the Apache License, Version 2.0 (the "License");
1217
+ * you may not use this file except in compliance with the License.
1218
+ * You may obtain a copy of the License at
1219
+ *
1220
+ * http://www.apache.org/licenses/LICENSE-2.0
1221
+ *
1222
+ * Unless required by applicable law or agreed to in writing, software
1223
+ * distributed under the License is distributed on an "AS IS" BASIS,
1224
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1225
+ * See the License for the specific language governing permissions and
1226
+ * limitations under the License.
1227
+ */function fu(n){na(Po),ho(new fo("database",(e,{instanceIdentifier:t})=>{const s=e.getProvider("app").getImmediate(),i=e.getProvider("auth-internal"),r=e.getProvider("app-check-internal");return lu(s,i,r,t)},"PUBLIC").setMultipleInstances(!0)),Rs(Os,Ds,n),Rs(Os,Ds,"esm2020")}oe.prototype.simpleListen=function(n,e){this.sendRequest("q",{p:n},e)};oe.prototype.echo=function(n,e){this.sendRequest("echo",{d:n},e)};fu();const _u="firebase-admin is not available in the browser. The playground only consumes @pyric/rtdb's modular surface (getDatabase, ref, set, get, …) at preview time. If you hit this, an admin code path leaked into the client bundle.";new Proxy({},{get(n,e){if(e!=="then")throw new Error(`${_u} Attempted access: ${String(e)}`)}});Z({databaseUrl:W().url()});xe(["RULES_FETCH_FAILED","RULES_PARSE_FAILED","INVALID_RULES_JSON","SHALLOW_FETCH_FAILED"]);xe(["READ_FAILED","WRITE_FAILED","PERMISSION_DENIED","NOT_FOUND"]);Z({path:W().describe("Database path to write to"),data:Ii().transform(n=>n??null).describe("The data to write"),operation:xe(["set","update","push"]).describe("Write operation type"),auth:Ti([Z({uid:W(),token:Pt(xt())}),ki()]).describe("Auth context for simulation")});xe(["WRITE_FAILED","PERMISSION_DENIED","INVALID_RULES_JSON"]);const pu=new Set(["__proto__","prototype","constructor"]);function E(n){if(n===""||n==="/")return[];const e=n.split("/").filter(t=>t.length>0);for(const t of e)if(pu.has(t))throw new Error(`Invalid RTDB path segment '${t}': the keys __proto__, prototype, and constructor are reserved and cannot appear in a path.`);return e}function P(n){return n.length===0?"/":"/"+n.join("/")}function he(n){if(n===null||typeof n!="object")return n;if(Array.isArray(n))return n.map(t=>he(t));const e={};for(const[t,s]of Object.entries(n))e[t]=he(s);return e}function pi(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function Ue(n,e){if(Object.is(n,e))return!0;if(Array.isArray(n)||Array.isArray(e))return!Array.isArray(n)||!Array.isArray(e)||n.length!==e.length?!1:n.every((i,r)=>Ue(i,e[r]));if(!pi(n)||!pi(e))return!1;const t=Object.keys(n),s=Object.keys(e);return t.length!==s.length?!1:t.every(i=>i in e&&Ue(n[i],e[i]))}class mu{root={};snapshot(){return he(this.root)}restore(e){this.root=he(e)}read(e){const t=E(e);let s=this.root;for(const i of t){if(s===null||typeof s!="object"||Array.isArray(s))return null;const r=s;if(!Object.hasOwn(r,i))return null;s=r[i]}return he(s)}write(e,t){const s=E(e),i=this.read(e);if(s.length===0)return t===null?(this.root={},i):(this.root=he(t),i);(this.root===null||typeof this.root!="object"||Array.isArray(this.root))&&(this.root={});let r=this.root;for(let a=0;a<s.length-1;a++){const l=s[a],c=Object.hasOwn(r,l)?r[l]:void 0;if(c==null||typeof c!="object"||Array.isArray(c)){const u={};r[l]=u,r=u}else r=c}const o=s[s.length-1];return t===null?(delete r[o],this.trim(s)):r[o]=he(t),i}multiUpdate(e){const s=Object.entries(e).map(([r,o])=>({path:P(E(r)),value:o}));for(let r=0;r<s.length;r++)for(let o=r+1;o<s.length;o++){const a=s[r].path,l=s[o].path;if(a===l)throw new Error(`multi-path update: duplicate path '${a}'.`);const c=a==="/"?"/":a+"/",u=l==="/"?"/":l+"/";if(a!=="/"&&l.startsWith(c))throw new Error(`multi-path update: '${l}' is a descendant of '${a}'.`);if(l!=="/"&&a.startsWith(u))throw new Error(`multi-path update: '${a}' is a descendant of '${l}'.`)}const i=[];for(const{path:r,value:o}of s){const a=this.write(r,o);i.push({path:r,prior:a})}return i}shallowUpdate(e,t){const s=[],i=E(e);for(const[r,o]of Object.entries(t)){const a=[...i,...E(r)],l=P(a),c=this.write(l,o);s.push({path:l,prior:c})}return s}trim(e){if(!(this.root===null||typeof this.root!="object"||Array.isArray(this.root)))for(let t=e.length-1;t>=1;t--){const s=e.slice(0,t),i=e[t-1];let r=this.root;for(let a=0;a<s.length-1;a++){const l=r[s[a]];if(l==null||typeof l!="object"||Array.isArray(l))return;r=l}const o=r[i];if(o!==void 0&&typeof o=="object"&&o!==null&&!Array.isArray(o)&&Object.keys(o).length===0){delete r[i];continue}return}}}const mi="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz";let gi=0;const ye=new Array(12).fill(0);function gu(n=Date.now()){const e=n===gi;gi=n;const t=new Array(8);let s=n;for(let r=7;r>=0;r--)t[r]=mi.charAt(s%64),s=Math.floor(s/64);if(s!==0)throw new Error("RTDB push-id: timestamp overflow.");let i=t.join("");if(e){let r;for(r=11;r>=0&&ye[r]===63;r--)ye[r]=0;if(r<0)for(let o=0;o<12;o++)ye[o]=Math.floor(Math.random()*64);else ye[r]=(ye[r]??0)+1}else for(let r=0;r<12;r++)ye[r]=Math.floor(Math.random()*64);for(let r=0;r<12;r++)i+=mi.charAt(ye[r]);if(i.length!==20)throw new Error(`RTDB push-id: bad length ${i.length}.`);return i}function yu(n){return n===null||typeof n!="object"?!1:n[".sv"]==="timestamp"}function vu(n){if(n===null||typeof n!="object")return!1;const e=n[".sv"];return e!==null&&typeof e=="object"&&typeof e.increment=="number"}function te(n,e,t){if(yu(n))return e;if(vu(n)){const r=n[".sv"].increment;return(typeof t=="number"?t:0)+r}if(n===null||typeof n!="object")return n;if(Array.isArray(n))return n.map((r,o)=>te(r,e,Array.isArray(t)?t[o]:void 0));const s=t!==null&&typeof t=="object"&&!Array.isArray(t)?t:void 0,i={};for(const[r,o]of Object.entries(n))i[r]=te(o,e,s?s[r]:void 0);return i}function Cu(){return{".sv":"timestamp"}}function ve(){const n=new Error("PERMISSION_DENIED: Permission denied");return n.code="PERMISSION_DENIED",n}class Eu{ir=null;handler=new ta;setRules(e){if(e===null){this.ir=null;return}this.ir=zo.mapToIR(e,null,"sandbox://rtdb")}hasRules(){return this.ir!==null}check(e,t,s){return this.evaluate(e,t,s).check}evaluate(e,t,s){if(this.ir===null)return{check:"allow",reasons:["No RTDB rules loaded; default allow."]};const i=s.auth===null?null:{uid:s.auth.uid,token:s.auth.token??{}},r=this.handler.execute(this.ir,{operation:e,path:t==="/"?"/":t,auth:i,mockData:s.mockData,newData:s.newData});return r.success?{check:r.data.allowed?"allow":"deny",reasons:[`${r.data.matchedPath} ${e} ${r.data.allowed?"ALLOW":"DENY"}: ${r.data.reason}`],matchedPath:r.data.matchedPath,matchedRule:r.data.matchedRule,reason:r.data.reason,pathVariableBindings:r.data.pathVariableBindings}:r.error.code==="NO_MATCHING_RULE"?{check:"no-rule",reasons:[r.error.message],errorCode:r.error.code,errorMessage:r.error.message}:{check:"no-rule",reasons:[r.error.message],errorCode:r.error.code,errorMessage:r.error.message}}}function no(n,e){if(n===e)return 0;if(n===null)return-1;if(e===null)return 1;const t=yi(n),s=yi(e);return t!==s?t-s:typeof n=="number"&&typeof e=="number"?n<e?-1:n>e?1:0:typeof n=="boolean"&&typeof e=="boolean"?n===e?0:n?1:-1:typeof n=="string"&&typeof e=="string"?n<e?-1:n>e?1:0:0}function yi(n){return n===null?0:typeof n=="boolean"?1:typeof n=="number"?2:typeof n=="string"?3:4}const wu=/^-?(0*)\d{1,10}$/,bu=-2147483648,Su=2147483647;function vi(n){if(wu.test(n)){const e=Number(n);if(e>=bu&&e<=Su)return e}return null}function Kt(n,e){if(n===e)return 0;const t=vi(n),s=vi(e);return t!==null?s!==null?t-s===0?n.length-e.length:t-s:-1:s!==null?1:n<e?-1:1}function Un(n,e,t){const s=n??{kind:"key"};switch(s.kind){case"key":return e;case"value":return t;case"child":{if(t===null||typeof t!="object"||Array.isArray(t))return null;const i=s.path.split("/").filter(o=>o.length>0);let r=t;for(const o of i){if(r===null||typeof r!="object"||Array.isArray(r))return null;r=r[o]??null}return r}}}function De(n,e){if(n===null||typeof n!="object"||Array.isArray(n))return[];let s=Object.entries(n).map(([r,o])=>({key:r,value:o}));const i=(e.orderBy??{kind:"key"}).kind==="key";s.sort((r,o)=>{if(i)return Kt(r.key,o.key);const a=Un(e.orderBy,r.key,r.value),l=Un(e.orderBy,o.key,o.value),c=no(a,l);return c!==0?c:Kt(r.key,o.key)});for(const r of e.bounds)s=s.filter(o=>Iu(r,o,e.orderBy));if(e.limit){const r=e.limit.n;e.limit.kind==="limitToFirst"?s=s.slice(0,r):s=r>=s.length?s:s.slice(s.length-r)}return s}function Iu(n,e,t){const i=(t??{kind:"key"}).kind==="key"?Kt(e.key,String(n.value)):no(Un(t,e.key,e.value),n.value),r=o=>Kt(e.key,o);switch(n.kind){case"startAt":return i>0?!0:i<0?!1:n.key===void 0||r(n.key)>=0;case"startAfter":return i>0?!0:i<0||n.key===void 0?!1:r(n.key)>0;case"endAt":return i<0?!0:i>0?!1:n.key===void 0||r(n.key)<=0;case"endBefore":return i<0?!0:i>0||n.key===void 0?!1:r(n.key)<0;case"equalTo":return i!==0?!1:n.key===void 0||r(n.key)===0}}const Tu=/[\[\].#$/\u0000-\u001F\u007F]/;function ku(n){return n.length!==0&&!Tu.test(n)}function Nu(n){return typeof n=="number"&&(Number.isNaN(n)||n===1/0||n===-1/0)}function xu(n){return n===".priority"||n===".value"||n===".sv"}function Ru(n,e){Bn(n,e,"set")}function Bn(n,e,t){if(n===void 0)throw new Error(`${t} failed: value argument contains undefined in property '${e}'`);if(typeof n=="function")throw new Error(`${t} failed: value argument contains a function in property '${e}'`);if(Nu(n))throw new Error(`${t} failed: value argument contains ${String(n)} in property '${e}'`);if(!(n===null||typeof n!="object")){if(Array.isArray(n)){for(let s=0;s<n.length;s++){if(!(s in n))continue;const i=n[s];i!==void 0&&Bn(i,`${e}/${s}`,t)}return}for(const[s,i]of Object.entries(n)){if(!xu(s)&&!ku(s))throw new Error(`${t} failed: value argument contains an invalid key (${s}) in path ${e}. Keys must be non-empty strings and can't contain ".", "#", "$", "/", "[", or "]"`);Bn(i,`${e}/${s}`,t)}}}function ce(n,e){return Ru(n,e),Vn(n)}function Vn(n){if(n==null)return null;if(typeof n!="object")return n;if(Array.isArray(n)){const t={};for(let s=0;s<n.length;s++){if(!(s in n))continue;const i=Vn(n[s]);i!==null&&(t[String(s)]=i)}return Object.keys(t).length===0?null:t}const e={};for(const[t,s]of Object.entries(n)){if(t===".sv"){e[t]=s;continue}const i=Vn(s);i!==null&&(e[t]=i)}return Object.keys(e).length===0?null:e}function Be(n){if(n===null||typeof n!="object")return n;if(Array.isArray(n))return n.map(o=>Be(o));const e=n,t=Object.keys(e);let s=t.length>0,i=0;for(const o of t)if(/^(0|[1-9]\d*)$/.test(o))i=Math.max(i,Number(o));else{s=!1;break}if(s&&i<2*t.length){const o=[];for(let a=0;a<=i;a++){const l=e[String(a)];o[a]=l===void 0?null:Be(l)}return o}const r={};for(const[o,a]of Object.entries(e))r[o]=Be(a);return r}class Au{tree=new mu;rules=new Eu;valueListeners=new Set;childListeners=new Set;nextId=0;writeSubscribers=new Set;sandbox;constructor(e){this.sandbox=e}emitRtdbEvent(e,t,s,i={}){if(this.sandbox)try{It(this.sandbox,Oo({service:"rtdb",op:t,path:s,auth:e,before:i.before,after:i.after,detail:i.detail}),{service:"rtdb"})}catch{}}nextListenerId(){return this.nextId+=1,`rtdb-listener-${this.nextId.toString(36)}`}nextGroupId(e){return this.nextId+=1,`rtdb-${e}-${this.nextId.toString(36)}`}emitOperation(e,t,s,i,r,o={}){if(this.sandbox)try{It(this.sandbox,Do({service:"rtdb",method:t,path:ee(s),auth:e,result:i,origin:o.origin??"user",durationMs:o.durationMs,reasons:r?.reasons,rules:r?{engine:"rtdb",matchedPath:r.matchedPath,matchedRule:r.matchedRule,pathVariableBindings:r.pathVariableBindings,reason:r.reason,errorCode:r.errorCode}:void 0,request:o.request,resourceBefore:o.resourceBefore,resourceAfter:o.resourceAfter,groupId:o.groupId,groupKind:o.groupKind,triggeredBy:o.triggeredBy,detail:o.detail,at:o.at}),{service:"rtdb"})}catch{}}emitCommit(e,t,s,i={}){if(this.sandbox)try{It(this.sandbox,Mo({service:"rtdb",method:t,path:ee(s),auth:e,data:i.data,priorState:i.priorState,nextState:i.nextState,groupId:i.groupId,groupKind:i.groupKind,replay:i.replay,detail:i.detail}),{service:"rtdb"})}catch{}}emitListener(e,t,s,i={}){if(this.sandbox)try{It(this.sandbox,Lo({service:"rtdb",phase:e,listenerId:t.id,target:{kind:i.event??"value",path:ee(t.path)},auth:s,result:i.result,size:i.size,sample:i.sample,reason:i.reason,error:i.error,triggeredBy:i.triggeredBy,detail:i.detail}),{service:"rtdb"})}catch{}}setData(e){this.tree.restore({});for(const[t,s]of Object.entries(e)){const i=ce(te(s,Date.now()),t==="/"?"":t);this.tree.write(t,i)}this.notifyWrite()}setRules(e){this.rules.setRules(e)}snapshotState(){return this.tree.snapshot()}adminGet(e){const t=this.tree.read(e);return this.emitOperation(null,"get",e,"not-applicable",void 0,{origin:"admin",resourceBefore:{data:t,exists:t!==null}}),t}adminGetQuery(e,t){const s=De(this.tree.read(e),t);return this.emitOperation(null,"get",e,"not-applicable",void 0,{origin:"admin",request:{query:t},resourceBefore:{data:Nt(s),exists:s.length>0}}),s}adminSet(e,t){const s=Date.now(),i=this.tree.read(e),r=ce(te(t,s,i),e==="/"?"":e);this.emitOperation(null,r===null?"remove":"set",e,"not-applicable",void 0,{origin:"admin",request:{data:t,resourceData:t},resourceBefore:{data:i,exists:i!==null},resourceAfter:{data:r,exists:r!==null}});const o=this.snapshotChildListenerParents();this.tree.write(e,r),this.fanOut([e]),this.fanOutChildren(o);const a=this.tree.read(e),l=a===null?"remove":"set";this.emitCommit(null,l,e,{data:t,priorState:i,nextState:a,replay:{requestTime:s},detail:{admin:!0}}),this.notifyWrite()}adminUpdate(e,t){const s=Date.now(),i=this.tree.read(e),r=Object.keys(t).some(u=>u.includes("/")),o=this.snapshotChildListenerParents();if(r){const u={};for(const[d,f]of Object.entries(t)){const p=P([...E(e),...E(d)]);u[p]=ce(te(f,s,this.tree.read(p)),p)}this.emitOperation(null,"update",e,"not-applicable",void 0,{origin:"admin",request:{data:t,resourceData:t},resourceBefore:{data:i,exists:i!==null},detail:{admin:!0,multiPath:!0,paths:Object.keys(u)}}),this.tree.multiUpdate(u),this.fanOut(Object.keys(u)),this.fanOutChildren(o);const h=this.tree.read(e);this.emitCommit(null,"update",e,{data:t,priorState:i,nextState:h,replay:{requestTime:s},detail:{admin:!0,multiPath:!0,paths:Object.keys(u)}}),this.notifyWrite();return}const a={},l=[];for(const[u,h]of Object.entries(t)){const d=P([...E(e),...E(u)]);l.push(d),a[u]=ce(te(h,s,this.tree.read(d)),d)}this.emitOperation(null,"update",e,"not-applicable",void 0,{origin:"admin",request:{data:t,resourceData:t},resourceBefore:{data:i,exists:i!==null},detail:{admin:!0,multiPath:!1,keys:Object.keys(a)}}),this.tree.shallowUpdate(e,a),this.fanOut(l),this.fanOutChildren(o);const c=this.tree.read(e);this.emitCommit(null,"update",e,{data:t,priorState:i,nextState:c,replay:{requestTime:s},detail:{admin:!0,multiPath:!1,keys:Object.keys(a)}}),this.notifyWrite()}adminRemove(e){this.adminSet(e,null)}get(e,t){const s=Date.now(),i=this.tree.read(t),r=this.rules.evaluate("read",t==="/"?"/":t,{auth:e,mockData:this.tree.snapshot()});if(r.check!=="allow")throw this.emitOperation(e,"get",t,"deny",r,{at:s,durationMs:Date.now()-s,resourceBefore:{data:i,exists:i!==null}}),ve();return this.emitOperation(e,"get",t,"allow",r,{at:s,durationMs:Date.now()-s,resourceBefore:{data:i,exists:i!==null}}),this.tree.read(t)}set(e,t,s){this.setInternal(e,t,s,"set")}setInternal(e,t,s,i){const r=Date.now(),o=te(s,r,this.tree.read(t)),a=ce(o,t==="/"?"":t),l=this.tree.read(t),c=Date.now(),u=this.rules.evaluate("write",t==="/"?"/":t,{auth:e,mockData:this.tree.snapshot(),newData:a}),h={data:l,exists:l!==null},d={data:a,exists:a!==null};if(u.check!=="allow")throw this.emitOperation(e,i,t,"deny",u,{at:c,durationMs:Date.now()-c,request:{data:s,resourceData:s},resourceBefore:h,resourceAfter:d}),ve();this.emitOperation(e,i,t,"allow",u,{at:c,durationMs:Date.now()-c,request:{data:s,resourceData:s},resourceBefore:h,resourceAfter:d});const f=this.snapshotChildListenerParents();this.tree.write(t,a),this.fanOut([t]),this.fanOutChildren(f);const p=this.tree.read(t),g=p===null?"remove":i;this.emitCommit(e,g,t,{data:s,priorState:l,nextState:p,replay:{requestTime:r}}),this.emitRtdbEvent(e,g,ee(t),{before:l,after:p}),this.notifyWrite()}remove(e,t){this.setInternal(e,t,null,"remove")}update(e,t,s){const i=Date.now();if(Object.keys(s).some(f=>f.includes("/"))){const f=this.nextGroupId("update"),p={};for(const[R,$]of Object.entries(s)){const ie=[...E(t),...E(R)],H=P(ie);p[H]=ce(te($,i,this.tree.read(H)),H)}const g=this.tree.snapshot();for(const[R,$]of Object.entries(p)){const ie=Date.now(),H=this.tree.read(R),Q=this.rules.evaluate("write",R,{auth:e,mockData:g,newData:$}),xs={at:ie,durationMs:Date.now()-ie,origin:"batch",request:{data:$,resourceData:$},resourceBefore:{data:H,exists:H!==null},resourceAfter:{data:$,exists:$!==null},groupId:f,groupKind:"batch",detail:{multiPath:!0,rootPath:ee(t)}};if(Q.check!=="allow")throw this.emitOperation(e,"update",R,"deny",Q,xs),ve();this.emitOperation(e,"update",R,"allow",Q,xs)}const b=this.tree.read(t),A=this.snapshotChildListenerParents();this.tree.multiUpdate(p),this.fanOut(Object.keys(p)),this.fanOutChildren(A);const x=this.tree.read(t);this.emitCommit(e,"update",t,{data:s,priorState:b,nextState:x,groupId:f,groupKind:"batch",replay:{requestTime:i},detail:{multiPath:!0,paths:Object.keys(p)}}),this.emitRtdbEvent(e,"update",ee(t),{after:p,detail:{multiPath:!0,paths:Object.keys(p)}}),this.notifyWrite();return}const o={};for(const[f,p]of Object.entries(s)){const g=P([...E(t),...E(f)]);o[f]=ce(te(p,i,this.tree.read(g)),g)}const a=this.tree.snapshot(),l=[],c=this.nextGroupId("update");for(const[f,p]of Object.entries(o)){const g=P([...E(t),...E(f)]);l.push(g);const b=Date.now(),A=this.tree.read(g),x=this.rules.evaluate("write",g,{auth:e,mockData:a,newData:p}),R={at:b,durationMs:Date.now()-b,origin:"batch",request:{data:p,resourceData:p},resourceBefore:{data:A,exists:A!==null},resourceAfter:{data:p,exists:p!==null},groupId:c,groupKind:"batch",detail:{multiPath:!1,rootPath:ee(t),key:f}};if(x.check!=="allow")throw this.emitOperation(e,"update",g,"deny",x,R),ve();this.emitOperation(e,"update",g,"allow",x,R)}const u=this.tree.read(t),h=this.snapshotChildListenerParents();this.tree.shallowUpdate(t,o),this.fanOut(l),this.fanOutChildren(h);const d=this.tree.read(t);this.emitCommit(e,"update",t,{data:s,priorState:u,nextState:d,groupId:c,groupKind:"batch",replay:{requestTime:i},detail:{multiPath:!1,keys:Object.keys(o)}}),this.emitRtdbEvent(e,"update",ee(t),{after:o,detail:{multiPath:!1,keys:Object.keys(o)}}),this.notifyWrite()}onValue(e,t,s,i){const r=this.nextListenerId(),o=Date.now(),a=this.rules.evaluate("read",t==="/"?"/":t,{auth:e,mockData:this.tree.snapshot()});if(a.check!=="allow")throw this.emitOperation(e,"listen",t,"deny",a,{at:o,durationMs:Date.now()-o,request:i?{query:i}:void 0,origin:"listener"}),this.emitListener("errored",{id:r,path:t},e,{event:"value",result:"deny",error:{code:"PERMISSION_DENIED",message:"PERMISSION_DENIED: Permission denied",reasons:a.reasons}}),ve();this.emitOperation(e,"listen",t,"allow",a,{at:o,durationMs:Date.now()-o,request:i?{query:i}:void 0,origin:"listener"});const l={id:r,auth:e,cb:s,path:t,query:i};if(this.valueListeners.add(l),this.emitListener("attach",l,e,{event:"value",result:"allow",detail:i?{query:i}:void 0}),i){const c=De(this.tree.read(t),i);l.lastWindow=c;const u={val:Nt(c),exists:c.length>0,key:this.keyForPath(t)};try{s(u),this.emitListener("delivery",l,e,{event:"value",size:c.length,sample:u.val,detail:{initial:!0,query:!0}})}catch(h){this.emitListener("errored",l,e,{event:"value",result:"error",error:{message:h instanceof Error?h.message:String(h)},detail:{initial:!0,query:!0}})}}else{const c=this.makeSnap(t);l.lastValue=c.val;try{s(c),this.emitListener("delivery",l,e,{event:"value",size:c.exists?1:0,sample:c.val,detail:{initial:!0}})}catch(u){this.emitListener("errored",l,e,{event:"value",result:"error",error:{message:u instanceof Error?u.message:String(u)},detail:{initial:!0}})}}return()=>{this.valueListeners.delete(l),this.emitListener("detach",l,e,{event:"value"})}}getQuery(e,t,s){const i=Date.now(),r=this.rules.evaluate("read",t==="/"?"/":t,{auth:e,mockData:this.tree.snapshot()});if(r.check!=="allow")throw this.emitOperation(e,"get",t,"deny",r,{at:i,durationMs:Date.now()-i,request:{query:s}}),ve();const o=De(this.tree.read(t),s);return this.emitOperation(e,"get",t,"allow",r,{at:i,durationMs:Date.now()-i,request:{query:s},resourceBefore:{data:Nt(o),exists:o.length>0}}),o}keyForPath(e){const t=E(e);return t.length===0?null:t[t.length-1]}makeSnap(e){const t=this.tree.read(e),s=t!==null,i=E(e),r=i.length===0?null:i[i.length-1];return{val:t,exists:s,key:r}}fanOut(e){if(this.valueListeners.size===0)return;const t=e.map(s=>P(E(s)));for(const s of this.valueListeners){const i=P(E(s.path));if(!t.some(l=>{if(l===i)return!0;const c=i==="/"?"/":i+"/",u=l==="/"?"/":l+"/";return!!(i==="/"||l.startsWith(c)||i.startsWith(u))}))continue;if(s.query){const l=De(this.tree.read(s.path),s.query);if(Pu(s.lastWindow??[],l)){this.emitListener("suppressed",s,s.auth,{event:"value",reason:"no-op",detail:{query:!0}});continue}s.lastWindow=l;const c={val:Nt(l),exists:l.length>0,key:this.keyForPath(s.path)};this.emitListener("delivery",s,s.auth,{event:"value",size:l.length,sample:c.val,detail:{query:!0}});try{s.cb(c)}catch(u){this.emitListener("errored",s,s.auth,{event:"value",result:"error",error:{message:u instanceof Error?u.message:String(u)},detail:{query:!0}})}continue}const o=this.makeSnap(s.path),a=s.lastValue;if(a!==void 0&&Ue(a,o.val)){this.emitListener("suppressed",s,s.auth,{event:"value",reason:"no-op"});continue}s.lastValue=o.val,this.emitListener("delivery",s,s.auth,{event:"value",size:o.exists?1:0,sample:o.val});try{s.cb(o)}catch(l){this.emitListener("errored",s,s.auth,{event:"value",result:"error",error:{message:l instanceof Error?l.message:String(l)}})}}}runTransaction(e,t,s,i){const r=i?.applyLocally!==!1,o=E(t),a=o.length===0?null:o[o.length-1],l=this.tree.read(t),c=l===null?null:Be(he(l)),u=s(c),h=this.nextGroupId("transaction");if(u===void 0)return this.emitOperation(e,"transaction",t,"not-applicable",void 0,{origin:"transaction",groupId:h,groupKind:"transaction",resourceBefore:{data:l,exists:l!==null},detail:{committed:!1,aborted:!0}}),{committed:!1,val:l,key:a};const d=Date.now(),f=ce(te(u,d,l),t==="/"?"":t);if(r){const b=this.tree.snapshot();this.tree.write(t,f),this.fanOut([t]);const A=Date.now(),x=this.rules.evaluate("write",t==="/"?"/":t,{auth:e,mockData:b,newData:f});if(x.check!=="allow")throw this.emitOperation(e,"transaction",t,"deny",x,{at:A,durationMs:Date.now()-A,origin:"transaction",request:{data:u,resourceData:u},resourceBefore:{data:l,exists:l!==null},resourceAfter:{data:f,exists:f!==null},groupId:h,groupKind:"transaction"}),this.tree.restore(b),this.fanOut([t]),Ci();return this.emitOperation(e,"transaction",t,"allow",x,{at:A,durationMs:Date.now()-A,origin:"transaction",request:{data:u,resourceData:u},resourceBefore:{data:l,exists:l!==null},resourceAfter:{data:f,exists:f!==null},groupId:h,groupKind:"transaction"}),this.emitCommit(e,"transaction",t,{data:u,priorState:l,nextState:f,groupId:h,groupKind:"transaction",replay:{requestTime:d},detail:{committed:!0,applyLocally:!0}}),this.emitRtdbEvent(e,"transaction",ee(t),{before:l,after:f,detail:{committed:!0}}),this.notifyWrite(),{committed:!0,val:f,key:a}}const p=Date.now(),g=this.rules.evaluate("write",t==="/"?"/":t,{auth:e,mockData:this.tree.snapshot(),newData:f});if(g.check!=="allow")throw this.emitOperation(e,"transaction",t,"deny",g,{at:p,durationMs:Date.now()-p,origin:"transaction",request:{data:u,resourceData:u},resourceBefore:{data:l,exists:l!==null},resourceAfter:{data:f,exists:f!==null},groupId:h,groupKind:"transaction"}),Ci();return this.emitOperation(e,"transaction",t,"allow",g,{at:p,durationMs:Date.now()-p,origin:"transaction",request:{data:u,resourceData:u},resourceBefore:{data:l,exists:l!==null},resourceAfter:{data:f,exists:f!==null},groupId:h,groupKind:"transaction"}),this.tree.write(t,f),this.fanOut([t]),this.emitCommit(e,"transaction",t,{data:u,priorState:l,nextState:f,groupId:h,groupKind:"transaction",replay:{requestTime:d},detail:{committed:!0,applyLocally:!1}}),this.emitRtdbEvent(e,"transaction",ee(t),{before:l,after:f,detail:{committed:!0}}),{committed:!0,val:f,key:a}}onChild(e,t,s,i,r){const o=this.nextListenerId(),a=Date.now(),l=this.rules.evaluate("read",s==="/"?"/":s,{auth:e,mockData:this.tree.snapshot()});if(l.check!=="allow")throw this.emitOperation(e,"listen",s,"deny",l,{at:a,durationMs:Date.now()-a,origin:"listener",detail:{event:t}}),this.emitListener("errored",{id:o,path:s},e,{event:t,result:"deny",error:{code:"PERMISSION_DENIED",message:"PERMISSION_DENIED: Permission denied",reasons:l.reasons}}),ve();this.emitOperation(e,"listen",s,"allow",l,{at:a,durationMs:Date.now()-a,origin:"listener",detail:{event:t}});const c={id:o,auth:e,event:t,path:s,cb:i,spec:r};if(this.childListeners.add(c),this.emitListener("attach",c,e,{event:t,result:"allow",detail:r?{query:r}:void 0}),r){const u=De(this.tree.read(s),r);if(c.lastWindow=u,t==="child_added")for(const{key:h,value:d}of u){this.emitListener("delivery",c,e,{event:t,size:1,sample:{key:h,val:d},detail:{initial:!0,query:!0}});try{i({key:h,val:d})}catch(f){this.emitListener("errored",c,e,{event:t,result:"error",error:{message:f instanceof Error?f.message:String(f)},detail:{initial:!0,query:!0}})}}}else if(t==="child_added")for(const{key:u,val:h}of this.directChildren(s)){this.emitListener("delivery",c,e,{event:t,size:1,sample:{key:u,val:h},detail:{initial:!0}});try{i({key:u,val:h})}catch(d){this.emitListener("errored",c,e,{event:t,result:"error",error:{message:d instanceof Error?d.message:String(d)},detail:{initial:!0}})}}return()=>{this.childListeners.delete(c),this.emitListener("detach",c,e,{event:t})}}off(e,t,s){const i=P(E(e));if(t===void 0||t==="value")for(const a of[...this.valueListeners])P(E(a.path))===i&&(s!==void 0&&a.cb!==s||(this.valueListeners.delete(a),this.emitListener("detach",a,a.auth,{event:"value"})));const o=t===void 0?["child_added","child_changed","child_removed","child_moved"]:t==="value"?[]:[t];if(o.length>0)for(const a of[...this.childListeners])o.includes(a.event)&&P(E(a.path))===i&&(s!==void 0&&a.cb!==s||(this.childListeners.delete(a),this.emitListener("detach",a,a.auth,{event:a.event})))}directChildren(e){const t=this.tree.read(e);if(t===null||typeof t!="object"||Array.isArray(t))return[];const s=[];for(const[i,r]of Object.entries(t))s.push({key:i,val:r});return s}snapshotChildListenerParents(){const e=new Map;if(this.childListeners.size===0)return e;for(const t of this.childListeners){const s=P(E(t.path));if(e.has(s))continue;const i=new Map;for(const{key:r,val:o}of this.directChildren(s))i.set(r,o);e.set(s,i)}return e}fanOutChildren(e){if(this.childListeners.size===0)return;const t=new Map;for(const s of this.childListeners){if(s.spec){this.fanOutQueryChild(s);continue}const i=P(E(s.path)),r=t.get(i)??[];r.push(s),t.set(i,r)}for(const[s,i]of t){const r=e.get(s)??new Map,o=new Map;for(const{key:u,val:h}of this.directChildren(s))o.set(u,h);const a=[],l=[],c=[];for(const[u,h]of o)r.has(u)?Ue(r.get(u),h)||l.push({key:u,val:h}):a.push({key:u,val:h});for(const[u,h]of r)o.has(u)||c.push({key:u,val:h});for(const u of i){let h;switch(u.event){case"child_added":h=a;break;case"child_changed":h=l;break;case"child_removed":h=c;break;case"child_moved":h=[];break}for(const d of h){this.emitListener("delivery",u,u.auth,{event:u.event,size:1,sample:d});try{u.cb(d)}catch(f){this.emitListener("errored",u,u.auth,{event:u.event,result:"error",error:{message:f instanceof Error?f.message:String(f)}})}}}}}fanOutQueryChild(e){const t=e.lastWindow??[],s=De(this.tree.read(e.path),e.spec);e.lastWindow=s;const i=new Map(t.map(a=>[a.key,a.value])),r=new Map(s.map(a=>[a.key,a.value]));let o=[];switch(e.event){case"child_added":for(const{key:a,value:l}of s)i.has(a)||o.push({key:a,val:l});break;case"child_changed":for(const{key:a,value:l}of s)i.has(a)&&!Ue(i.get(a),l)&&o.push({key:a,val:l});break;case"child_removed":for(const{key:a,value:l}of t)r.has(a)||o.push({key:a,val:l});break;case"child_moved":o=[];break}for(const a of o){this.emitListener("delivery",e,e.auth,{event:e.event,size:1,sample:a,detail:{query:!0}});try{e.cb(a)}catch(l){this.emitListener("errored",e,e.auth,{event:e.event,result:"error",error:{message:l instanceof Error?l.message:String(l)},detail:{query:!0}})}}}exportTree(){return this.tree.snapshot()}restoreTree(e){const t=this.snapshotChildListenerParents();this.tree.restore(e??{}),this.fanOut(["/"]),this.fanOutChildren(t)}subscribeWrites(e){return this.writeSubscribers.add(e),()=>{this.writeSubscribers.delete(e)}}notifyWrite(){if(this.writeSubscribers.size!==0)for(const e of this.writeSubscribers)try{e()}catch{}}mintKey(){return gu()}listenerCount(){return this.valueListeners.size}childListenerCount(){return this.childListeners.size}}function ee(n){return P(E(n))}function Ci(){return new Error("permission_denied")}function Nt(n){if(n.length===0)return null;const e={};for(const{key:t,value:s}of n)e[t]=s;return e}function Pu(n,e){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++){const s=n[t],i=e[t];if(s.key!==i.key||!Ue(s.value,i.value))return!1}return!0}const Ve=Symbol("@pyric/rtdb/target");function j(n){return n.kind==="sandbox"||n.kind==="sandbox-live"}function ke(n){return n.admin?null:n.kind==="sandbox"?n.auth:n.sandbox.currentUser}const Ei=new WeakMap;function jn(n){let e=Ei.get(n);if(!e){e=new Au(n),Ei.set(n,e);const t=e;n.registerPersistableService("rtdb",{snapshot:()=>t.exportTree(),restore:s=>{t.restoreTree(s)},subscribe:s=>t.subscribeWrites(s)})}return e}const so=new WeakMap;function St(n,e){return so.set(n,e),n}function q(n){if(Ve in n)return n[Ve];const e=so.get(n);if(!e)throw new TypeError("@pyric/rtdb: unrecognized reference — was it produced by a factory in this package?");return e}const Ou=Symbol("@pyric/rtdb/query");function io(n){return Ou in n}function wi(n){if(ro(n))return n[Gn]==="sandbox"?wi(n.sandbox):wi(n.firebaseApp);if(oo(n)){const i={kind:"sandbox",backend:jn(n.sandbox),auth:n.auth};return{[Ve]:i}}if(Mu(n)){const i={kind:"sandbox-live",backend:jn(n),sandbox:n};return{[Ve]:i}}const t={kind:"prod",db:du(n)};return{[Ve]:t}}function Du(n){if(ro(n)){if(n[Gn]!=="sandbox")throw new TypeError("getAdminDatabase: the admin (rules-bypass) lens is sandbox-only — a prod-backed app has no way to bypass deployed security rules.");return Du(n.sandbox)}const e=oo(n)?n.sandbox:n,s={kind:"sandbox",backend:jn(e),auth:null,admin:!0};return{[Ve]:s}}function ro(n){return n!==null&&typeof n=="object"&&Gn in n}function oo(n){return n instanceof Fo}function Mu(n){if(n===null||typeof n!="object")return!1;const e=n;return typeof e.withAuth=="function"&&typeof e.onCurrentUserChanged=="function"&&"currentUser"in e&&"admin"in e}function Ku(n,e){const t=q(n);if(j(t))return Qe(t,e??"/");const s=eu(t.db,e);return St(s,t),s}function Yt(n,e){const t=q(n);if(j(t)){const i=[...E(n._path),...E(e)];return Qe(t,P(i))}const s=Te(n,e);return St(s,t),s}function Qe(n,e){const t=P(E(e)),s=E(t),r={key:s.length===0?null:s[s.length-1],_path:t,get parent(){return s.length===0?null:Qe(n,P(s.slice(0,-1)))},get root(){return Qe(n,"/")},toString(){return`sandbox://rtdb${t}`}};return St(r,n),r}async function Yu(n){if(io(n)){const i=n,r=q(i.ref);if(j(r)){const l=r.admin?r.backend.adminGetQuery(i.ref._path,i._spec):r.backend.getQuery(ke(r),i.ref._path,i._spec);return Gu(r,i.ref,l)}const o=i._fbQuery??i.ref,a=await fi(o);return zt(a,r,i.ref)}const e=n,t=q(e);if(j(t)){const i=t.admin?t.backend.adminGet(e._path):t.backend.get(ke(t),e._path);return qu(t,e,i)}const s=await fi(e);return zt(s,t,e)}async function Lu(n,e){const t=q(n);if(j(t)){t.admin?t.backend.adminSet(n._path,e):t.backend.set(ke(t),n._path,e);return}await Ts(n,e)}async function Qu(n,e){const t=q(n);if(j(t)){t.admin?t.backend.adminUpdate(n._path,e):t.backend.update(ke(t),n._path,e);return}await nu(n,e)}async function zu(n){const e=q(n);if(j(e)){e.admin?e.backend.adminRemove(n._path):e.backend.remove(ke(e),n._path);return}await tu(n)}function Xu(n,e){const t=q(n);if(j(t)){const i=t.backend.mintKey(),r=P([...E(n._path),i]),o=Qe(t,r),a=Qe(t,r),l=e===void 0?Promise.resolve(a):Lu(a,e).then(()=>a);return Fu(o,l)}const s=e===void 0?di(n):di(n,e);return St(s,t),s}function Fu(n,e){const t=n;return t.then=e.then.bind(e),t.catch=e.catch.bind(e),t}function Wu(n,e,t){if(t?.onlyOnce){let o=null,a=!1;return o=Wu(n,c=>{a||(a=!0,o&&o(),e(c))}),a&&o(),a?()=>{}:o}if(io(n)){const o=n,a=q(o.ref);if(j(a))return a.backend.onValue(ke(a),o.ref._path,u=>{const h=Ne(a,o.ref,u.val);try{e(h)}catch{}},o._spec);const l=o._fbQuery??o.ref;return _i(l,u=>{e(zt(u,a,o.ref))})}const s=n,i=q(s);if(j(i)){const o=l=>{const c=Ne(i,s,l.val);try{e(c)}catch{}};Vu(i.backend,s._path,"value",e,o);const a=i.backend.onValue(ke(i),s._path,o);return()=>{ao(i.backend,s._path,"value",e),a()}}return _i(s,o=>{e(zt(o,i,s))})}const Qt=new WeakMap;function Ns(n,e,t){const s=Bu(t);return`${n}\0${e}\0${s}`}let Uu=1;const bi=new WeakMap;function Bu(n){let e=bi.get(n);return e===void 0&&(e=Uu++,bi.set(n,e)),e}function Vu(n,e,t,s,i){let r=Qt.get(n);r||(r=new Map,Qt.set(n,r)),r.set(Ns(e,t,s),i)}function ju(n,e,t,s){return Qt.get(n)?.get(Ns(e,t,s))}function ao(n,e,t,s){Qt.get(n)?.delete(Ns(e,t,s))}function Ju(n,e,t){const s=q(n);if(j(s)){if(t!==void 0&&e!==void 0){const i=ju(s.backend,n._path,e,t);i!==void 0&&(s.backend.off(n._path,e,i),ao(s.backend,n._path,e,t));return}s.backend.off(n._path,e,void 0);return}iu(n,e,t)}function Zu(){return Cu()}function eh(n,e,t,s){const i=q(n);j(i)||to(i.db,e,t,s)}const th={setRules(n,e){const t=q(n);if(!j(t))throw new Error("sandbox.setRules is sandbox-only.");t.backend.setRules(e)},setData(n,e){const t=q(n);if(!j(t))throw new Error("sandbox.setData is sandbox-only.");t.backend.setData(e)},snapshotState(n){const e=q(n);if(!j(e))throw new Error("sandbox.snapshotState is sandbox-only.");return e.backend.snapshotState()}};function qu(n,e,t){return Ne(n,e,t)}function Ne(n,e,t){const s=t!==null,i=Be(t),r=t!==null&&typeof t=="object"&&!Array.isArray(t)?Object.keys(t).length:0;return{key:e.key,ref:e,size:r,priority:null,exists(){return s},val(){return i},child(o){const a=E(o);let l=t;for(const u of a){if(l===null||typeof l!="object"||Array.isArray(l)){l=null;break}l=l[u]??null}const c=Yt(e,o);return Ne(n,c,l)},hasChild(o){return this.child(o).exists()},hasChildren(){return t!==null&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length>0},exportVal(){return i},toJSON(){return i},forEach(o){if(t===null||typeof t!="object"||Array.isArray(t))return!1;for(const[a,l]of Object.entries(t)){const c=Yt(e,a),u=Ne(n,c,l);if(o(u)===!0)return!0}return!1}}}function Gu(n,e,t){let s;if(t.length===0)s=null;else{const o={};for(const{key:a,value:l}of t)o[a]=l;s=o}const i=t.length>0,r=Be(s);return{key:e.key,ref:e,size:t.length,priority:null,exists(){return i},val(){return r},child(o){const a=E(o);let l=s;for(const u of a){if(l===null||typeof l!="object"||Array.isArray(l)){l=null;break}l=l[u]??null}const c=Yt(e,o);return Ne(n,c,l)},hasChild(o){return this.child(o).exists()},hasChildren(){return t.length>0},exportVal(){return r},toJSON(){return r},forEach(o){for(const{key:a,value:l}of t){const c=Yt(e,a),u=Ne(n,c,l);if(o(u)===!0)return!0}return!1}}}function zt(n,e,t){return St(n.ref,e),new Proxy(n,{get(s,i){if(i==="ref")return t;const r=s[i];return typeof r=="function"?r.bind(s):r}})}export{Bo as ParsedExpressionSchema,Ou as QUERY_SYMBOL,zo as RtdbMapper,Wo as RuleErrorSchema,Uo as RuleLintSchema,ta as SimulateHandler,Zo as SimulationInputSchema,Ve as TARGET_SYMBOL,dn as buildRuleExpression,Yt as child,eh as connectDatabaseEmulator,Yu as get,Du as getAdminDatabase,wi as getDatabase,Ju as off,Wu as onValue,Xu as push,Ku as ref,zu as remove,th as sandbox,Zu as serverTimestamp,Lu as set,Qu as update};