@pyric/cli 0.1.0-alpha.20 → 0.1.0-alpha.21

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 (491) hide show
  1. package/README.md +64 -89
  2. package/dist/assurance/.generated/conformance-verdicts.d.ts +68 -1
  3. package/dist/assurance/.generated/conformance-verdicts.d.ts.map +1 -1
  4. package/dist/assurance/.generated/conformance-verdicts.js +68 -1
  5. package/dist/assurance/.generated/conformance-verdicts.js.map +1 -1
  6. package/dist/bridge/client/dispatch.d.ts +25 -19
  7. package/dist/bridge/client/dispatch.d.ts.map +1 -1
  8. package/dist/bridge/client/dispatch.js +41 -48
  9. package/dist/bridge/client/dispatch.js.map +1 -1
  10. package/dist/bridge/client/tool-family-factories.d.ts +26 -0
  11. package/dist/bridge/client/tool-family-factories.d.ts.map +1 -0
  12. package/dist/bridge/client/tool-family-factories.js +10 -0
  13. package/dist/bridge/client/tool-family-factories.js.map +1 -0
  14. package/dist/bridge/server/mcp-contract.d.ts +7 -6
  15. package/dist/bridge/server/mcp-contract.d.ts.map +1 -1
  16. package/dist/bridge/server/mcp-contract.js +9 -48
  17. package/dist/bridge/server/mcp-contract.js.map +1 -1
  18. package/dist/bridge/server/peer.d.ts +11 -1
  19. package/dist/bridge/server/peer.d.ts.map +1 -1
  20. package/dist/bridge/server/peer.js +22 -1
  21. package/dist/bridge/server/peer.js.map +1 -1
  22. package/dist/bridge/server/tool-family-factories.d.ts +30 -0
  23. package/dist/bridge/server/tool-family-factories.d.ts.map +1 -0
  24. package/dist/bridge/server/tool-family-factories.js +22 -0
  25. package/dist/bridge/server/tool-family-factories.js.map +1 -0
  26. package/dist/bridge/server/tool-metadata.d.ts +17 -18
  27. package/dist/bridge/server/tool-metadata.d.ts.map +1 -1
  28. package/dist/bridge/server/tool-metadata.js +24 -59
  29. package/dist/bridge/server/tool-metadata.js.map +1 -1
  30. package/dist/bridge/tool-families.d.ts +48 -0
  31. package/dist/bridge/tool-families.d.ts.map +1 -0
  32. package/dist/bridge/tool-families.generated.d.ts +32 -0
  33. package/dist/bridge/tool-families.generated.d.ts.map +1 -0
  34. package/dist/bridge/tool-families.generated.js +15 -0
  35. package/dist/bridge/tool-families.generated.js.map +1 -0
  36. package/dist/bridge/tool-families.js +51 -0
  37. package/dist/bridge/tool-families.js.map +1 -0
  38. package/dist/bridge/tool-family-records/conformance.d.ts +7 -0
  39. package/dist/bridge/tool-family-records/conformance.d.ts.map +1 -0
  40. package/dist/bridge/tool-family-records/conformance.js +6 -0
  41. package/dist/bridge/tool-family-records/conformance.js.map +1 -0
  42. package/dist/bridge/tool-family-records/firestore-data.d.ts +7 -0
  43. package/dist/bridge/tool-family-records/firestore-data.d.ts.map +1 -0
  44. package/dist/bridge/tool-family-records/firestore-data.js +15 -0
  45. package/dist/bridge/tool-family-records/firestore-data.js.map +1 -0
  46. package/dist/bridge/tool-family-records/firestore-inspect.d.ts +7 -0
  47. package/dist/bridge/tool-family-records/firestore-inspect.d.ts.map +1 -0
  48. package/dist/bridge/tool-family-records/firestore-inspect.js +6 -0
  49. package/dist/bridge/tool-family-records/firestore-inspect.js.map +1 -0
  50. package/dist/bridge/tool-family-records/firestore-rules.d.ts +7 -0
  51. package/dist/bridge/tool-family-records/firestore-rules.d.ts.map +1 -0
  52. package/dist/bridge/tool-family-records/firestore-rules.js +15 -0
  53. package/dist/bridge/tool-family-records/firestore-rules.js.map +1 -0
  54. package/dist/bridge/tool-family-records/firestore-simulator.d.ts +7 -0
  55. package/dist/bridge/tool-family-records/firestore-simulator.d.ts.map +1 -0
  56. package/dist/bridge/tool-family-records/firestore-simulator.js +16 -0
  57. package/dist/bridge/tool-family-records/firestore-simulator.js.map +1 -0
  58. package/dist/bridge/tool-family-records/rtdb-inspection.d.ts +7 -0
  59. package/dist/bridge/tool-family-records/rtdb-inspection.d.ts.map +1 -0
  60. package/dist/bridge/tool-family-records/rtdb-inspection.js +6 -0
  61. package/dist/bridge/tool-family-records/rtdb-inspection.js.map +1 -0
  62. package/dist/bundler/externals.d.ts +37 -0
  63. package/dist/bundler/externals.d.ts.map +1 -0
  64. package/dist/bundler/externals.js +52 -0
  65. package/dist/bundler/externals.js.map +1 -0
  66. package/dist/bundler/index.d.ts +17 -0
  67. package/dist/bundler/index.d.ts.map +1 -0
  68. package/dist/bundler/index.js +17 -0
  69. package/dist/bundler/index.js.map +1 -0
  70. package/dist/cli/inlined-sdk-scanner.d.ts +6 -0
  71. package/dist/cli/inlined-sdk-scanner.d.ts.map +1 -0
  72. package/dist/cli/inlined-sdk-scanner.js +82 -0
  73. package/dist/cli/inlined-sdk-scanner.js.map +1 -0
  74. package/dist/cli/sandbox-interlock.d.ts +97 -0
  75. package/dist/cli/sandbox-interlock.d.ts.map +1 -0
  76. package/dist/cli/sandbox-interlock.js +112 -0
  77. package/dist/cli/sandbox-interlock.js.map +1 -0
  78. package/dist/cli/sandbox-runner.d.ts +20 -12
  79. package/dist/cli/sandbox-runner.d.ts.map +1 -1
  80. package/dist/cli/sandbox-runner.js +24 -21
  81. package/dist/cli/sandbox-runner.js.map +1 -1
  82. package/dist/cli/serve.d.ts +6 -10
  83. package/dist/cli/serve.d.ts.map +1 -1
  84. package/dist/cli/serve.js +57 -77
  85. package/dist/cli/serve.js.map +1 -1
  86. package/dist/cli/unsupported-runtime.d.ts +27 -0
  87. package/dist/cli/unsupported-runtime.d.ts.map +1 -0
  88. package/dist/cli/unsupported-runtime.js +63 -0
  89. package/dist/cli/unsupported-runtime.js.map +1 -0
  90. package/dist/conformance/.generated/can-i-use-browser.d.ts +1 -1
  91. package/dist/conformance/.generated/can-i-use-browser.d.ts.map +1 -1
  92. package/dist/conformance/.generated/can-i-use-browser.js +1 -1
  93. package/dist/conformance/.generated/can-i-use-browser.js.map +1 -1
  94. package/dist/conformance/.generated/can-i-use.d.ts +1 -1
  95. package/dist/conformance/.generated/can-i-use.d.ts.map +1 -1
  96. package/dist/conformance/.generated/can-i-use.js +1 -1
  97. package/dist/conformance/.generated/can-i-use.js.map +1 -1
  98. package/dist/conformance/.generated/conformance-docs.d.ts.map +1 -1
  99. package/dist/conformance/.generated/conformance-docs.js +1 -1
  100. package/dist/conformance/.generated/conformance-docs.js.map +1 -1
  101. package/dist/functions-rtdb/child.d.ts +37 -0
  102. package/dist/functions-rtdb/child.d.ts.map +1 -1
  103. package/dist/functions-rtdb/child.js +90 -21
  104. package/dist/functions-rtdb/child.js.map +1 -1
  105. package/dist/functions-rtdb/development-runtime.d.ts +3 -0
  106. package/dist/functions-rtdb/development-runtime.d.ts.map +1 -1
  107. package/dist/functions-rtdb/development-runtime.js +1 -0
  108. package/dist/functions-rtdb/development-runtime.js.map +1 -1
  109. package/dist/google-endpoints.d.ts +67 -0
  110. package/dist/google-endpoints.d.ts.map +1 -0
  111. package/dist/google-endpoints.js +119 -0
  112. package/dist/google-endpoints.js.map +1 -0
  113. package/dist/next/runtime-env.d.ts.map +1 -1
  114. package/dist/next/runtime-env.js +5 -0
  115. package/dist/next/runtime-env.js.map +1 -1
  116. package/dist/next/with-pyric.d.ts +1 -1
  117. package/dist/next/with-pyric.js +1 -1
  118. package/dist/register/beacon.d.ts +69 -0
  119. package/dist/register/beacon.d.ts.map +1 -0
  120. package/dist/register/beacon.js +199 -0
  121. package/dist/register/beacon.js.map +1 -0
  122. package/dist/register/index.d.ts.map +1 -1
  123. package/dist/register/index.js +65 -6
  124. package/dist/register/index.js.map +1 -1
  125. package/dist/register/net-guard.d.ts +110 -0
  126. package/dist/register/net-guard.d.ts.map +1 -0
  127. package/dist/register/net-guard.js +462 -0
  128. package/dist/register/net-guard.js.map +1 -0
  129. package/dist/serve/ai-diagnostics-relay.d.ts +63 -0
  130. package/dist/serve/ai-diagnostics-relay.d.ts.map +1 -0
  131. package/dist/serve/ai-diagnostics-relay.js +125 -0
  132. package/dist/serve/ai-diagnostics-relay.js.map +1 -0
  133. package/dist/serve/ai-proxy.d.ts +92 -0
  134. package/dist/serve/ai-proxy.d.ts.map +1 -0
  135. package/dist/serve/ai-proxy.js +269 -0
  136. package/dist/serve/ai-proxy.js.map +1 -0
  137. package/dist/serve/ai-status.d.ts +44 -0
  138. package/dist/serve/ai-status.d.ts.map +1 -0
  139. package/dist/serve/ai-status.js +77 -0
  140. package/dist/serve/ai-status.js.map +1 -0
  141. package/dist/serve/ai-terminal-blocks.d.ts +97 -0
  142. package/dist/serve/ai-terminal-blocks.d.ts.map +1 -0
  143. package/dist/serve/ai-terminal-blocks.js +128 -0
  144. package/dist/serve/ai-terminal-blocks.js.map +1 -0
  145. package/dist/serve/ai-terminal-text.d.ts +36 -0
  146. package/dist/serve/ai-terminal-text.d.ts.map +1 -0
  147. package/dist/serve/ai-terminal-text.js +48 -0
  148. package/dist/serve/ai-terminal-text.js.map +1 -0
  149. package/dist/serve/beacon-route.d.ts +53 -0
  150. package/dist/serve/beacon-route.d.ts.map +1 -0
  151. package/dist/serve/beacon-route.js +101 -0
  152. package/dist/serve/beacon-route.js.map +1 -0
  153. package/dist/serve/entries/active-auth-registry.d.ts +16 -0
  154. package/dist/serve/entries/active-auth-registry.d.ts.map +1 -0
  155. package/dist/serve/entries/active-auth-registry.js +48 -0
  156. package/dist/serve/entries/active-auth-registry.js.map +1 -0
  157. package/dist/serve/entries/active-auth.d.ts +18 -0
  158. package/dist/serve/entries/active-auth.d.ts.map +1 -0
  159. package/dist/serve/entries/active-auth.js +84 -0
  160. package/dist/serve/entries/active-auth.js.map +1 -0
  161. package/dist/serve/entries/auth-helper-core.d.ts +1 -0
  162. package/dist/serve/entries/auth-helper-core.d.ts.map +1 -1
  163. package/dist/serve/entries/auth-helper-core.js +4 -0
  164. package/dist/serve/entries/auth-helper-core.js.map +1 -1
  165. package/dist/serve/entries/auth-helper-dom.d.ts.map +1 -1
  166. package/dist/serve/entries/auth-helper-dom.js +28 -2
  167. package/dist/serve/entries/auth-helper-dom.js.map +1 -1
  168. package/dist/serve/entries/auth.d.ts.map +1 -1
  169. package/dist/serve/entries/auth.js +8 -0
  170. package/dist/serve/entries/auth.js.map +1 -1
  171. package/dist/serve/entries/bridge-url.d.ts +1 -1
  172. package/dist/serve/entries/bridge-url.js +1 -1
  173. package/dist/serve/entries/init.d.ts.map +1 -1
  174. package/dist/serve/entries/init.js +70 -4
  175. package/dist/serve/entries/init.js.map +1 -1
  176. package/dist/serve/entries/runtime.d.ts.map +1 -1
  177. package/dist/serve/entries/runtime.js +9 -0
  178. package/dist/serve/entries/runtime.js.map +1 -1
  179. package/dist/serve/namespace.d.ts +14 -5
  180. package/dist/serve/namespace.d.ts.map +1 -1
  181. package/dist/serve/namespace.js +57 -124
  182. package/dist/serve/namespace.js.map +1 -1
  183. package/dist/serve/runtime/chip-config.d.ts.map +1 -1
  184. package/dist/serve/runtime/chip-config.js +16 -2
  185. package/dist/serve/runtime/chip-config.js.map +1 -1
  186. package/dist/serve/runtime/chip-dialog.d.ts +18 -0
  187. package/dist/serve/runtime/chip-dialog.d.ts.map +1 -0
  188. package/dist/serve/runtime/chip-dialog.js +315 -0
  189. package/dist/serve/runtime/chip-dialog.js.map +1 -0
  190. package/dist/serve/runtime/chip-install.d.ts +2 -0
  191. package/dist/serve/runtime/chip-install.d.ts.map +1 -1
  192. package/dist/serve/runtime/chip-install.js +9 -4
  193. package/dist/serve/runtime/chip-install.js.map +1 -1
  194. package/dist/serve/runtime/chip-user-search.d.ts +16 -0
  195. package/dist/serve/runtime/chip-user-search.d.ts.map +1 -0
  196. package/dist/serve/runtime/chip-user-search.js +354 -0
  197. package/dist/serve/runtime/chip-user-search.js.map +1 -0
  198. package/dist/serve/runtime/chip.d.ts +10 -0
  199. package/dist/serve/runtime/chip.d.ts.map +1 -1
  200. package/dist/serve/runtime/chip.js +118 -15
  201. package/dist/serve/runtime/chip.js.map +1 -1
  202. package/dist/serve/runtime/identity.d.ts +17 -0
  203. package/dist/serve/runtime/identity.d.ts.map +1 -0
  204. package/dist/serve/runtime/identity.js +10 -0
  205. package/dist/serve/runtime/identity.js.map +1 -0
  206. package/dist/serve/sandbox-session.d.ts +7 -0
  207. package/dist/serve/sandbox-session.d.ts.map +1 -1
  208. package/dist/serve/sandbox-session.js +2 -0
  209. package/dist/serve/sandbox-session.js.map +1 -1
  210. package/dist/serve/site-ui/_astro/{RulesCodeEditor.XtDmHOlN.js → RulesCodeEditor.DsTAsKIa.js} +1 -1
  211. package/dist/serve/site-ui/_astro/app.BOr2kwae.js +115 -0
  212. package/dist/serve/site-ui/_astro/app.DhAcImFD.js +1 -0
  213. package/dist/serve/site-ui/_astro/{chess-showcase.B72XYeoh.js → chess-showcase.Bn_pP6UJ.js} +2 -2
  214. package/dist/serve/site-ui/_astro/{example-runtime.C25_lx6Z.js → example-runtime.CXopTGv7.js} +1 -1
  215. package/dist/serve/site-ui/_astro/sandbox-controls.rOuZTOUG.js +510 -0
  216. package/dist/serve/site-ui/_astro/{seed.Co0yUJY5.js → seed.03a08f9t.js} +2 -2
  217. package/dist/serve/site-ui/_astro/writes.BsPBG3dp.js +653 -0
  218. package/dist/serve/site-ui/auth/index.html +1 -1
  219. package/dist/serve/site-ui/docs/_rhythm/index.html +1 -1
  220. package/dist/serve/site-ui/docs/agent/set-up-your-agent/index.html +1 -1
  221. package/dist/serve/site-ui/docs/agent/watch-and-review/index.html +1 -1
  222. package/dist/serve/site-ui/docs/agent/work-with-an-agent/index.html +1 -1
  223. package/dist/serve/site-ui/docs/ai-compat/index.html +1 -1
  224. package/dist/serve/site-ui/docs/api-reference/index.html +8 -1
  225. package/dist/serve/site-ui/docs/api-reference.md +7 -0
  226. package/dist/serve/site-ui/docs/app-compat/index.html +1 -1
  227. package/dist/serve/site-ui/docs/auth-compat/index.html +3 -3
  228. package/dist/serve/site-ui/docs/auth-compat.md +2 -2
  229. package/dist/serve/site-ui/docs/build/ai-logic/index.html +6 -1
  230. package/dist/serve/site-ui/docs/build/ai-logic.md +6 -0
  231. package/dist/serve/site-ui/docs/build/authentication/index.html +1 -1
  232. package/dist/serve/site-ui/docs/build/cloud-firestore/index.html +1 -1
  233. package/dist/serve/site-ui/docs/build/cloud-messaging/index.html +1 -1
  234. package/dist/serve/site-ui/docs/build/cloud-storage/index.html +1 -1
  235. package/dist/serve/site-ui/docs/build/realtime-database/index.html +1 -1
  236. package/dist/serve/site-ui/docs/conformance-scores/index.html +6 -2
  237. package/dist/serve/site-ui/docs/conformance-scores.md +5 -1
  238. package/dist/serve/site-ui/docs/create-pyric-reference-api/index.html +1 -1
  239. package/dist/serve/site-ui/docs/database-compat/index.html +44 -44
  240. package/dist/serve/site-ui/docs/database-compat.md +43 -43
  241. package/dist/serve/site-ui/docs/examples/chess/index.html +1 -1
  242. package/dist/serve/site-ui/docs/examples/index.html +1 -1
  243. package/dist/serve/site-ui/docs/firestore-compat/index.html +4 -4
  244. package/dist/serve/site-ui/docs/firestore-compat.md +3 -3
  245. package/dist/serve/site-ui/docs/firestore-flutter-compat/index.html +319 -0
  246. package/dist/serve/site-ui/docs/firestore-flutter-compat.md +344 -0
  247. package/dist/serve/site-ui/docs/functions-rtdb-compat/index.html +1 -1
  248. package/dist/serve/site-ui/docs/get-started/backend-bundlers/index.html +105 -0
  249. package/dist/serve/site-ui/docs/get-started/backend-bundlers.md +165 -0
  250. package/dist/serve/site-ui/docs/get-started/how-the-swap-works/index.html +1 -1
  251. package/dist/serve/site-ui/docs/get-started/nextjs/index.html +1 -1
  252. package/dist/serve/site-ui/docs/get-started/start-building/index.html +1 -1
  253. package/dist/serve/site-ui/docs/get-started/vite/index.html +1 -1
  254. package/dist/serve/site-ui/docs/index.json +2967 -1482
  255. package/dist/serve/site-ui/docs/messaging-compat/index.html +1 -1
  256. package/dist/serve/site-ui/docs/observe/resolve-runtime-status/index.html +1 -1
  257. package/dist/serve/site-ui/docs/observe/see-whats-happening/index.html +1 -1
  258. package/dist/serve/site-ui/docs/observe/shape-your-data/index.html +1 -1
  259. package/dist/serve/site-ui/docs/overview/index.html +1 -1
  260. package/dist/serve/site-ui/docs/pyric-admin-app-reference-api/index.html +1 -1
  261. package/dist/serve/site-ui/docs/pyric-admin-auth-reference-api/index.html +1 -1
  262. package/dist/serve/site-ui/docs/pyric-admin-database-reference-api/index.html +1 -1
  263. package/dist/serve/site-ui/docs/pyric-admin-firestore-reference-api/index.html +1 -1
  264. package/dist/serve/site-ui/docs/pyric-admin-messaging-reference-api/index.html +1 -1
  265. package/dist/serve/site-ui/docs/pyric-admin-reference-api/index.html +1 -1
  266. package/dist/serve/site-ui/docs/pyric-admin-storage-reference-api/index.html +1 -1
  267. package/dist/serve/site-ui/docs/pyric-ai-reference-api/index.html +1 -1
  268. package/dist/serve/site-ui/docs/pyric-ai-scripting-reference-api/index.html +1 -1
  269. package/dist/serve/site-ui/docs/pyric-analytics-reference-api/index.html +124 -0
  270. package/dist/serve/site-ui/docs/pyric-analytics-reference-api.md +287 -0
  271. package/dist/serve/site-ui/docs/pyric-app-check-reference-api/index.html +87 -0
  272. package/dist/serve/site-ui/docs/pyric-app-check-reference-api.md +199 -0
  273. package/dist/serve/site-ui/docs/pyric-app-reference-api/index.html +1 -1
  274. package/dist/serve/site-ui/docs/pyric-auth-reference-api/index.html +6 -2
  275. package/dist/serve/site-ui/docs/pyric-auth-reference-api.md +2 -1
  276. package/dist/serve/site-ui/docs/pyric-cli-assurance-browser-reference-api/index.html +1 -1
  277. package/dist/serve/site-ui/docs/pyric-cli-assurance-reference-api/index.html +1 -1
  278. package/dist/serve/site-ui/docs/pyric-cli-bridge-client-reference-api/index.html +2 -2
  279. package/dist/serve/site-ui/docs/pyric-cli-bridge-client-reference-api.md +1 -1
  280. package/dist/serve/site-ui/docs/pyric-cli-bridge-reference-api/index.html +1 -1
  281. package/dist/serve/site-ui/docs/pyric-cli-bundler-reference-api/index.html +56 -0
  282. package/dist/serve/site-ui/docs/pyric-cli-bundler-reference-api.md +72 -0
  283. package/dist/serve/site-ui/docs/pyric-cli-conformance-browser-reference-api/index.html +2 -1
  284. package/dist/serve/site-ui/docs/pyric-cli-conformance-browser-reference-api.md +1 -0
  285. package/dist/serve/site-ui/docs/pyric-cli-conformance-docs-reference-api/index.html +1 -1
  286. package/dist/serve/site-ui/docs/pyric-cli-conformance-reference-api/index.html +2 -1
  287. package/dist/serve/site-ui/docs/pyric-cli-conformance-reference-api.md +1 -0
  288. package/dist/serve/site-ui/docs/pyric-cli-credentials-node-reference-api/index.html +1 -1
  289. package/dist/serve/site-ui/docs/pyric-cli-discover-reference-api/index.html +1 -1
  290. package/dist/serve/site-ui/docs/pyric-cli-next-reference-api/index.html +2 -2
  291. package/dist/serve/site-ui/docs/pyric-cli-next-reference-api.md +1 -1
  292. package/dist/serve/site-ui/docs/pyric-cli-register-app-bridge-reference-api/index.html +1 -1
  293. package/dist/serve/site-ui/docs/pyric-cli-register-reference-api/index.html +1 -1
  294. package/dist/serve/site-ui/docs/pyric-cli-remote-reference-api/index.html +34 -9
  295. package/dist/serve/site-ui/docs/pyric-cli-remote-reference-api.md +16 -8
  296. package/dist/serve/site-ui/docs/pyric-cli-serve-worker-reference-api/index.html +133 -93
  297. package/dist/serve/site-ui/docs/pyric-cli-serve-worker-reference-api.md +61 -1
  298. package/dist/serve/site-ui/docs/pyric-cli-verify-reference-api/index.html +2 -2
  299. package/dist/serve/site-ui/docs/pyric-cli-verify-reference-api.md +1 -1
  300. package/dist/serve/site-ui/docs/pyric-cli-vite-reference-api/index.html +2 -2
  301. package/dist/serve/site-ui/docs/pyric-cli-vite-reference-api.md +2 -2
  302. package/dist/serve/site-ui/docs/pyric-database-reference-api/index.html +2 -2
  303. package/dist/serve/site-ui/docs/pyric-database-reference-api.md +1 -1
  304. package/dist/serve/site-ui/docs/pyric-firestore-lite-reference-api/index.html +559 -0
  305. package/dist/serve/site-ui/docs/pyric-firestore-lite-reference-api.md +1240 -0
  306. package/dist/serve/site-ui/docs/pyric-firestore-reference-api/index.html +40 -11
  307. package/dist/serve/site-ui/docs/pyric-firestore-reference-api.md +18 -8
  308. package/dist/serve/site-ui/docs/pyric-functions-reference-api/index.html +67 -0
  309. package/dist/serve/site-ui/docs/pyric-functions-reference-api.md +149 -0
  310. package/dist/serve/site-ui/docs/pyric-messaging-reference-api/index.html +1 -1
  311. package/dist/serve/site-ui/docs/pyric-messaging-sw-reference-api/index.html +1 -1
  312. package/dist/serve/site-ui/docs/pyric-performance-reference-api/index.html +35 -0
  313. package/dist/serve/site-ui/docs/pyric-performance-reference-api.md +69 -0
  314. package/dist/serve/site-ui/docs/pyric-remote-config-reference-api/index.html +132 -0
  315. package/dist/serve/site-ui/docs/pyric-remote-config-reference-api.md +307 -0
  316. package/dist/serve/site-ui/docs/pyric-rules-reference-api/index.html +1 -1
  317. package/dist/serve/site-ui/docs/pyric-sandbox-database-reference-api/index.html +52 -17
  318. package/dist/serve/site-ui/docs/pyric-sandbox-database-reference-api.md +48 -9
  319. package/dist/serve/site-ui/docs/pyric-sandbox-firestore-reference-api/index.html +1 -1
  320. package/dist/serve/site-ui/docs/pyric-sandbox-reference-api/index.html +239 -49
  321. package/dist/serve/site-ui/docs/pyric-sandbox-reference-api.md +148 -31
  322. package/dist/serve/site-ui/docs/pyric-storage-reference-api/index.html +22 -4
  323. package/dist/serve/site-ui/docs/pyric-storage-reference-api.md +24 -2
  324. package/dist/serve/site-ui/docs/pyric-ui-agents-reference-api/index.html +26 -96
  325. package/dist/serve/site-ui/docs/pyric-ui-agents-reference-api.md +20 -51
  326. package/dist/serve/site-ui/docs/pyric-ui-auth-hooks-reference-api/index.html +1 -1
  327. package/dist/serve/site-ui/docs/pyric-ui-auth-reference-api/index.html +2 -2
  328. package/dist/serve/site-ui/docs/pyric-ui-auth-reference-api.md +1 -1
  329. package/dist/serve/site-ui/docs/pyric-ui-events-hooks-reference-api/index.html +1 -1
  330. package/dist/serve/site-ui/docs/pyric-ui-events-reference-api/index.html +1 -1
  331. package/dist/serve/site-ui/docs/pyric-ui-firestore-hooks-reference-api/index.html +1 -1
  332. package/dist/serve/site-ui/docs/pyric-ui-firestore-reference-api/index.html +2 -2
  333. package/dist/serve/site-ui/docs/pyric-ui-firestore-reference-api.md +1 -1
  334. package/dist/serve/site-ui/docs/pyric-ui-primitives-reference-api/index.html +124 -26
  335. package/dist/serve/site-ui/docs/pyric-ui-primitives-reference-api.md +58 -5
  336. package/dist/serve/site-ui/docs/pyric-ui-rtdb-reference-api/index.html +1 -1
  337. package/dist/serve/site-ui/docs/pyric-ui-rules-hooks-reference-api/index.html +1 -1
  338. package/dist/serve/site-ui/docs/pyric-ui-rules-reference-api/index.html +1 -1
  339. package/dist/serve/site-ui/docs/pyric-ui-storage-hooks-reference-api/index.html +1 -1
  340. package/dist/serve/site-ui/docs/pyric-ui-storage-reference-api/index.html +4 -5
  341. package/dist/serve/site-ui/docs/pyric-ui-storage-reference-api.md +3 -4
  342. package/dist/serve/site-ui/docs/pyric-ui-traffic-hooks-reference-api/index.html +1 -1
  343. package/dist/serve/site-ui/docs/pyric-ui-traffic-reference-api/index.html +1 -1
  344. package/dist/serve/site-ui/docs/reference/cli/index.html +6 -3
  345. package/dist/serve/site-ui/docs/reference/cli.md +8 -2
  346. package/dist/serve/site-ui/docs/rules-compat/index.html +10 -2
  347. package/dist/serve/site-ui/docs/rules-compat.md +9 -1
  348. package/dist/serve/site-ui/docs/secure/audit-your-rules/index.html +1 -1
  349. package/dist/serve/site-ui/docs/secure/firestore-rules-limits/index.html +1 -1
  350. package/dist/serve/site-ui/docs/secure/read-a-denial/index.html +1 -1
  351. package/dist/serve/site-ui/docs/secure/rtdb-rules-in-typescript/index.html +1 -1
  352. package/dist/serve/site-ui/docs/secure/rules-standard-library/index.html +1 -1
  353. package/dist/serve/site-ui/docs/secure/secure-it-with-rules/index.html +1 -1
  354. package/dist/serve/site-ui/docs/secure/simulate-and-lint/index.html +1 -1
  355. package/dist/serve/site-ui/docs/secure/write-a-rules-test-suite/index.html +1 -1
  356. package/dist/serve/site-ui/docs/ship/ship-to-production/index.html +1 -1
  357. package/dist/serve/site-ui/docs/ship/test-in-node/index.html +1 -1
  358. package/dist/serve/site-ui/docs/storage-compat/index.html +13 -13
  359. package/dist/serve/site-ui/docs/storage-compat.md +12 -12
  360. package/dist/serve/site-ui/docs/trust/how-we-know-it-matches-firebase/index.html +1 -1
  361. package/dist/serve/site-ui/docs/trust/rules-standard-library/index.html +1 -1
  362. package/dist/serve/site-ui/docs/trust/versioning-and-compatibility/index.html +1 -1
  363. package/dist/serve/site-ui/docs/tutorial/index.html +1 -1
  364. package/dist/serve/site-ui/examples/chess/index.html +1 -1
  365. package/dist/serve/site-ui/firestore/index.html +1 -1
  366. package/dist/serve/site-ui/llms.txt +9 -0
  367. package/dist/serve/site-ui/rtdb/index.html +1 -1
  368. package/dist/serve/site-ui/settings/index.html +1 -1
  369. package/dist/serve/site-ui/storage/index.html +1 -1
  370. package/dist/serve/site-ui/studio/index.html +1 -1
  371. package/dist/serve/site-ui/traffic/index.html +1 -1
  372. package/dist/serve/studio/disk-workspace.d.ts.map +1 -1
  373. package/dist/serve/studio/disk-workspace.js +64 -2
  374. package/dist/serve/studio/disk-workspace.js.map +1 -1
  375. package/dist/serve/vite-plugin.d.ts +7 -7
  376. package/dist/serve/vite-plugin.js +1 -1
  377. package/dist/serve/vite-plugin.js.map +1 -1
  378. package/dist/serve/vite-sandbox-generation.d.ts.map +1 -1
  379. package/dist/serve/vite-sandbox-generation.js +12 -0
  380. package/dist/serve/vite-sandbox-generation.js.map +1 -1
  381. package/dist/serve/worker/client/auth.js +1 -2
  382. package/dist/serve/worker/client/auth.js.map +1 -1
  383. package/dist/serve/worker/client/core.d.ts +21 -1
  384. package/dist/serve/worker/client/core.d.ts.map +1 -1
  385. package/dist/serve/worker/client/core.js +79 -3
  386. package/dist/serve/worker/client/core.js.map +1 -1
  387. package/dist/serve/worker/client.d.ts +1 -1
  388. package/dist/serve/worker/client.d.ts.map +1 -1
  389. package/dist/serve/worker/client.js +1 -1
  390. package/dist/serve/worker/client.js.map +1 -1
  391. package/dist/serve/worker/context-resolver.d.ts +30 -0
  392. package/dist/serve/worker/context-resolver.d.ts.map +1 -0
  393. package/dist/serve/worker/context-resolver.js +44 -0
  394. package/dist/serve/worker/context-resolver.js.map +1 -0
  395. package/dist/serve/worker/entry.js +23 -19
  396. package/dist/serve/worker/entry.js.map +1 -1
  397. package/dist/serve/worker/host/core.d.ts +1 -0
  398. package/dist/serve/worker/host/core.d.ts.map +1 -1
  399. package/dist/serve/worker/host/core.js +12 -6
  400. package/dist/serve/worker/host/core.js.map +1 -1
  401. package/dist/serve/worker/host/storage.js +2 -2
  402. package/dist/serve/worker/host-auth.js +1 -2
  403. package/dist/serve/worker/host-auth.js.map +1 -1
  404. package/dist/serve/worker/index.d.ts +1 -1
  405. package/dist/serve/worker/index.d.ts.map +1 -1
  406. package/dist/serve/worker/index.js +2 -2
  407. package/dist/serve/worker/index.js.map +1 -1
  408. package/dist/serve/worker/port-lifecycle.d.ts +18 -0
  409. package/dist/serve/worker/port-lifecycle.d.ts.map +1 -0
  410. package/dist/serve/worker/port-lifecycle.js +28 -0
  411. package/dist/serve/worker/port-lifecycle.js.map +1 -0
  412. package/dist/serve/worker/serve-init.d.ts.map +1 -1
  413. package/dist/serve/worker/serve-init.js +8 -2
  414. package/dist/serve/worker/serve-init.js.map +1 -1
  415. package/dist/verify/fixture.d.ts +1 -1
  416. package/package.json +16 -5
  417. package/src/assurance/.generated/conformance-verdicts.ts +68 -1
  418. package/src/bridge/client/dispatch.ts +52 -56
  419. package/src/bridge/client/tool-family-factories.ts +34 -0
  420. package/src/bridge/server/mcp-contract.ts +15 -59
  421. package/src/bridge/server/peer.ts +24 -1
  422. package/src/bridge/server/tool-family-factories.ts +40 -0
  423. package/src/bridge/server/tool-metadata.ts +29 -61
  424. package/src/bridge/tool-families.generated.ts +17 -0
  425. package/src/bridge/tool-families.ts +87 -0
  426. package/src/bridge/tool-family-records/conformance.ts +6 -0
  427. package/src/bridge/tool-family-records/firestore-data.ts +15 -0
  428. package/src/bridge/tool-family-records/firestore-inspect.ts +6 -0
  429. package/src/bridge/tool-family-records/firestore-rules.ts +15 -0
  430. package/src/bridge/tool-family-records/firestore-simulator.ts +16 -0
  431. package/src/bridge/tool-family-records/rtdb-inspection.ts +6 -0
  432. package/src/bundler/externals.ts +55 -0
  433. package/src/bundler/index.ts +21 -0
  434. package/src/cli/cli.test.ts +0 -44
  435. package/src/cli/inlined-sdk-scanner.ts +77 -0
  436. package/src/cli/sandbox-interlock.ts +167 -0
  437. package/src/cli/sandbox-runner.ts +37 -26
  438. package/src/cli/serve.ts +68 -69
  439. package/src/cli/unsupported-runtime.ts +68 -0
  440. package/src/conformance/.generated/can-i-use-browser.ts +2 -2
  441. package/src/conformance/.generated/can-i-use.ts +2 -2
  442. package/src/conformance/.generated/conformance-docs.ts +1 -1
  443. package/src/functions-rtdb/child.ts +115 -21
  444. package/src/functions-rtdb/development-runtime.ts +4 -0
  445. package/src/google-endpoints.ts +155 -0
  446. package/src/next/runtime-env.ts +5 -0
  447. package/src/next/with-pyric.ts +1 -1
  448. package/src/register/beacon.ts +232 -0
  449. package/src/register/index.ts +68 -6
  450. package/src/register/net-guard.ts +567 -0
  451. package/src/serve/ai-diagnostics-relay.ts +243 -0
  452. package/src/serve/ai-proxy.ts +327 -0
  453. package/src/serve/ai-status.ts +109 -0
  454. package/src/serve/ai-terminal-blocks.ts +210 -0
  455. package/src/serve/ai-terminal-text.ts +52 -0
  456. package/src/serve/beacon-route.ts +141 -0
  457. package/src/serve/entries/active-auth-registry.ts +56 -0
  458. package/src/serve/entries/active-auth.ts +100 -0
  459. package/src/serve/entries/auth-helper-core.ts +5 -0
  460. package/src/serve/entries/auth-helper-dom.ts +26 -2
  461. package/src/serve/entries/auth.ts +8 -0
  462. package/src/serve/entries/bridge-url.ts +1 -1
  463. package/src/serve/entries/init.ts +78 -3
  464. package/src/serve/entries/runtime.ts +10 -0
  465. package/src/serve/namespace.ts +73 -140
  466. package/src/serve/runtime/chip-config.ts +16 -2
  467. package/src/serve/runtime/chip-dialog.ts +366 -0
  468. package/src/serve/runtime/chip-install.ts +10 -4
  469. package/src/serve/runtime/chip-user-search.ts +391 -0
  470. package/src/serve/runtime/chip.ts +140 -15
  471. package/src/serve/runtime/identity.ts +26 -0
  472. package/src/serve/sandbox-session.ts +9 -0
  473. package/src/serve/studio/disk-workspace.ts +76 -2
  474. package/src/serve/vite-plugin.ts +8 -8
  475. package/src/serve/vite-sandbox-generation.ts +15 -0
  476. package/src/serve/worker/client/auth.ts +1 -1
  477. package/src/serve/worker/client/core.ts +80 -3
  478. package/src/serve/worker/client.ts +1 -1
  479. package/src/serve/worker/context-resolver.ts +60 -0
  480. package/src/serve/worker/entry.ts +22 -18
  481. package/src/serve/worker/host/core.ts +9 -7
  482. package/src/serve/worker/host/storage.ts +2 -2
  483. package/src/serve/worker/host-auth.ts +1 -1
  484. package/src/serve/worker/index.ts +4 -1
  485. package/src/serve/worker/port-lifecycle.ts +45 -0
  486. package/src/serve/worker/serve-init.ts +9 -2
  487. package/src/verify/fixture.ts +1 -1
  488. package/dist/serve/site-ui/_astro/app.B52xr-DK.js +0 -1
  489. package/dist/serve/site-ui/_astro/app.DWBraPUw.js +0 -12
  490. package/dist/serve/site-ui/_astro/sandbox-controls.DEpnKg-O.js +0 -1169
  491. package/dist/serve/site-ui/_astro/writes.rpjrFzmu.js +0 -102
@@ -1,102 +0,0 @@
1
- import{G as Tt,H,I as _t,J as W,K as R,L as fe,M as Dt,N as jt,O as Ke,P as Pe,c as Pt,Q as Se,U as re,V as It,W as _,X as qt,Y as f,_ as Vt,$ as Nt,a0 as zt,a1 as oe,a2 as v,a3 as Mt,a4 as $t,h as Ee,a5 as k,a6 as Xe,a7 as Lt,a8 as Ut,q as Ce,D as m,B as F,T as Ie,l as Wt,a9 as Bt,aa as Qt,ab as Ht,t as Re,ac as Jt,ad as Gt,ae as Yt,af as Kt,ag as Xt,S as Zt,ah as en}from"./sandbox-controls.DEpnKg-O.js";const tn=`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+ exponent? -- float
63
- | digit+ exponent -- exp
64
- | digit+ -- int
65
-
66
- exponent = ("e" | "E") ("+" | "-")? digit+
67
-
68
- string
69
- = "\\"" doubleStringChar* "\\"" -- double
70
- | "'" singleStringChar* "'" -- single
71
-
72
- doubleStringChar
73
- = "\\\\" any -- escape
74
- | ~"\\"" any -- char
75
-
76
- singleStringChar
77
- = "\\\\" any -- escape
78
- | ~"'" any -- char
79
-
80
- regex = "/" regexBody "/" regexFlags
81
-
82
- regexBody = regexChar+
83
-
84
- regexChar
85
- = "\\\\" any -- escape
86
- | ~("/" | "\\n") any -- char
87
-
88
- regexFlags = alnum*
89
-
90
- bool
91
- = "true" ~identChar -- true
92
- | "false" ~identChar -- false
93
-
94
- null = "null" ~identChar
95
-
96
- ident = "$"? identStart identChar*
97
-
98
- identStart = letter | "_"
99
-
100
- identChar = alnum | "_" | "$"
101
- }
102
- `;let qe;function Ze(){return qe??=Tt(tn),qe}function nn(t){return Ze().match(t.trim())}function rn(){return Ze().createSemantics()}const on=Symbol.for("pyric.remote.sandbox");function ve(t){return t!=null&&t[on]===!0}const sn={read:new Set(["auth","data","root","now"]),write:new Set(["auth","data","newData","root","now"]),validate:new Set(["auth","data","newData","root","now"])},an=new Set(["val","exists","hasChild","hasChildren","isString","isNumber","isBoolean","child","parent","getPriority"]),cn=new Set(["matches","contains","beginsWith","endsWith","replace","toLowerCase","toUpperCase","length"]),un=new Set([...an,...cn]);let q=[],J="read",et=new Set,ce;function dn(){if(ce)return ce;const t=rn();return t.addOperation("validate",{_nonterminal(...e){e.forEach(n=>n.validate())},_iter(...e){e.forEach(n=>n.validate())},_terminal(){},CallExpr_methodCall(e,n,r,o,s,i){e.validate();const a=r.sourceString;un.has(a)||q.push({code:"UNKNOWN_METHOD",message:`Unknown method '${a}'`}),s.asIteration().children.forEach(u=>u.validate())},CallExpr_memberAccess(e,n,r){e.validate()},CallExpr_indexAccess(e,n,r,o){e.validate(),r.validate()},ident(e,n,r){const o=this.sourceString;if(e.sourceString==="$")return;const i=sn[J];i&&(!i.has(o)&&!et.has(o)&&q.push({code:"UNKNOWN_IDENTIFIER",message:`Identifier '${o}' is not allowed in '${J}' context`}),o==="newData"&&J==="read"&&q.push({code:"NEWDATA_IN_READ",message:"'newData' is not available in 'read' context"}))}}),ce=t,t}function nr(t,e,n=[]){const r=nn(t);return r.failed()?[]:(q=[],J=e,et=new Set(n.map(o=>o.startsWith("$")?o.slice(1):o)),dn()(r).validate(),[...q])}const rr=H({operation:Ke(["read","write","validate"]),path:R().min(1).startsWith("/"),auth:Dt([H({uid:R(),token:fe(W())}),jt()]),mockData:fe(W()),newData:W().optional(),updates:_t(H({path:R().min(1).startsWith("/"),value:W()})).optional()});Ke(["INVALID_INPUT","NO_MATCHING_RULE","EVALUATION_ERROR"]);H({allowed:Pe(),unsupported:Pe().optional(),matchedPath:R(),matchedRule:R(),reason:R(),pathVariableBindings:fe(R())});const Ve="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz";let Ne=0;const E=new Array(12).fill(0);function or(t=Date.now()){const e=t===Ne;Ne=t;const n=new Array(8);let r=t;for(let s=7;s>=0;s--)n[s]=Ve.charAt(r%64),r=Math.floor(r/64);if(r!==0)throw new Error("RTDB push-id: timestamp overflow.");let o=n.join("");if(e){let s;for(s=11;s>=0&&E[s]===63;s--)E[s]=0;if(s<0)for(let i=0;i<12;i++)E[i]=Math.floor(Math.random()*64);else E[s]=(E[s]??0)+1}else for(let s=0;s<12;s++)E[s]=Math.floor(Math.random()*64);for(let s=0;s<12;s++)o+=Ve.charAt(E[s]);if(o.length!==20)throw new Error(`RTDB push-id: bad length ${o.length}.`);return o}function sr(t={}){return Pt()}function N(t){return t.replace(/^\/+|\/+$/g,"").split("/")}function tt(t){return N(t).length%2===0&&N(t).length>0}function Oe(t){return N(t).length%2===1}function se(t){const e=N(t);return e[e.length-1]??""}function nt(t){return N(t).slice(0,-1).join("/")}function rt(t,e){const n=e!==void 0,r=n?Se(e):void 0;return{id:t.id,ref:t,exists:n,data:()=>n?r:void 0,get:o=>re(r,o)}}const ze=new WeakMap;let ln=1;function Me(t){let e=ze.get(t);return e===void 0&&(e=ln++,ze.set(t,e)),e}function X(t){if(t===null||typeof t=="boolean")return t;if(typeof t=="string")return It(t);if(typeof t>"u")return{type:"undefined"};if(typeof t=="bigint")return _("bigint",t.toString());if(typeof t=="number"){const n=Number.isNaN(t)?"NaN":t===1/0?"Infinity":t===-1/0?"-Infinity":Object.is(t,-0)?"-0":String(t);return _("number",n)}if(typeof t!="object"&&typeof t!="function")return{type:typeof t,value:String(t)};const e=qt(t);if(e!==void 0)return e;try{if(Array.isArray(t))return{type:"array",id:Me(t)}}catch{}return{type:"opaque-object",id:Me(t)}}function x(t){return new f({code:"invalid-argument",message:t})}function pe(t,e,n,r=!1,o=!1){if(t===null||typeof t=="string"||typeof t=="boolean")return{comparison:t,execution:t};if(typeof t=="number")return{comparison:t,execution:t};if(typeof t>"u"||typeof t=="bigint"||typeof t=="function"||typeof t=="symbol")throw x(`Unsupported Firestore query value: ${typeof t}.`);if(typeof t!="object")throw x("Unsupported Firestore query value.");const s=Vt(t);if(s!==void 0){const a=Nt(t);if(a!==void 0&&n!==void 0&&a!==n)throw x("Document reference belongs to a different Firestore database.");return{comparison:{type:"registered-firestore-value",value:s},execution:zt(t)}}if(t instanceof Date){const a=t.getTime();if(!Number.isFinite(a))throw x("Invalid Date query value.");const u=Math.floor(a/1e3),c=Object.freeze({seconds:u,nanoseconds:Math.floor((a-u*1e3)*1e6)}),l={type:"timestamp",...c};return oe(c,l,()=>Object.freeze({...c})),{comparison:{type:"registered-firestore-value",value:l},execution:c}}if(t instanceof Uint8Array){const a=t.slice();return{comparison:{type:"bytes",values:Array.from(a)},execution:a}}if(e.has(t))throw x("Cyclic query operands are not Firestore values.");const i=Object.getPrototypeOf(t);if(i!==Object.prototype&&i!==null&&!Array.isArray(t))throw x("Firestore query maps must be plain objects.");e.add(t);try{if(Array.isArray(t)){if(o&&!r)throw x("Nested arrays are not supported.");const c=t.map(d=>pe(d,e,n,r,!0)),l=c.map(d=>d.execution);return v(l,X(t)),{comparison:{type:"array",values:c.map(d=>d.comparison)},execution:l}}const a=Object.keys(t).sort().map(c=>({key:c,captured:pe(t[c],e,n,r,!1)})),u=Object.fromEntries(a.map(({key:c,captured:l})=>[c,l.execution]));return v(u,X(t)),{comparison:{type:"map",entries:a.map(({key:c,captured:l})=>[c,l.comparison])},execution:u}}finally{e.delete(t)}}function ot(t,e,n=!1){try{const r=pe(t,new Set,e,n);return Object.freeze({kind:"canonical",value:r.comparison,executionValue:r.execution})}catch(r){if(r instanceof f)throw r;const o=r instanceof Error?r.message:String(r);throw x(`Invalid Firestore query value: ${o}`)}}function st(t,e){return Mt(t.value,e.value)}function G(t,e){if(t.kind==="where"){const n="comparisonValue"in t?t.comparisonValue:ot(t.value,e,t.op==="in"||t.op==="not-in");return Object.freeze({kind:"where",field:t.field,op:t.op,value:n.executionValue,comparisonValue:n})}return Object.freeze({kind:t.kind,filters:Object.freeze(t.filters.map(n=>G(n,e)))})}function B(t,e,n,r){const o=t.map(s=>ot(s,r));return Object.freeze({values:Object.freeze(o.map(s=>s.executionValue)),comparisonValues:Object.freeze(o),inclusive:e,fromSnapshot:n})}function it(t,e){return t.length!==e.length?!1:t.every((n,r)=>{const o=e[r];return n.kind!==o.kind?!1:n.kind==="where"&&o.kind==="where"?n.field===o.field&&n.op===o.op&&st(n.comparisonValue,o.comparisonValue):n.kind!=="where"&&o.kind!=="where"&&it(n.filters,o.filters)})}function $e(t,e){return t===void 0||e===void 0?t===e:t.inclusive===e.inclusive&&t.comparisonValues.length===e.comparisonValues.length&&t.comparisonValues.every((n,r)=>st(n,e.comparisonValues[r]))}function hn(t,e){return t.kind!==e.kind?!1:t.kind==="collection"&&e.kind==="collection"?t.path===e.path:t.kind==="collection-group"&&e.kind==="collection-group"&&t.collectionId===e.collectionId}function at(t){return t.kind==="where"?Object.freeze({kind:t.kind,field:t.field,op:t.op,value:t.value}):Object.freeze({kind:t.kind,filters:Object.freeze(t.filters.map(at))})}function Le(t){if(t!==void 0)return Object.freeze({values:t.values,inclusive:t.inclusive,fromSnapshot:t.fromSnapshot})}function fn(t,e){return it(t.filters,e.filters)&&t.orders.length===e.orders.length&&t.orders.every((n,r)=>{const o=e.orders[r];return n.field===o.field&&n.direction===o.direction})&&t.limitCount===e.limitCount&&t.limitFromEnd===e.limitFromEnd&&$e(t.start,e.start)&&$e(t.end,e.end)}const ct="__name__";function Ue(t,e){const n=t.data();if(n===void 0)throw new f({code:"not-found",message:`Snapshot-based cursors require an existing document — got an empty snapshot for ${t.id??"<unknown>"}.`});return e.map(r=>r.field===ct?t.ref:n[r.field])}class z{env;auth;collectionPath;clauses;orders;limitCount;limitFromEnd;start;end;bypassRules;documentRef;constructor(e){this.env=e.env,this.auth=e.auth,this.collectionPath=e.collectionPath,this.documentRef=e.documentRef,this.clauses=Object.freeze((e.clauses??[]).map(n=>G(n))),this.orders=Object.freeze((e.orders??[]).map(n=>Object.freeze({...n}))),this.limitCount=e.limitCount,this.limitFromEnd=e.limitFromEnd??!1,this.start=e.start===void 0?void 0:Object.freeze({...e.start,values:Object.freeze(e.start.comparisonValues.map(n=>n.executionValue)),comparisonValues:e.start.comparisonValues}),this.end=e.end===void 0?void 0:Object.freeze({...e.end,values:Object.freeze(e.end.comparisonValues.map(n=>n.executionValue)),comparisonValues:e.end.comparisonValues}),this.bypassRules=e.bypassRules??!1}where(e,n,r){return this.clone({clauses:[...this.clauses,G({kind:"where",field:e,op:n,value:r})]})}applyFilter(e){return this.clone({clauses:[...this.clauses,G(e)]})}orderBy(e,n="asc"){return this.clone({orders:[...this.orders,{field:e,direction:n}]})}limit(e){return this.clone({limitCount:e,limitFromEnd:!1})}limitToLast(e){return this.clone({limitCount:e,limitFromEnd:!0})}startCursor(e,n){return this.clone({start:B(this.normalizeExplicitCursorValues(e),n,!1)})}endCursor(e,n){return this.clone({end:B(this.normalizeExplicitCursorValues(e),n,!1)})}startCursorFromSnapshot(e,n){return this.clone({start:B(Ue(e,this.normalizedOrders()),n,!0)})}endCursorFromSnapshot(e,n){return this.clone({end:B(Ue(e,this.normalizedOrders()),n,!0)})}isStructurallyEqual(e){return e instanceof z?this.env===e.env&&this.bypassRules===e.bypassRules&&hn(this.queryScope(),e.queryScope())&&fn(this.comparableExecutionSpec(),e.comparableExecutionSpec()):!1}clone(e){return new z({env:this.env,auth:this.auth,collectionPath:this.collectionPath,documentRef:this.documentRef,clauses:e.clauses??this.clauses,orders:e.orders??this.orders,limitCount:"limitCount"in e?e.limitCount:this.limitCount,limitFromEnd:e.limitFromEnd??this.limitFromEnd,start:"start"in e?e.start:this.start,end:"end"in e?e.end:this.end,bypassRules:this.bypassRules})}queryScope(){return{kind:"collection",path:this.collectionPath}}readQueryRows(e){const n=e?.auth!==void 0?e.auth:this.auth;let r;try{r=this.env.runQuery({scope:this.queryScope(),auth:n,execution:this.executionSpec(),bypassRules:this.bypassRules,activityQuery:this.activityQuery()})}catch(o){const s=o?.simError;throw s?new f(s):o}if(!r.allowed)throw new f(r.error);return r.docs}activityQuery(){const e=r=>r.kind==="where"?{kind:"where",field:r.field,op:r.op,value:X(r.value)}:{kind:r.kind,filters:r.filters.map(e)},n=r=>r===void 0?null:{values:r.values.map(o=>X(o)),inclusive:r.inclusive,fromSnapshot:r.fromSnapshot};return{scope:this.activityScope(),filters:this.clauses.map(e),orderBy:this.orders.map(r=>({...r})),limit:this.limitCount??null,limitFromEnd:this.limitFromEnd,start:n(this.start),end:n(this.end)}}activityScope(){return{kind:"collection"}}normalizedOrders(){return $t(this.executionSpec())}normalizeExplicitCursorValues(e){const n=this.orders;return e.map((r,o)=>{if(n[o]?.field!==ct)return r;if(typeof r!="string")throw new f({code:"invalid-argument",message:"Expected a string for a document ID cursor value."});const s=r.includes("/")?r:`${this.collectionPath}/${r}`;return this.documentRef(s)})}executionSpec(){const e={filters:Object.freeze(this.clauses.map(at)),orders:this.orders,limitCount:this.limitCount,limitFromEnd:this.limitFromEnd,start:Le(this.start),end:Le(this.end)};return Object.freeze(e)}comparableExecutionSpec(){return{filters:this.clauses,orders:this.orders,limitCount:this.limitCount,limitFromEnd:this.limitFromEnd,start:this.start,end:this.end}}snapshotConstraints(){return Object.freeze({execution:this.executionSpec(),activityQuery:this.activityQuery()})}async get(e){const r=this.readQueryRows(e).map(o=>{const s=this.documentRef(o.path),i=Se(o.data);return{id:s.id,ref:s,exists:!0,data:()=>i,get:a=>re(i,a)}});return{size:r.length,empty:r.length===0,docs:r,forEach(o){r.forEach(o)}}}async aggregate(e,n){const r=this.readQueryRows(n),o={};for(const s of Object.keys(e))o[s]=mn(e[s],r);return{data:()=>o}}}function pn(t,e){if(!e.includes("."))return t[e];let n=t;for(const r of e.split(".")){if(typeof n!="object"||n===null||Array.isArray(n))return;n=n[r]}return n}function mn(t,e){if(t.kind==="count")return e.length;let n=0,r=0;for(const o of e){const s=pn(o.data,t.field);typeof s=="number"&&Number.isFinite(s)&&(n+=s,r++)}return t.kind==="sum"?n:r===0?null:n/r}function A(t,e){if(t.error)throw new f(t.error);const n=t.debugMessages.length>0?t.debugMessages.join("; "):"(no debug message)";throw new f(k("permission-denied",`${e}: ${n}`))}class yn{env;auth;bypassRules;collectionRef;id;path;constructor(e,n,r,o=!1,s){this.env=e,this.auth=n,this.bypassRules=o,this.collectionRef=s,this.path=r,this.id=se(r),v(this,_("reference",r)),Ee(this,r,e)}get parent(){return this.collectionRef(nt(this.path))}collection(e){return this.collectionRef(`${this.path}/${e}`)}async get(e){const n=this.env.execute({method:"get",path:this.path,auth:e?.auth!==void 0?e.auth:this.auth,bypassRules:this.bypassRules});n.allowed||A(n,"get denied");const r=n.data===void 0||n.data===null?void 0:n.data;return rt(this,r)}async set(e,n){const r=n?.auth!==void 0?n.auth:this.auth;if(n?.mergeFields!==void 0){const s=n.mergeFields.map(c=>String(c)),a=this.env.getDocument(this.path)===null?"create":"update",u=this.env.execute({method:a,path:this.path,data:e,auth:r,merge:{mergeFields:s},bypassRules:this.bypassRules});u.allowed||A(u,`set denied (as ${a})`);return}if(n?.merge===!0){const i=this.env.getDocument(this.path)===null?"create":"update",a=this.env.execute({method:i,path:this.path,data:e,auth:r,merge:!0,bypassRules:this.bypassRules});a.allowed||A(a,`set denied (as ${i})`);return}const o=this.env.execute({method:"set",path:this.path,data:e,auth:r,bypassRules:this.bypassRules});o.allowed||A(o,"set denied")}async update(e,n){const r=this.env.execute({method:"update",path:this.path,data:e,auth:n?.auth!==void 0?n.auth:this.auth,bypassRules:this.bypassRules});r.allowed||A(r,"update denied")}async delete(e){const n=this.env.execute({method:"delete",path:this.path,auth:e?.auth!==void 0?e.auth:this.auth,bypassRules:this.bypassRules});n.allowed||A(n,"delete denied")}}function Z(t,e,n,r){return new yn(t,e,n,r,o=>new ut(t,e,o,r))}class ut extends z{id;path;constructor(e,n,r,o=!1){super({env:e,auth:n,collectionPath:r,bypassRules:o,documentRef:s=>Z(e,n,s,o)}),this.path=r,this.id=se(r)}doc(e){const n=e??Xe();return Z(this.env,this.auth,`${this.path}/${n}`,this.bypassRules)}async add(e,n){const r=this.doc();return await r.set(e,n),r}}class Ae extends z{collectionId;constructor(e){super({...e,collectionPath:"",documentRef:n=>Z(e.env,e.auth,n,e.bypassRules??!1)}),this.collectionId=e.collectionId}clone(e){return new Ae({env:this.env,auth:this.auth,collectionId:this.collectionId,clauses:e.clauses??this.clauses,orders:e.orders??this.orders,limitCount:"limitCount"in e?e.limitCount:this.limitCount,limitFromEnd:e.limitFromEnd??this.limitFromEnd,start:"start"in e?e.start:this.start,end:"end"in e?e.end:this.end,bypassRules:this.bypassRules})}queryScope(){return{kind:"collection-group",collectionId:this.collectionId}}activityScope(){return{kind:"collection-group"}}}class bn{env;auth;bypassRules;ops=[];constructor(e,n,r=!1){this.env=e,this.auth=n,this.bypassRules=r}set(e,n){const o=this.env.getDocument(e.path)===null?"create":"update";return this.ops.push({method:o,path:e.path,data:n}),this}update(e,n){return this.ops.push({method:"update",path:e.path,data:n}),this}delete(e){return this.ops.push({method:"delete",path:e.path}),this}async commit(e){if(this.ops.length===0)return;const n=this.env.batch(this.ops,e?.auth!==void 0?e.auth:this.auth,this.bypassRules);if(n.allowed)return;if(n.error)throw new f(n.error);const o=n.results.find(s=>!s.allowed)?.debugMessages.join("; ")??"batch denied";throw new f(k("permission-denied",`batch failed: ${o}`))}}function gn(t){return typeof t.where=="function"}class wn{simTx;constructor(e){this.simTx=e}async get(e){if(gn(e)){const o=await e.get();return o.size>0&&this.simTx.getAll(...o.docs.map(s=>s.ref.path)),o}const r=this.simTx.get(e.path).data();return rt(e,r)}set(e,n){return this.simTx.set(e.path,n),this}update(e,n){return this.simTx.update(e.path,n),this}delete(e){return this.simTx.delete(e.path),this}}class xn{env;auth;bypassRules;provenance;constructor(e,n,r=!1,o){this.env=e,this.auth=n,this.bypassRules=r,this.provenance=o}collection(e){if(!Oe(e))throw new f(k("invalid-argument",`collection path must have an odd number of segments: ${e}`));return new ut(this.env,this.auth,e,this.bypassRules)}doc(e){if(!tt(e))throw new f(k("invalid-argument",`document path must have an even number of segments: ${e}`));return Z(this.env,this.auth,e,this.bypassRules)}collectionGroup(e){if(e.length===0||e.includes("/"))throw new f(k("invalid-argument",`collection group id must be a single non-empty segment with no '/': ${e}`));return new Ae({env:this.env,auth:this.auth,collectionId:e,bypassRules:this.bypassRules})}batch(){return new bn(this.env,this.auth,this.bypassRules)}async runTransaction(e,n){let r;try{r=await this.env.transaction(o=>{const s=new wn(o);return e(s)},{auth:n?.auth!==void 0?n.auth:this.auth,bypassRules:this.bypassRules,provenance:this.provenance,maxAttempts:n?.maxAttempts})}catch(o){throw o instanceof Lt?new f(o.simError):o instanceof Ut?new f(o.simError):o}if(!r.allowed){if(r.error)throw new f(r.error);const s=r.writes.find(i=>!i.allowed)?.debugMessages.join("; ")??"transaction denied at commit";throw new f(k("permission-denied",`transaction failed: ${s}`))}return r.returnValue}}function Sn(t,e){return new xn(t,e?.auth??null,e?.bypassRules??!1,e?.provenance)}const dt=Symbol("pyric/sandbox/context"),lt=Symbol("pyric/sandbox/bypassRules");let me=null;function En(t){me=t}function Cn(t){const e=t;return typeof e.path=="string"&&e.path.length>0||typeof e.collectionPath=="string"&&e.collectionPath.length>0}function Rn(t){const e=t.trim();if(!e)return[];const n=e.indexOf(": ");if(n!==-1){const o=e.slice(n+2).trim().split("; ").map(s=>s.trim()).filter(s=>s.length>0);if(o.length>0)return o}return[e]}function We(t,e){if(t instanceof f===!1)return t;const r=t.code;if(r==="permission-denied"===!1)return new m(r,t.message);const s={auth:e.auth,reasons:Rn(t.message)},i=t.simError;if(i!==void 0){if(i.request!==void 0){const p=i.request;s.request={method:p.method,path:p.path},p.resourceData!==void 0&&(s.request.resourceData=p.resourceData)}if(i.resource!==void 0&&(s.resource={data:i.resource.data,exists:i.resource.exists}),i.query!==void 0&&(s.query=i.query),i.rule!==void 0&&(s.rule=i.rule),i.remediation!==void 0)return new m({code:r,message:t.message,denialContext:s,remediation:i.remediation})}return new m(r,t.message,s)}function ee(t,e,n=!1){return new Proxy(t,{get(r,o,s){if(o===dt)return e;if(o===lt)return n;if(o==="onSnapshot"&&me!==null&&!(o in r)&&Cn(r))return(...a)=>me(s,...a);const i=Reflect.get(r,o,s);return typeof i!="function"?i:function(...a){let u;try{const c=()=>i.apply(r,a);u=e.sandbox.runWithProvenance?.(Ce(e.operationContext),c)??c()}catch(c){throw We(c,e)}return u instanceof Promise?u.then(c=>c&&typeof c=="object"?ee(c,e,n):c).catch(c=>{throw We(c,e)}):u&&typeof u=="object"?ee(u,e,n):u}}})}function ht(t,e=!1){if(ve(t.sandbox))throw new Error("pyric/sandbox/admin-firestore: internal — a remote sandbox context reached the local engine builder; remote dispatch should have handled it. Please report this.");const n=()=>Sn(F(t.sandbox),{auth:t.auth,bypassRules:e,provenance:Ce(t.operationContext)});return{collection(r){return n().collection(r)},doc(r){return n().doc(r)},collectionGroup(r){return n().collectionGroup(r)},batch(){return n().batch()},runTransaction(r,o){return n().runTransaction(r,o)},setRules(r){return F(t.sandbox).deployRules(r)},seed(r){const o=F(t.sandbox);return o.seed({rules:o.getRules(),documents:r?.documents??{}})},snapshot(){return F(t.sandbox).snapshot()}}}function ye(t){if(t instanceof m)return t;if(t!==null&&typeof t=="object"){const e=t;if(typeof e.code=="string"&&typeof e.message=="string"){const n=e.denialContext!==null&&typeof e.denialContext=="object"?e.denialContext:void 0;return new m(e.code,e.message,n)}}return t}function g(t){return new m("invalid-argument",t)}async function y(t,e){try{return await t.sandbox.channel.op({...e,actAs:t.lens})}catch(n){throw ye(n)}}const vn=new Set(["serverTimestamp","increment","arrayUnion","arrayRemove","deleteField"]);function On(t){return t!==null&&typeof t=="object"&&typeof t.__type=="string"&&vn.has(t.__type)}function An(t){switch(t.__type){case"serverTimestamp":return{__sentinel:"serverTimestamp"};case"increment":return{__sentinel:"increment",n:t.value};case"arrayUnion":return{__sentinel:"arrayUnion",values:t.values.map(w)};case"arrayRemove":return{__sentinel:"arrayRemove",values:t.values.map(w)};case"deleteField":return{__sentinel:"deleteField"}}}function w(t){if(t===null||typeof t!="object")return t;if(On(t))return An(t);if(t instanceof Ie)return t.toJSON();if(t instanceof Date)return Ie.fromDate(t).toJSON();if(Array.isArray(t))return t.map(w);const e=Object.getPrototypeOf(t);if(e!==Object.prototype&&e!==null){const r=t.toJSON;if(typeof r=="function")return r.call(t);throw g(`remote Firestore: cannot serialize a ${e.constructor?.name??"class"} instance for the wire — use plain data, Timestamp, Date, or FieldValue sentinels.`)}const n={};for(const[r,o]of Object.entries(t))n[r]=w(o);return n}function O(t){return w(t)}function be(t){return Wt(JSON.parse(t.json))}function ft(t){return Se(be(t))}function pt(t,e){const n=e.exists&&e.data?ft(e.data):void 0;return{id:t.id,ref:t,exists:e.exists,data:()=>n,get:r=>re(n,r)}}function mt(t,e){const n=e.docs.map(r=>{const o=r.path??r.id,s=te(t,o),i=r.data?ft(r.data):{};return{id:s.id,ref:s,exists:!0,data:()=>i,get:a=>re(i,a)}});return{size:n.length,empty:n.length===0,docs:n,forEach(r){n.forEach(o=>r(o))}}}const ke=Symbol("pyric/sandbox/admin-firestore/remoteSnapshotRegistrar");function kn(t){if(t===null||typeof t!="object")return;const e=t[ke];return typeof e=="function"?e:void 0}let ge=null;function Fn(t){ge=t}function yt(...t){if(ge===null)throw new m("failed-precondition","remote Firestore: onSnapshot is not wired yet — import pyric-admin/firestore (or pyric/sandbox/admin-firestore) before subscribing.");return ge(this,...t)}function bt(t,e,n,r,o){const s=n.includeMetadataChanges!==!0;let i,a;try{a=t.sandbox.channel.subscribe({target:e,actAs:t.lens},u=>{if(!r)return;const c=u;if(Array.isArray(c.docs)){const l=c.docs.map(p=>({path:p.path??p.id,data:p.data?be(p.data):{}})),d=e.__ref==="query"?e.source.__ref==="group"?e.source.collectionId:e.source.path:e.__ref==="group"?e.collectionId:e.path,h=Bt({path:d},l,{excludesMetadataChanges:s},i);i=l,r(h)}else if(typeof c.id=="string"){const l=c.path??c.id,d=c.exists&&c.data?be(c.data):null;r(Qt(l,d))}},u=>{const c=ye(u);o?o(c):console.error("pyric remote Firestore: uncaught onSnapshot error:",c)})}catch(u){throw ye(u)}return a}const gt=Symbol("pyric/sandbox/admin-firestore/remoteQueryState");function Tn(t){if(!(t===null||typeof t!="object"))return t[gt]}function wt(t){return t.kind==="where"?(xt(t.op),{kind:"where",field:t.field,op:t.op,value:w(t.value)}):{kind:t.kind,filters:t.filters.map(wt)}}const _n=new Set(["<","<=","==","!=",">=",">","in","not-in","array-contains","array-contains-any"]);function xt(t){if(!_n.has(t))throw g(`invalid where operator: ${String(t)}`)}function Y(t){const e=[...t.filters];for(const n of t.orders)e.push({kind:"orderBy",field:n.field,direction:n.direction});return t.start&&e.push({kind:t.start.inclusive?"startAt":"startAfter",values:t.start.values.map(w)}),t.end&&e.push({kind:t.end.inclusive?"endAt":"endBefore",values:t.end.values.map(w)}),t.limitCount!==void 0&&e.push(t.limitFromEnd?{kind:"limitToLast",n:t.limitCount}:{kind:"limit",n:t.limitCount}),e.length===0?t.source:{__ref:"query",source:t.source,constraints:e}}function Be(t,e,n){if(e.length===0)throw g(`${n}(snapshot) on a remote sandbox requires at least one explicit orderBy() clause — the relay protocol has no document-key cursor.`);if(e.some(o=>o.field==="__name__"))throw g(`${n}(snapshot) on a remote sandbox does not support orderBy('__name__') — the relay protocol has no document-key cursor, and __name__ is not a data field a value cursor can carry. Order by a real document field instead.`);const r=t.data();if(r===void 0)throw new m("not-found",`Snapshot-based cursors require an existing document — got an empty snapshot for ${t.id??"<unknown>"}.`);return e.map(o=>r[o.field])}function Fe(t,e){const n=o=>Fe(t,{...e,...o});return{[gt]:e,where(o,s,i){return xt(s),n({filters:[...e.filters,{kind:"where",field:o,op:s,value:w(i)}]})},applyFilter(o){return n({filters:[...e.filters,wt(o)]})},orderBy(o,s="asc"){return n({orders:[...e.orders,{field:o,direction:s}]})},limit(o){return n({limitCount:o,limitFromEnd:!1})},limitToLast(o){return n({limitCount:o,limitFromEnd:!0})},startCursor(o,s){return n({start:{values:[...o],inclusive:s}})},endCursor(o,s){return n({end:{values:[...o],inclusive:s}})},startCursorFromSnapshot(o,s){return n({start:{values:Be(o,e.orders,s?"startAt":"startAfter"),inclusive:s}})},endCursorFromSnapshot(o,s){return n({end:{values:Be(o,e.orders,s?"endAt":"endBefore"),inclusive:s}})},async get(o){K(e);const s=await y(t,{method:"getDocs",source:Y(e)});return mt(t,s)},async aggregate(o){K(e);const s=await y(t,{method:"aggregate",source:Y(e),spec:o});return{data:()=>s.data}},[ke]:(o,s,i)=>(K(e),bt(t,Y(e),o,s,i)),onSnapshot:yt}}function K(t){if(t.limitFromEnd&&t.orders.length===0)throw g("limitToLast() queries require at least one orderBy clause.")}function we(t,e){const n=Fe(t,{source:{__ref:"collection",path:e},filters:[],orders:[],limitFromEnd:!1});return Object.assign(Object.create(Object.getPrototypeOf(n)),n,{id:se(e),path:e,doc(o){const s=o??Xe();return te(t,`${e}/${s}`)},async add(o,s){const i=await y(t,{method:"addDoc",collectionPath:e,data:O(o)});return te(t,i.path)}})}function te(t,e){const n={id:se(e),path:e,get parent(){return we(t,nt(e))},collection(r){const o=`${e}/${r}`;if(!Oe(o))throw g(`collection path must have an odd number of segments: ${o}`);return we(t,o)},async get(r){const o=await y(t,{method:"getDoc",path:e});return pt(n,o)},async set(r,o){await y(t,{method:"setDoc",path:e,data:O(r),...Qe(o)?{options:Qe(o)}:{}})},async update(r,o){await y(t,{method:"updateDoc",path:e,data:O(r)})},async delete(r){await y(t,{method:"deleteDoc",path:e})},[ke]:(r,o,s)=>bt(t,{__ref:"doc",path:e},r,o,s),onSnapshot:yt};return n}function Qe(t){if(!t)return;const e={};return t.merge!==void 0&&(e.merge=t.merge),t.mergeFields!==void 0&&(e.mergeFields=[...t.mergeFields]),e.merge!==void 0||e.mergeFields!==void 0?e:void 0}function Dn(t){const e=[];let n=!1;const r={set(s,i){return o(),e.push({method:"set",path:s.path,data:O(i)}),r},update(s,i){return o(),e.push({method:"update",path:s.path,data:O(i)}),r},delete(s){return o(),e.push({method:"delete",path:s.path}),r},async commit(s){o(),n=!0,await y(t,{method:"batchCommit",writes:e})}};function o(){if(n)throw new m("failed-precondition","WriteBatch has already been committed.")}return r}const jn=5;async function Pn(t,e,n=jn){for(let r=0;r<n;r++){const o=[],s=[],i=()=>{if(s.length>0)throw new m("failed-precondition",Ht)},a={get(d){i();const h=Tn(d);return h!==void 0?c(h):u(d)},set(d,h){return s.push({method:"set",path:d.path,data:O(h)}),a},update(d,h){return s.push({method:"update",path:d.path,data:O(h)}),a},delete(d){return s.push({method:"delete",path:d.path}),a}};async function u(d){const h=await y(t,{method:"getDoc",path:d.path});return o.push({path:h.path??d.path,data:h.exists&&h.data?h.data:null}),pt(d,h)}async function c(d){K(d);const h=await y(t,{method:"getDocs",source:Y(d)});for(const p of h.docs)o.push({path:p.path??p.id,data:p.data??null});return mt(t,h)}const l=await e(a);try{return await y(t,{method:"txnCommit",reads:o,writes:s}),l}catch(d){if(d instanceof m&&d.code==="aborted")continue;throw d}}throw new m("aborted",`Transaction failed after ${n} attempts due to repeated conflicts. Another writer is concurrently updating the same documents.`)}function ue(t,e){return new m("unimplemented",`SandboxFirestore.${t} is not available on a remote sandbox — its return value is synchronous and the data lives in the browser worker. ${e}`)}function St(t,e){const n={sandbox:t,lens:e};return{collection(r){if(!Oe(r))throw g(`collection path must have an odd number of segments: ${r}`);return we(n,r)},doc(r){if(!tt(r))throw g(`document path must have an even number of segments: ${r}`);return te(n,r)},collectionGroup(r){if(r.length===0||r.includes("/"))throw g(`collection group id must be a single non-empty segment with no '/': ${r}`);return Fe(n,{source:{__ref:"group",collectionId:r},filters:[],orders:[],limitFromEnd:!1})},batch(){return Dn(n)},runTransaction(r,o){return Pn(n,r,o?.maxAttempts)},setRules(){throw ue("setRules","Deploy rules asynchronously through the relay instead: `await sandbox.channel.op({ method: 'setFirestoreRules', source })`.")},seed(){throw ue("seed","The relay has no atomic seed op; write seed docs through this handle (`db.doc(path).set(data)` / `db.batch()`), or drive `sandbox.channel.op({ method: 'admin.setDocument', path, data })` per document.")},snapshot(){throw ue("snapshot","Read the worker state asynchronously instead: `await sandbox.channel.op({ method: 'admin.readState' })`.")}}}const He=new WeakMap;function Et(t){const e=He.get(t);if(e)return e;const n=ve(t.sandbox)?St(t.sandbox,In(t.auth)):ee(ht(t),t);return He.set(t,n),n}function In(t){return t==null?{mode:"anon"}:t.token===void 0?{mode:"as",uid:t.uid}:{mode:"as",uid:t.uid,token:t.token}}const Je=new WeakMap;function qn(t){const e=Vn(t)?t:t.withAuth(null),n=Je.get(e);if(n)return n;const r=e.operationContext.authLens.mode==="admin"?e:Re(e,{source:e.operationContext.source,authLens:{mode:"admin"},...e.operationContext.planId===void 0?{}:{planId:e.operationContext.planId}}),o=ve(r.sandbox)?St(r.sandbox,{mode:"admin"}):ee(ht(r,!0),r,!0);return Je.set(e,o),o}function Vn(t){return t!==null&&typeof t=="object"&&"sandbox"in t&&typeof t.withAuth=="function"}const Q=Symbol("pyric/firestore/followsCurrentUser"),de=Symbol("pyric/firestore/authSessionScope");function Nn(t){if(t===null||typeof t!="object")return null;const e=t;return typeof e.path=="string"&&e.path.length>0?e.path:typeof e.collectionPath=="string"&&e.collectionPath.length>0?e.collectionPath:null}function zn(t){if(t!==null&&typeof t=="object"){const e=t.snapshotConstraints;if(typeof e=="function")return e.call(t)}}function Mn(t){if(t===null||typeof t!="object")return!1;const e=t;return typeof e.path=="string"&&e.path.length>0&&e.parent!==void 0&&e.parent!==null}function Ct(t,e,n,r,o){let s={},i,a;if(typeof e=="object"&&e!==null&&typeof e.next!="function"&&typeof e.error!="function"&&typeof e.complete!="function"){if(s=e,typeof n=="function")i=n,a=r;else if(typeof n=="object"&&n!==null){const b=n;i=b.next,a=b.error}}else if(typeof e=="function")i=e,a=n;else if(typeof e=="object"&&e!==null){const b=e;i=b.next,a=b.error}if(!i&&!a)throw new TypeError("onSnapshot: missing handler. Provide a callback, or an observer with a `next` and/or `error` method.");const c=kn(t);if(c){if(s[Q]===!0)throw new m("unimplemented","onSnapshot: live (follows-current-user) listeners are not supported on a remote sandbox — remote listeners are frozen to the identity of the context that created the ref.");return c(s,i,a)}const l=$n(t),d=F(l.sandbox);let h;if(Mn(t))h={kind:"doc",path:t.path};else{const b=Nn(t);if(b===null)throw new TypeError("onSnapshot: could not determine the collection path for this Query. Pass a CollectionReference or a Query produced by `.where`/`.orderBy`/`.limit` on a CollectionReference obtained from `getFirestore(ctx)`.");const I=zn(t);h={kind:"query",collection:b,constraints:I}}const p=s[Q]===!0,De=s[de],Ft=t[lt]===!0;if(Q in s){const{[Q]:b,...I}=s;s=I}if(de in s){const{[de]:b,...I}=s;s=I}const je=()=>d.addSnapshotListener(h,i??(()=>{}),s,l.auth,a,p,Ft,De);return l.sandbox.runWithProvenance?.(Ce(l.operationContext),je)??je()}function $n(t){if(t===null||typeof t!="object")throw new TypeError("onSnapshot: reference must be a DocumentReference or Query.");const e=t[dt];if(!e)throw new TypeError("onSnapshot: reference was not produced by a sandbox context — pass a ref obtained from `getFirestore(ctx)`.");return e}En(Ct);Fn(Ct);class C{bytes;constructor(e){this.bytes=e,v(this,Jt(e)),oe(this,Object.freeze({type:"bytes",values:Object.freeze(Array.from(e))}),()=>new C(e.slice()))}static fromBase64String(e){const n=atob(e),r=new Uint8Array(n.length);for(let o=0;o<n.length;o+=1)r[o]=n.charCodeAt(o);return new C(r)}static fromUint8Array(e){return new C(e.slice())}toBase64(){let e="";for(const n of this.bytes)e+=String.fromCharCode(n);return btoa(e)}toUint8Array(){return this.bytes.slice()}toString(){return`Bytes(base64: ${this.toBase64()})`}isEqual(e){return e instanceof C&&this.bytes.length===e.bytes.length&&this.bytes.every((n,r)=>n===e.bytes[r])}toJSON(){return{type:"firestore/bytes/1.0",bytes:this.toBase64()}}static fromJSON(e){const n=e;if(n.type!=="firestore/bytes/1.0"||typeof n.bytes!="string")throw new TypeError("Invalid Bytes JSON value.");return C.fromBase64String(n.bytes)}}class V{lat;lng;constructor(e,n){if(this.lat=e,this.lng=n,!Number.isFinite(e)||e<-90||e>90)throw new TypeError("Latitude must be a number between -90 and 90.");if(!Number.isFinite(n)||n<-180||n>180)throw new TypeError("Longitude must be a number between -180 and 180.");v(this,_("geo-point",String(e),"\0",String(n))),oe(this,Object.freeze({type:"geo-point",latitude:e,longitude:n}),()=>new V(e,n))}get latitude(){return this.lat}get longitude(){return this.lng}isEqual(e){return e instanceof V&&this.lat===e.lat&&this.lng===e.lng}toJSON(){return{latitude:this.lat,longitude:this.lng,type:"firestore/geoPoint/1.0"}}static fromJSON(e){const n=e;if(n.type!=="firestore/geoPoint/1.0"||typeof n.latitude!="number"||typeof n.longitude!="number")throw new TypeError("Invalid GeoPoint JSON value.");return new V(n.latitude,n.longitude)}}class T{_values;constructor(e){this._values=e,oe(this,Object.freeze({type:"vector",values:Object.freeze(e.slice())}),()=>new T(e.slice()))}static create(e){if(!e.every(n=>typeof n=="number"))throw new TypeError("Vector values must be numbers.");return new T(e.slice())}toArray(){return this._values.slice()}isEqual(e){const n=e instanceof T?e._values:void 0;return n!==void 0&&this._values.length===n.length&&this._values.every((r,o)=>r===n[o])}toJSON(){return{type:"firestore/vectorValue/1.0",vectorValues:this.toArray()}}static fromJSON(e){const n=e;if(n.type!=="firestore/vectorValue/1.0"||!Array.isArray(n.vectorValues)||!n.vectorValues.every(r=>typeof r=="number"))throw new TypeError("Invalid VectorValue JSON value.");return T.create(n.vectorValues)}}function Ln(t=[]){return T.create(t)}function ir(){return Gt.serverTimestamp()}const S=Symbol("pyric/firestore/target");function L(t){return t.kind==="sandbox"?t.db:t.getDb()}const ie=new WeakMap;function Un(t,e){return ie.set(t,e),t}const U=new WeakMap;function Wn(t,e,n){return ie.set(t,e),U.set(t,n),t}function Te(t,e){const n=P(e);if(t.kind==="sandbox")return n;const r=U.get(n);if(!r)throw new TypeError("pyric/firestore: live ref missing rebuild closure — was it produced by a factory in this package?");return r(L(t))}function Bn(t,e){const n=P(e);if(t.kind==="sandbox")return n;const r=U.get(n);if(!r)throw new TypeError("pyric/firestore: live collection ref missing rebuild closure.");return r(L(t))}function ar(t,e){const n=P(e);if(t.kind==="sandbox")return n;const r=U.get(n);if(!r)throw new TypeError("pyric/firestore: live query missing rebuild closure.");return r(L(t))}function M(t,e,n){return e.kind==="sandbox-live"?Wn(t,e,n):Un(t,e)}function cr(t){const e=P(t),n=U.get(e);return n||(()=>e)}function j(t){const e=Qn(t);return e.assertUsable?.(),e}function Qn(t){let e;if(S in t?e=t[S]:e=ie.get(t),!e)throw new TypeError("pyric/firestore: unrecognized reference — was it produced by a factory in this package?");return e}const Rt=new WeakMap,vt=new WeakMap;function _e(t){return Rt.get(t)}function P(t){return vt.get(t)??t}function Ot(t,e,n){const r={id:t.id??"",path:t.path??""};return Rt.set(r,n),vt.set(r,t),ie.set(r,e),r}function Hn(t){return t instanceof Xt?Array.from(t.value):null}function xe(t){if(t instanceof Yt)return C.fromUint8Array(t.data);if(t instanceof Kt)return new V(t.lat,t.lng);const e=Hn(t);if(e)return Ln(e);if(Array.isArray(t))return t.map(xe);if(t!==null&&typeof t=="object"){const n=Object.getPrototypeOf(t);if(n===Object.prototype||n===null){const r={};for(const[o,s]of Object.entries(t))r[o]=xe(s);return r}}return t}function ur(t){if(t!==void 0)return xe(t)}class D extends Error{code;customData;name="FirebaseError";constructor(e,n,r){super(n),this.code=e,this.customData=r,Object.setPrototypeOf(this,new.target.prototype)}}Object.defineProperty(D,"name",{value:"FirebaseError"});let ne;function dr(t){ne=t}function At(t){return ne?.resolve(t,!1)}function Jn(){if(!ne)throw new TypeError("No default sandbox app registry is installed - import and initialize pyric/app before calling a service factory without an app.");return ne.defaultApp()}function Gn(t){if(t===void 0)return Gn(Jn());const e=At(t);if(e)return e.service("firestore/default",()=>{const{sandbox:n,session:r}=e,o=le();e.onDelete(o.terminate);const s=e.authScope;s&&o.own(r.onCurrentUserChanged(a=>{F(n).reevaluateLiveListeners(a,s)}));const i={kind:"sandbox-live",sandbox:n,getDb:Ge(n,()=>r.currentUser),authScope:s,...o};return{[S]:i,app:t}});if(kt(t)){const r={kind:"sandbox",db:Et(t),sandbox:t.sandbox,...le()};return{[S]:r}}if(Kn(t)){const n={kind:"sandbox-live",sandbox:t,getDb:Ge(t),...le()};return{[S]:n}}throw new TypeError("pyric/firestore is a sandbox-only mirror. Package resolution must leave firebase/firestore unchanged for production; activate pyric sandbox or @pyric/cli/register before importing to select the sandbox.")}function le(){let t=!1;const e=new Set;return{own(n){return t?(n(),()=>{}):(e.add(n),()=>e.delete(n))},assertUsable(){if(t)throw new D("failed-precondition","The client has already been terminated.")},terminate(){if(!t){t=!0;for(const n of e)n();e.clear()}}}}function Yn(t){const e=At(t);if(e){e.assertAlive();const i=e.sandbox;return Yn(Re(i.withAuth(null),{source:{kind:"app"},authLens:{mode:"admin"}}))}const n=kt(t)?t:t.withAuth(null),r=n.sandbox,s={kind:"sandbox",db:qn(n),sandbox:r};return{[S]:s}}function kt(t){return t instanceof Zt}function Kn(t){if(t===null||typeof t!="object")return!1;const e=t;return typeof e.withAuth=="function"&&typeof e.onCurrentUserChanged=="function"&&"currentUser"in e&&"admin"in e}function Ge(t,e=()=>t.currentUser){return()=>{const n=Re(t.withAuth(e()),{source:{kind:"app"},authLens:{mode:"app-session"}});return Et(n)}}class Xn{started=!1;networkEnabled=!0;persistenceMode;pending=new Set;cachedPaths=new Set;cachedQueries=new WeakSet;syncObservers=new Set;syncScheduled=!1;markStarted(){this.started=!0}enablePersistence(e){if(this.started||this.persistenceMode!==void 0)throw new D("failed-precondition","Firestore has already been started and persistence can no longer be enabled.");this.persistenceMode=e,this.started=!0}disableNetwork(){this.started=!0,this.networkEnabled=!1}async enableNetwork(){this.started=!0,this.networkEnabled=!0;for(const e of this.pending)e.localDone&&e.resolve(e.value);await Promise.all([...this.pending].map(e=>e.promise))}runWrite(e,n){if(this.started=!0,n&&this.cachedPaths.add(n),this.networkEnabled)return e();let r,o;const s=new Promise((a,u)=>{r=a,o=u}),i={path:n,promise:s,localDone:!1,resolve:r,reject:o};return this.pending.add(i),e().then(a=>{i.localDone=!0,i.value=a,this.networkEnabled&&i.resolve(a)},a=>i.reject(a)),s.then(()=>this.pending.delete(i),()=>this.pending.delete(i)),s}waitForPendingWrites(){this.started=!0;const e=[...this.pending].map(n=>n.promise);return Promise.all(e).then(()=>{})}cachePath(e){this.started=!0,this.cachedPaths.add(e)}assertPathCached(e){if(this.started=!0,!this.cachedPaths.has(e))throw new D("unavailable","Failed to get document from cache. (However, this document may exist on the server.)")}cacheQuery(e){this.started=!0,this.cachedQueries.add(e)}hasCachedQuery(e){return this.started=!0,this.cachedQueries.has(e)||this.cachedPaths.size>0}snapshotMetadata(e){return Object.freeze({fromCache:!this.networkEnabled,hasPendingWrites:[...this.pending].some(n=>n.path===e)})}querySnapshotMetadata(){return Object.freeze({fromCache:!this.networkEnabled,hasPendingWrites:this.pending.size>0})}addSnapshotsInSyncObserver(e){return this.syncObservers.add(e),e(),()=>this.syncObservers.delete(e)}notifySnapshotDelivered(){this.syncScheduled||this.syncObservers.size===0||(this.syncScheduled=!0,queueMicrotask(()=>{this.syncScheduled=!1;for(const e of[...this.syncObservers])e()}))}}const Ye=new WeakMap;function $(t){let e=Ye.get(t);return e||(e=new Xn,Ye.set(t,e)),e}function he(t,e,n){return v(t,_("reference",e)),Ee(t,e,n),t}function lr(t,...e){const n=j(t),r=S in t,o=r?void 0:_e(t),s=L(n);if(r){if(e.length===0)throw new TypeError("doc(db, path) requires at least one path segment.");const l=e.join("/"),d=s.doc(l),h=M(d,n,p=>p.doc(l));return he(h,l,n)}const i=P(t),a=e.length===0?i.doc():i.doc(e.join("/")),u=a.path,c=M(a,n,l=>l.doc(u));if(o){const l=Ot(c,n,o);return he(l,u,n)}return he(c,u,n)}function hr(t,...e){const n=j(t),r=S in t;if(e.length===0)throw new TypeError("collection() requires at least one path segment.");if(r){const u=e.join("/"),c=L(n).collection(u);return M(c,n,l=>l.collection(u))}const o=P(t),s=e.join("/"),i=o.collection(s),a=i.path;return M(i,n,u=>u.collection(a))}function Zn(t){return t instanceof Error&&"code"in t&&typeof t.code=="string"}function er(t){if(t instanceof D||!Zn(t))return t;const e={};t.denialContext!==void 0&&(e.denialContext=t.denialContext),t.remediation!==void 0&&(e.remediation=t.remediation);const n=new D(t.code,t.message,Object.keys(e).length===0?void 0:e);return t.denialContext!==void 0&&Object.assign(n,{denialContext:t.denialContext}),t.remediation!==void 0&&Object.assign(n,{remediation:t.remediation}),n}async function ae(t){try{return await t()}catch(e){throw er(e)}}async function fr(t,e,n){const r=j(t),o=_e(t),s=o?o.toFirestore(e):e;return $(r).runWrite(()=>ae(()=>Te(r,t).set(s,n)),t.path)}async function pr(t,e){const n=j(t);return $(n).runWrite(()=>ae(()=>Te(n,t).update(e)),t.path)}async function mr(t){const e=j(t);return $(e).runWrite(()=>ae(()=>Te(e,t).delete()),t.path)}async function yr(t,e){const n=j(t),r=_e(t),o=r?r.toFirestore(e):e,s=await $(n).runWrite(async()=>{const u=await ae(()=>Bn(n,t).add(o));return $(n).cachePath(u.path),u}),i=s.path,a=M(s,n,u=>u.doc(i));if(v(a,_("reference",i)),Ee(a,i,n,a),r){const u=Ot(a,n,r);return en(a,u),u}return a}export{de as A,hr as B,yr as C,pr as D,mr as E,Q as F,dr as G,Yn as H,Jn as I,At as J,V as K,C as L,ir as M,rr as S,or as a,$ as b,rn as c,lr as d,_e as e,ur as f,Gn as g,L as h,sr as i,U as j,ot as k,st as l,nn as m,j as n,Te as o,ar as p,cr as q,vt as r,fr as s,Un as t,P as u,nr as v,er as w,M as x,Ot as y,D as z};