@madarco/agentbox 0.22.1 → 0.23.0

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 (217) hide show
  1. package/CHANGELOG.md +93 -0
  2. package/dist/{_cloud-attach-YH2SU75S.js → _cloud-attach-RFPLNACE.js} +5 -5
  3. package/dist/{chunk-GGWVTWJM.js → chunk-6OQENOJZ.js} +16 -13
  4. package/dist/chunk-6OQENOJZ.js.map +1 -0
  5. package/dist/{chunk-ALEYDWAO.js → chunk-CKC3CP7Y.js} +494 -148
  6. package/dist/chunk-CKC3CP7Y.js.map +1 -0
  7. package/dist/{chunk-O67ZESNL.js → chunk-ERMU7RMK.js} +43 -58
  8. package/dist/{chunk-O67ZESNL.js.map → chunk-ERMU7RMK.js.map} +1 -1
  9. package/dist/chunk-G3H2L3O2.js +0 -0
  10. package/dist/{chunk-KBVD2UUQ.js → chunk-JXDSSSXS.js} +3 -3
  11. package/dist/{chunk-CDEJ2GQK.js → chunk-L5SOSNQI.js} +4 -4
  12. package/dist/{chunk-W2FLHB54.js → chunk-Q626V2YX.js} +2 -2
  13. package/dist/{chunk-YZXXBHWG.js → chunk-QGL734YX.js} +170 -53
  14. package/dist/chunk-QGL734YX.js.map +1 -0
  15. package/dist/{chunk-VBSRJG53.js → chunk-QT3SHMLY.js} +9 -1
  16. package/dist/chunk-QT3SHMLY.js.map +1 -0
  17. package/dist/{chunk-O2NDZQHN.js → chunk-QVWGQJV6.js} +2 -2
  18. package/dist/chunk-WJFZJZIM.js +0 -0
  19. package/dist/cloud-poller-SUNA6ZQC-7M5LJHHE.js +0 -0
  20. package/dist/{dist-QBXEP4VY.js → dist-2BTJQUJS.js} +2 -2
  21. package/dist/{dist-UR2DB2HT.js → dist-GEHCZJCS.js} +6 -6
  22. package/dist/{dist-LJHS4PTC.js → dist-GJCIKH2C.js} +6 -6
  23. package/dist/{dist-EJXUKIR7.js → dist-JFUUDAI3.js} +18 -4
  24. package/dist/{dist-QNV4H6NN.js → dist-W5476E2U.js} +6 -6
  25. package/dist/{dist-YECTRVGD.js → dist-Z3GSHEFO.js} +8 -7
  26. package/dist/index.js +1339 -782
  27. package/dist/index.js.map +1 -1
  28. package/dist/{prepared-state-5FIGV4BE-BMUK63FD.js → prepared-state-LW2PKTEQ-5YMKG7UN.js} +2 -2
  29. package/package.json +28 -27
  30. package/runtime/_shared/agentbox-checkpoint-cleanup +0 -0
  31. package/runtime/_shared/agentbox-dockerd-start +0 -0
  32. package/runtime/_shared/agentbox-open +0 -0
  33. package/runtime/_shared/agentbox-portless-trust +0 -0
  34. package/runtime/_shared/agentbox-vnc-start +0 -0
  35. package/runtime/_shared/ctl.cjs +13 -1
  36. package/runtime/_shared/gh-shim +0 -0
  37. package/runtime/_shared/git-shim +0 -0
  38. package/runtime/_shared/linear-shim +0 -0
  39. package/runtime/_shared/ntn-shim +0 -0
  40. package/runtime/docker/Dockerfile.box +12 -0
  41. package/runtime/docker/packages/ctl/dist/bin.cjs +13 -1
  42. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-checkpoint-cleanup +0 -0
  43. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-dockerd-start +0 -0
  44. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-open +0 -0
  45. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-portless-trust +0 -0
  46. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-sshd-start +44 -0
  47. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-vnc-start +0 -0
  48. package/runtime/docker/packages/sandbox-docker/scripts/chromium-resolver +0 -0
  49. package/runtime/docker/packages/sandbox-docker/scripts/gh-shim +0 -0
  50. package/runtime/docker/packages/sandbox-docker/scripts/git-shim +0 -0
  51. package/runtime/docker/packages/sandbox-docker/scripts/linear-shim +0 -0
  52. package/runtime/docker/packages/sandbox-docker/scripts/ntn-shim +0 -0
  53. package/runtime/e2b/agentbox-checkpoint-cleanup +0 -0
  54. package/runtime/e2b/agentbox-dockerd-start +0 -0
  55. package/runtime/e2b/agentbox-open +0 -0
  56. package/runtime/e2b/agentbox-vnc-start +0 -0
  57. package/runtime/e2b/ctl.cjs +13 -1
  58. package/runtime/e2b/gh-shim +0 -0
  59. package/runtime/e2b/git-shim +0 -0
  60. package/runtime/e2b/linear-shim +0 -0
  61. package/runtime/e2b/ntn-shim +0 -0
  62. package/runtime/e2b/scripts/build-template.sh +0 -0
  63. package/runtime/hetzner/agentbox-checkpoint-cleanup +0 -0
  64. package/runtime/hetzner/agentbox-dockerd-start +0 -0
  65. package/runtime/hetzner/agentbox-open +0 -0
  66. package/runtime/hetzner/agentbox-portless-trust +0 -0
  67. package/runtime/hetzner/agentbox-vnc-start +0 -0
  68. package/runtime/hetzner/ctl.cjs +13 -1
  69. package/runtime/hetzner/gh-shim +0 -0
  70. package/runtime/hetzner/git-shim +0 -0
  71. package/runtime/hetzner/linear-shim +0 -0
  72. package/runtime/hetzner/ntn-shim +0 -0
  73. package/runtime/hetzner/scripts/install-box.sh +0 -0
  74. package/runtime/hub/apps/hub/.next/BUILD_ID +1 -1
  75. package/runtime/hub/apps/hub/.next/app-path-routes-manifest.json +3 -0
  76. package/runtime/hub/apps/hub/.next/build-manifest.json +3 -3
  77. package/runtime/hub/apps/hub/.next/routes-manifest.json +22 -0
  78. package/runtime/hub/apps/hub/.next/server/app/(auth)/signin/page_client-reference-manifest.js +1 -1
  79. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/open/route/app-paths-manifest.json +3 -0
  80. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/open/route/build-manifest.json +9 -0
  81. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/open/route/server-reference-manifest.json +4 -0
  82. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/open/route.js +9 -0
  83. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/open/route.js.map +5 -0
  84. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/open/route.js.nft.json +1 -0
  85. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/open/route_client-reference-manifest.js +3 -0
  86. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/rename/route/app-paths-manifest.json +3 -0
  87. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/rename/route/build-manifest.json +9 -0
  88. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/rename/route/server-reference-manifest.json +4 -0
  89. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/rename/route.js +9 -0
  90. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/rename/route.js.map +5 -0
  91. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/rename/route.js.nft.json +1 -0
  92. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/rename/route_client-reference-manifest.js +3 -0
  93. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/open-targets/route/app-paths-manifest.json +3 -0
  94. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/open-targets/route/build-manifest.json +9 -0
  95. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/open-targets/route/server-reference-manifest.json +4 -0
  96. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/open-targets/route.js +8 -0
  97. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/open-targets/route.js.map +5 -0
  98. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/open-targets/route.js.nft.json +1 -0
  99. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/open-targets/route_client-reference-manifest.js +3 -0
  100. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/approvals/page_client-reference-manifest.js +1 -1
  101. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/page/server-reference-manifest.json +12 -0
  102. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/page_client-reference-manifest.js +1 -1
  103. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/page/server-reference-manifest.json +12 -0
  104. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/page_client-reference-manifest.js +1 -1
  105. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/projects/[id]/page/server-reference-manifest.json +12 -0
  106. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/projects/[id]/page_client-reference-manifest.js +1 -1
  107. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/settings/page_client-reference-manifest.js +1 -1
  108. package/runtime/hub/apps/hub/.next/server/app/_global-error.html +1 -1
  109. package/runtime/hub/apps/hub/.next/server/app/_global-error.rsc +1 -1
  110. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  111. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  112. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  113. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  114. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  115. package/runtime/hub/apps/hub/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  116. package/runtime/hub/apps/hub/.next/server/app-paths-manifest.json +3 -0
  117. package/runtime/hub/apps/hub/.next/server/chunks/0m4a_kysely_dist_095p8vu._.js +1 -1
  118. package/runtime/hub/apps/hub/.next/server/chunks/0ssw__next-internal_server_app_(dashboard)_api_v1_open-targets_route_actions_1z-vd4m.js +3 -0
  119. package/runtime/hub/apps/hub/.next/server/chunks/1jcg_server_app_(dashboard)_api_v1_boxes_[id]_open_route_actions_1agwl8h.js +3 -0
  120. package/runtime/hub/apps/hub/.next/server/chunks/1jcg_server_app_(dashboard)_api_v1_boxes_[id]_rename_route_actions_0mf3a9p.js +3 -0
  121. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0d1lmiq._.js +1 -1
  122. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0keu6we._.js +1 -1
  123. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0ql4fjo._.js +1 -1
  124. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0szd4sh._.js +3 -0
  125. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0vs8fma._.js +1 -1
  126. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0w9ud8u._.js +1 -1
  127. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0yhb0gc._.js +1 -1
  128. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1-0flwc._.js +3 -0
  129. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1a50b07._.js +3 -0
  130. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1bqbkd5._.js +2 -2
  131. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1dn_3i1._.js +1 -1
  132. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1hqla7-._.js +1 -1
  133. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1js2jdv._.js +1 -1
  134. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1nepkp-._.js +1 -1
  135. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1q5bqse._.js +1 -1
  136. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1qa4a0v._.js +2 -2
  137. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1thipug._.js +3 -0
  138. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1v9om6g._.js +1 -1
  139. package/runtime/hub/apps/hub/.next/server/chunks/_06f2faq._.js +1 -1
  140. package/runtime/hub/apps/hub/.next/server/chunks/_0760z6y._.js +14 -14
  141. package/runtime/hub/apps/hub/.next/server/chunks/_0f3molr._.js +3 -0
  142. package/runtime/hub/apps/hub/.next/server/chunks/_0lgs9kd._.js +3 -0
  143. package/runtime/hub/apps/hub/.next/server/chunks/ssr/044u_hub__next-internal_server_app_(dashboard)_projects_[id]_page_actions_15f56np.js +1 -1
  144. package/runtime/hub/apps/hub/.next/server/chunks/ssr/_09gdzmo._.js +1 -1
  145. package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0ozyjt1._.js +1 -1
  146. package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0ro6vh6._.js +1 -1
  147. package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0tgpglr._.js +1 -1
  148. package/runtime/hub/apps/hub/.next/server/chunks/ssr/_1laion6._.js +1 -1
  149. package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub_0b_hsjl._.js +1 -1
  150. package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub__next-internal_server_app_(dashboard)_boxes_[id]_page_actions_0k7kgn2.js +1 -1
  151. package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub__next-internal_server_app_(dashboard)_page_actions_1t3u0xy.js +1 -1
  152. package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub_app_(dashboard)_boxes_[id]_page_tsx_1-j_972._.js +1 -1
  153. package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub_app_(dashboard)_boxes_components_box-table_tsx_0a9pyn_._.js +1 -1
  154. package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub_components_1z1p98f._.js +1 -1
  155. package/runtime/hub/apps/hub/.next/server/functions-config-manifest.json +3 -0
  156. package/runtime/hub/apps/hub/.next/server/middleware-build-manifest.js +3 -3
  157. package/runtime/hub/apps/hub/.next/server/pages/500.html +1 -1
  158. package/runtime/hub/apps/hub/.next/server/server-reference-manifest.js +1 -1
  159. package/runtime/hub/apps/hub/.next/server/server-reference-manifest.json +24 -0
  160. package/runtime/hub/apps/hub/.next/static/chunks/1py5tlz57h7ra.js +1 -0
  161. package/runtime/hub/apps/hub/.next/static/chunks/{3y2c7woqhtx9s.js → 23fswvjrabu89.js} +1 -1
  162. package/runtime/hub/apps/hub/.next/static/chunks/2xc1sm79a6tsb.js +1 -0
  163. package/runtime/hub/apps/hub/.next/static/chunks/3nedwutnzpdis.css +3 -0
  164. package/runtime/hub/apps/hub/.next/static/chunks/3p86ecqhr_7yy.js +1 -0
  165. package/runtime/hub/apps/hub/.next/static/chunks/3qof5hg87qf5n.js +1 -0
  166. package/runtime/hub/apps/hub/{auth-YBXDRLHG.js → auth-675P3LQS.js} +2 -2
  167. package/runtime/hub/apps/hub/{auth-config-LJGI76HI.js → auth-config-AOBEKRZQ.js} +2 -2
  168. package/runtime/hub/apps/hub/{chunk-OBKLTPIR.js → chunk-56YQBVN2.js} +1 -1
  169. package/runtime/hub/apps/hub/{chunk-JDA7BPPN.js → chunk-6HD4PARX.js} +9 -9
  170. package/runtime/hub/apps/hub/{chunk-AKLBSCSZ.js → chunk-EXQCBM5Q.js} +8 -0
  171. package/runtime/hub/apps/hub/{chunk-V5KGFHCF.js → chunk-JQFB2CNA.js} +132 -16
  172. package/runtime/hub/apps/hub/{chunk-LJG4CEGS.js → chunk-K6RA5GJI.js} +412 -117
  173. package/runtime/hub/apps/hub/{dist-ELOY2IUE.js → dist-3HR4RIPE.js} +17 -3
  174. package/runtime/hub/apps/hub/{dist-GGM4BUKM.js → dist-7GNKBKFV.js} +29 -42
  175. package/runtime/hub/apps/hub/{dist-BF54UNHK.js → dist-JWVTVHBT.js} +4 -4
  176. package/runtime/hub/apps/hub/{dist-CM4YAQLI.js → dist-OUNL2TCW.js} +4 -4
  177. package/runtime/hub/apps/hub/{dist-IENF7YOD.js → dist-STQK5XM6.js} +1 -1
  178. package/runtime/hub/apps/hub/{dist-FDBOJ74K.js → dist-TOHA4OA5.js} +4 -4
  179. package/runtime/hub/apps/hub/{hub-token-EW32VDIU.js → hub-token-2BZFBBW3.js} +2 -2
  180. package/runtime/hub/apps/hub/{prepared-state-5FIGV4BE-FIXKBF5A.js → prepared-state-LW2PKTEQ-7BCXARGA.js} +1 -1
  181. package/runtime/hub/apps/hub/server.js +153 -31
  182. package/runtime/relay/bin.cjs +13 -1
  183. package/runtime/vercel/agentbox-checkpoint-cleanup +0 -0
  184. package/runtime/vercel/agentbox-dockerd-start +0 -0
  185. package/runtime/vercel/agentbox-open +0 -0
  186. package/runtime/vercel/agentbox-vnc-start +0 -0
  187. package/runtime/vercel/ctl.cjs +13 -1
  188. package/runtime/vercel/gh-shim +0 -0
  189. package/runtime/vercel/git-shim +0 -0
  190. package/runtime/vercel/linear-shim +0 -0
  191. package/runtime/vercel/ntn-shim +0 -0
  192. package/runtime/vercel/scripts/provision.sh +0 -0
  193. package/LICENSE +0 -21
  194. package/dist/chunk-ALEYDWAO.js.map +0 -1
  195. package/dist/chunk-GGWVTWJM.js.map +0 -1
  196. package/dist/chunk-VBSRJG53.js.map +0 -1
  197. package/dist/chunk-YZXXBHWG.js.map +0 -1
  198. package/runtime/hub/apps/hub/.next/static/chunks/0dx4alyqu7cq1.css +0 -3
  199. package/runtime/hub/apps/hub/.next/static/chunks/0lq354ziiwxxl.js +0 -1
  200. package/runtime/hub/apps/hub/.next/static/chunks/11vmjdy3390ik.js +0 -1
  201. package/runtime/hub/apps/hub/.next/static/chunks/1svigjdfotduh.js +0 -1
  202. package/runtime/hub/apps/hub/.next/static/chunks/2d5e6t-5j4etp.js +0 -1
  203. /package/dist/{_cloud-attach-YH2SU75S.js.map → _cloud-attach-RFPLNACE.js.map} +0 -0
  204. /package/dist/{chunk-KBVD2UUQ.js.map → chunk-JXDSSSXS.js.map} +0 -0
  205. /package/dist/{chunk-CDEJ2GQK.js.map → chunk-L5SOSNQI.js.map} +0 -0
  206. /package/dist/{chunk-W2FLHB54.js.map → chunk-Q626V2YX.js.map} +0 -0
  207. /package/dist/{chunk-O2NDZQHN.js.map → chunk-QVWGQJV6.js.map} +0 -0
  208. /package/dist/{dist-EJXUKIR7.js.map → dist-2BTJQUJS.js.map} +0 -0
  209. /package/dist/{dist-UR2DB2HT.js.map → dist-GEHCZJCS.js.map} +0 -0
  210. /package/dist/{dist-LJHS4PTC.js.map → dist-GJCIKH2C.js.map} +0 -0
  211. /package/dist/{dist-QBXEP4VY.js.map → dist-JFUUDAI3.js.map} +0 -0
  212. /package/dist/{dist-QNV4H6NN.js.map → dist-W5476E2U.js.map} +0 -0
  213. /package/dist/{dist-YECTRVGD.js.map → dist-Z3GSHEFO.js.map} +0 -0
  214. /package/dist/{prepared-state-5FIGV4BE-BMUK63FD.js.map → prepared-state-LW2PKTEQ-5YMKG7UN.js.map} +0 -0
  215. /package/runtime/hub/apps/hub/.next/static/{TpPTWVdZDxqrPlONtJcR5 → 6WtaFwavHBpin3eT7-HjR}/_buildManifest.js +0 -0
  216. /package/runtime/hub/apps/hub/.next/static/{TpPTWVdZDxqrPlONtJcR5 → 6WtaFwavHBpin3eT7-HjR}/_clientMiddlewareManifest.js +0 -0
  217. /package/runtime/hub/apps/hub/.next/static/{TpPTWVdZDxqrPlONtJcR5 → 6WtaFwavHBpin3eT7-HjR}/_ssgManifest.js +0 -0
@@ -1,3 +1,3 @@
1
- module.exports=[77373,e=>{"use strict";var r=e.i(5292);let t=(0,r.freeze)({is:e=>"AliasNode"===e.kind,create:(e,t)=>(0,r.freeze)({kind:"AliasNode",node:e,alias:t})});e.s(["AliasNode",0,t])},39328,e=>{"use strict";var r=e.i(5292),t=e.i(15196);let o=(0,r.freeze)({is:e=>"TableNode"===e.kind,create:e=>(0,r.freeze)({kind:"TableNode",table:t.SchemableIdentifierNode.create(e)}),createWithSchema:(e,o)=>(0,r.freeze)({kind:"TableNode",table:t.SchemableIdentifierNode.createWithSchema(e,o)})});e.s(["TableNode",0,o])},52369,e=>{"use strict";var r=e.i(5292);e.s(["isOperationNodeSource",0,function(e){return(0,r.isObject)(e)&&(0,r.isFunction)(e.toOperationNode)}])},69372,80827,39001,3392,79111,87974,e=>{"use strict";var r=e.i(52369),t=e.i(5292);e.s(["isAliasedExpression",0,function(e){return(0,t.isObject)(e)&&"expression"in e&&(0,t.isString)(e.alias)&&(0,r.isOperationNodeSource)(e)},"isExpression",0,function(e){return(0,t.isObject)(e)&&"expressionType"in e&&(0,r.isOperationNodeSource)(e)}],69372);let o=(0,t.freeze)({is:e=>"SelectModifierNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"SelectModifierNode",modifier:e,of:r}),createWithExpression:e=>(0,t.freeze)({kind:"SelectModifierNode",rawModifier:e})});e.s(["SelectModifierNode",0,o],80827);let i=(0,t.freeze)({is:e=>"AndNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"AndNode",left:e,right:r})});e.s(["AndNode",0,i],39001);let n=(0,t.freeze)({is:e=>"OrNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"OrNode",left:e,right:r})});e.s(["OrNode",0,n],3392);let s=(0,t.freeze)({is:e=>"OnNode"===e.kind,create:e=>(0,t.freeze)({kind:"OnNode",on:e}),cloneWithOperation:(e,r,o)=>(0,t.freeze)({...e,on:"And"===r?i.create(e.on,o):n.create(e.on,o)})}),a=(0,t.freeze)({is:e=>"JoinNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"JoinNode",joinType:e,table:r,on:void 0}),createWithOn:(e,r,o)=>(0,t.freeze)({kind:"JoinNode",joinType:e,table:r,on:s.create(o)}),cloneWithOn:(e,r)=>(0,t.freeze)({...e,on:e.on?s.cloneWithOperation(e.on,"And",r):s.create(r)})});e.s(["JoinNode",0,a],79111);let d=(0,t.freeze)({is:e=>"BinaryOperationNode"===e.kind,create:(e,r,o)=>(0,t.freeze)({kind:"BinaryOperationNode",leftOperand:e,operator:r,rightOperand:o})});e.s(["BinaryOperationNode",0,d],87974)},50022,52183,99934,e=>{"use strict";var r=e.i(5292),t=e.i(55514);let o=(0,r.freeze)({is:e=>"ColumnNode"===e.kind,create:e=>(0,r.freeze)({kind:"ColumnNode",column:t.IdentifierNode.create(e)})});e.s(["ColumnNode",0,o],50022);let i=(0,r.freeze)({is:e=>"SelectAllNode"===e.kind,create:()=>(0,r.freeze)({kind:"SelectAllNode"})});e.s(["SelectAllNode",0,i],52183);let n=(0,r.freeze)({is:e=>"ReferenceNode"===e.kind,create:(e,t)=>(0,r.freeze)({kind:"ReferenceNode",table:t,column:e}),createSelectAll:e=>(0,r.freeze)({kind:"ReferenceNode",table:e,column:i.create()})});e.s(["ReferenceNode",0,n],99934)},66511,82180,41731,e=>{"use strict";e.s(["isOrderByDirection",()=>N,"parseOrderBy",()=>m],66511),e.s(["DynamicReferenceBuilder",()=>i,"isDynamicReferenceBuilder",()=>n],82180);var r=e.i(52369),t=e.i(19834),o=e.i(5292);class i{#e;get dynamicReference(){return this.#e}get refType(){}constructor(e){this.#e=e}toOperationNode(){return(0,t.parseSimpleReferenceExpression)(this.#e)}}function n(e){return(0,o.isObject)(e)&&(0,r.isOperationNodeSource)(e)&&(0,o.isString)(e.dynamicReference)}var s=e.i(69372);let a=(0,o.freeze)({is:e=>"OrderByItemNode"===e.kind,create:(e,r)=>(0,o.freeze)({kind:"OrderByItemNode",orderBy:e,direction:r}),cloneWith:(e,r)=>(0,o.freeze)({...e,...r})});var d=e.i(3731),u=e.i(55514);let p=(0,o.freeze)({is:e=>"CollateNode"===e.kind,create:e=>(0,o.freeze)({kind:"CollateNode",collation:u.IdentifierNode.create(e)})});class l{#r;constructor(e){this.#r=(0,o.freeze)(e)}desc(){return new l({node:a.cloneWith(this.#r.node,{direction:d.RawNode.createWithSql("desc")})})}asc(){return new l({node:a.cloneWith(this.#r.node,{direction:d.RawNode.createWithSql("asc")})})}nullsLast(){return new l({node:a.cloneWith(this.#r.node,{nulls:"last"})})}nullsFirst(){return new l({node:a.cloneWith(this.#r.node,{nulls:"first"})})}collate(e){return new l({node:a.cloneWith(this.#r.node,{collation:p.create(e)})})}toOperationNode(){return this.#r.node}}let h=new Set;function c(e){h.has(e)||(h.add(e),console.log(e))}e.s(["logOnce",0,c],41731);var f=e.i(85381);function N(e){return"asc"===e||"desc"===e}function m(e){if(2===e.length)return[y(e[0],e[1])];if(1===e.length){let[r]=e;return Array.isArray(r)?(c("orderBy(array) is deprecated, use multiple orderBy calls instead."),r.map(e=>y(e))):[y(r)]}throw Error(`Invalid number of arguments at order by! expected 1-2, received ${e.length}`)}function y(e,r){let o=function(e){if((0,f.isExpressionOrFactory)(e))return(0,f.parseExpression)(e);if(n(e))return e.toOperationNode();let[r,o]=e.split(" ");return o?(c("`orderBy('column asc')` is deprecated. Use `orderBy('column', 'asc')` instead."),w((0,t.parseStringReference)(r),o)):(0,t.parseStringReference)(e)}(e);if(a.is(o)){if(r)throw Error("Cannot specify direction twice!");return o}return w(o,r)}function w(e,r){if("string"==typeof r){if(!N(r))throw Error(`Invalid order by direction: ${r}`);return a.create(e,d.RawNode.createWithSql(r))}if((0,s.isExpression)(r))return c("`orderBy(..., expr)` is deprecated. Use `orderBy(..., 'asc')` or `orderBy(..., (ob) => ...)` instead."),a.create(e,r.toOperationNode());let t=a.create(e);return r?r(new l({node:t})).toOperationNode():t}},17708,e=>{"use strict";var r=e.i(5292);let t=(0,r.freeze)({is:e=>"JSONReferenceNode"===e.kind,create:(e,t)=>(0,r.freeze)({kind:"JSONReferenceNode",reference:e,traversal:t}),cloneWithTraversal:(e,t)=>(0,r.freeze)({...e,traversal:t})});e.s(["JSONReferenceNode",0,t])},55e3,e=>{"use strict";var r=e.i(5292);let t=(0,r.freeze)({is:e=>"JSONOperatorChainNode"===e.kind,create:e=>(0,r.freeze)({kind:"JSONOperatorChainNode",operator:e,values:(0,r.freeze)([])}),cloneWithValue:(e,t)=>(0,r.freeze)({...e,values:(0,r.freeze)([...e.values,t])})});e.s(["JSONOperatorChainNode",0,t])},5114,e=>{"use strict";var r=e.i(5292);let t=(0,r.freeze)({is:e=>"JSONPathNode"===e.kind,create:e=>(0,r.freeze)({kind:"JSONPathNode",inOperator:e,pathLegs:(0,r.freeze)([])}),cloneWithLeg:(e,t)=>(0,r.freeze)({...e,pathLegs:(0,r.freeze)([...e.pathLegs,t])})});e.s(["JSONPathNode",0,t])},19834,e=>{"use strict";e.s(["parseAliasedStringReference",()=>w,"parseColumnName",()=>g,"parseJSONReference",()=>m,"parseOrderedColumnName",()=>O,"parseReferenceExpression",()=>N,"parseReferenceExpressionOrList",()=>f,"parseSimpleReferenceExpression",()=>c,"parseStringReference",()=>y]);var r=e.i(77373),t=e.i(50022),o=e.i(99934),i=e.i(39328),n=e.i(5292),s=e.i(85381),a=e.i(55514),d=e.i(66511),u=e.i(36662),p=e.i(17708),l=e.i(55e3),h=e.i(5114);function c(e){return(0,n.isString)(e)?y(e):e.toOperationNode()}function f(e){return(0,n.isReadonlyArray)(e)?e.map(e=>N(e)):[N(e)]}function N(e){return(0,s.isExpressionOrFactory)(e)?(0,s.parseExpression)(e):c(e)}function m(e,r){if((0,u.isJSONOperator)(r))return p.JSONReferenceNode.create(y(e),l.JSONOperatorChainNode.create(u.OperatorNode.create(r)));if("->$"===r||"->>$"===r)return p.JSONReferenceNode.create(y(e),h.JSONPathNode.create(u.OperatorNode.create(r.slice(0,-1))));throw Error(`Invalid JSON operator: ${r}`)}function y(e){if(!e.includes("."))return o.ReferenceNode.create(t.ColumnNode.create(e));let r=e.split(".").map(x);if(3===r.length)return function(e){let[r,n,s]=e;return o.ReferenceNode.create(t.ColumnNode.create(s),i.TableNode.createWithSchema(r,n))}(r);if(2===r.length)return function(e){let[r,n]=e;return o.ReferenceNode.create(t.ColumnNode.create(n),i.TableNode.create(r))}(r);throw Error(`invalid column reference ${e}`)}function w(e){let t=" as ";if(!e.includes(t))return y(e);{let[o,i]=e.split(t).map(x);return r.AliasNode.create(y(o),a.IdentifierNode.create(i))}}function g(e){return t.ColumnNode.create(e)}function O(e){if(!e.includes(" "))return g(e);{let[r,t]=e.split(" ").map(x);if(!(0,d.isOrderByDirection)(t))throw Error(`invalid order direction "${t}" next to "${r}"`);return(0,d.parseOrderBy)([r,t])[0]}}function x(e){return e.trim()}},74955,82561,e=>{"use strict";var r=e.i(5292);let t=(0,r.freeze)({is:e=>"PrimitiveValueListNode"===e.kind,create:e=>(0,r.freeze)({kind:"PrimitiveValueListNode",values:(0,r.freeze)([...e])})});e.s(["PrimitiveValueListNode",0,t],74955);let o=(0,r.freeze)({is:e=>"ValueListNode"===e.kind,create:e=>(0,r.freeze)({kind:"ValueListNode",values:(0,r.freeze)(e)})});e.s(["ValueListNode",0,o],82561)},84480,e=>{"use strict";var r=e.i(5292);let t=(0,r.freeze)({is:e=>"ValueNode"===e.kind,create:e=>(0,r.freeze)({kind:"ValueNode",value:e}),createImmediate:e=>(0,r.freeze)({kind:"ValueNode",value:e,immediate:!0})});e.s(["ValueNode",0,t])},23669,43097,3329,20857,4372,34067,32694,40642,76413,83715,79685,19285,22350,e=>{"use strict";e.s(["parseFilterList",()=>x,"parseFilterObject",()=>O,"parseReferentialBinaryOperation",()=>g,"parseValueBinaryOperation",()=>w,"parseValueBinaryOperationOrExpression",()=>y],23669);var r=e.i(87974),t=e.i(5292),o=e.i(52369),i=e.i(36662),n=e.i(19834);e.s(["isSafeImmediateValue",()=>h,"parseSafeImmediateValue",()=>c,"parseValueExpression",()=>l,"parseValueExpressionOrList",()=>p],43097);var s=e.i(74955),a=e.i(82561),d=e.i(84480),u=e.i(85381);function p(e){var r;return(0,t.isReadonlyArray)(e)?(r=e).some(u.isExpressionOrFactory)?a.ValueListNode.create(r.map(e=>l(e))):s.PrimitiveValueListNode.create(r):l(e)}function l(e){return(0,u.isExpressionOrFactory)(e)?(0,u.parseExpression)(e):d.ValueNode.create(e)}function h(e){return(0,t.isNumber)(e)||(0,t.isBoolean)(e)||(0,t.isNull)(e)}function c(e){if(!h(e))throw Error(`unsafe immediate value ${JSON.stringify(e)}`);return d.ValueNode.createImmediate(e)}var f=e.i(39001),N=e.i(56802),m=e.i(3392);function y(e){if(3===e.length)return w(e[0],e[1],e[2]);if(1===e.length)return l(e[0]);throw Error(`invalid arguments: ${JSON.stringify(e)}`)}function w(e,t,o){var i;return("is"===(i=t)||"is not"===i)&&W(o)?r.BinaryOperationNode.create((0,n.parseReferenceExpression)(e),b(t),d.ValueNode.createImmediate(o)):r.BinaryOperationNode.create((0,n.parseReferenceExpression)(e),b(t),p(o))}function g(e,t,o){return r.BinaryOperationNode.create((0,n.parseReferenceExpression)(e),b(t),(0,n.parseReferenceExpression)(o))}function O(e,r){return x(Object.entries(e).filter(([,e])=>!(0,t.isUndefined)(e)).map(([e,r])=>w(e,W(r)?"is":"=",r)),r)}function x(e,t,o=!0){let n="and"===t?f.AndNode.create:m.OrNode.create;if(0===e.length)return r.BinaryOperationNode.create(d.ValueNode.createImmediate(1),i.OperatorNode.create("="),d.ValueNode.createImmediate(+("and"===t)));let s=q(e[0]);for(let r=1;r<e.length;++r)s=n(s,q(e[r]));return e.length>1&&o?N.ParensNode.create(s):s}function W(e){return(0,t.isNull)(e)||(0,t.isBoolean)(e)}function b(e){if((0,i.isBinaryOperator)(e))return i.OperatorNode.create(e);if((0,o.isOperationNodeSource)(e))return e.toOperationNode();throw Error(`invalid operator ${JSON.stringify(e)}`)}function q(e){return(0,o.isOperationNodeSource)(e)?e.toOperationNode():e}let z=(0,t.freeze)({is:e=>"OrderByNode"===e.kind,create:e=>(0,t.freeze)({kind:"OrderByNode",items:(0,t.freeze)([...e])}),cloneWithItems:(e,r)=>(0,t.freeze)({...e,items:(0,t.freeze)([...e.items,...r])})});e.s(["OrderByNode",0,z],3329);let S=(0,t.freeze)({is:e=>"PartitionByNode"===e.kind,create:e=>(0,t.freeze)({kind:"PartitionByNode",items:(0,t.freeze)(e)}),cloneWithItems:(e,r)=>(0,t.freeze)({...e,items:(0,t.freeze)([...e.items,...r])})}),k=(0,t.freeze)({is:e=>"OverNode"===e.kind,create:()=>(0,t.freeze)({kind:"OverNode"}),cloneWithOrderByItems:(e,r)=>(0,t.freeze)({...e,orderBy:e.orderBy?z.cloneWithItems(e.orderBy,r):z.create(r)}),cloneWithPartitionByItems:(e,r)=>(0,t.freeze)({...e,partitionBy:e.partitionBy?S.cloneWithItems(e.partitionBy,r):S.create(r)})});e.s(["OverNode",0,k],20857),e.s(["JoinBuilder",()=>v],4372);var E=e.i(79111),I=e.i(3731);class v{#r;constructor(e){this.#r=(0,t.freeze)(e)}on(...e){return new v({...this.#r,joinNode:E.JoinNode.cloneWithOn(this.#r.joinNode,y(e))})}onRef(e,r,t){return new v({...this.#r,joinNode:E.JoinNode.cloneWithOn(this.#r.joinNode,g(e,r,t))})}onTrue(){return new v({...this.#r,joinNode:E.JoinNode.cloneWithOn(this.#r.joinNode,I.RawNode.createWithSql("true"))})}$call(e){return e(this)}toOperationNode(){return this.#r.joinNode}}e.s(["QueryNode",()=>$],22350);var C=e.i(91114);e.s(["SelectQueryNode",()=>R],34067);let B=(0,t.freeze)({is:e=>"FromNode"===e.kind,create:e=>(0,t.freeze)({kind:"FromNode",froms:(0,t.freeze)(e)}),cloneWithFroms:(e,r)=>(0,t.freeze)({...e,froms:(0,t.freeze)([...e.froms,...r])})}),Q=(0,t.freeze)({is:e=>"GroupByNode"===e.kind,create:e=>(0,t.freeze)({kind:"GroupByNode",items:(0,t.freeze)(e)}),cloneWithItems:(e,r)=>(0,t.freeze)({...e,items:(0,t.freeze)([...e.items,...r])})}),T=(0,t.freeze)({is:e=>"HavingNode"===e.kind,create:e=>(0,t.freeze)({kind:"HavingNode",having:e}),cloneWithOperation:(e,r,o)=>(0,t.freeze)({...e,having:"And"===r?f.AndNode.create(e.having,o):m.OrNode.create(e.having,o)})}),R=(0,t.freeze)({is:e=>"SelectQueryNode"===e.kind,create:e=>(0,t.freeze)({kind:"SelectQueryNode",...e&&{with:e}}),createFrom:(e,r)=>(0,t.freeze)({kind:"SelectQueryNode",from:B.create(e),...r&&{with:r}}),cloneWithSelections:(e,r)=>(0,t.freeze)({...e,selections:e.selections?(0,t.freeze)([...e.selections,...r]):(0,t.freeze)(r)}),cloneWithDistinctOn:(e,r)=>(0,t.freeze)({...e,distinctOn:e.distinctOn?(0,t.freeze)([...e.distinctOn,...r]):(0,t.freeze)(r)}),cloneWithFrontModifier:(e,r)=>(0,t.freeze)({...e,frontModifiers:e.frontModifiers?(0,t.freeze)([...e.frontModifiers,r]):(0,t.freeze)([r])}),cloneWithOrderByItems:(e,r)=>$.cloneWithOrderByItems(e,r),cloneWithGroupByItems:(e,r)=>(0,t.freeze)({...e,groupBy:e.groupBy?Q.cloneWithItems(e.groupBy,r):Q.create(r)}),cloneWithLimit:(e,r)=>(0,t.freeze)({...e,limit:r}),cloneWithOffset:(e,r)=>(0,t.freeze)({...e,offset:r}),cloneWithFetch:(e,r)=>(0,t.freeze)({...e,fetch:r}),cloneWithHaving:(e,r)=>(0,t.freeze)({...e,having:e.having?T.cloneWithOperation(e.having,"And",r):T.create(r)}),cloneWithSetOperations:(e,r)=>(0,t.freeze)({...e,setOperations:e.setOperations?(0,t.freeze)([...e.setOperations,...r]):(0,t.freeze)([...r])}),cloneWithoutSelections:e=>(0,t.freeze)({...e,selections:[]}),cloneWithoutLimit:e=>(0,t.freeze)({...e,limit:void 0}),cloneWithoutOffset:e=>(0,t.freeze)({...e,offset:void 0}),cloneWithoutOrderBy:e=>$.cloneWithoutOrderBy(e),cloneWithoutGroupBy:e=>(0,t.freeze)({...e,groupBy:void 0})}),A=(0,t.freeze)({is:e=>"ListNode"===e.kind,create:e=>(0,t.freeze)({kind:"ListNode",items:(0,t.freeze)(e)})});e.s(["ListNode",0,A],32694);let L=(0,t.freeze)({is:e=>"UpdateQueryNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"UpdateQueryNode",table:1===e.length?e[0]:A.create(e),...r&&{with:r}}),createWithoutTable:()=>(0,t.freeze)({kind:"UpdateQueryNode"}),cloneWithFromItems:(e,r)=>(0,t.freeze)({...e,from:e.from?B.cloneWithFroms(e.from,r):B.create(r)}),cloneWithUpdates:(e,r)=>(0,t.freeze)({...e,updates:e.updates?(0,t.freeze)([...e.updates,...r]):r}),cloneWithLimit:(e,r)=>(0,t.freeze)({...e,limit:r})});e.s(["UpdateQueryNode",0,L],40642),e.s(["DeleteQueryNode",()=>V],83715);let F=(0,t.freeze)({is:e=>"UsingNode"===e.kind,create:e=>(0,t.freeze)({kind:"UsingNode",tables:(0,t.freeze)(e)}),cloneWithTables:(e,r)=>(0,t.freeze)({...e,tables:(0,t.freeze)([...e.tables,...r])})});e.s(["UsingNode",0,F],76413);let V=(0,t.freeze)({is:e=>"DeleteQueryNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"DeleteQueryNode",from:B.create(e),...r&&{with:r}}),cloneWithOrderByItems:(e,r)=>$.cloneWithOrderByItems(e,r),cloneWithoutOrderBy:e=>$.cloneWithoutOrderBy(e),cloneWithLimit:(e,r)=>(0,t.freeze)({...e,limit:r}),cloneWithoutLimit:e=>(0,t.freeze)({...e,limit:void 0}),cloneWithUsing:(e,r)=>(0,t.freeze)({...e,using:void 0!==e.using?F.cloneWithTables(e.using,r):F.create(r)})}),M=(0,t.freeze)({is:e=>"WhereNode"===e.kind,create:e=>(0,t.freeze)({kind:"WhereNode",where:e}),cloneWithOperation:(e,r,o)=>(0,t.freeze)({...e,where:"And"===r?f.AndNode.create(e.where,o):m.OrNode.create(e.where,o)})});e.s(["WhereNode",0,M],79685);let D=(0,t.freeze)({is:e=>"ReturningNode"===e.kind,create:e=>(0,t.freeze)({kind:"ReturningNode",selections:(0,t.freeze)(e)}),cloneWithSelections:(e,r)=>(0,t.freeze)({...e,selections:e.selections?(0,t.freeze)([...e.selections,...r]):(0,t.freeze)(r)})}),J=(0,t.freeze)({is:e=>"ExplainNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"ExplainNode",format:e,options:r})});var P=e.i(54860);let U=(0,t.freeze)({is:e=>"MergeQueryNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"MergeQueryNode",into:e,...r&&{with:r}}),cloneWithUsing:(e,r)=>(0,t.freeze)({...e,using:r}),cloneWithWhen:(e,r)=>(0,t.freeze)({...e,whens:e.whens?(0,t.freeze)([...e.whens,r]):(0,t.freeze)([r])}),cloneWithThen:(e,r)=>(0,t.freeze)({...e,whens:e.whens?(0,t.freeze)([...e.whens.slice(0,-1),P.WhenNode.cloneWithResult(e.whens[e.whens.length-1],r)]):void 0})});e.s(["MergeQueryNode",0,U],19285);let j=(0,t.freeze)({is:e=>"OutputNode"===e.kind,create:e=>(0,t.freeze)({kind:"OutputNode",selections:(0,t.freeze)(e)}),cloneWithSelections:(e,r)=>(0,t.freeze)({...e,selections:e.selections?(0,t.freeze)([...e.selections,...r]):(0,t.freeze)(r)})}),$=(0,t.freeze)({is:e=>R.is(e)||C.InsertQueryNode.is(e)||L.is(e)||V.is(e)||U.is(e),cloneWithEndModifier:(e,r)=>(0,t.freeze)({...e,endModifiers:e.endModifiers?(0,t.freeze)([...e.endModifiers,r]):(0,t.freeze)([r])}),cloneWithWhere:(e,r)=>(0,t.freeze)({...e,where:e.where?M.cloneWithOperation(e.where,"And",r):M.create(r)}),cloneWithJoin:(e,r)=>(0,t.freeze)({...e,joins:e.joins?(0,t.freeze)([...e.joins,r]):(0,t.freeze)([r])}),cloneWithReturning:(e,r)=>(0,t.freeze)({...e,returning:e.returning?D.cloneWithSelections(e.returning,r):D.create(r)}),cloneWithoutReturning:e=>(0,t.freeze)({...e,returning:void 0}),cloneWithoutWhere:e=>(0,t.freeze)({...e,where:void 0}),cloneWithExplain:(e,r,o)=>(0,t.freeze)({...e,explain:J.create(r,o?.toOperationNode())}),cloneWithTop:(e,r)=>(0,t.freeze)({...e,top:r}),cloneWithOutput:(e,r)=>(0,t.freeze)({...e,output:e.output?j.cloneWithSelections(e.output,r):j.create(r)}),cloneWithOrderByItems:(e,r)=>(0,t.freeze)({...e,orderBy:e.orderBy?z.cloneWithItems(e.orderBy,r):z.create(r)}),cloneWithoutOrderBy:e=>(0,t.freeze)({...e,orderBy:void 0})})},69062,17868,e=>{"use strict";e.s(["OverBuilder",()=>a],69062);var r=e.i(20857),t=e.i(22350),o=e.i(66511),i=e.i(5292);let n=(0,i.freeze)({is:e=>"PartitionByItemNode"===e.kind,create:e=>(0,i.freeze)({kind:"PartitionByItemNode",partitionBy:e})});var s=e.i(19834);class a{#r;constructor(e){this.#r=(0,i.freeze)(e)}orderBy(...e){return new a({overNode:r.OverNode.cloneWithOrderByItems(this.#r.overNode,(0,o.parseOrderBy)(e))})}clearOrderBy(){return new a({overNode:t.QueryNode.cloneWithoutOrderBy(this.#r.overNode)})}partitionBy(e){return new a({overNode:r.OverNode.cloneWithPartitionByItems(this.#r.overNode,(0,s.parseReferenceExpressionOrList)(e).map(n.create))})}$call(e){return e(this)}toOperationNode(){return this.#r.overNode}}var d=e.i(99934),u=e.i(52183);let p=(0,i.freeze)({is:e=>"SelectionNode"===e.kind,create:e=>(0,i.freeze)({kind:"SelectionNode",selection:e}),createSelectAll:()=>(0,i.freeze)({kind:"SelectionNode",selection:u.SelectAllNode.create()}),createSelectAllFromTable:e=>(0,i.freeze)({kind:"SelectionNode",selection:d.ReferenceNode.createSelectAll(e)})});e.s(["SelectionNode",0,p],17868)},94993,31461,89737,98149,8882,992,98130,27797,55642,34755,e=>{"use strict";e.s(["InsertQueryBuilder",()=>V],94993),e.s(["parseSelectAll",()=>h,"parseSelectArg",()=>p],31461);var r,t,o=e.i(5292),i=e.i(17868),n=e.i(19834),s=e.i(82180),a=e.i(85381),d=e.i(27952),u=e.i(71731);function p(e){return(0,o.isFunction)(e)?p(e((0,u.expressionBuilder)())):(0,o.isReadonlyArray)(e)?e.map(e=>l(e)):[l(e)]}function l(e){return(0,o.isString)(e)?i.SelectionNode.create((0,n.parseAliasedStringReference)(e)):(0,s.isDynamicReferenceBuilder)(e)?i.SelectionNode.create(e.toOperationNode()):i.SelectionNode.create((0,a.parseAliasedExpression)(e))}function h(e){return e?Array.isArray(e)?e.map(c):[c(e)]:[i.SelectionNode.createSelectAll()]}function c(e){if((0,o.isString)(e))return i.SelectionNode.createSelectAllFromTable((0,d.parseTable)(e));throw Error(`invalid value selectAll expression: ${JSON.stringify(e)}`)}e.s(["parseInsertExpression",()=>O],89737);var f=e.i(50022),N=e.i(74955),m=e.i(82561),y=e.i(43097);let w=(0,o.freeze)({is:e=>"ValuesNode"===e.kind,create:e=>(0,o.freeze)({kind:"ValuesNode",values:(0,o.freeze)(e)})}),g=(0,o.freeze)({is:e=>"DefaultInsertValueNode"===e.kind,create:()=>(0,o.freeze)({kind:"DefaultInsertValueNode"})});function O(e){var r;let t,i=(0,o.isFunction)(e)?e((0,u.expressionBuilder)()):e;return t=function(e){let r=new Map;for(let t of e)for(let e of Object.keys(t))r.has(e)||void 0===t[e]||r.set(e,r.size);return r}(r=(0,o.isReadonlyArray)(i)?i:(0,o.freeze)([i])),[(0,o.freeze)([...t.keys()].map(f.ColumnNode.create)),w.create(r.map(e=>(function(e,r){let t=Object.keys(e),i=Array.from({length:r.size}),n=!1,s=t.length;for(let d of t){let t=r.get(d);if((0,o.isUndefined)(t)){s--;continue}let u=e[d];((0,o.isUndefined)(u)||(0,a.isExpressionOrFactory)(u))&&(n=!0),i[t]=u}if(s<r.size||n){let e=g.create();return m.ValueListNode.create(i.map(r=>(0,o.isUndefined)(r)?e:(0,y.parseValueExpression)(r)))}return N.PrimitiveValueListNode.create(i)})(e,t)))]}var x=e.i(91114),W=e.i(22350);let b=(0,o.freeze)({is:e=>"ColumnUpdateNode"===e.kind,create:(e,r)=>(0,o.freeze)({kind:"ColumnUpdateNode",column:e,value:r})});function q(e){return Object.entries((0,o.isFunction)(e)?e((0,u.expressionBuilder)()):e).filter(([e,r])=>void 0!==r).map(([e,r])=>b.create(f.ColumnNode.create(e),(0,y.parseValueExpression)(r)))}let z=(0,o.freeze)({is:e=>"OnDuplicateKeyNode"===e.kind,create:e=>(0,o.freeze)({kind:"OnDuplicateKeyNode",updates:e})});class S{insertId;numInsertedOrUpdatedRows;constructor(e,r){this.insertId=e,this.numInsertedOrUpdatedRows=r}}class k extends Error{node;constructor(e){super("no result"),this.node=e}}function E(e){return Object.prototype.hasOwnProperty.call(e,"prototype")}e.s(["NoResultError",0,k,"isNoResultErrorConstructor",0,E],98149);var I=e.i(55514),v=e.i(79685);let C=(0,o.freeze)({is:e=>"OnConflictNode"===e.kind,create:()=>(0,o.freeze)({kind:"OnConflictNode"}),cloneWith:(e,r)=>(0,o.freeze)({...e,...r}),cloneWithIndexWhere:(e,r)=>(0,o.freeze)({...e,indexWhere:e.indexWhere?v.WhereNode.cloneWithOperation(e.indexWhere,"And",r):v.WhereNode.create(r)}),cloneWithIndexOrWhere:(e,r)=>(0,o.freeze)({...e,indexWhere:e.indexWhere?v.WhereNode.cloneWithOperation(e.indexWhere,"Or",r):v.WhereNode.create(r)}),cloneWithUpdateWhere:(e,r)=>(0,o.freeze)({...e,updateWhere:e.updateWhere?v.WhereNode.cloneWithOperation(e.updateWhere,"And",r):v.WhereNode.create(r)}),cloneWithUpdateOrWhere:(e,r)=>(0,o.freeze)({...e,updateWhere:e.updateWhere?v.WhereNode.cloneWithOperation(e.updateWhere,"Or",r):v.WhereNode.create(r)}),cloneWithoutIndexWhere:e=>(0,o.freeze)({...e,indexWhere:void 0}),cloneWithoutUpdateWhere:e=>(0,o.freeze)({...e,updateWhere:void 0})});var B=e.i(23669);class Q{#r;constructor(e){this.#r=(0,o.freeze)(e)}column(e){let r=f.ColumnNode.create(e);return new Q({...this.#r,onConflictNode:C.cloneWith(this.#r.onConflictNode,{columns:this.#r.onConflictNode.columns?(0,o.freeze)([...this.#r.onConflictNode.columns,r]):(0,o.freeze)([r])})})}columns(e){let r=e.map(f.ColumnNode.create);return new Q({...this.#r,onConflictNode:C.cloneWith(this.#r.onConflictNode,{columns:this.#r.onConflictNode.columns?(0,o.freeze)([...this.#r.onConflictNode.columns,...r]):(0,o.freeze)(r)})})}constraint(e){return new Q({...this.#r,onConflictNode:C.cloneWith(this.#r.onConflictNode,{constraint:I.IdentifierNode.create(e)})})}expression(e){return new Q({...this.#r,onConflictNode:C.cloneWith(this.#r.onConflictNode,{indexExpression:e.toOperationNode()})})}where(...e){return new Q({...this.#r,onConflictNode:C.cloneWithIndexWhere(this.#r.onConflictNode,(0,B.parseValueBinaryOperationOrExpression)(e))})}whereRef(e,r,t){return new Q({...this.#r,onConflictNode:C.cloneWithIndexWhere(this.#r.onConflictNode,(0,B.parseReferentialBinaryOperation)(e,r,t))})}clearWhere(){return new Q({...this.#r,onConflictNode:C.cloneWithoutIndexWhere(this.#r.onConflictNode)})}doNothing(){return new T({...this.#r,onConflictNode:C.cloneWith(this.#r.onConflictNode,{doNothing:!0})})}doUpdateSet(e){return new R({...this.#r,onConflictNode:C.cloneWith(this.#r.onConflictNode,{updates:q(e)})})}$call(e){return e(this)}}class T{#r;constructor(e){this.#r=(0,o.freeze)(e)}toOperationNode(){return this.#r.onConflictNode}}class R{#r;constructor(e){this.#r=(0,o.freeze)(e)}where(...e){return new R({...this.#r,onConflictNode:C.cloneWithUpdateWhere(this.#r.onConflictNode,(0,B.parseValueBinaryOperationOrExpression)(e))})}whereRef(e,r,t){return new R({...this.#r,onConflictNode:C.cloneWithUpdateWhere(this.#r.onConflictNode,(0,B.parseReferentialBinaryOperation)(e,r,t))})}clearWhere(){return new R({...this.#r,onConflictNode:C.cloneWithoutUpdateWhere(this.#r.onConflictNode)})}$call(e){return e(this)}toOperationNode(){return this.#r.onConflictNode}}let A=(0,o.freeze)({is:e=>"TopNode"===e.kind,create:(e,r)=>(0,o.freeze)({kind:"TopNode",expression:e,modifiers:r})});function L(e,r){var t;if(!(0,o.isNumber)(e)&&!(0,o.isBigInt)(e))throw Error(`Invalid top expression: ${e}`);if(!(0,o.isUndefined)(r)&&"percent"!==(t=r)&&"with ties"!==t&&"percent with ties"!==t)throw Error(`Invalid top modifiers: ${r}`);return A.create(e,r)}e.s(["parseTop",0,L],8882);let F=(0,o.freeze)({is:e=>"OrActionNode"===e.kind,create:e=>(0,o.freeze)({kind:"OrActionNode",action:e})});class V{#r;constructor(e){this.#r=(0,o.freeze)(e)}values(e){let[r,t]=O(e);return new V({...this.#r,queryNode:x.InsertQueryNode.cloneWith(this.#r.queryNode,{columns:r,values:t})})}columns(e){return new V({...this.#r,queryNode:x.InsertQueryNode.cloneWith(this.#r.queryNode,{columns:(0,o.freeze)(e.map(f.ColumnNode.create))})})}expression(e){return new V({...this.#r,queryNode:x.InsertQueryNode.cloneWith(this.#r.queryNode,{values:(0,a.parseExpression)(e)})})}defaultValues(){return new V({...this.#r,queryNode:x.InsertQueryNode.cloneWith(this.#r.queryNode,{defaultValues:!0})})}modifyEnd(e){return new V({...this.#r,queryNode:W.QueryNode.cloneWithEndModifier(this.#r.queryNode,e.toOperationNode())})}ignore(){return new V({...this.#r,queryNode:x.InsertQueryNode.cloneWith(this.#r.queryNode,{orAction:F.create("ignore")})})}orIgnore(){return new V({...this.#r,queryNode:x.InsertQueryNode.cloneWith(this.#r.queryNode,{orAction:F.create("ignore")})})}orAbort(){return new V({...this.#r,queryNode:x.InsertQueryNode.cloneWith(this.#r.queryNode,{orAction:F.create("abort")})})}orFail(){return new V({...this.#r,queryNode:x.InsertQueryNode.cloneWith(this.#r.queryNode,{orAction:F.create("fail")})})}orReplace(){return new V({...this.#r,queryNode:x.InsertQueryNode.cloneWith(this.#r.queryNode,{orAction:F.create("replace")})})}orRollback(){return new V({...this.#r,queryNode:x.InsertQueryNode.cloneWith(this.#r.queryNode,{orAction:F.create("rollback")})})}top(e,r){return new V({...this.#r,queryNode:W.QueryNode.cloneWithTop(this.#r.queryNode,L(e,r))})}onConflict(e){return new V({...this.#r,queryNode:x.InsertQueryNode.cloneWith(this.#r.queryNode,{onConflict:e(new Q({onConflictNode:C.create()})).toOperationNode()})})}onDuplicateKeyUpdate(e){return new V({...this.#r,queryNode:x.InsertQueryNode.cloneWith(this.#r.queryNode,{onDuplicateKey:z.create(q(e))})})}returning(e){return new V({...this.#r,queryNode:W.QueryNode.cloneWithReturning(this.#r.queryNode,p(e))})}returningAll(){return new V({...this.#r,queryNode:W.QueryNode.cloneWithReturning(this.#r.queryNode,h())})}output(e){return new V({...this.#r,queryNode:W.QueryNode.cloneWithOutput(this.#r.queryNode,p(e))})}outputAll(e){return new V({...this.#r,queryNode:W.QueryNode.cloneWithOutput(this.#r.queryNode,h(e))})}clearReturning(){return new V({...this.#r,queryNode:W.QueryNode.cloneWithoutReturning(this.#r.queryNode)})}$call(e){return e(this)}$if(e,r){return e?r(this):new V({...this.#r})}$castTo(){return new V(this.#r)}$narrowType(){return new V(this.#r)}$assertType(){return new V(this.#r)}withPlugin(e){return new V({...this.#r,executor:this.#r.executor.withPlugin(e)})}toOperationNode(){return this.#r.executor.transformQuery(this.#r.queryNode,this.#r.queryId)}compile(){return this.#r.executor.compileQuery(this.toOperationNode(),this.#r.queryId)}async execute(e){let r=this.compile(),t=await this.#r.executor.executeQuery(r,e),{adapter:o}=this.#r.executor,i=r.query;return i.returning&&o.supportsReturning||i.output&&o.supportsOutput?t.rows:[new S(t.insertId,t.numAffectedRows??BigInt(0))]}async executeTakeFirst(e){let[r]=await this.execute(e);return r}async executeTakeFirstOrThrow(e){"function"==typeof e&&(e={errorConstructor:e});let r=await this.executeTakeFirst(e);if(void 0===r){let r=e?.errorConstructor??k;throw E(r)?new r(this.toOperationNode()):r(this.toOperationNode())}return r}async *stream(e){"object"!=typeof e&&(e={chunkSize:e});let r=this.compile();for await(let t of this.#r.executor.stream(r,e.chunkSize??100,e))yield*t.rows}async explain(e,r){let t=new V({...this.#r,queryNode:W.QueryNode.cloneWithExplain(this.#r.queryNode,e,r)});return await t.execute()}}e.s(["DeleteQueryBuilder",()=>j],98130);var M=e.i(38584);class D{numDeletedRows;constructor(e){this.numDeletedRows=e}}var J=e.i(83715);let P=(0,o.freeze)({is:e=>"LimitNode"===e.kind,create:e=>(0,o.freeze)({kind:"LimitNode",limit:e})});e.s(["LimitNode",0,P],992);var U=e.i(66511);class j{#r;constructor(e){this.#r=(0,o.freeze)(e)}where(...e){return new r({...this.#r,queryNode:W.QueryNode.cloneWithWhere(this.#r.queryNode,(0,B.parseValueBinaryOperationOrExpression)(e))})}whereRef(e,t,o){return new r({...this.#r,queryNode:W.QueryNode.cloneWithWhere(this.#r.queryNode,(0,B.parseReferentialBinaryOperation)(e,t,o))})}clearWhere(){return new r({...this.#r,queryNode:W.QueryNode.cloneWithoutWhere(this.#r.queryNode)})}top(e,t){return new r({...this.#r,queryNode:W.QueryNode.cloneWithTop(this.#r.queryNode,L(e,t))})}using(e){return new r({...this.#r,queryNode:J.DeleteQueryNode.cloneWithUsing(this.#r.queryNode,(0,d.parseTableExpressionOrList)(e))})}innerJoin(...e){return this.#t("InnerJoin",e)}leftJoin(...e){return this.#t("LeftJoin",e)}rightJoin(...e){return this.#t("RightJoin",e)}fullJoin(...e){return this.#t("FullJoin",e)}#t(e,t){return new r({...this.#r,queryNode:W.QueryNode.cloneWithJoin(this.#r.queryNode,(0,M.parseJoin)(e,t))})}returning(e){return new r({...this.#r,queryNode:W.QueryNode.cloneWithReturning(this.#r.queryNode,p(e))})}returningAll(e){return new r({...this.#r,queryNode:W.QueryNode.cloneWithReturning(this.#r.queryNode,h(e))})}output(e){return new r({...this.#r,queryNode:W.QueryNode.cloneWithOutput(this.#r.queryNode,p(e))})}outputAll(e){return new r({...this.#r,queryNode:W.QueryNode.cloneWithOutput(this.#r.queryNode,h(e))})}clearReturning(){return new r({...this.#r,queryNode:W.QueryNode.cloneWithoutReturning(this.#r.queryNode)})}clearLimit(){return new r({...this.#r,queryNode:J.DeleteQueryNode.cloneWithoutLimit(this.#r.queryNode)})}orderBy(...e){return new r({...this.#r,queryNode:W.QueryNode.cloneWithOrderByItems(this.#r.queryNode,(0,U.parseOrderBy)(e))})}clearOrderBy(){return new r({...this.#r,queryNode:W.QueryNode.cloneWithoutOrderBy(this.#r.queryNode)})}limit(e){return new r({...this.#r,queryNode:J.DeleteQueryNode.cloneWithLimit(this.#r.queryNode,P.create((0,y.parseValueExpression)(e)))})}modifyEnd(e){return new r({...this.#r,queryNode:W.QueryNode.cloneWithEndModifier(this.#r.queryNode,e.toOperationNode())})}$call(e){return e(this)}$if(e,t){return e?t(this):new r({...this.#r})}$castTo(){return new r(this.#r)}$narrowType(){return new r(this.#r)}$assertType(){return new r(this.#r)}withPlugin(e){return new r({...this.#r,executor:this.#r.executor.withPlugin(e)})}toOperationNode(){return this.#r.executor.transformQuery(this.#r.queryNode,this.#r.queryId)}compile(){return this.#r.executor.compileQuery(this.toOperationNode(),this.#r.queryId)}async execute(e){let r=this.compile(),t=await this.#r.executor.executeQuery(r,e),{adapter:o}=this.#r.executor,i=r.query;return i.returning&&o.supportsReturning||i.output&&o.supportsOutput?t.rows:[new D(t.numAffectedRows??BigInt(0))]}async executeTakeFirst(e){let[r]=await this.execute(e);return r}async executeTakeFirstOrThrow(e){"function"==typeof e&&(e={errorConstructor:e});let r=await this.executeTakeFirst(e);if(void 0===r){let r=e?.errorConstructor??k;throw E(r)?new r(this.toOperationNode()):r(this.toOperationNode())}return r}async *stream(e){"object"!=typeof e&&(e={chunkSize:e});let r=this.compile();for await(let t of this.#r.executor.stream(r,e.chunkSize??100,e))yield*t.rows}async explain(e,t){let o=new r({...this.#r,queryNode:W.QueryNode.cloneWithExplain(this.#r.queryNode,e,t)});return await o.execute()}}r=j,e.s(["UpdateQueryBuilder",()=>K],27797);var $=e.i(40642);class G{numUpdatedRows;numChangedRows;constructor(e,r){this.numUpdatedRows=e,this.numChangedRows=r}}class K{#r;constructor(e){this.#r=(0,o.freeze)(e)}where(...e){return new t({...this.#r,queryNode:W.QueryNode.cloneWithWhere(this.#r.queryNode,(0,B.parseValueBinaryOperationOrExpression)(e))})}whereRef(e,r,o){return new t({...this.#r,queryNode:W.QueryNode.cloneWithWhere(this.#r.queryNode,(0,B.parseReferentialBinaryOperation)(e,r,o))})}clearWhere(){return new t({...this.#r,queryNode:W.QueryNode.cloneWithoutWhere(this.#r.queryNode)})}top(e,r){return new t({...this.#r,queryNode:W.QueryNode.cloneWithTop(this.#r.queryNode,L(e,r))})}from(e){return new t({...this.#r,queryNode:$.UpdateQueryNode.cloneWithFromItems(this.#r.queryNode,(0,d.parseTableExpressionOrList)(e))})}innerJoin(...e){return this.#t("InnerJoin",e)}leftJoin(...e){return this.#t("LeftJoin",e)}rightJoin(...e){return this.#t("RightJoin",e)}fullJoin(...e){return this.#t("FullJoin",e)}#t(e,r){return new t({...this.#r,queryNode:W.QueryNode.cloneWithJoin(this.#r.queryNode,(0,M.parseJoin)(e,r))})}orderBy(...e){return new t({...this.#r,queryNode:W.QueryNode.cloneWithOrderByItems(this.#r.queryNode,(0,U.parseOrderBy)(e))})}clearOrderBy(){return new t({...this.#r,queryNode:W.QueryNode.cloneWithoutOrderBy(this.#r.queryNode)})}limit(e){return new t({...this.#r,queryNode:$.UpdateQueryNode.cloneWithLimit(this.#r.queryNode,P.create((0,y.parseValueExpression)(e)))})}set(...e){return new t({...this.#r,queryNode:$.UpdateQueryNode.cloneWithUpdates(this.#r.queryNode,function(...e){return 2===e.length?[b.create((0,n.parseReferenceExpression)(e[0]),(0,y.parseValueExpression)(e[1]))]:q(e[0])}(...e))})}returning(e){return new t({...this.#r,queryNode:W.QueryNode.cloneWithReturning(this.#r.queryNode,p(e))})}returningAll(e){return new t({...this.#r,queryNode:W.QueryNode.cloneWithReturning(this.#r.queryNode,h(e))})}output(e){return new t({...this.#r,queryNode:W.QueryNode.cloneWithOutput(this.#r.queryNode,p(e))})}outputAll(e){return new t({...this.#r,queryNode:W.QueryNode.cloneWithOutput(this.#r.queryNode,h(e))})}modifyEnd(e){return new t({...this.#r,queryNode:W.QueryNode.cloneWithEndModifier(this.#r.queryNode,e.toOperationNode())})}clearReturning(){return new t({...this.#r,queryNode:W.QueryNode.cloneWithoutReturning(this.#r.queryNode)})}$call(e){return e(this)}$if(e,r){return e?r(this):new t({...this.#r})}$castTo(){return new t(this.#r)}$narrowType(){return new t(this.#r)}$assertType(){return new t(this.#r)}withPlugin(e){return new t({...this.#r,executor:this.#r.executor.withPlugin(e)})}toOperationNode(){return this.#r.executor.transformQuery(this.#r.queryNode,this.#r.queryId)}compile(){return this.#r.executor.compileQuery(this.toOperationNode(),this.#r.queryId)}async execute(e){let r=this.compile(),t=await this.#r.executor.executeQuery(r,e),{adapter:o}=this.#r.executor,i=r.query;return i.returning&&o.supportsReturning||i.output&&o.supportsOutput?t.rows:[new G(t.numAffectedRows??BigInt(0),t.numChangedRows)]}async executeTakeFirst(e){let[r]=await this.execute(e);return r}async executeTakeFirstOrThrow(e){"function"==typeof e&&(e={errorConstructor:e});let r=await this.executeTakeFirst(e);if(void 0===r){let r=e?.errorConstructor??k;throw E(r)?new r(this.toOperationNode()):r(this.toOperationNode())}return r}async *stream(e){"object"!=typeof e&&(e={chunkSize:e});let r=this.compile();for await(let t of this.#r.executor.stream(r,e.chunkSize??100,e))yield*t.rows}async explain(e,r){let o=new t({...this.#r,queryNode:W.QueryNode.cloneWithExplain(this.#r.queryNode,e,r)});return await o.execute()}}t=K,e.s(["parseCommonTableExpression",()=>er],55642);var _=e.i(39328);let H=(0,o.freeze)({is:e=>"CommonTableExpressionNameNode"===e.kind,create:(e,r)=>(0,o.freeze)({kind:"CommonTableExpressionNameNode",table:_.TableNode.create(e),columns:r?(0,o.freeze)(r.map(f.ColumnNode.create)):void 0})});var X=e.i(74832);let Y=(0,o.freeze)({is:e=>"CommonTableExpressionNode"===e.kind,create:(e,r)=>(0,o.freeze)({kind:"CommonTableExpressionNode",name:e,expression:r}),cloneWith:(e,r)=>(0,o.freeze)({...e,...r})});class Z{#r;constructor(e){this.#r=(0,o.freeze)(e)}materialized(){return new Z({...this.#r,node:Y.cloneWith(this.#r.node,{materialized:!0})})}notMaterialized(){return new Z({...this.#r,node:Y.cloneWith(this.#r.node,{materialized:!1})})}toOperationNode(){return this.#r.node}}var ee=e.i(52369);function er(e,r){var t;let i=(0,ee.isOperationNodeSource)(r)?r.toOperationNode():r((0,X.createQueryCreator)()).toOperationNode();return(0,o.isFunction)(e)?e((t=i,e=>new Z({node:Y.create(et(e),t)}))).toOperationNode():Y.create(et(e),i)}function et(e){if(!e.includes("("))return H.create(e);{let r=e.split(/[\(\)]/),t=r[0],o=r[1].split(",").map(e=>e.trim());return H.create(t,o)}}let eo=(0,o.freeze)({is:e=>"WithNode"===e.kind,create:(e,r)=>(0,o.freeze)({kind:"WithNode",expressions:(0,o.freeze)([e]),...r}),cloneWithExpression:(e,r)=>(0,o.freeze)({...e,expressions:(0,o.freeze)([...e.expressions,r])})});e.s(["WithNode",0,eo],34755)},15249,11719,e=>{"use strict";let r=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"];function t(e){let t="";for(let o=0;o<e;++o)t+=r[~~(Math.random()*r.length)];return t}e.s(["randomString",0,t],11719);class o{#o;get queryId(){return void 0===this.#o&&(this.#o=t(8)),this.#o}}e.s(["createQueryId",0,function(){return new o}],15249)},22284,18264,62926,55505,742,47007,95776,97078,13071,74832,38584,85569,72127,12365,81442,70420,e=>{"use strict";e.s(["createSelectQueryBuilder",()=>eB],22284);var r,t=e.i(77373),o=e.i(80827);e.s(["parseJoin",()=>el],38584);var i=e.i(79111),n=e.i(23669);e.s(["createJoinBuilder",()=>eu,"createOverBuilder",()=>ep,"createQueryCreator",()=>ed],74832);var s=e.i(20857),a=e.i(4372),d=e.i(69062);e.s(["QueryCreator",()=>ea],13071);var u=e.i(94993),p=e.i(98130),l=e.i(27797),h=e.i(83715),c=e.i(91114),f=e.i(34067),N=e.i(40642),m=e.i(27952),y=e.i(55642),w=e.i(34755),g=e.i(15249),O=e.i(55514),x=e.i(32694),W=e.i(5292);class b{nodeStack=[];#i=(0,W.freeze)({AliasNode:this.transformAlias.bind(this),ColumnNode:this.transformColumn.bind(this),IdentifierNode:this.transformIdentifier.bind(this),SchemableIdentifierNode:this.transformSchemableIdentifier.bind(this),RawNode:this.transformRaw.bind(this),ReferenceNode:this.transformReference.bind(this),SelectQueryNode:this.transformSelectQuery.bind(this),SelectionNode:this.transformSelection.bind(this),TableNode:this.transformTable.bind(this),FromNode:this.transformFrom.bind(this),SelectAllNode:this.transformSelectAll.bind(this),AndNode:this.transformAnd.bind(this),OrNode:this.transformOr.bind(this),ValueNode:this.transformValue.bind(this),ValueListNode:this.transformValueList.bind(this),PrimitiveValueListNode:this.transformPrimitiveValueList.bind(this),ParensNode:this.transformParens.bind(this),JoinNode:this.transformJoin.bind(this),OperatorNode:this.transformOperator.bind(this),WhereNode:this.transformWhere.bind(this),InsertQueryNode:this.transformInsertQuery.bind(this),DeleteQueryNode:this.transformDeleteQuery.bind(this),ReturningNode:this.transformReturning.bind(this),CreateTableNode:this.transformCreateTable.bind(this),AddColumnNode:this.transformAddColumn.bind(this),ColumnDefinitionNode:this.transformColumnDefinition.bind(this),DropTableNode:this.transformDropTable.bind(this),DataTypeNode:this.transformDataType.bind(this),OrderByNode:this.transformOrderBy.bind(this),OrderByItemNode:this.transformOrderByItem.bind(this),GroupByNode:this.transformGroupBy.bind(this),GroupByItemNode:this.transformGroupByItem.bind(this),UpdateQueryNode:this.transformUpdateQuery.bind(this),ColumnUpdateNode:this.transformColumnUpdate.bind(this),LimitNode:this.transformLimit.bind(this),OffsetNode:this.transformOffset.bind(this),OnConflictNode:this.transformOnConflict.bind(this),OnDuplicateKeyNode:this.transformOnDuplicateKey.bind(this),CreateIndexNode:this.transformCreateIndex.bind(this),DropIndexNode:this.transformDropIndex.bind(this),ListNode:this.transformList.bind(this),PrimaryKeyConstraintNode:this.transformPrimaryKeyConstraint.bind(this),UniqueConstraintNode:this.transformUniqueConstraint.bind(this),ReferencesNode:this.transformReferences.bind(this),CheckConstraintNode:this.transformCheckConstraint.bind(this),WithNode:this.transformWith.bind(this),CommonTableExpressionNode:this.transformCommonTableExpression.bind(this),CommonTableExpressionNameNode:this.transformCommonTableExpressionName.bind(this),HavingNode:this.transformHaving.bind(this),CreateSchemaNode:this.transformCreateSchema.bind(this),DropSchemaNode:this.transformDropSchema.bind(this),AlterTableNode:this.transformAlterTable.bind(this),DropColumnNode:this.transformDropColumn.bind(this),RenameColumnNode:this.transformRenameColumn.bind(this),AlterColumnNode:this.transformAlterColumn.bind(this),ModifyColumnNode:this.transformModifyColumn.bind(this),AddConstraintNode:this.transformAddConstraint.bind(this),DropConstraintNode:this.transformDropConstraint.bind(this),RenameConstraintNode:this.transformRenameConstraint.bind(this),ForeignKeyConstraintNode:this.transformForeignKeyConstraint.bind(this),CreateViewNode:this.transformCreateView.bind(this),RefreshMaterializedViewNode:this.transformRefreshMaterializedView.bind(this),DropViewNode:this.transformDropView.bind(this),GeneratedNode:this.transformGenerated.bind(this),DefaultValueNode:this.transformDefaultValue.bind(this),OnNode:this.transformOn.bind(this),ValuesNode:this.transformValues.bind(this),SelectModifierNode:this.transformSelectModifier.bind(this),CreateTypeNode:this.transformCreateType.bind(this),DropTypeNode:this.transformDropType.bind(this),ExplainNode:this.transformExplain.bind(this),DefaultInsertValueNode:this.transformDefaultInsertValue.bind(this),AggregateFunctionNode:this.transformAggregateFunction.bind(this),OverNode:this.transformOver.bind(this),PartitionByNode:this.transformPartitionBy.bind(this),PartitionByItemNode:this.transformPartitionByItem.bind(this),SetOperationNode:this.transformSetOperation.bind(this),BinaryOperationNode:this.transformBinaryOperation.bind(this),UnaryOperationNode:this.transformUnaryOperation.bind(this),UsingNode:this.transformUsing.bind(this),FunctionNode:this.transformFunction.bind(this),CaseNode:this.transformCase.bind(this),WhenNode:this.transformWhen.bind(this),JSONReferenceNode:this.transformJSONReference.bind(this),JSONPathNode:this.transformJSONPath.bind(this),JSONPathLegNode:this.transformJSONPathLeg.bind(this),JSONOperatorChainNode:this.transformJSONOperatorChain.bind(this),TupleNode:this.transformTuple.bind(this),MergeQueryNode:this.transformMergeQuery.bind(this),MatchedNode:this.transformMatched.bind(this),AddIndexNode:this.transformAddIndex.bind(this),CastNode:this.transformCast.bind(this),FetchNode:this.transformFetch.bind(this),TopNode:this.transformTop.bind(this),OutputNode:this.transformOutput.bind(this),OrActionNode:this.transformOrAction.bind(this),CollateNode:this.transformCollate.bind(this),AlterTypeNode:this.transformAlterType.bind(this),AddValueNode:this.transformAddValue.bind(this),RenameValueNode:this.transformRenameValue.bind(this)});transformNode(e,r){if(!e)return e;this.nodeStack.push(e);let t=this.transformNodeImpl(e,r);return this.nodeStack.pop(),(0,W.freeze)(t)}transformNodeImpl(e,r){return this.#i[e.kind](e,r)}transformNodeList(e,r){return e?(0,W.freeze)(e.map(e=>this.transformNode(e,r))):e}transformSelectQuery(e,r){return{kind:"SelectQueryNode",from:this.transformNode(e.from,r),selections:this.transformNodeList(e.selections,r),distinctOn:this.transformNodeList(e.distinctOn,r),joins:this.transformNodeList(e.joins,r),groupBy:this.transformNode(e.groupBy,r),orderBy:this.transformNode(e.orderBy,r),where:this.transformNode(e.where,r),frontModifiers:this.transformNodeList(e.frontModifiers,r),endModifiers:this.transformNodeList(e.endModifiers,r),limit:this.transformNode(e.limit,r),offset:this.transformNode(e.offset,r),with:this.transformNode(e.with,r),having:this.transformNode(e.having,r),explain:this.transformNode(e.explain,r),setOperations:this.transformNodeList(e.setOperations,r),fetch:this.transformNode(e.fetch,r),top:this.transformNode(e.top,r)}}transformSelection(e,r){return{kind:"SelectionNode",selection:this.transformNode(e.selection,r)}}transformColumn(e,r){return{kind:"ColumnNode",column:this.transformNode(e.column,r)}}transformAlias(e,r){return{kind:"AliasNode",node:this.transformNode(e.node,r),alias:this.transformNode(e.alias,r)}}transformTable(e,r){return{kind:"TableNode",table:this.transformNode(e.table,r)}}transformFrom(e,r){return{kind:"FromNode",froms:this.transformNodeList(e.froms,r)}}transformReference(e,r){return{kind:"ReferenceNode",column:this.transformNode(e.column,r),table:this.transformNode(e.table,r)}}transformAnd(e,r){return{kind:"AndNode",left:this.transformNode(e.left,r),right:this.transformNode(e.right,r)}}transformOr(e,r){return{kind:"OrNode",left:this.transformNode(e.left,r),right:this.transformNode(e.right,r)}}transformValueList(e,r){return{kind:"ValueListNode",values:this.transformNodeList(e.values,r)}}transformParens(e,r){return{kind:"ParensNode",node:this.transformNode(e.node,r)}}transformJoin(e,r){return{kind:"JoinNode",joinType:e.joinType,table:this.transformNode(e.table,r),on:this.transformNode(e.on,r)}}transformRaw(e,r){return{kind:"RawNode",sqlFragments:(0,W.freeze)([...e.sqlFragments]),parameters:this.transformNodeList(e.parameters,r)}}transformWhere(e,r){return{kind:"WhereNode",where:this.transformNode(e.where,r)}}transformInsertQuery(e,r){return{kind:"InsertQueryNode",into:this.transformNode(e.into,r),columns:this.transformNodeList(e.columns,r),values:this.transformNode(e.values,r),returning:this.transformNode(e.returning,r),onConflict:this.transformNode(e.onConflict,r),onDuplicateKey:this.transformNode(e.onDuplicateKey,r),endModifiers:this.transformNodeList(e.endModifiers,r),with:this.transformNode(e.with,r),orAction:this.transformNode(e.orAction,r),replace:e.replace,explain:this.transformNode(e.explain,r),defaultValues:e.defaultValues,top:this.transformNode(e.top,r),output:this.transformNode(e.output,r)}}transformValues(e,r){return{kind:"ValuesNode",values:this.transformNodeList(e.values,r)}}transformDeleteQuery(e,r){return{kind:"DeleteQueryNode",from:this.transformNode(e.from,r),using:this.transformNode(e.using,r),joins:this.transformNodeList(e.joins,r),where:this.transformNode(e.where,r),returning:this.transformNode(e.returning,r),endModifiers:this.transformNodeList(e.endModifiers,r),with:this.transformNode(e.with,r),orderBy:this.transformNode(e.orderBy,r),limit:this.transformNode(e.limit,r),explain:this.transformNode(e.explain,r),top:this.transformNode(e.top,r),output:this.transformNode(e.output,r)}}transformReturning(e,r){return{kind:"ReturningNode",selections:this.transformNodeList(e.selections,r)}}transformCreateTable(e,r){return{kind:"CreateTableNode",table:this.transformNode(e.table,r),columns:this.transformNodeList(e.columns,r),constraints:this.transformNodeList(e.constraints,r),indexes:this.transformNodeList(e.indexes,r),temporary:e.temporary,ifNotExists:e.ifNotExists,onCommit:e.onCommit,frontModifiers:this.transformNodeList(e.frontModifiers,r),endModifiers:this.transformNodeList(e.endModifiers,r),selectQuery:this.transformNode(e.selectQuery,r)}}transformColumnDefinition(e,r){return{kind:"ColumnDefinitionNode",column:this.transformNode(e.column,r),dataType:this.transformNode(e.dataType,r),references:this.transformNode(e.references,r),primaryKey:e.primaryKey,autoIncrement:e.autoIncrement,unique:e.unique,notNull:e.notNull,unsigned:e.unsigned,defaultTo:this.transformNode(e.defaultTo,r),check:this.transformNode(e.check,r),generated:this.transformNode(e.generated,r),frontModifiers:this.transformNodeList(e.frontModifiers,r),endModifiers:this.transformNodeList(e.endModifiers,r),nullsNotDistinct:e.nullsNotDistinct,identity:e.identity,ifNotExists:e.ifNotExists}}transformAddColumn(e,r){return{kind:"AddColumnNode",column:this.transformNode(e.column,r)}}transformDropTable(e,r){return{kind:"DropTableNode",table:this.transformNode(e.table,r),ifExists:e.ifExists,cascade:e.cascade,temporary:e.temporary}}transformOrderBy(e,r){return{kind:"OrderByNode",items:this.transformNodeList(e.items,r)}}transformOrderByItem(e,r){return{kind:"OrderByItemNode",orderBy:this.transformNode(e.orderBy,r),direction:this.transformNode(e.direction,r),collation:this.transformNode(e.collation,r),nulls:e.nulls}}transformGroupBy(e,r){return{kind:"GroupByNode",items:this.transformNodeList(e.items,r)}}transformGroupByItem(e,r){return{kind:"GroupByItemNode",groupBy:this.transformNode(e.groupBy,r)}}transformUpdateQuery(e,r){return{kind:"UpdateQueryNode",table:this.transformNode(e.table,r),from:this.transformNode(e.from,r),joins:this.transformNodeList(e.joins,r),where:this.transformNode(e.where,r),updates:this.transformNodeList(e.updates,r),returning:this.transformNode(e.returning,r),endModifiers:this.transformNodeList(e.endModifiers,r),with:this.transformNode(e.with,r),explain:this.transformNode(e.explain,r),limit:this.transformNode(e.limit,r),top:this.transformNode(e.top,r),output:this.transformNode(e.output,r),orderBy:this.transformNode(e.orderBy,r)}}transformColumnUpdate(e,r){return{kind:"ColumnUpdateNode",column:this.transformNode(e.column,r),value:this.transformNode(e.value,r)}}transformLimit(e,r){return{kind:"LimitNode",limit:this.transformNode(e.limit,r)}}transformOffset(e,r){return{kind:"OffsetNode",offset:this.transformNode(e.offset,r)}}transformOnConflict(e,r){return{kind:"OnConflictNode",columns:this.transformNodeList(e.columns,r),constraint:this.transformNode(e.constraint,r),indexExpression:this.transformNode(e.indexExpression,r),indexWhere:this.transformNode(e.indexWhere,r),updates:this.transformNodeList(e.updates,r),updateWhere:this.transformNode(e.updateWhere,r),doNothing:e.doNothing}}transformOnDuplicateKey(e,r){return{kind:"OnDuplicateKeyNode",updates:this.transformNodeList(e.updates,r)}}transformCreateIndex(e,r){return{kind:"CreateIndexNode",name:this.transformNode(e.name,r),table:this.transformNode(e.table,r),columns:this.transformNodeList(e.columns,r),unique:e.unique,using:this.transformNode(e.using,r),ifNotExists:e.ifNotExists,where:this.transformNode(e.where,r),nullsNotDistinct:e.nullsNotDistinct}}transformList(e,r){return{kind:"ListNode",items:this.transformNodeList(e.items,r)}}transformDropIndex(e,r){return{kind:"DropIndexNode",name:this.transformNode(e.name,r),table:this.transformNode(e.table,r),ifExists:e.ifExists,cascade:e.cascade}}transformPrimaryKeyConstraint(e,r){return{kind:"PrimaryKeyConstraintNode",columns:this.transformNodeList(e.columns,r),name:this.transformNode(e.name,r),deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred}}transformUniqueConstraint(e,r){return{kind:"UniqueConstraintNode",columns:this.transformNodeList(e.columns,r),name:this.transformNode(e.name,r),nullsNotDistinct:e.nullsNotDistinct,deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred}}transformForeignKeyConstraint(e,r){return{kind:"ForeignKeyConstraintNode",columns:this.transformNodeList(e.columns,r),references:this.transformNode(e.references,r),name:this.transformNode(e.name,r),onDelete:e.onDelete,onUpdate:e.onUpdate,deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred}}transformSetOperation(e,r){return{kind:"SetOperationNode",operator:e.operator,expression:this.transformNode(e.expression,r),all:e.all}}transformReferences(e,r){return{kind:"ReferencesNode",table:this.transformNode(e.table,r),columns:this.transformNodeList(e.columns,r),onDelete:e.onDelete,onUpdate:e.onUpdate}}transformCheckConstraint(e,r){return{kind:"CheckConstraintNode",expression:this.transformNode(e.expression,r),name:this.transformNode(e.name,r)}}transformWith(e,r){return{kind:"WithNode",expressions:this.transformNodeList(e.expressions,r),recursive:e.recursive}}transformCommonTableExpression(e,r){return{kind:"CommonTableExpressionNode",name:this.transformNode(e.name,r),materialized:e.materialized,expression:this.transformNode(e.expression,r)}}transformCommonTableExpressionName(e,r){return{kind:"CommonTableExpressionNameNode",table:this.transformNode(e.table,r),columns:this.transformNodeList(e.columns,r)}}transformHaving(e,r){return{kind:"HavingNode",having:this.transformNode(e.having,r)}}transformCreateSchema(e,r){return{kind:"CreateSchemaNode",schema:this.transformNode(e.schema,r),ifNotExists:e.ifNotExists}}transformDropSchema(e,r){return{kind:"DropSchemaNode",schema:this.transformNode(e.schema,r),ifExists:e.ifExists,cascade:e.cascade}}transformAlterTable(e,r){return{kind:"AlterTableNode",table:this.transformNode(e.table,r),renameTo:this.transformNode(e.renameTo,r),setSchema:this.transformNode(e.setSchema,r),columnAlterations:this.transformNodeList(e.columnAlterations,r),addConstraint:this.transformNode(e.addConstraint,r),dropConstraint:this.transformNode(e.dropConstraint,r),renameConstraint:this.transformNode(e.renameConstraint,r),addIndex:this.transformNode(e.addIndex,r),dropIndex:this.transformNode(e.dropIndex,r)}}transformDropColumn(e,r){return{kind:"DropColumnNode",column:this.transformNode(e.column,r),ifExists:e.ifExists}}transformRenameColumn(e,r){return{kind:"RenameColumnNode",column:this.transformNode(e.column,r),renameTo:this.transformNode(e.renameTo,r)}}transformAlterColumn(e,r){return{kind:"AlterColumnNode",column:this.transformNode(e.column,r),dataType:this.transformNode(e.dataType,r),dataTypeExpression:this.transformNode(e.dataTypeExpression,r),setDefault:this.transformNode(e.setDefault,r),dropDefault:e.dropDefault,setNotNull:e.setNotNull,dropNotNull:e.dropNotNull}}transformModifyColumn(e,r){return{kind:"ModifyColumnNode",column:this.transformNode(e.column,r)}}transformAddConstraint(e,r){return{kind:"AddConstraintNode",constraint:this.transformNode(e.constraint,r)}}transformDropConstraint(e,r){return{kind:"DropConstraintNode",constraintName:this.transformNode(e.constraintName,r),ifExists:e.ifExists,modifier:e.modifier}}transformRenameConstraint(e,r){return{kind:"RenameConstraintNode",oldName:this.transformNode(e.oldName,r),newName:this.transformNode(e.newName,r)}}transformCreateView(e,r){return{kind:"CreateViewNode",name:this.transformNode(e.name,r),temporary:e.temporary,orReplace:e.orReplace,ifNotExists:e.ifNotExists,materialized:e.materialized,columns:this.transformNodeList(e.columns,r),as:this.transformNode(e.as,r)}}transformRefreshMaterializedView(e,r){return{kind:"RefreshMaterializedViewNode",name:this.transformNode(e.name,r),concurrently:e.concurrently,withNoData:e.withNoData}}transformDropView(e,r){return{kind:"DropViewNode",name:this.transformNode(e.name,r),ifExists:e.ifExists,materialized:e.materialized,cascade:e.cascade}}transformGenerated(e,r){return{kind:"GeneratedNode",byDefault:e.byDefault,always:e.always,identity:e.identity,stored:e.stored,expression:this.transformNode(e.expression,r)}}transformDefaultValue(e,r){return{kind:"DefaultValueNode",defaultValue:this.transformNode(e.defaultValue,r)}}transformOn(e,r){return{kind:"OnNode",on:this.transformNode(e.on,r)}}transformSelectModifier(e,r){return{kind:"SelectModifierNode",modifier:e.modifier,rawModifier:this.transformNode(e.rawModifier,r),of:this.transformNodeList(e.of,r)}}transformCreateType(e,r){return{kind:"CreateTypeNode",name:this.transformNode(e.name,r),enum:this.transformNode(e.enum,r)}}transformDropType(e,r){return{kind:"DropTypeNode",name:this.transformNode(e.name,r),additionalNames:this.transformNodeList(e.additionalNames,r),cascade:e.cascade,ifExists:e.ifExists}}transformExplain(e,r){return{kind:"ExplainNode",format:e.format,options:this.transformNode(e.options,r)}}transformSchemableIdentifier(e,r){return{kind:"SchemableIdentifierNode",schema:this.transformNode(e.schema,r),identifier:this.transformNode(e.identifier,r)}}transformAggregateFunction(e,r){return{kind:"AggregateFunctionNode",func:e.func,aggregated:this.transformNodeList(e.aggregated,r),distinct:e.distinct,orderBy:this.transformNode(e.orderBy,r),withinGroup:this.transformNode(e.withinGroup,r),filter:this.transformNode(e.filter,r),over:this.transformNode(e.over,r)}}transformOver(e,r){return{kind:"OverNode",orderBy:this.transformNode(e.orderBy,r),partitionBy:this.transformNode(e.partitionBy,r)}}transformPartitionBy(e,r){return{kind:"PartitionByNode",items:this.transformNodeList(e.items,r)}}transformPartitionByItem(e,r){return{kind:"PartitionByItemNode",partitionBy:this.transformNode(e.partitionBy,r)}}transformBinaryOperation(e,r){return{kind:"BinaryOperationNode",leftOperand:this.transformNode(e.leftOperand,r),operator:this.transformNode(e.operator,r),rightOperand:this.transformNode(e.rightOperand,r)}}transformUnaryOperation(e,r){return{kind:"UnaryOperationNode",operator:this.transformNode(e.operator,r),operand:this.transformNode(e.operand,r)}}transformUsing(e,r){return{kind:"UsingNode",tables:this.transformNodeList(e.tables,r)}}transformFunction(e,r){return{kind:"FunctionNode",func:e.func,arguments:this.transformNodeList(e.arguments,r)}}transformCase(e,r){return{kind:"CaseNode",value:this.transformNode(e.value,r),when:this.transformNodeList(e.when,r),else:this.transformNode(e.else,r),isStatement:e.isStatement}}transformWhen(e,r){return{kind:"WhenNode",condition:this.transformNode(e.condition,r),result:this.transformNode(e.result,r)}}transformJSONReference(e,r){return{kind:"JSONReferenceNode",reference:this.transformNode(e.reference,r),traversal:this.transformNode(e.traversal,r)}}transformJSONPath(e,r){return{kind:"JSONPathNode",inOperator:this.transformNode(e.inOperator,r),pathLegs:this.transformNodeList(e.pathLegs,r)}}transformJSONPathLeg(e,r){return{kind:"JSONPathLegNode",type:e.type,value:e.value}}transformJSONOperatorChain(e,r){return{kind:"JSONOperatorChainNode",operator:this.transformNode(e.operator,r),values:this.transformNodeList(e.values,r)}}transformTuple(e,r){return{kind:"TupleNode",values:this.transformNodeList(e.values,r)}}transformMergeQuery(e,r){return{kind:"MergeQueryNode",into:this.transformNode(e.into,r),using:this.transformNode(e.using,r),whens:this.transformNodeList(e.whens,r),with:this.transformNode(e.with,r),top:this.transformNode(e.top,r),endModifiers:this.transformNodeList(e.endModifiers,r),output:this.transformNode(e.output,r),returning:this.transformNode(e.returning,r)}}transformMatched(e,r){return{kind:"MatchedNode",not:e.not,bySource:e.bySource}}transformAddIndex(e,r){return{kind:"AddIndexNode",name:this.transformNode(e.name,r),columns:this.transformNodeList(e.columns,r),unique:e.unique,using:this.transformNode(e.using,r),ifNotExists:e.ifNotExists}}transformCast(e,r){return{kind:"CastNode",expression:this.transformNode(e.expression,r),dataType:this.transformNode(e.dataType,r)}}transformFetch(e,r){return{kind:"FetchNode",rowCount:this.transformNode(e.rowCount,r),modifier:e.modifier}}transformTop(e,r){return{kind:"TopNode",expression:e.expression,modifiers:e.modifiers}}transformOutput(e,r){return{kind:"OutputNode",selections:this.transformNodeList(e.selections,r)}}transformAlterType(e,r){return{kind:"AlterTypeNode",name:this.transformNode(e.name,r),addValue:this.transformNode(e.addValue,r),renameTo:this.transformNode(e.renameTo,r),renameValue:this.transformNode(e.renameValue,r),setSchema:this.transformNode(e.setSchema,r)}}transformAddValue(e,r){return{kind:"AddValueNode",value:this.transformNode(e.value,r),ifNotExists:e.ifNotExists,isBefore:e.isBefore,neighborValue:this.transformNode(e.neighborValue,r)}}transformRenameValue(e,r){return{kind:"RenameValueNode",oldValue:this.transformNode(e.oldValue,r),newValue:this.transformNode(e.newValue,r)}}transformDataType(e,r){return e}transformSelectAll(e,r){return e}transformIdentifier(e,r){return e}transformValue(e,r){return e}transformPrimitiveValueList(e,r){return e}transformOperator(e,r){return e}transformDefaultInsertValue(e,r){return e}transformOrAction(e,r){return e}transformCollate(e,r){return e}}e.s(["OperationNodeTransformer",0,b],18264);let q={AlterTableNode:!0,AlterTypeNode:!0,CreateIndexNode:!0,CreateSchemaNode:!0,CreateTableNode:!0,CreateTypeNode:!0,CreateViewNode:!0,DeleteQueryNode:!0,DropIndexNode:!0,DropSchemaNode:!0,DropTableNode:!0,DropTypeNode:!0,RefreshMaterializedViewNode:!0,DropViewNode:!0,InsertQueryNode:!0,RawNode:!0,SelectQueryNode:!0,UpdateQueryNode:!0,MergeQueryNode:!0};var z=e.i(15196),S=e.i(39328),k=e.i(76413);let E=(0,W.freeze)({json_agg:!0,to_json:!0});class I extends b{#n;#s=new Set;#a=new Set;constructor(e){super(),this.#n=e}transformNodeImpl(e,r){if(!((0,W.isObject)(e)&&(0,W.isString)(e.kind))||!0!==q[e.kind])return super.transformNodeImpl(e,r);let t=this.#d(e);for(let e of t)this.#a.add(e);let o=this.#u(e);for(let e of o)this.#s.add(e);let i=super.transformNodeImpl(e,r);for(let e of o)this.#s.delete(e);for(let e of t)this.#a.delete(e);return i}transformSchemableIdentifier(e,r){let t=super.transformSchemableIdentifier(e,r);return t.schema||!this.#s.has(e.identifier.name)?t:{...t,schema:O.IdentifierNode.create(this.#n)}}transformReferences(e,r){let t=super.transformReferences(e,r);return t.table.table.schema?t:{...t,table:S.TableNode.createWithSchema(this.#n,t.table.table.identifier.name)}}transformAggregateFunction(e,r){return{...super.transformAggregateFunction({...e,aggregated:[]},r),aggregated:this.#p(e,r,"aggregated")}}transformFunction(e,r){return{...super.transformFunction({...e,arguments:[]},r),arguments:this.#p(e,r,"arguments")}}transformSelectModifier(e,r){return{...super.transformSelectModifier({...e,of:void 0},r),of:e.of?.map(e=>S.TableNode.is(e)&&!e.table.schema?{...e,table:this.transformIdentifier(e.table.identifier,r)}:this.transformNode(e,r))}}#p(e,r,t){return E[e.func]?e[t].map(e=>!S.TableNode.is(e)||e.table.schema?this.transformNode(e,r):{...e,table:this.transformIdentifier(e.table.identifier,r)}):this.transformNodeList(e[t],r)}#u(e){let r=new Set;if("name"in e&&e.name&&z.SchemableIdentifierNode.is(e.name)&&this.#l(e.name,r),"from"in e&&e.from)for(let t of e.from.froms)this.#h(t,r);if("into"in e&&e.into&&this.#h(e.into,r),"table"in e&&e.table&&this.#h(e.table,r),"joins"in e&&e.joins)for(let t of e.joins)this.#h(t.table,r);return"using"in e&&e.using&&(i.JoinNode.is(e.using)?this.#h(e.using.table,r):this.#h(e.using,r)),r}#d(e){let r=new Set;return"with"in e&&e.with&&this.#c(e.with,r),r}#h(e,r){if(S.TableNode.is(e))return this.#l(e.table,r);if(t.AliasNode.is(e)&&S.TableNode.is(e.node))return this.#l(e.node.table,r);if(x.ListNode.is(e)){for(let t of e.items)this.#h(t,r);return}if(k.UsingNode.is(e)){for(let t of e.tables)this.#h(t,r);return}}#l(e,r){let t=e.identifier.name;this.#s.has(t)||this.#a.has(t)||r.add(t)}#c(e,r){for(let t of e.expressions){let e=t.name.table.table.identifier.name;this.#a.has(e)||r.add(e)}}}class v{#f;constructor(e){this.#f=new I(e)}transformQuery(e){return this.#f.transformNode(e.node,e.queryId)}async transformResult(e){return e.result}}e.s(["WithSchemaPlugin",0,v],62926);var C=e.i(31461),B=e.i(19285),Q=e.i(22350),T=e.i(89737);let R=(0,W.freeze)({is:e=>"MatchedNode"===e.kind,create:(e,r=!1)=>(0,W.freeze)({kind:"MatchedNode",not:e,bySource:r})});var A=e.i(52369),L=e.i(3731),F=e.i(54860);function V(e,r,t){return F.WhenNode.create((0,n.parseFilterList)([R.create(!e.isMatched,e.bySource),...r&&r.length>0?[3===r.length&&t?(0,n.parseReferentialBinaryOperation)(r[0],r[1],r[2]):(0,n.parseValueBinaryOperationOrExpression)(r)]:[]],"and",!1))}function M(e){return(0,W.isString)(e)?L.RawNode.create([e],[]):(0,A.isOperationNodeSource)(e)?e.toOperationNode():e}var D=e.i(8882);class J{#N;#m;#y;constructor(){this.#N=new Promise((e,r)=>{this.#y=r,this.#m=e})}get promise(){return this.#N}resolve=e=>{this.#m?.(e),this.#m=this.#y=void 0};reject=e=>{this.#y?.(e),this.#y=this.#m=void 0}}async function P(e,r){let t=new J,o=new J;return e.provideConnection(async e=>(t.resolve(e),await o.promise),r).catch(e=>t.reject(e)),(0,W.freeze)({connection:await t.promise,release:o.resolve})}function U(e="ignore query",r,t){if("ignore query"!==e){if("cancel query"===e){let t=r.cancelQuery;return t||j(e,r.killSession?"kill session":void 0),t.bind(r)}if("kill session"===e){let t=r.killSession;return t||j(e,r.cancelQuery?"cancel query":void 0),t.bind(r)}throw t(),Error(`Unexpected \`inflightQueryAbortStrategy\`: "${e}"`)}}function j(e,r){throw Error(`This dialect doesn't support \`inflightQueryAbortStrategy\` "${e}". Use "ignore query"${r?` or "${r}"`:""} instead.`)}function $(e,r,t){e?.aborted&&(t?.(),G(e.reason,r))}function G(e,r){var t,o;throw t=e,o=r,null===t||"object"!=typeof t||Object.isFrozen(t)||Object.defineProperty(t,"__kysely_timing__",{configurable:!0,enumerable:!1,value:o,writable:!1}),e}e.s(["Deferred",0,J],55505),e.s(["provideControlledConnection",0,P],742);let K={};async function _(e,r,t,o){if(!r)return e;$(r,`before ${t}`,o);let{promise:i,resolve:n}=new J,s=()=>n(K);r.addEventListener("abort",s);try{$(r,`before ${t}`,o);let n=await Promise.race([e,i]);if(n!==K)return n;o?.(),G(r.reason,`during ${t}`)}finally{r.removeEventListener("abort",s),n(K)}}function H(e){return r=>console.error(`\`${e}\` failed in the background after abortion: ${(0,W.getMessage)(r)}`)}e.s(["ABORTED",0,K,"assertNotAborted",0,$,"getInflightQueryAbortHandler",0,U,"printBackgroundFail",0,H,"throwReasonWithTiming",0,G,"waitOrAbort",0,_],47007);let X=(0,W.freeze)([]);class Y{#w;constructor(e=X){this.#w=e}get plugins(){return this.#w}transformQuery(e,r){for(let t of this.#w){let o=t.transformQuery({node:e,queryId:r});if(o.kind===e.kind)e=o;else throw Error(`KyselyPlugin.transformQuery must return a node of the same kind that was given to it. The plugin was given a ${e.kind} but it returned a ${o.kind}`)}return e}async executeQuery(e,r){let{inflightQueryAbortStrategy:t="ignore query",signal:o}=r||{};if(!o){let t=await this.provideConnection(async r=>await r.executeQuery(e),r);return await this.#g(t,e.queryId)}$(o,"before query execution"),r=(0,W.freeze)({signal:o});let{connection:i,release:n}=await P(this,r),s=this.provideConnection.bind(this),{promise:a,resolve:d}=new J,u=()=>d(K);o.addEventListener("abort",u,{once:!0});try{$(o,"before query execution",n);let d=U(t,i,n);if(d&&i.collectSessionInfo){$(o,"before query execution",n);let e=i.collectSessionInfo();await Promise.race([a,e]).catch(e=>{throw n(),e})===K&&(e.catch(H("collectSessionInfo")).finally(n),G(o.reason,"before query execution"))}let u=i.executeQuery(e,r),p=await Promise.race([a,u]).catch(e=>{throw n(),e});p===K?(Promise.allSettled([u.catch(H("query")),d?.(s).catch(H("inflightQueryAbortHandler"))]).finally(n),G(o.reason,"during query execution")):n();let l=this.#g(p,e.queryId,r),h=await Promise.race([a,l]);return h===K&&(l.catch(H("plugins.transformResult")),G(o.reason,"during result transformation")),h}finally{d(K),o.removeEventListener("abort",u)}}async *stream(e,r,t){let o,i,{signal:n}=t||{};if(!n){let{connection:o,release:i}=await P(this);try{for await(let i of o.streamQuery(e,r))yield await this.#g(i,e.queryId,t)}finally{i()}return}t=(0,W.freeze)({signal:n}),$(n,"before connection acquisition");let{connection:s,release:a}=await P(this,t),{promise:d,resolve:u}=new J,p=()=>u(K);n.addEventListener("abort",p,{once:!0}),$(n,"before query streaming",a);let{queryId:l}=e;try{for(o=s.streamQuery(e,r,t);;){$(n,"during query streaming");let e=o.next(),r=await Promise.race([d,e]);if(r===K&&(i=e.catch(H("iterator.next")),G(n.reason,"during query streaming")),r.done)break;let s=this.#g(r.value,l,t),a=await Promise.race([d,s]);a===K&&(i=s.catch(H("plugins.transformResult")),G(n.reason,"during result transformation")),yield a}}finally{u(K),n.removeEventListener("abort",p);let e=(o?.return?.()||Promise.resolve()).finally(()=>i).finally(a);i||await e}}async #g(e,r,t){let{signal:o}=t||{};for(let t of this.#w)e=await t.transformResult((0,W.freeze)({queryId:r,result:e,signal:o}));return e}}e.s(["QueryExecutorBase",0,Y],95776);class Z extends Y{get adapter(){throw Error("this query cannot be compiled to SQL")}compileQuery(){throw Error("this query cannot be compiled to SQL")}provideConnection(){throw Error("this query cannot be executed")}withConnectionProvider(){throw Error("this query cannot have a connection provider")}withPlugin(e){return new Z([...this.plugins,e])}withPlugins(e){return new Z([...this.plugins,...e])}withPluginAtFront(e){return new Z([e,...this.plugins])}withoutPlugins(){return new Z([])}}let ee=new Z;e.s(["NOOP_QUERY_EXECUTOR",0,ee],97078);class er{numChangedRows;constructor(e){this.numChangedRows=e}}var et=e.i(98149);class eo{#r;constructor(e){this.#r=(0,W.freeze)(e)}modifyEnd(e){return new eo({...this.#r,queryNode:Q.QueryNode.cloneWithEndModifier(this.#r.queryNode,e.toOperationNode())})}top(e,r){return new eo({...this.#r,queryNode:Q.QueryNode.cloneWithTop(this.#r.queryNode,(0,D.parseTop)(e,r))})}using(...e){return new ei({...this.#r,queryNode:B.MergeQueryNode.cloneWithUsing(this.#r.queryNode,el("Using",e))})}returning(e){return new eo({...this.#r,queryNode:Q.QueryNode.cloneWithReturning(this.#r.queryNode,(0,C.parseSelectArg)(e))})}returningAll(e){return new eo({...this.#r,queryNode:Q.QueryNode.cloneWithReturning(this.#r.queryNode,(0,C.parseSelectAll)(e))})}output(e){return new eo({...this.#r,queryNode:Q.QueryNode.cloneWithOutput(this.#r.queryNode,(0,C.parseSelectArg)(e))})}outputAll(e){return new eo({...this.#r,queryNode:Q.QueryNode.cloneWithOutput(this.#r.queryNode,(0,C.parseSelectAll)(e))})}}class ei{#r;constructor(e){this.#r=(0,W.freeze)(e)}modifyEnd(e){return new ei({...this.#r,queryNode:Q.QueryNode.cloneWithEndModifier(this.#r.queryNode,e.toOperationNode())})}top(e,r){return new ei({...this.#r,queryNode:Q.QueryNode.cloneWithTop(this.#r.queryNode,(0,D.parseTop)(e,r))})}whenMatched(){return this.#O([])}whenMatchedAnd(...e){return this.#O(e)}whenMatchedAndRef(e,r,t){return this.#O([e,r,t],!0)}#O(e,r){return new en({...this.#r,queryNode:B.MergeQueryNode.cloneWithWhen(this.#r.queryNode,V({isMatched:!0},e,r))})}whenNotMatched(){return this.#x([])}whenNotMatchedAnd(...e){return this.#x(e)}whenNotMatchedAndRef(e,r,t){return this.#x([e,r,t],!0)}whenNotMatchedBySource(){return this.#x([],!1,!0)}whenNotMatchedBySourceAnd(...e){return this.#x(e,!1,!0)}whenNotMatchedBySourceAndRef(e,r,t){return this.#x([e,r,t],!0,!0)}returning(e){return new ei({...this.#r,queryNode:Q.QueryNode.cloneWithReturning(this.#r.queryNode,(0,C.parseSelectArg)(e))})}returningAll(e){return new ei({...this.#r,queryNode:Q.QueryNode.cloneWithReturning(this.#r.queryNode,(0,C.parseSelectAll)(e))})}output(e){return new ei({...this.#r,queryNode:Q.QueryNode.cloneWithOutput(this.#r.queryNode,(0,C.parseSelectArg)(e))})}outputAll(e){return new ei({...this.#r,queryNode:Q.QueryNode.cloneWithOutput(this.#r.queryNode,(0,C.parseSelectAll)(e))})}#x(e,r=!1,t=!1){let o={...this.#r,queryNode:B.MergeQueryNode.cloneWithWhen(this.#r.queryNode,V({isMatched:!1,bySource:t},e,r))};return new(t?en:es)(o)}$call(e){return e(this)}$if(e,r){return e?r(this):new ei({...this.#r})}toOperationNode(){return this.#r.executor.transformQuery(this.#r.queryNode,this.#r.queryId)}compile(){return this.#r.executor.compileQuery(this.toOperationNode(),this.#r.queryId)}async execute(e){let r=this.compile(),t=await this.#r.executor.executeQuery(r,e),{adapter:o}=this.#r.executor,i=r.query;return i.returning&&o.supportsReturning||i.output&&o.supportsOutput?t.rows:[new er(t.numAffectedRows)]}async executeTakeFirst(e){let[r]=await this.execute(e);return r}async executeTakeFirstOrThrow(e){"function"==typeof e&&(e={errorConstructor:e});let r=await this.executeTakeFirst(e);if(void 0===r){let r=e?.errorConstructor??et.NoResultError;throw(0,et.isNoResultErrorConstructor)(r)?new r(this.toOperationNode()):r(this.toOperationNode())}return r}}class en{#r;constructor(e){this.#r=(0,W.freeze)(e)}thenDelete(){return new ei({...this.#r,queryNode:B.MergeQueryNode.cloneWithThen(this.#r.queryNode,M("delete"))})}thenDoNothing(){return new ei({...this.#r,queryNode:B.MergeQueryNode.cloneWithThen(this.#r.queryNode,M("do nothing"))})}thenUpdate(e){return new ei({...this.#r,queryNode:B.MergeQueryNode.cloneWithThen(this.#r.queryNode,M(e(new l.UpdateQueryBuilder({queryId:this.#r.queryId,executor:ee,queryNode:N.UpdateQueryNode.createWithoutTable()}))))})}thenUpdateSet(...e){return this.thenUpdate(r=>r.set(...e))}}class es{#r;constructor(e){this.#r=(0,W.freeze)(e)}thenDoNothing(){return new ei({...this.#r,queryNode:B.MergeQueryNode.cloneWithThen(this.#r.queryNode,M("do nothing"))})}thenInsertValues(e){let[r,t]=(0,T.parseInsertExpression)(e);return new ei({...this.#r,queryNode:B.MergeQueryNode.cloneWithThen(this.#r.queryNode,M(c.InsertQueryNode.cloneWith(c.InsertQueryNode.createWithoutInto(),{columns:r,values:t})))})}}class ea{#r;constructor(e){this.#r=(0,W.freeze)(e)}selectFrom(e){return eB({queryId:(0,g.createQueryId)(),executor:this.#r.executor,queryNode:f.SelectQueryNode.createFrom((0,m.parseTableExpressionOrList)(e),this.#r.withNode)})}selectNoFrom(e){return eB({queryId:(0,g.createQueryId)(),executor:this.#r.executor,queryNode:f.SelectQueryNode.cloneWithSelections(f.SelectQueryNode.create(this.#r.withNode),(0,C.parseSelectArg)(e))})}insertInto(e){return new u.InsertQueryBuilder({queryId:(0,g.createQueryId)(),executor:this.#r.executor,queryNode:c.InsertQueryNode.create((0,m.parseTable)(e),this.#r.withNode)})}replaceInto(e){return new u.InsertQueryBuilder({queryId:(0,g.createQueryId)(),executor:this.#r.executor,queryNode:c.InsertQueryNode.create((0,m.parseTable)(e),this.#r.withNode,!0)})}deleteFrom(e){return new p.DeleteQueryBuilder({queryId:(0,g.createQueryId)(),executor:this.#r.executor,queryNode:h.DeleteQueryNode.create((0,m.parseTableExpressionOrList)(e),this.#r.withNode)})}updateTable(e){return new l.UpdateQueryBuilder({queryId:(0,g.createQueryId)(),executor:this.#r.executor,queryNode:N.UpdateQueryNode.create((0,m.parseTableExpressionOrList)(e),this.#r.withNode)})}mergeInto(e){return new eo({queryId:(0,g.createQueryId)(),executor:this.#r.executor,queryNode:B.MergeQueryNode.create((0,m.parseAliasedTable)(e),this.#r.withNode)})}with(e,r){let t=(0,y.parseCommonTableExpression)(e,r);return new ea({...this.#r,withNode:this.#r.withNode?w.WithNode.cloneWithExpression(this.#r.withNode,t):w.WithNode.create(t)})}withRecursive(e,r){let t=(0,y.parseCommonTableExpression)(e,r);return new ea({...this.#r,withNode:this.#r.withNode?w.WithNode.cloneWithExpression(this.#r.withNode,t):w.WithNode.create(t,{recursive:!0})})}withPlugin(e){return new ea({...this.#r,executor:this.#r.executor.withPlugin(e)})}withoutPlugins(){return new ea({...this.#r,executor:this.#r.executor.withoutPlugins()})}withSchema(e){return new ea({...this.#r,executor:this.#r.executor.withPluginAtFront(new v(e))})}}function ed(){return new ea({executor:ee})}function eu(e,r){return new a.JoinBuilder({joinNode:i.JoinNode.create(e,(0,m.parseTableExpression)(r))})}function ep(){return new d.OverBuilder({overNode:s.OverNode.create()})}function el(e,r){var t,o,s,a,d,u,p,l;if(3===r.length){return t=e,o=r[0],s=r[1],a=r[2],i.JoinNode.createWithOn(t,(0,m.parseTableExpression)(o),(0,n.parseReferentialBinaryOperation)(s,"=",a))}if(2===r.length){return d=e,u=r[0],(0,r[1])(eu(d,u)).toOperationNode()}if(1===r.length){return p=e,l=r[0],i.JoinNode.create(p,(0,m.parseTableExpression)(l))}throw Error("not implemented")}var eh=e.i(19834),ec=e.i(66511),ef=e.i(992);let eN=(0,W.freeze)({is:e=>"OffsetNode"===e.kind,create:e=>(0,W.freeze)({kind:"OffsetNode",offset:e})}),em=(0,W.freeze)({is:e=>"GroupByItemNode"===e.kind,create:e=>(0,W.freeze)({kind:"GroupByItemNode",groupBy:e})});var ey=e.i(71731),ew=e.i(87981),eg=e.i(85381);function eO(e,r,t){return(0,W.isFunction)(r)&&(r=r((0,ey.createExpressionBuilder)())),(0,W.isReadonlyArray)(r)||(r=[r]),r.map(r=>ew.SetOperationNode.create(e,(0,eg.parseExpression)(r),t))}e.s(["ExpressionWrapper",()=>eq],85569);var ex=e.i(39001),eW=e.i(3392),eb=e.i(56802);class eq{#W;constructor(e){this.#W=e}get expressionType(){}as(e){return new ez(this,e)}or(...e){return new eS(eW.OrNode.create(this.#W,(0,n.parseValueBinaryOperationOrExpression)(e)))}and(...e){return new ek(ex.AndNode.create(this.#W,(0,n.parseValueBinaryOperationOrExpression)(e)))}$castTo(){return new eq(this.#W)}$notNull(){return new eq(this.#W)}toOperationNode(){return this.#W}}class ez{#b;#q;constructor(e,r){this.#b=e,this.#q=r}get expression(){return this.#b}get alias(){return this.#q}toOperationNode(){return t.AliasNode.create(this.#b.toOperationNode(),(0,A.isOperationNodeSource)(this.#q)?this.#q.toOperationNode():O.IdentifierNode.create(this.#q))}}class eS{#W;constructor(e){this.#W=e}get expressionType(){}as(e){return new ez(this,e)}or(...e){return new eS(eW.OrNode.create(this.#W,(0,n.parseValueBinaryOperationOrExpression)(e)))}$castTo(){return new eS(this.#W)}toOperationNode(){return eb.ParensNode.create(this.#W)}}class ek{#W;constructor(e){this.#W=e}get expressionType(){}as(e){return new ez(this,e)}and(...e){return new ek(ex.AndNode.create(this.#W,(0,n.parseValueBinaryOperationOrExpression)(e)))}$castTo(){return new ek(this.#W)}toOperationNode(){return eb.ParensNode.create(this.#W)}}var eE=e.i(43097),eI=e.i(84480);let ev=(0,W.freeze)({is:e=>"FetchNode"===e.kind,create:(e,r)=>({kind:"FetchNode",rowCount:eI.ValueNode.create(e),modifier:r})});class eC{#r;constructor(e){this.#r=(0,W.freeze)(e)}get expressionType(){}get isSelectQueryBuilder(){return!0}where(...e){return new r({...this.#r,queryNode:Q.QueryNode.cloneWithWhere(this.#r.queryNode,(0,n.parseValueBinaryOperationOrExpression)(e))})}whereRef(e,t,o){return new r({...this.#r,queryNode:Q.QueryNode.cloneWithWhere(this.#r.queryNode,(0,n.parseReferentialBinaryOperation)(e,t,o))})}having(...e){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithHaving(this.#r.queryNode,(0,n.parseValueBinaryOperationOrExpression)(e))})}havingRef(e,t,o){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithHaving(this.#r.queryNode,(0,n.parseReferentialBinaryOperation)(e,t,o))})}select(e){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithSelections(this.#r.queryNode,(0,C.parseSelectArg)(e))})}distinctOn(e){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithDistinctOn(this.#r.queryNode,(0,eh.parseReferenceExpressionOrList)(e))})}modifyFront(e){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithFrontModifier(this.#r.queryNode,o.SelectModifierNode.createWithExpression(e.toOperationNode()))})}modifyEnd(e){return new r({...this.#r,queryNode:Q.QueryNode.cloneWithEndModifier(this.#r.queryNode,o.SelectModifierNode.createWithExpression(e.toOperationNode()))})}distinct(){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithFrontModifier(this.#r.queryNode,o.SelectModifierNode.create("Distinct"))})}forUpdate(e){return new r({...this.#r,queryNode:Q.QueryNode.cloneWithEndModifier(this.#r.queryNode,o.SelectModifierNode.create("ForUpdate",e?(0,W.asArray)(e).map(m.parseTable):void 0))})}forShare(e){return new r({...this.#r,queryNode:Q.QueryNode.cloneWithEndModifier(this.#r.queryNode,o.SelectModifierNode.create("ForShare",e?(0,W.asArray)(e).map(m.parseTable):void 0))})}forKeyShare(e){return new r({...this.#r,queryNode:Q.QueryNode.cloneWithEndModifier(this.#r.queryNode,o.SelectModifierNode.create("ForKeyShare",e?(0,W.asArray)(e).map(m.parseTable):void 0))})}forNoKeyUpdate(e){return new r({...this.#r,queryNode:Q.QueryNode.cloneWithEndModifier(this.#r.queryNode,o.SelectModifierNode.create("ForNoKeyUpdate",e?(0,W.asArray)(e).map(m.parseTable):void 0))})}skipLocked(){return new r({...this.#r,queryNode:Q.QueryNode.cloneWithEndModifier(this.#r.queryNode,o.SelectModifierNode.create("SkipLocked"))})}noWait(){return new r({...this.#r,queryNode:Q.QueryNode.cloneWithEndModifier(this.#r.queryNode,o.SelectModifierNode.create("NoWait"))})}selectAll(e){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithSelections(this.#r.queryNode,(0,C.parseSelectAll)(e))})}innerJoin(...e){return this.#t("InnerJoin",e)}leftJoin(...e){return this.#t("LeftJoin",e)}rightJoin(...e){return this.#t("RightJoin",e)}fullJoin(...e){return this.#t("FullJoin",e)}crossJoin(...e){return this.#t("CrossJoin",e)}innerJoinLateral(...e){return this.#t("LateralInnerJoin",e)}leftJoinLateral(...e){return this.#t("LateralLeftJoin",e)}crossJoinLateral(...e){return this.#t("LateralCrossJoin",e)}crossApply(...e){return this.#t("CrossApply",e)}outerApply(...e){return this.#t("OuterApply",e)}#t(e,t){return new r({...this.#r,queryNode:Q.QueryNode.cloneWithJoin(this.#r.queryNode,el(e,t))})}orderBy(...e){return new r({...this.#r,queryNode:Q.QueryNode.cloneWithOrderByItems(this.#r.queryNode,(0,ec.parseOrderBy)(e))})}groupBy(e){var t;return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithGroupByItems(this.#r.queryNode,(t=e,t=(0,W.isFunction)(t)?t((0,ey.expressionBuilder)()):t,(0,eh.parseReferenceExpressionOrList)(t).map(em.create)))})}limit(e){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithLimit(this.#r.queryNode,ef.LimitNode.create((0,eE.parseValueExpression)(e)))})}offset(e){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithOffset(this.#r.queryNode,eN.create((0,eE.parseValueExpression)(e)))})}fetch(e,t="only"){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithFetch(this.#r.queryNode,function(e,r){var t;if(!(0,W.isNumber)(e)&&!(0,W.isBigInt)(e))throw Error(`Invalid fetch row count: ${e}`);if("only"!==(t=r)&&"with ties"!==t)throw Error(`Invalid fetch modifier: ${r}`);return ev.create(e,r)}(e,t))})}top(e,t){return new r({...this.#r,queryNode:Q.QueryNode.cloneWithTop(this.#r.queryNode,(0,D.parseTop)(e,t))})}union(e){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithSetOperations(this.#r.queryNode,eO("union",e,!1))})}unionAll(e){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithSetOperations(this.#r.queryNode,eO("union",e,!0))})}intersect(e){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithSetOperations(this.#r.queryNode,eO("intersect",e,!1))})}intersectAll(e){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithSetOperations(this.#r.queryNode,eO("intersect",e,!0))})}except(e){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithSetOperations(this.#r.queryNode,eO("except",e,!1))})}exceptAll(e){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithSetOperations(this.#r.queryNode,eO("except",e,!0))})}as(e){return new eQ(this,e)}clearSelect(){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithoutSelections(this.#r.queryNode)})}clearWhere(){return new r({...this.#r,queryNode:Q.QueryNode.cloneWithoutWhere(this.#r.queryNode)})}clearLimit(){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithoutLimit(this.#r.queryNode)})}clearOffset(){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithoutOffset(this.#r.queryNode)})}clearOrderBy(){return new r({...this.#r,queryNode:Q.QueryNode.cloneWithoutOrderBy(this.#r.queryNode)})}clearGroupBy(){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithoutGroupBy(this.#r.queryNode)})}$call(e){return e(this)}$if(e,t){return e?t(this):new r({...this.#r})}$castTo(){return new r(this.#r)}$narrowType(){return new r(this.#r)}$assertType(){return new r(this.#r)}$asTuple(){return new eq(this.toOperationNode())}$asScalar(){return new eq(this.toOperationNode())}withPlugin(e){return new r({...this.#r,executor:this.#r.executor.withPlugin(e)})}toOperationNode(){return this.#r.executor.transformQuery(this.#r.queryNode,this.#r.queryId)}compile(){return this.#r.executor.compileQuery(this.toOperationNode(),this.#r.queryId)}async execute(e){let r=this.compile();return(await this.#r.executor.executeQuery(r,e)).rows}async executeTakeFirst(e){let[r]=await this.execute(e);return r}async executeTakeFirstOrThrow(e){"function"==typeof e&&(e={errorConstructor:e});let r=await this.executeTakeFirst(e);if(void 0===r){let r=e?.errorConstructor??et.NoResultError;throw(0,et.isNoResultErrorConstructor)(r)?new r(this.toOperationNode()):r(this.toOperationNode())}return r}async *stream(e){"object"!=typeof e&&(e={chunkSize:e});let r=this.compile();for await(let t of this.#r.executor.stream(r,e.chunkSize??100,e))yield*t.rows}async explain(e,t){let o=new r({...this.#r,queryNode:Q.QueryNode.cloneWithExplain(this.#r.queryNode,e,t)});return await o.execute()}}function eB(e){return new eC(e)}r=eC;class eQ{#z;#q;constructor(e,r){this.#z=e,this.#q=r}get expression(){return this.#z}get alias(){return this.#q}get isAliasedSelectQueryBuilder(){return!0}toOperationNode(){return t.AliasNode.create(this.#z.toOperationNode(),O.IdentifierNode.create(this.#q))}}e.s(["createFunctionModule",()=>eM],72127);var eT=e.i(79685),eR=e.i(3329);let eA=(0,W.freeze)({is:e=>"AggregateFunctionNode"===e.kind,create:(e,r=[])=>(0,W.freeze)({kind:"AggregateFunctionNode",func:e,aggregated:r}),cloneWithDistinct:e=>(0,W.freeze)({...e,distinct:!0}),cloneWithOrderBy(e,r,t=!1){let o=t?"withinGroup":"orderBy";return(0,W.freeze)({...e,[o]:e[o]?eR.OrderByNode.cloneWithItems(e[o],r):eR.OrderByNode.create(r)})},cloneWithFilter:(e,r)=>(0,W.freeze)({...e,filter:e.filter?eT.WhereNode.cloneWithOperation(e.filter,"And",r):eT.WhereNode.create(r)}),cloneWithOrFilter:(e,r)=>(0,W.freeze)({...e,filter:e.filter?eT.WhereNode.cloneWithOperation(e.filter,"Or",r):eT.WhereNode.create(r)}),cloneWithOver:(e,r)=>(0,W.freeze)({...e,over:r})}),eL=(0,W.freeze)({is:e=>"FunctionNode"===e.kind,create:(e,r)=>(0,W.freeze)({kind:"FunctionNode",func:e,arguments:r})});class eF{#r;constructor(e){this.#r=(0,W.freeze)(e)}get expressionType(){}as(e){return new eV(this,e)}distinct(){return new eF({...this.#r,aggregateFunctionNode:eA.cloneWithDistinct(this.#r.aggregateFunctionNode)})}orderBy(...e){return new eF({...this.#r,aggregateFunctionNode:Q.QueryNode.cloneWithOrderByItems(this.#r.aggregateFunctionNode,(0,ec.parseOrderBy)(e))})}clearOrderBy(){return new eF({...this.#r,aggregateFunctionNode:Q.QueryNode.cloneWithoutOrderBy(this.#r.aggregateFunctionNode)})}withinGroupOrderBy(...e){return new eF({...this.#r,aggregateFunctionNode:eA.cloneWithOrderBy(this.#r.aggregateFunctionNode,(0,ec.parseOrderBy)(e),!0)})}filterWhere(...e){return new eF({...this.#r,aggregateFunctionNode:eA.cloneWithFilter(this.#r.aggregateFunctionNode,(0,n.parseValueBinaryOperationOrExpression)(e))})}filterWhereRef(e,r,t){return new eF({...this.#r,aggregateFunctionNode:eA.cloneWithFilter(this.#r.aggregateFunctionNode,(0,n.parseReferentialBinaryOperation)(e,r,t))})}over(e){let r=ep();return new eF({...this.#r,aggregateFunctionNode:eA.cloneWithOver(this.#r.aggregateFunctionNode,(e?e(r):r).toOperationNode())})}$call(e){return e(this)}$castTo(){return new eF(this.#r)}$notNull(){return new eF(this.#r)}toOperationNode(){return this.#r.aggregateFunctionNode}}class eV{#S;#q;constructor(e,r){this.#S=e,this.#q=r}get expression(){return this.#S}get alias(){return this.#q}toOperationNode(){return t.AliasNode.create(this.#S.toOperationNode(),O.IdentifierNode.create(this.#q))}}function eM(){let e=(e,r)=>new eq(eL.create(e,(0,eh.parseReferenceExpressionOrList)(r??[]))),r=(e,r)=>new eF({aggregateFunctionNode:eA.create(e,r?(0,eh.parseReferenceExpressionOrList)(r):void 0)});return Object.assign(e,{agg:r,avg:e=>r("avg",[e]),coalesce:(...r)=>e("coalesce",r),count:e=>r("count",[e]),countAll:e=>new eF({aggregateFunctionNode:eA.create("count",(0,C.parseSelectAll)(e))}),max:e=>r("max",[e]),min:e=>r("min",[e]),sum:e=>r("sum",[e]),any:r=>e("any",[r]),jsonAgg:e=>new eF({aggregateFunctionNode:eA.create("json_agg",[(0,W.isString)(e)?(0,m.parseTable)(e):e.toOperationNode()])}),toJson:e=>new eq(eL.create("to_json",[(0,W.isString)(e)?(0,m.parseTable)(e):e.toOperationNode()]))})}e.s(["parseUnaryOperation",()=>eP],12365);var eD=e.i(36662);let eJ=(0,W.freeze)({is:e=>"UnaryOperationNode"===e.kind,create:(e,r)=>(0,W.freeze)({kind:"UnaryOperationNode",operator:e,operand:r})});function eP(e,r){if((0,eD.isUnaryOperator)(e))return eJ.create(eD.OperatorNode.create(e),(0,eh.parseReferenceExpression)(r));throw Error(`invalid unary operator ${JSON.stringify(e)}`)}e.s(["CaseBuilder",()=>ej],70420);let eU=(0,W.freeze)({is:e=>"CaseNode"===e.kind,create:e=>(0,W.freeze)({kind:"CaseNode",value:e}),cloneWithWhen:(e,r)=>(0,W.freeze)({...e,when:(0,W.freeze)(e.when?[...e.when,r]:[r])}),cloneWithThen:(e,r)=>(0,W.freeze)({...e,when:e.when?(0,W.freeze)([...e.when.slice(0,-1),F.WhenNode.cloneWithResult(e.when[e.when.length-1],r)]):void 0}),cloneWith:(e,r)=>(0,W.freeze)({...e,...r})});e.s(["CaseNode",0,eU],81442);class ej{#r;constructor(e){this.#r=(0,W.freeze)(e)}when(...e){return new e$({...this.#r,node:eU.cloneWithWhen(this.#r.node,F.WhenNode.create((0,n.parseValueBinaryOperationOrExpression)(e)))})}whenRef(e,r,t){return new e$({...this.#r,node:eU.cloneWithWhen(this.#r.node,F.WhenNode.create((0,n.parseReferentialBinaryOperation)(e,r,t)))})}}class e${#r;constructor(e){this.#r=(0,W.freeze)(e)}then(e){return new eG({...this.#r,node:eU.cloneWithThen(this.#r.node,(0,eE.isSafeImmediateValue)(e)?(0,eE.parseSafeImmediateValue)(e):(0,eE.parseValueExpression)(e))})}thenRef(e){return new eG({...this.#r,node:eU.cloneWithThen(this.#r.node,(0,eh.parseReferenceExpression)(e))})}}class eG{#r;constructor(e){this.#r=(0,W.freeze)(e)}when(...e){return new e$({...this.#r,node:eU.cloneWithWhen(this.#r.node,F.WhenNode.create((0,n.parseValueBinaryOperationOrExpression)(e)))})}whenRef(e,r,t){return new e$({...this.#r,node:eU.cloneWithWhen(this.#r.node,F.WhenNode.create((0,n.parseReferentialBinaryOperation)(e,r,t)))})}else(e){return new eK({...this.#r,node:eU.cloneWith(this.#r.node,{else:(0,eE.isSafeImmediateValue)(e)?(0,eE.parseSafeImmediateValue)(e):(0,eE.parseValueExpression)(e)})})}elseRef(e){return new eK({...this.#r,node:eU.cloneWith(this.#r.node,{else:(0,eh.parseReferenceExpression)(e)})})}end(){return new eq(eU.cloneWith(this.#r.node,{isStatement:!1}))}endCase(){return new eq(eU.cloneWith(this.#r.node,{isStatement:!0}))}}class eK{#r;constructor(e){this.#r=(0,W.freeze)(e)}end(){return new eq(eU.cloneWith(this.#r.node,{isStatement:!1}))}endCase(){return new eq(eU.cloneWith(this.#r.node,{isStatement:!0}))}}},83835,e=>{"use strict";var r=e.i(5292);let t=(0,r.freeze)({is:e=>"JSONPathLegNode"===e.kind,create:(e,t)=>(0,r.freeze)({kind:"JSONPathLegNode",type:e,value:t})});e.s(["JSONPathLegNode",0,t])},85381,16745,71731,e=>{"use strict";e.s(["isExpressionOrFactory",()=>J,"parseAliasedExpression",()=>D,"parseExpression",()=>M],85381);var r=e.i(69372),t=e.i(52369);e.s(["createExpressionBuilder",()=>F,"expressionBuilder",()=>V],71731);var o=e.i(22284),i=e.i(34067),n=e.i(27952),s=e.i(15249),a=e.i(72127),d=e.i(19834),u=e.i(23669),p=e.i(56802),l=e.i(85569),h=e.i(36662),c=e.i(12365),f=e.i(43097),N=e.i(97078),m=e.i(70420),y=e.i(81442),w=e.i(5292),g=e.i(77373),O=e.i(55514),x=e.i(55e3),W=e.i(83835),b=e.i(5114),q=e.i(17708),z=e.i(84480);let S=/^#-\d+$/;class k{#W;constructor(e){this.#W=e}at(e){if("number"!=typeof e&&"string"!=typeof e||"number"==typeof e&&!Number.isInteger(e)||"string"==typeof e&&"last"!==e&&!S.test(e))throw Error(`Unexpected index value in .at(...): ${e}`);return this.#k("ArrayLocation",e)}key(e){return this.#k("Member",e)}#k(e,r){return new E(q.JSONReferenceNode.is(this.#W)?q.JSONReferenceNode.cloneWithTraversal(this.#W,b.JSONPathNode.is(this.#W.traversal)?b.JSONPathNode.cloneWithLeg(this.#W.traversal,W.JSONPathLegNode.create(e,r)):x.JSONOperatorChainNode.cloneWithValue(this.#W.traversal,z.ValueNode.createImmediate(r))):b.JSONPathNode.cloneWithLeg(this.#W,W.JSONPathLegNode.create(e,r)))}}class E extends k{#W;constructor(e){super(e),this.#W=e}get expressionType(){}as(e){return new I(this,e)}$castTo(){return new E(this.#W)}$notNull(){return new E(this.#W)}toOperationNode(){return this.#W}}class I{#E;#q;constructor(e,r){this.#E=e,this.#q=r}get expression(){return this.#E}get alias(){return this.#q}toOperationNode(){return g.AliasNode.create(this.#E.toOperationNode(),(0,t.isOperationNodeSource)(this.#q)?this.#q.toOperationNode():O.IdentifierNode.create(this.#q))}}var v=e.i(87974),C=e.i(39001);let B=(0,w.freeze)({is:e=>"TupleNode"===e.kind,create:e=>(0,w.freeze)({kind:"TupleNode",values:(0,w.freeze)(e)})}),Q=(0,w.freeze)({bigint:!0,bigserial:!0,binary:!0,blob:!0,boolean:!0,bytea:!0,char:!0,date:!0,datemultirange:!0,daterange:!0,datetime:!0,datetime2:!0,decimal:!0,"double precision":!0,float4:!0,float8:!0,int2:!0,int4:!0,int4multirange:!0,int4range:!0,int8:!0,int8multirange:!0,int8range:!0,integer:!0,json:!0,jsonb:!0,numeric:!0,nummultirange:!0,numrange:!0,real:!0,serial:!0,smallint:!0,text:!0,time:!0,timestamp:!0,timestamptz:!0,timetz:!0,tsmultirange:!0,tsrange:!0,tstzmultirange:!0,tstzrange:!0,uuid:!0,varbinary:!0,varchar:!0}),T=(0,w.freeze)([/^varchar\(\d+\)$/,/^char\(\d+\)$/,/^decimal\(\d+, \d+\)$/,/^numeric\(\d+, \d+\)$/,/^binary\(\d+\)$/,/^datetime\(\d+\)$/,/^time\(\d+\)$/,/^timetz\(\d+\)$/,/^timestamp\(\d+\)$/,/^timestamptz\(\d+\)$/,/^datetime2\(\d+\)$/,/^varbinary\(\d+\)$/]),R=(0,w.freeze)({is:e=>"DataTypeNode"===e.kind,create:e=>(0,w.freeze)({kind:"DataTypeNode",dataType:e})});function A(e){if((0,t.isOperationNodeSource)(e))return e.toOperationNode();if(Q[e]||T.some(r=>r.test(e)))return R.create(e);throw Error(`invalid column data type ${JSON.stringify(e)}`)}e.s(["parseDataTypeExpression",0,A],16745);let L=(0,w.freeze)({is:e=>"CastNode"===e.kind,create:(e,r)=>(0,w.freeze)({kind:"CastNode",expression:e,dataType:r})});function F(e=N.NOOP_QUERY_EXECUTOR){function r(e,r){return new l.ExpressionWrapper((0,c.parseUnaryOperation)(e,r))}let t=Object.assign(function(e,r,t){return new l.ExpressionWrapper((0,u.parseValueBinaryOperation)(e,r,t))},{fn:void 0,eb:void 0,selectFrom:r=>(0,o.createSelectQueryBuilder)({queryId:(0,s.createQueryId)(),executor:e,queryNode:i.SelectQueryNode.createFrom((0,n.parseTableExpressionOrList)(r))}),case:e=>new m.CaseBuilder({node:y.CaseNode.create((0,w.isUndefined)(e)?void 0:(0,d.parseReferenceExpression)(e))}),ref:(e,r)=>(0,w.isUndefined)(r)?new l.ExpressionWrapper((0,d.parseStringReference)(e)):new k((0,d.parseJSONReference)(e,r)),jsonPath:()=>new k(b.JSONPathNode.create()),table:e=>new l.ExpressionWrapper((0,n.parseTable)(e)),val:e=>new l.ExpressionWrapper((0,f.parseValueExpression)(e)),refTuple:(...e)=>new l.ExpressionWrapper(B.create(e.map(d.parseReferenceExpression))),tuple:(...e)=>new l.ExpressionWrapper(B.create(e.map(f.parseValueExpression))),lit:e=>new l.ExpressionWrapper((0,f.parseSafeImmediateValue)(e)),unary:r,not:e=>r("not",e),exists:e=>r("exists",e),neg:e=>r("-",e),between:(e,r,t)=>new l.ExpressionWrapper(v.BinaryOperationNode.create((0,d.parseReferenceExpression)(e),h.OperatorNode.create("between"),C.AndNode.create((0,f.parseValueExpression)(r),(0,f.parseValueExpression)(t)))),betweenSymmetric:(e,r,t)=>new l.ExpressionWrapper(v.BinaryOperationNode.create((0,d.parseReferenceExpression)(e),h.OperatorNode.create("between symmetric"),C.AndNode.create((0,f.parseValueExpression)(r),(0,f.parseValueExpression)(t)))),and:e=>new l.ExpressionWrapper((0,w.isReadonlyArray)(e)?(0,u.parseFilterList)(e,"and"):(0,u.parseFilterObject)(e,"and")),or:e=>new l.ExpressionWrapper((0,w.isReadonlyArray)(e)?(0,u.parseFilterList)(e,"or"):(0,u.parseFilterObject)(e,"or")),parens(...e){let r=(0,u.parseValueBinaryOperationOrExpression)(e);return new l.ExpressionWrapper(p.ParensNode.is(r)?r:p.ParensNode.create(r))},cast:(e,r)=>new l.ExpressionWrapper(L.create((0,d.parseReferenceExpression)(e),A(r)))});return t.fn=(0,a.createFunctionModule)(),t.eb=t,t}function V(e){return F()}function M(e){if((0,t.isOperationNodeSource)(e))return e.toOperationNode();if((0,w.isFunction)(e))return e(F()).toOperationNode();throw Error(`invalid expression: ${JSON.stringify(e)}`)}function D(e){if((0,t.isOperationNodeSource)(e))return e.toOperationNode();if((0,w.isFunction)(e))return e(F()).toOperationNode();throw Error(`invalid aliased expression: ${JSON.stringify(e)}`)}function J(e){return(0,r.isExpression)(e)||(0,r.isAliasedExpression)(e)||(0,w.isFunction)(e)}},27952,821,e=>{"use strict";e.s(["parseAliasedTable",()=>h,"parseTable",()=>c,"parseTableExpression",()=>l,"parseTableExpressionOrList",()=>p],27952);var r=e.i(5292),t=e.i(77373),o=e.i(39328),i=e.i(85381),n=e.i(55514);e.s(["DynamicTableBuilder",()=>a,"isAliasedDynamicTableBuilder",()=>u],821);var s=e.i(52369);class a{#I;get table(){return this.#I}constructor(e){this.#I=e}as(e){return new d(this.#I,e)}}class d{#I;#q;get table(){return this.#I}get alias(){return this.#q}constructor(e,r){this.#I=e,this.#q=r}toOperationNode(){return t.AliasNode.create(c(this.#I),n.IdentifierNode.create(this.#q))}}function u(e){return(0,r.isObject)(e)&&(0,s.isOperationNodeSource)(e)&&(0,r.isString)(e.table)&&(0,r.isString)(e.alias)}function p(e){return(0,r.isReadonlyArray)(e)?e.map(e=>l(e)):[l(e)]}function l(e){return(0,r.isString)(e)?h(e):u(e)?e.toOperationNode():(0,i.parseAliasedExpression)(e)}function h(e){let r=" as ";if(!e.includes(r))return c(e);{let[o,i]=e.split(r).map(f);return t.AliasNode.create(c(o),n.IdentifierNode.create(i))}}function c(e){if(!e.includes("."))return o.TableNode.create(e);{let[r,t]=e.split(".").map(f);return o.TableNode.createWithSchema(r,t)}}function f(e){return e.trim()}},29401,e=>{"use strict";var r=e.i(55514),t=e.i(52369),o=e.i(3731),i=e.i(84480),n=e.i(19834),s=e.i(27952),a=e.i(43097),d=e.i(15249),u=e.i(77373),p=e.i(5292),l=e.i(97078);class h{#r;constructor(e){this.#r=(0,p.freeze)(e)}get expressionType(){}get isRawBuilder(){return!0}as(e){return new f(this,e)}$castTo(){return new h({...this.#r})}$notNull(){return new h(this.#r)}withPlugin(e){return new h({...this.#r,plugins:void 0!==this.#r.plugins?(0,p.freeze)([...this.#r.plugins,e]):(0,p.freeze)([e])})}toOperationNode(){return this.#v(this.#C())}compile(e){return this.#B(this.#C(e))}async execute(e,r){let t=this.#C(e);return t.executeQuery(this.#B(t),r)}#C(e){let r=void 0!==e?e.getExecutor():l.NOOP_QUERY_EXECUTOR;return void 0!==this.#r.plugins?r.withPlugins(this.#r.plugins):r}#v(e){return e.transformQuery(this.#r.rawNode,this.#r.queryId)}#B(e){return e.compileQuery(this.#v(e),this.#r.queryId)}}function c(e){return new h(e)}class f{#Q;#q;constructor(e,r){this.#Q=e,this.#q=r}get expression(){return this.#Q}get alias(){return this.#q}get rawBuilder(){return this.#Q}toOperationNode(){return u.AliasNode.create(this.#Q.toOperationNode(),(0,t.isOperationNodeSource)(this.#q)?this.#q.toOperationNode():r.IdentifierNode.create(this.#q))}}let N=Object.assign((e,...r)=>c({queryId:(0,d.createQueryId)(),rawNode:o.RawNode.create(e,r?.map(m)??[])}),{ref:e=>c({queryId:(0,d.createQueryId)(),rawNode:o.RawNode.createWithChild((0,n.parseStringReference)(e))}),val:e=>c({queryId:(0,d.createQueryId)(),rawNode:o.RawNode.createWithChild((0,a.parseValueExpression)(e))}),table:e=>c({queryId:(0,d.createQueryId)(),rawNode:o.RawNode.createWithChild((0,s.parseTable)(e))}),id(...e){let t=Array(e.length+1).fill(".");return t[0]="",t[t.length-1]="",c({queryId:(0,d.createQueryId)(),rawNode:o.RawNode.create(t,e.map(r.IdentifierNode.create))})},lit:e=>c({queryId:(0,d.createQueryId)(),rawNode:o.RawNode.createWithChild(i.ValueNode.createImmediate(e))}),raw:e=>c({queryId:(0,d.createQueryId)(),rawNode:o.RawNode.createWithSql(e)}),join(e,r=N`, `){let t=Array(Math.max(2*e.length-1,0)),i=r.toOperationNode();for(let r=0;r<e.length;++r)t[2*r]=m(e[r]),r!==e.length-1&&(t[2*r+1]=i);return c({queryId:(0,d.createQueryId)(),rawNode:o.RawNode.createWithChildren(t)})}});function m(e){return(0,t.isOperationNodeSource)(e)?e.toOperationNode():(0,a.parseValueExpression)(e)}e.s(["sql",0,N],29401)},50162,e=>{"use strict";var r=e.i(3731),t=e.i(5292),o=e.i(15249);let i=(0,t.freeze)({raw:(e,i=[])=>(0,t.freeze)({sql:e,query:r.RawNode.createWithSql(e),parameters:(0,t.freeze)(i),queryId:(0,o.createQueryId)()})});e.s(["CompiledQuery",0,i])}];
1
+ module.exports=[77373,e=>{"use strict";var r=e.i(5292);let t=(0,r.freeze)({is:e=>"AliasNode"===e.kind,create:(e,t)=>(0,r.freeze)({kind:"AliasNode",node:e,alias:t})});e.s(["AliasNode",0,t])},39328,e=>{"use strict";var r=e.i(5292),t=e.i(15196);let o=(0,r.freeze)({is:e=>"TableNode"===e.kind,create:e=>(0,r.freeze)({kind:"TableNode",table:t.SchemableIdentifierNode.create(e)}),createWithSchema:(e,o)=>(0,r.freeze)({kind:"TableNode",table:t.SchemableIdentifierNode.createWithSchema(e,o)})});e.s(["TableNode",0,o])},52369,e=>{"use strict";var r=e.i(5292);e.s(["isOperationNodeSource",0,function(e){return(0,r.isObject)(e)&&(0,r.isFunction)(e.toOperationNode)}])},69372,80827,39001,3392,79111,87974,e=>{"use strict";var r=e.i(52369),t=e.i(5292);e.s(["isAliasedExpression",0,function(e){return(0,t.isObject)(e)&&"expression"in e&&(0,t.isString)(e.alias)&&(0,r.isOperationNodeSource)(e)},"isExpression",0,function(e){return(0,t.isObject)(e)&&"expressionType"in e&&(0,r.isOperationNodeSource)(e)}],69372);let o=(0,t.freeze)({is:e=>"SelectModifierNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"SelectModifierNode",modifier:e,of:r}),createWithExpression:e=>(0,t.freeze)({kind:"SelectModifierNode",rawModifier:e})});e.s(["SelectModifierNode",0,o],80827);let i=(0,t.freeze)({is:e=>"AndNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"AndNode",left:e,right:r})});e.s(["AndNode",0,i],39001);let n=(0,t.freeze)({is:e=>"OrNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"OrNode",left:e,right:r})});e.s(["OrNode",0,n],3392);let s=(0,t.freeze)({is:e=>"OnNode"===e.kind,create:e=>(0,t.freeze)({kind:"OnNode",on:e}),cloneWithOperation:(e,r,o)=>(0,t.freeze)({...e,on:"And"===r?i.create(e.on,o):n.create(e.on,o)})}),a=(0,t.freeze)({is:e=>"JoinNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"JoinNode",joinType:e,table:r,on:void 0}),createWithOn:(e,r,o)=>(0,t.freeze)({kind:"JoinNode",joinType:e,table:r,on:s.create(o)}),cloneWithOn:(e,r)=>(0,t.freeze)({...e,on:e.on?s.cloneWithOperation(e.on,"And",r):s.create(r)})});e.s(["JoinNode",0,a],79111);let d=(0,t.freeze)({is:e=>"BinaryOperationNode"===e.kind,create:(e,r,o)=>(0,t.freeze)({kind:"BinaryOperationNode",leftOperand:e,operator:r,rightOperand:o})});e.s(["BinaryOperationNode",0,d],87974)},50022,52183,99934,e=>{"use strict";var r=e.i(5292),t=e.i(55514);let o=(0,r.freeze)({is:e=>"ColumnNode"===e.kind,create:e=>(0,r.freeze)({kind:"ColumnNode",column:t.IdentifierNode.create(e)})});e.s(["ColumnNode",0,o],50022);let i=(0,r.freeze)({is:e=>"SelectAllNode"===e.kind,create:()=>(0,r.freeze)({kind:"SelectAllNode"})});e.s(["SelectAllNode",0,i],52183);let n=(0,r.freeze)({is:e=>"ReferenceNode"===e.kind,create:(e,t)=>(0,r.freeze)({kind:"ReferenceNode",table:t,column:e}),createSelectAll:e=>(0,r.freeze)({kind:"ReferenceNode",table:e,column:i.create()})});e.s(["ReferenceNode",0,n],99934)},66511,82180,41731,e=>{"use strict";e.s(["isOrderByDirection",()=>N,"parseOrderBy",()=>m],66511),e.s(["DynamicReferenceBuilder",()=>i,"isDynamicReferenceBuilder",()=>n],82180);var r=e.i(52369),t=e.i(19834),o=e.i(5292);class i{#e;get dynamicReference(){return this.#e}get refType(){}constructor(e){this.#e=e}toOperationNode(){return(0,t.parseSimpleReferenceExpression)(this.#e)}}function n(e){return(0,o.isObject)(e)&&(0,r.isOperationNodeSource)(e)&&(0,o.isString)(e.dynamicReference)}var s=e.i(69372);let a=(0,o.freeze)({is:e=>"OrderByItemNode"===e.kind,create:(e,r)=>(0,o.freeze)({kind:"OrderByItemNode",orderBy:e,direction:r}),cloneWith:(e,r)=>(0,o.freeze)({...e,...r})});var d=e.i(3731),u=e.i(55514);let p=(0,o.freeze)({is:e=>"CollateNode"===e.kind,create:e=>(0,o.freeze)({kind:"CollateNode",collation:u.IdentifierNode.create(e)})});class l{#r;constructor(e){this.#r=(0,o.freeze)(e)}desc(){return new l({node:a.cloneWith(this.#r.node,{direction:d.RawNode.createWithSql("desc")})})}asc(){return new l({node:a.cloneWith(this.#r.node,{direction:d.RawNode.createWithSql("asc")})})}nullsLast(){return new l({node:a.cloneWith(this.#r.node,{nulls:"last"})})}nullsFirst(){return new l({node:a.cloneWith(this.#r.node,{nulls:"first"})})}collate(e){return new l({node:a.cloneWith(this.#r.node,{collation:p.create(e)})})}toOperationNode(){return this.#r.node}}let h=new Set;function c(e){h.has(e)||(h.add(e),console.log(e))}e.s(["logOnce",0,c],41731);var f=e.i(85381);function N(e){return"asc"===e||"desc"===e}function m(e){if(2===e.length)return[y(e[0],e[1])];if(1===e.length){let[r]=e;return Array.isArray(r)?(c("orderBy(array) is deprecated, use multiple orderBy calls instead."),r.map(e=>y(e))):[y(r)]}throw Error(`Invalid number of arguments at order by! expected 1-2, received ${e.length}`)}function y(e,r){let o=function(e){if((0,f.isExpressionOrFactory)(e))return(0,f.parseExpression)(e);if(n(e))return e.toOperationNode();let[r,o]=e.split(" ");return o?(c("`orderBy('column asc')` is deprecated. Use `orderBy('column', 'asc')` instead."),w((0,t.parseStringReference)(r),o)):(0,t.parseStringReference)(e)}(e);if(a.is(o)){if(r)throw Error("Cannot specify direction twice!");return o}return w(o,r)}function w(e,r){if("string"==typeof r){if(!N(r))throw Error(`Invalid order by direction: ${r}`);return a.create(e,d.RawNode.createWithSql(r))}if((0,s.isExpression)(r))return c("`orderBy(..., expr)` is deprecated. Use `orderBy(..., 'asc')` or `orderBy(..., (ob) => ...)` instead."),a.create(e,r.toOperationNode());let t=a.create(e);return r?r(new l({node:t})).toOperationNode():t}},17708,e=>{"use strict";var r=e.i(5292);let t=(0,r.freeze)({is:e=>"JSONReferenceNode"===e.kind,create:(e,t)=>(0,r.freeze)({kind:"JSONReferenceNode",reference:e,traversal:t}),cloneWithTraversal:(e,t)=>(0,r.freeze)({...e,traversal:t})});e.s(["JSONReferenceNode",0,t])},55e3,e=>{"use strict";var r=e.i(5292);let t=(0,r.freeze)({is:e=>"JSONOperatorChainNode"===e.kind,create:e=>(0,r.freeze)({kind:"JSONOperatorChainNode",operator:e,values:(0,r.freeze)([])}),cloneWithValue:(e,t)=>(0,r.freeze)({...e,values:(0,r.freeze)([...e.values,t])})});e.s(["JSONOperatorChainNode",0,t])},5114,e=>{"use strict";var r=e.i(5292);let t=(0,r.freeze)({is:e=>"JSONPathNode"===e.kind,create:e=>(0,r.freeze)({kind:"JSONPathNode",inOperator:e,pathLegs:(0,r.freeze)([])}),cloneWithLeg:(e,t)=>(0,r.freeze)({...e,pathLegs:(0,r.freeze)([...e.pathLegs,t])})});e.s(["JSONPathNode",0,t])},19834,e=>{"use strict";e.s(["parseAliasedStringReference",()=>w,"parseColumnName",()=>g,"parseJSONReference",()=>m,"parseOrderedColumnName",()=>O,"parseReferenceExpression",()=>N,"parseReferenceExpressionOrList",()=>f,"parseSimpleReferenceExpression",()=>c,"parseStringReference",()=>y]);var r=e.i(77373),t=e.i(50022),o=e.i(99934),i=e.i(39328),n=e.i(5292),s=e.i(85381),a=e.i(55514),d=e.i(66511),u=e.i(36662),p=e.i(17708),l=e.i(55e3),h=e.i(5114);function c(e){return(0,n.isString)(e)?y(e):e.toOperationNode()}function f(e){return(0,n.isReadonlyArray)(e)?e.map(e=>N(e)):[N(e)]}function N(e){return(0,s.isExpressionOrFactory)(e)?(0,s.parseExpression)(e):c(e)}function m(e,r){if((0,u.isJSONOperator)(r))return p.JSONReferenceNode.create(y(e),l.JSONOperatorChainNode.create(u.OperatorNode.create(r)));if("->$"===r||"->>$"===r)return p.JSONReferenceNode.create(y(e),h.JSONPathNode.create(u.OperatorNode.create(r.slice(0,-1))));throw Error(`Invalid JSON operator: ${r}`)}function y(e){if(!e.includes("."))return o.ReferenceNode.create(t.ColumnNode.create(e));let r=e.split(".").map(x);if(3===r.length)return function(e){let[r,n,s]=e;return o.ReferenceNode.create(t.ColumnNode.create(s),i.TableNode.createWithSchema(r,n))}(r);if(2===r.length)return function(e){let[r,n]=e;return o.ReferenceNode.create(t.ColumnNode.create(n),i.TableNode.create(r))}(r);throw Error(`invalid column reference ${e}`)}function w(e){let t=" as ";if(!e.includes(t))return y(e);{let[o,i]=e.split(t).map(x);return r.AliasNode.create(y(o),a.IdentifierNode.create(i))}}function g(e){return t.ColumnNode.create(e)}function O(e){if(!e.includes(" "))return g(e);{let[r,t]=e.split(" ").map(x);if(!(0,d.isOrderByDirection)(t))throw Error(`invalid order direction "${t}" next to "${r}"`);return(0,d.parseOrderBy)([r,t])[0]}}function x(e){return e.trim()}},74955,82561,e=>{"use strict";var r=e.i(5292);let t=(0,r.freeze)({is:e=>"PrimitiveValueListNode"===e.kind,create:e=>(0,r.freeze)({kind:"PrimitiveValueListNode",values:(0,r.freeze)([...e])})});e.s(["PrimitiveValueListNode",0,t],74955);let o=(0,r.freeze)({is:e=>"ValueListNode"===e.kind,create:e=>(0,r.freeze)({kind:"ValueListNode",values:(0,r.freeze)(e)})});e.s(["ValueListNode",0,o],82561)},84480,e=>{"use strict";var r=e.i(5292);let t=(0,r.freeze)({is:e=>"ValueNode"===e.kind,create:e=>(0,r.freeze)({kind:"ValueNode",value:e}),createImmediate:e=>(0,r.freeze)({kind:"ValueNode",value:e,immediate:!0})});e.s(["ValueNode",0,t])},23669,43097,3329,20857,4372,34067,32694,40642,76413,83715,79685,19285,22350,e=>{"use strict";e.s(["parseFilterList",()=>x,"parseFilterObject",()=>O,"parseReferentialBinaryOperation",()=>g,"parseValueBinaryOperation",()=>w,"parseValueBinaryOperationOrExpression",()=>y],23669);var r=e.i(87974),t=e.i(5292),o=e.i(52369),i=e.i(36662),n=e.i(19834);e.s(["isSafeImmediateValue",()=>h,"parseSafeImmediateValue",()=>c,"parseValueExpression",()=>l,"parseValueExpressionOrList",()=>p],43097);var s=e.i(74955),a=e.i(82561),d=e.i(84480),u=e.i(85381);function p(e){var r;return(0,t.isReadonlyArray)(e)?(r=e).some(u.isExpressionOrFactory)?a.ValueListNode.create(r.map(e=>l(e))):s.PrimitiveValueListNode.create(r):l(e)}function l(e){return(0,u.isExpressionOrFactory)(e)?(0,u.parseExpression)(e):d.ValueNode.create(e)}function h(e){return(0,t.isNumber)(e)||(0,t.isBoolean)(e)||(0,t.isNull)(e)}function c(e){if(!h(e))throw Error(`unsafe immediate value ${JSON.stringify(e)}`);return d.ValueNode.createImmediate(e)}var f=e.i(39001),N=e.i(56802),m=e.i(3392);function y(e){if(3===e.length)return w(e[0],e[1],e[2]);if(1===e.length)return l(e[0]);throw Error(`invalid arguments: ${JSON.stringify(e)}`)}function w(e,t,o){var i;return("is"===(i=t)||"is not"===i)&&W(o)?r.BinaryOperationNode.create((0,n.parseReferenceExpression)(e),b(t),d.ValueNode.createImmediate(o)):r.BinaryOperationNode.create((0,n.parseReferenceExpression)(e),b(t),p(o))}function g(e,t,o){return r.BinaryOperationNode.create((0,n.parseReferenceExpression)(e),b(t),(0,n.parseReferenceExpression)(o))}function O(e,r){return x(Object.entries(e).filter(([,e])=>!(0,t.isUndefined)(e)).map(([e,r])=>w(e,W(r)?"is":"=",r)),r)}function x(e,t,o=!0){let n="and"===t?f.AndNode.create:m.OrNode.create;if(0===e.length)return r.BinaryOperationNode.create(d.ValueNode.createImmediate(1),i.OperatorNode.create("="),d.ValueNode.createImmediate(+("and"===t)));let s=q(e[0]);for(let r=1;r<e.length;++r)s=n(s,q(e[r]));return e.length>1&&o?N.ParensNode.create(s):s}function W(e){return(0,t.isNull)(e)||(0,t.isBoolean)(e)}function b(e){if((0,i.isBinaryOperator)(e))return i.OperatorNode.create(e);if((0,o.isOperationNodeSource)(e))return e.toOperationNode();throw Error(`invalid operator ${JSON.stringify(e)}`)}function q(e){return(0,o.isOperationNodeSource)(e)?e.toOperationNode():e}let z=(0,t.freeze)({is:e=>"OrderByNode"===e.kind,create:e=>(0,t.freeze)({kind:"OrderByNode",items:(0,t.freeze)([...e])}),cloneWithItems:(e,r)=>(0,t.freeze)({...e,items:(0,t.freeze)([...e.items,...r])})});e.s(["OrderByNode",0,z],3329);let S=(0,t.freeze)({is:e=>"PartitionByNode"===e.kind,create:e=>(0,t.freeze)({kind:"PartitionByNode",items:(0,t.freeze)(e)}),cloneWithItems:(e,r)=>(0,t.freeze)({...e,items:(0,t.freeze)([...e.items,...r])})}),k=(0,t.freeze)({is:e=>"OverNode"===e.kind,create:()=>(0,t.freeze)({kind:"OverNode"}),cloneWithOrderByItems:(e,r)=>(0,t.freeze)({...e,orderBy:e.orderBy?z.cloneWithItems(e.orderBy,r):z.create(r)}),cloneWithPartitionByItems:(e,r)=>(0,t.freeze)({...e,partitionBy:e.partitionBy?S.cloneWithItems(e.partitionBy,r):S.create(r)})});e.s(["OverNode",0,k],20857),e.s(["JoinBuilder",()=>v],4372);var E=e.i(79111),I=e.i(3731);class v{#r;constructor(e){this.#r=(0,t.freeze)(e)}on(...e){return new v({...this.#r,joinNode:E.JoinNode.cloneWithOn(this.#r.joinNode,y(e))})}onRef(e,r,t){return new v({...this.#r,joinNode:E.JoinNode.cloneWithOn(this.#r.joinNode,g(e,r,t))})}onTrue(){return new v({...this.#r,joinNode:E.JoinNode.cloneWithOn(this.#r.joinNode,I.RawNode.createWithSql("true"))})}$call(e){return e(this)}toOperationNode(){return this.#r.joinNode}}e.s(["QueryNode",()=>$],22350);var C=e.i(91114);e.s(["SelectQueryNode",()=>R],34067);let B=(0,t.freeze)({is:e=>"FromNode"===e.kind,create:e=>(0,t.freeze)({kind:"FromNode",froms:(0,t.freeze)(e)}),cloneWithFroms:(e,r)=>(0,t.freeze)({...e,froms:(0,t.freeze)([...e.froms,...r])})}),Q=(0,t.freeze)({is:e=>"GroupByNode"===e.kind,create:e=>(0,t.freeze)({kind:"GroupByNode",items:(0,t.freeze)(e)}),cloneWithItems:(e,r)=>(0,t.freeze)({...e,items:(0,t.freeze)([...e.items,...r])})}),T=(0,t.freeze)({is:e=>"HavingNode"===e.kind,create:e=>(0,t.freeze)({kind:"HavingNode",having:e}),cloneWithOperation:(e,r,o)=>(0,t.freeze)({...e,having:"And"===r?f.AndNode.create(e.having,o):m.OrNode.create(e.having,o)})}),R=(0,t.freeze)({is:e=>"SelectQueryNode"===e.kind,create:e=>(0,t.freeze)({kind:"SelectQueryNode",...e&&{with:e}}),createFrom:(e,r)=>(0,t.freeze)({kind:"SelectQueryNode",from:B.create(e),...r&&{with:r}}),cloneWithSelections:(e,r)=>(0,t.freeze)({...e,selections:e.selections?(0,t.freeze)([...e.selections,...r]):(0,t.freeze)(r)}),cloneWithDistinctOn:(e,r)=>(0,t.freeze)({...e,distinctOn:e.distinctOn?(0,t.freeze)([...e.distinctOn,...r]):(0,t.freeze)(r)}),cloneWithFrontModifier:(e,r)=>(0,t.freeze)({...e,frontModifiers:e.frontModifiers?(0,t.freeze)([...e.frontModifiers,r]):(0,t.freeze)([r])}),cloneWithOrderByItems:(e,r)=>$.cloneWithOrderByItems(e,r),cloneWithGroupByItems:(e,r)=>(0,t.freeze)({...e,groupBy:e.groupBy?Q.cloneWithItems(e.groupBy,r):Q.create(r)}),cloneWithLimit:(e,r)=>(0,t.freeze)({...e,limit:r}),cloneWithOffset:(e,r)=>(0,t.freeze)({...e,offset:r}),cloneWithFetch:(e,r)=>(0,t.freeze)({...e,fetch:r}),cloneWithHaving:(e,r)=>(0,t.freeze)({...e,having:e.having?T.cloneWithOperation(e.having,"And",r):T.create(r)}),cloneWithSetOperations:(e,r)=>(0,t.freeze)({...e,setOperations:e.setOperations?(0,t.freeze)([...e.setOperations,...r]):(0,t.freeze)([...r])}),cloneWithoutSelections:e=>(0,t.freeze)({...e,selections:[]}),cloneWithoutLimit:e=>(0,t.freeze)({...e,limit:void 0}),cloneWithoutOffset:e=>(0,t.freeze)({...e,offset:void 0}),cloneWithoutOrderBy:e=>$.cloneWithoutOrderBy(e),cloneWithoutGroupBy:e=>(0,t.freeze)({...e,groupBy:void 0})}),A=(0,t.freeze)({is:e=>"ListNode"===e.kind,create:e=>(0,t.freeze)({kind:"ListNode",items:(0,t.freeze)(e)})});e.s(["ListNode",0,A],32694);let L=(0,t.freeze)({is:e=>"UpdateQueryNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"UpdateQueryNode",table:1===e.length?e[0]:A.create(e),...r&&{with:r}}),createWithoutTable:()=>(0,t.freeze)({kind:"UpdateQueryNode"}),cloneWithFromItems:(e,r)=>(0,t.freeze)({...e,from:e.from?B.cloneWithFroms(e.from,r):B.create(r)}),cloneWithUpdates:(e,r)=>(0,t.freeze)({...e,updates:e.updates?(0,t.freeze)([...e.updates,...r]):r}),cloneWithLimit:(e,r)=>(0,t.freeze)({...e,limit:r})});e.s(["UpdateQueryNode",0,L],40642),e.s(["DeleteQueryNode",()=>V],83715);let F=(0,t.freeze)({is:e=>"UsingNode"===e.kind,create:e=>(0,t.freeze)({kind:"UsingNode",tables:(0,t.freeze)(e)}),cloneWithTables:(e,r)=>(0,t.freeze)({...e,tables:(0,t.freeze)([...e.tables,...r])})});e.s(["UsingNode",0,F],76413);let V=(0,t.freeze)({is:e=>"DeleteQueryNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"DeleteQueryNode",from:B.create(e),...r&&{with:r}}),cloneWithOrderByItems:(e,r)=>$.cloneWithOrderByItems(e,r),cloneWithoutOrderBy:e=>$.cloneWithoutOrderBy(e),cloneWithLimit:(e,r)=>(0,t.freeze)({...e,limit:r}),cloneWithoutLimit:e=>(0,t.freeze)({...e,limit:void 0}),cloneWithUsing:(e,r)=>(0,t.freeze)({...e,using:void 0!==e.using?F.cloneWithTables(e.using,r):F.create(r)})}),M=(0,t.freeze)({is:e=>"WhereNode"===e.kind,create:e=>(0,t.freeze)({kind:"WhereNode",where:e}),cloneWithOperation:(e,r,o)=>(0,t.freeze)({...e,where:"And"===r?f.AndNode.create(e.where,o):m.OrNode.create(e.where,o)})});e.s(["WhereNode",0,M],79685);let D=(0,t.freeze)({is:e=>"ReturningNode"===e.kind,create:e=>(0,t.freeze)({kind:"ReturningNode",selections:(0,t.freeze)(e)}),cloneWithSelections:(e,r)=>(0,t.freeze)({...e,selections:e.selections?(0,t.freeze)([...e.selections,...r]):(0,t.freeze)(r)})}),J=(0,t.freeze)({is:e=>"ExplainNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"ExplainNode",format:e,options:r})});var P=e.i(54860);let U=(0,t.freeze)({is:e=>"MergeQueryNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"MergeQueryNode",into:e,...r&&{with:r}}),cloneWithUsing:(e,r)=>(0,t.freeze)({...e,using:r}),cloneWithWhen:(e,r)=>(0,t.freeze)({...e,whens:e.whens?(0,t.freeze)([...e.whens,r]):(0,t.freeze)([r])}),cloneWithThen:(e,r)=>(0,t.freeze)({...e,whens:e.whens?(0,t.freeze)([...e.whens.slice(0,-1),P.WhenNode.cloneWithResult(e.whens[e.whens.length-1],r)]):void 0})});e.s(["MergeQueryNode",0,U],19285);let j=(0,t.freeze)({is:e=>"OutputNode"===e.kind,create:e=>(0,t.freeze)({kind:"OutputNode",selections:(0,t.freeze)(e)}),cloneWithSelections:(e,r)=>(0,t.freeze)({...e,selections:e.selections?(0,t.freeze)([...e.selections,...r]):(0,t.freeze)(r)})}),$=(0,t.freeze)({is:e=>R.is(e)||C.InsertQueryNode.is(e)||L.is(e)||V.is(e)||U.is(e),cloneWithEndModifier:(e,r)=>(0,t.freeze)({...e,endModifiers:e.endModifiers?(0,t.freeze)([...e.endModifiers,r]):(0,t.freeze)([r])}),cloneWithWhere:(e,r)=>(0,t.freeze)({...e,where:e.where?M.cloneWithOperation(e.where,"And",r):M.create(r)}),cloneWithJoin:(e,r)=>(0,t.freeze)({...e,joins:e.joins?(0,t.freeze)([...e.joins,r]):(0,t.freeze)([r])}),cloneWithReturning:(e,r)=>(0,t.freeze)({...e,returning:e.returning?D.cloneWithSelections(e.returning,r):D.create(r)}),cloneWithoutReturning:e=>(0,t.freeze)({...e,returning:void 0}),cloneWithoutWhere:e=>(0,t.freeze)({...e,where:void 0}),cloneWithExplain:(e,r,o)=>(0,t.freeze)({...e,explain:J.create(r,o?.toOperationNode())}),cloneWithTop:(e,r)=>(0,t.freeze)({...e,top:r}),cloneWithOutput:(e,r)=>(0,t.freeze)({...e,output:e.output?j.cloneWithSelections(e.output,r):j.create(r)}),cloneWithOrderByItems:(e,r)=>(0,t.freeze)({...e,orderBy:e.orderBy?z.cloneWithItems(e.orderBy,r):z.create(r)}),cloneWithoutOrderBy:e=>(0,t.freeze)({...e,orderBy:void 0})})},69062,26514,e=>{"use strict";e.s(["OverBuilder",()=>a],69062);var r=e.i(20857),t=e.i(22350),o=e.i(66511),i=e.i(5292);let n=(0,i.freeze)({is:e=>"PartitionByItemNode"===e.kind,create:e=>(0,i.freeze)({kind:"PartitionByItemNode",partitionBy:e})});var s=e.i(19834);class a{#r;constructor(e){this.#r=(0,i.freeze)(e)}orderBy(...e){return new a({overNode:r.OverNode.cloneWithOrderByItems(this.#r.overNode,(0,o.parseOrderBy)(e))})}clearOrderBy(){return new a({overNode:t.QueryNode.cloneWithoutOrderBy(this.#r.overNode)})}partitionBy(e){return new a({overNode:r.OverNode.cloneWithPartitionByItems(this.#r.overNode,(0,s.parseReferenceExpressionOrList)(e).map(n.create))})}$call(e){return e(this)}toOperationNode(){return this.#r.overNode}}var d=e.i(99934),u=e.i(52183);let p=(0,i.freeze)({is:e=>"SelectionNode"===e.kind,create:e=>(0,i.freeze)({kind:"SelectionNode",selection:e}),createSelectAll:()=>(0,i.freeze)({kind:"SelectionNode",selection:u.SelectAllNode.create()}),createSelectAllFromTable:e=>(0,i.freeze)({kind:"SelectionNode",selection:d.ReferenceNode.createSelectAll(e)})});e.s(["SelectionNode",0,p],26514)},94993,31461,89737,98149,8882,992,98130,27797,55642,34755,e=>{"use strict";e.s(["InsertQueryBuilder",()=>V],94993),e.s(["parseSelectAll",()=>h,"parseSelectArg",()=>p],31461);var r,t,o=e.i(5292),i=e.i(26514),n=e.i(19834),s=e.i(82180),a=e.i(85381),d=e.i(27952),u=e.i(71731);function p(e){return(0,o.isFunction)(e)?p(e((0,u.expressionBuilder)())):(0,o.isReadonlyArray)(e)?e.map(e=>l(e)):[l(e)]}function l(e){return(0,o.isString)(e)?i.SelectionNode.create((0,n.parseAliasedStringReference)(e)):(0,s.isDynamicReferenceBuilder)(e)?i.SelectionNode.create(e.toOperationNode()):i.SelectionNode.create((0,a.parseAliasedExpression)(e))}function h(e){return e?Array.isArray(e)?e.map(c):[c(e)]:[i.SelectionNode.createSelectAll()]}function c(e){if((0,o.isString)(e))return i.SelectionNode.createSelectAllFromTable((0,d.parseTable)(e));throw Error(`invalid value selectAll expression: ${JSON.stringify(e)}`)}e.s(["parseInsertExpression",()=>O],89737);var f=e.i(50022),N=e.i(74955),m=e.i(82561),y=e.i(43097);let w=(0,o.freeze)({is:e=>"ValuesNode"===e.kind,create:e=>(0,o.freeze)({kind:"ValuesNode",values:(0,o.freeze)(e)})}),g=(0,o.freeze)({is:e=>"DefaultInsertValueNode"===e.kind,create:()=>(0,o.freeze)({kind:"DefaultInsertValueNode"})});function O(e){var r;let t,i=(0,o.isFunction)(e)?e((0,u.expressionBuilder)()):e;return t=function(e){let r=new Map;for(let t of e)for(let e of Object.keys(t))r.has(e)||void 0===t[e]||r.set(e,r.size);return r}(r=(0,o.isReadonlyArray)(i)?i:(0,o.freeze)([i])),[(0,o.freeze)([...t.keys()].map(f.ColumnNode.create)),w.create(r.map(e=>(function(e,r){let t=Object.keys(e),i=Array.from({length:r.size}),n=!1,s=t.length;for(let d of t){let t=r.get(d);if((0,o.isUndefined)(t)){s--;continue}let u=e[d];((0,o.isUndefined)(u)||(0,a.isExpressionOrFactory)(u))&&(n=!0),i[t]=u}if(s<r.size||n){let e=g.create();return m.ValueListNode.create(i.map(r=>(0,o.isUndefined)(r)?e:(0,y.parseValueExpression)(r)))}return N.PrimitiveValueListNode.create(i)})(e,t)))]}var x=e.i(91114),W=e.i(22350);let b=(0,o.freeze)({is:e=>"ColumnUpdateNode"===e.kind,create:(e,r)=>(0,o.freeze)({kind:"ColumnUpdateNode",column:e,value:r})});function q(e){return Object.entries((0,o.isFunction)(e)?e((0,u.expressionBuilder)()):e).filter(([e,r])=>void 0!==r).map(([e,r])=>b.create(f.ColumnNode.create(e),(0,y.parseValueExpression)(r)))}let z=(0,o.freeze)({is:e=>"OnDuplicateKeyNode"===e.kind,create:e=>(0,o.freeze)({kind:"OnDuplicateKeyNode",updates:e})});class S{insertId;numInsertedOrUpdatedRows;constructor(e,r){this.insertId=e,this.numInsertedOrUpdatedRows=r}}class k extends Error{node;constructor(e){super("no result"),this.node=e}}function E(e){return Object.prototype.hasOwnProperty.call(e,"prototype")}e.s(["NoResultError",0,k,"isNoResultErrorConstructor",0,E],98149);var I=e.i(55514),v=e.i(79685);let C=(0,o.freeze)({is:e=>"OnConflictNode"===e.kind,create:()=>(0,o.freeze)({kind:"OnConflictNode"}),cloneWith:(e,r)=>(0,o.freeze)({...e,...r}),cloneWithIndexWhere:(e,r)=>(0,o.freeze)({...e,indexWhere:e.indexWhere?v.WhereNode.cloneWithOperation(e.indexWhere,"And",r):v.WhereNode.create(r)}),cloneWithIndexOrWhere:(e,r)=>(0,o.freeze)({...e,indexWhere:e.indexWhere?v.WhereNode.cloneWithOperation(e.indexWhere,"Or",r):v.WhereNode.create(r)}),cloneWithUpdateWhere:(e,r)=>(0,o.freeze)({...e,updateWhere:e.updateWhere?v.WhereNode.cloneWithOperation(e.updateWhere,"And",r):v.WhereNode.create(r)}),cloneWithUpdateOrWhere:(e,r)=>(0,o.freeze)({...e,updateWhere:e.updateWhere?v.WhereNode.cloneWithOperation(e.updateWhere,"Or",r):v.WhereNode.create(r)}),cloneWithoutIndexWhere:e=>(0,o.freeze)({...e,indexWhere:void 0}),cloneWithoutUpdateWhere:e=>(0,o.freeze)({...e,updateWhere:void 0})});var B=e.i(23669);class Q{#r;constructor(e){this.#r=(0,o.freeze)(e)}column(e){let r=f.ColumnNode.create(e);return new Q({...this.#r,onConflictNode:C.cloneWith(this.#r.onConflictNode,{columns:this.#r.onConflictNode.columns?(0,o.freeze)([...this.#r.onConflictNode.columns,r]):(0,o.freeze)([r])})})}columns(e){let r=e.map(f.ColumnNode.create);return new Q({...this.#r,onConflictNode:C.cloneWith(this.#r.onConflictNode,{columns:this.#r.onConflictNode.columns?(0,o.freeze)([...this.#r.onConflictNode.columns,...r]):(0,o.freeze)(r)})})}constraint(e){return new Q({...this.#r,onConflictNode:C.cloneWith(this.#r.onConflictNode,{constraint:I.IdentifierNode.create(e)})})}expression(e){return new Q({...this.#r,onConflictNode:C.cloneWith(this.#r.onConflictNode,{indexExpression:e.toOperationNode()})})}where(...e){return new Q({...this.#r,onConflictNode:C.cloneWithIndexWhere(this.#r.onConflictNode,(0,B.parseValueBinaryOperationOrExpression)(e))})}whereRef(e,r,t){return new Q({...this.#r,onConflictNode:C.cloneWithIndexWhere(this.#r.onConflictNode,(0,B.parseReferentialBinaryOperation)(e,r,t))})}clearWhere(){return new Q({...this.#r,onConflictNode:C.cloneWithoutIndexWhere(this.#r.onConflictNode)})}doNothing(){return new T({...this.#r,onConflictNode:C.cloneWith(this.#r.onConflictNode,{doNothing:!0})})}doUpdateSet(e){return new R({...this.#r,onConflictNode:C.cloneWith(this.#r.onConflictNode,{updates:q(e)})})}$call(e){return e(this)}}class T{#r;constructor(e){this.#r=(0,o.freeze)(e)}toOperationNode(){return this.#r.onConflictNode}}class R{#r;constructor(e){this.#r=(0,o.freeze)(e)}where(...e){return new R({...this.#r,onConflictNode:C.cloneWithUpdateWhere(this.#r.onConflictNode,(0,B.parseValueBinaryOperationOrExpression)(e))})}whereRef(e,r,t){return new R({...this.#r,onConflictNode:C.cloneWithUpdateWhere(this.#r.onConflictNode,(0,B.parseReferentialBinaryOperation)(e,r,t))})}clearWhere(){return new R({...this.#r,onConflictNode:C.cloneWithoutUpdateWhere(this.#r.onConflictNode)})}$call(e){return e(this)}toOperationNode(){return this.#r.onConflictNode}}let A=(0,o.freeze)({is:e=>"TopNode"===e.kind,create:(e,r)=>(0,o.freeze)({kind:"TopNode",expression:e,modifiers:r})});function L(e,r){var t;if(!(0,o.isNumber)(e)&&!(0,o.isBigInt)(e))throw Error(`Invalid top expression: ${e}`);if(!(0,o.isUndefined)(r)&&"percent"!==(t=r)&&"with ties"!==t&&"percent with ties"!==t)throw Error(`Invalid top modifiers: ${r}`);return A.create(e,r)}e.s(["parseTop",0,L],8882);let F=(0,o.freeze)({is:e=>"OrActionNode"===e.kind,create:e=>(0,o.freeze)({kind:"OrActionNode",action:e})});class V{#r;constructor(e){this.#r=(0,o.freeze)(e)}values(e){let[r,t]=O(e);return new V({...this.#r,queryNode:x.InsertQueryNode.cloneWith(this.#r.queryNode,{columns:r,values:t})})}columns(e){return new V({...this.#r,queryNode:x.InsertQueryNode.cloneWith(this.#r.queryNode,{columns:(0,o.freeze)(e.map(f.ColumnNode.create))})})}expression(e){return new V({...this.#r,queryNode:x.InsertQueryNode.cloneWith(this.#r.queryNode,{values:(0,a.parseExpression)(e)})})}defaultValues(){return new V({...this.#r,queryNode:x.InsertQueryNode.cloneWith(this.#r.queryNode,{defaultValues:!0})})}modifyEnd(e){return new V({...this.#r,queryNode:W.QueryNode.cloneWithEndModifier(this.#r.queryNode,e.toOperationNode())})}ignore(){return new V({...this.#r,queryNode:x.InsertQueryNode.cloneWith(this.#r.queryNode,{orAction:F.create("ignore")})})}orIgnore(){return new V({...this.#r,queryNode:x.InsertQueryNode.cloneWith(this.#r.queryNode,{orAction:F.create("ignore")})})}orAbort(){return new V({...this.#r,queryNode:x.InsertQueryNode.cloneWith(this.#r.queryNode,{orAction:F.create("abort")})})}orFail(){return new V({...this.#r,queryNode:x.InsertQueryNode.cloneWith(this.#r.queryNode,{orAction:F.create("fail")})})}orReplace(){return new V({...this.#r,queryNode:x.InsertQueryNode.cloneWith(this.#r.queryNode,{orAction:F.create("replace")})})}orRollback(){return new V({...this.#r,queryNode:x.InsertQueryNode.cloneWith(this.#r.queryNode,{orAction:F.create("rollback")})})}top(e,r){return new V({...this.#r,queryNode:W.QueryNode.cloneWithTop(this.#r.queryNode,L(e,r))})}onConflict(e){return new V({...this.#r,queryNode:x.InsertQueryNode.cloneWith(this.#r.queryNode,{onConflict:e(new Q({onConflictNode:C.create()})).toOperationNode()})})}onDuplicateKeyUpdate(e){return new V({...this.#r,queryNode:x.InsertQueryNode.cloneWith(this.#r.queryNode,{onDuplicateKey:z.create(q(e))})})}returning(e){return new V({...this.#r,queryNode:W.QueryNode.cloneWithReturning(this.#r.queryNode,p(e))})}returningAll(){return new V({...this.#r,queryNode:W.QueryNode.cloneWithReturning(this.#r.queryNode,h())})}output(e){return new V({...this.#r,queryNode:W.QueryNode.cloneWithOutput(this.#r.queryNode,p(e))})}outputAll(e){return new V({...this.#r,queryNode:W.QueryNode.cloneWithOutput(this.#r.queryNode,h(e))})}clearReturning(){return new V({...this.#r,queryNode:W.QueryNode.cloneWithoutReturning(this.#r.queryNode)})}$call(e){return e(this)}$if(e,r){return e?r(this):new V({...this.#r})}$castTo(){return new V(this.#r)}$narrowType(){return new V(this.#r)}$assertType(){return new V(this.#r)}withPlugin(e){return new V({...this.#r,executor:this.#r.executor.withPlugin(e)})}toOperationNode(){return this.#r.executor.transformQuery(this.#r.queryNode,this.#r.queryId)}compile(){return this.#r.executor.compileQuery(this.toOperationNode(),this.#r.queryId)}async execute(e){let r=this.compile(),t=await this.#r.executor.executeQuery(r,e),{adapter:o}=this.#r.executor,i=r.query;return i.returning&&o.supportsReturning||i.output&&o.supportsOutput?t.rows:[new S(t.insertId,t.numAffectedRows??BigInt(0))]}async executeTakeFirst(e){let[r]=await this.execute(e);return r}async executeTakeFirstOrThrow(e){"function"==typeof e&&(e={errorConstructor:e});let r=await this.executeTakeFirst(e);if(void 0===r){let r=e?.errorConstructor??k;throw E(r)?new r(this.toOperationNode()):r(this.toOperationNode())}return r}async *stream(e){"object"!=typeof e&&(e={chunkSize:e});let r=this.compile();for await(let t of this.#r.executor.stream(r,e.chunkSize??100,e))yield*t.rows}async explain(e,r){let t=new V({...this.#r,queryNode:W.QueryNode.cloneWithExplain(this.#r.queryNode,e,r)});return await t.execute()}}e.s(["DeleteQueryBuilder",()=>j],98130);var M=e.i(38584);class D{numDeletedRows;constructor(e){this.numDeletedRows=e}}var J=e.i(83715);let P=(0,o.freeze)({is:e=>"LimitNode"===e.kind,create:e=>(0,o.freeze)({kind:"LimitNode",limit:e})});e.s(["LimitNode",0,P],992);var U=e.i(66511);class j{#r;constructor(e){this.#r=(0,o.freeze)(e)}where(...e){return new r({...this.#r,queryNode:W.QueryNode.cloneWithWhere(this.#r.queryNode,(0,B.parseValueBinaryOperationOrExpression)(e))})}whereRef(e,t,o){return new r({...this.#r,queryNode:W.QueryNode.cloneWithWhere(this.#r.queryNode,(0,B.parseReferentialBinaryOperation)(e,t,o))})}clearWhere(){return new r({...this.#r,queryNode:W.QueryNode.cloneWithoutWhere(this.#r.queryNode)})}top(e,t){return new r({...this.#r,queryNode:W.QueryNode.cloneWithTop(this.#r.queryNode,L(e,t))})}using(e){return new r({...this.#r,queryNode:J.DeleteQueryNode.cloneWithUsing(this.#r.queryNode,(0,d.parseTableExpressionOrList)(e))})}innerJoin(...e){return this.#t("InnerJoin",e)}leftJoin(...e){return this.#t("LeftJoin",e)}rightJoin(...e){return this.#t("RightJoin",e)}fullJoin(...e){return this.#t("FullJoin",e)}#t(e,t){return new r({...this.#r,queryNode:W.QueryNode.cloneWithJoin(this.#r.queryNode,(0,M.parseJoin)(e,t))})}returning(e){return new r({...this.#r,queryNode:W.QueryNode.cloneWithReturning(this.#r.queryNode,p(e))})}returningAll(e){return new r({...this.#r,queryNode:W.QueryNode.cloneWithReturning(this.#r.queryNode,h(e))})}output(e){return new r({...this.#r,queryNode:W.QueryNode.cloneWithOutput(this.#r.queryNode,p(e))})}outputAll(e){return new r({...this.#r,queryNode:W.QueryNode.cloneWithOutput(this.#r.queryNode,h(e))})}clearReturning(){return new r({...this.#r,queryNode:W.QueryNode.cloneWithoutReturning(this.#r.queryNode)})}clearLimit(){return new r({...this.#r,queryNode:J.DeleteQueryNode.cloneWithoutLimit(this.#r.queryNode)})}orderBy(...e){return new r({...this.#r,queryNode:W.QueryNode.cloneWithOrderByItems(this.#r.queryNode,(0,U.parseOrderBy)(e))})}clearOrderBy(){return new r({...this.#r,queryNode:W.QueryNode.cloneWithoutOrderBy(this.#r.queryNode)})}limit(e){return new r({...this.#r,queryNode:J.DeleteQueryNode.cloneWithLimit(this.#r.queryNode,P.create((0,y.parseValueExpression)(e)))})}modifyEnd(e){return new r({...this.#r,queryNode:W.QueryNode.cloneWithEndModifier(this.#r.queryNode,e.toOperationNode())})}$call(e){return e(this)}$if(e,t){return e?t(this):new r({...this.#r})}$castTo(){return new r(this.#r)}$narrowType(){return new r(this.#r)}$assertType(){return new r(this.#r)}withPlugin(e){return new r({...this.#r,executor:this.#r.executor.withPlugin(e)})}toOperationNode(){return this.#r.executor.transformQuery(this.#r.queryNode,this.#r.queryId)}compile(){return this.#r.executor.compileQuery(this.toOperationNode(),this.#r.queryId)}async execute(e){let r=this.compile(),t=await this.#r.executor.executeQuery(r,e),{adapter:o}=this.#r.executor,i=r.query;return i.returning&&o.supportsReturning||i.output&&o.supportsOutput?t.rows:[new D(t.numAffectedRows??BigInt(0))]}async executeTakeFirst(e){let[r]=await this.execute(e);return r}async executeTakeFirstOrThrow(e){"function"==typeof e&&(e={errorConstructor:e});let r=await this.executeTakeFirst(e);if(void 0===r){let r=e?.errorConstructor??k;throw E(r)?new r(this.toOperationNode()):r(this.toOperationNode())}return r}async *stream(e){"object"!=typeof e&&(e={chunkSize:e});let r=this.compile();for await(let t of this.#r.executor.stream(r,e.chunkSize??100,e))yield*t.rows}async explain(e,t){let o=new r({...this.#r,queryNode:W.QueryNode.cloneWithExplain(this.#r.queryNode,e,t)});return await o.execute()}}r=j,e.s(["UpdateQueryBuilder",()=>K],27797);var $=e.i(40642);class G{numUpdatedRows;numChangedRows;constructor(e,r){this.numUpdatedRows=e,this.numChangedRows=r}}class K{#r;constructor(e){this.#r=(0,o.freeze)(e)}where(...e){return new t({...this.#r,queryNode:W.QueryNode.cloneWithWhere(this.#r.queryNode,(0,B.parseValueBinaryOperationOrExpression)(e))})}whereRef(e,r,o){return new t({...this.#r,queryNode:W.QueryNode.cloneWithWhere(this.#r.queryNode,(0,B.parseReferentialBinaryOperation)(e,r,o))})}clearWhere(){return new t({...this.#r,queryNode:W.QueryNode.cloneWithoutWhere(this.#r.queryNode)})}top(e,r){return new t({...this.#r,queryNode:W.QueryNode.cloneWithTop(this.#r.queryNode,L(e,r))})}from(e){return new t({...this.#r,queryNode:$.UpdateQueryNode.cloneWithFromItems(this.#r.queryNode,(0,d.parseTableExpressionOrList)(e))})}innerJoin(...e){return this.#t("InnerJoin",e)}leftJoin(...e){return this.#t("LeftJoin",e)}rightJoin(...e){return this.#t("RightJoin",e)}fullJoin(...e){return this.#t("FullJoin",e)}#t(e,r){return new t({...this.#r,queryNode:W.QueryNode.cloneWithJoin(this.#r.queryNode,(0,M.parseJoin)(e,r))})}orderBy(...e){return new t({...this.#r,queryNode:W.QueryNode.cloneWithOrderByItems(this.#r.queryNode,(0,U.parseOrderBy)(e))})}clearOrderBy(){return new t({...this.#r,queryNode:W.QueryNode.cloneWithoutOrderBy(this.#r.queryNode)})}limit(e){return new t({...this.#r,queryNode:$.UpdateQueryNode.cloneWithLimit(this.#r.queryNode,P.create((0,y.parseValueExpression)(e)))})}set(...e){return new t({...this.#r,queryNode:$.UpdateQueryNode.cloneWithUpdates(this.#r.queryNode,function(...e){return 2===e.length?[b.create((0,n.parseReferenceExpression)(e[0]),(0,y.parseValueExpression)(e[1]))]:q(e[0])}(...e))})}returning(e){return new t({...this.#r,queryNode:W.QueryNode.cloneWithReturning(this.#r.queryNode,p(e))})}returningAll(e){return new t({...this.#r,queryNode:W.QueryNode.cloneWithReturning(this.#r.queryNode,h(e))})}output(e){return new t({...this.#r,queryNode:W.QueryNode.cloneWithOutput(this.#r.queryNode,p(e))})}outputAll(e){return new t({...this.#r,queryNode:W.QueryNode.cloneWithOutput(this.#r.queryNode,h(e))})}modifyEnd(e){return new t({...this.#r,queryNode:W.QueryNode.cloneWithEndModifier(this.#r.queryNode,e.toOperationNode())})}clearReturning(){return new t({...this.#r,queryNode:W.QueryNode.cloneWithoutReturning(this.#r.queryNode)})}$call(e){return e(this)}$if(e,r){return e?r(this):new t({...this.#r})}$castTo(){return new t(this.#r)}$narrowType(){return new t(this.#r)}$assertType(){return new t(this.#r)}withPlugin(e){return new t({...this.#r,executor:this.#r.executor.withPlugin(e)})}toOperationNode(){return this.#r.executor.transformQuery(this.#r.queryNode,this.#r.queryId)}compile(){return this.#r.executor.compileQuery(this.toOperationNode(),this.#r.queryId)}async execute(e){let r=this.compile(),t=await this.#r.executor.executeQuery(r,e),{adapter:o}=this.#r.executor,i=r.query;return i.returning&&o.supportsReturning||i.output&&o.supportsOutput?t.rows:[new G(t.numAffectedRows??BigInt(0),t.numChangedRows)]}async executeTakeFirst(e){let[r]=await this.execute(e);return r}async executeTakeFirstOrThrow(e){"function"==typeof e&&(e={errorConstructor:e});let r=await this.executeTakeFirst(e);if(void 0===r){let r=e?.errorConstructor??k;throw E(r)?new r(this.toOperationNode()):r(this.toOperationNode())}return r}async *stream(e){"object"!=typeof e&&(e={chunkSize:e});let r=this.compile();for await(let t of this.#r.executor.stream(r,e.chunkSize??100,e))yield*t.rows}async explain(e,r){let o=new t({...this.#r,queryNode:W.QueryNode.cloneWithExplain(this.#r.queryNode,e,r)});return await o.execute()}}t=K,e.s(["parseCommonTableExpression",()=>er],55642);var _=e.i(39328);let H=(0,o.freeze)({is:e=>"CommonTableExpressionNameNode"===e.kind,create:(e,r)=>(0,o.freeze)({kind:"CommonTableExpressionNameNode",table:_.TableNode.create(e),columns:r?(0,o.freeze)(r.map(f.ColumnNode.create)):void 0})});var X=e.i(74832);let Y=(0,o.freeze)({is:e=>"CommonTableExpressionNode"===e.kind,create:(e,r)=>(0,o.freeze)({kind:"CommonTableExpressionNode",name:e,expression:r}),cloneWith:(e,r)=>(0,o.freeze)({...e,...r})});class Z{#r;constructor(e){this.#r=(0,o.freeze)(e)}materialized(){return new Z({...this.#r,node:Y.cloneWith(this.#r.node,{materialized:!0})})}notMaterialized(){return new Z({...this.#r,node:Y.cloneWith(this.#r.node,{materialized:!1})})}toOperationNode(){return this.#r.node}}var ee=e.i(52369);function er(e,r){var t;let i=(0,ee.isOperationNodeSource)(r)?r.toOperationNode():r((0,X.createQueryCreator)()).toOperationNode();return(0,o.isFunction)(e)?e((t=i,e=>new Z({node:Y.create(et(e),t)}))).toOperationNode():Y.create(et(e),i)}function et(e){if(!e.includes("("))return H.create(e);{let r=e.split(/[\(\)]/),t=r[0],o=r[1].split(",").map(e=>e.trim());return H.create(t,o)}}let eo=(0,o.freeze)({is:e=>"WithNode"===e.kind,create:(e,r)=>(0,o.freeze)({kind:"WithNode",expressions:(0,o.freeze)([e]),...r}),cloneWithExpression:(e,r)=>(0,o.freeze)({...e,expressions:(0,o.freeze)([...e.expressions,r])})});e.s(["WithNode",0,eo],34755)},15249,11719,e=>{"use strict";let r=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"];function t(e){let t="";for(let o=0;o<e;++o)t+=r[~~(Math.random()*r.length)];return t}e.s(["randomString",0,t],11719);class o{#o;get queryId(){return void 0===this.#o&&(this.#o=t(8)),this.#o}}e.s(["createQueryId",0,function(){return new o}],15249)},22284,18264,62926,55505,742,47007,95776,97078,13071,74832,38584,85569,72127,12365,81442,70420,e=>{"use strict";e.s(["createSelectQueryBuilder",()=>eB],22284);var r,t=e.i(77373),o=e.i(80827);e.s(["parseJoin",()=>el],38584);var i=e.i(79111),n=e.i(23669);e.s(["createJoinBuilder",()=>eu,"createOverBuilder",()=>ep,"createQueryCreator",()=>ed],74832);var s=e.i(20857),a=e.i(4372),d=e.i(69062);e.s(["QueryCreator",()=>ea],13071);var u=e.i(94993),p=e.i(98130),l=e.i(27797),h=e.i(83715),c=e.i(91114),f=e.i(34067),N=e.i(40642),m=e.i(27952),y=e.i(55642),w=e.i(34755),g=e.i(15249),O=e.i(55514),x=e.i(32694),W=e.i(5292);class b{nodeStack=[];#i=(0,W.freeze)({AliasNode:this.transformAlias.bind(this),ColumnNode:this.transformColumn.bind(this),IdentifierNode:this.transformIdentifier.bind(this),SchemableIdentifierNode:this.transformSchemableIdentifier.bind(this),RawNode:this.transformRaw.bind(this),ReferenceNode:this.transformReference.bind(this),SelectQueryNode:this.transformSelectQuery.bind(this),SelectionNode:this.transformSelection.bind(this),TableNode:this.transformTable.bind(this),FromNode:this.transformFrom.bind(this),SelectAllNode:this.transformSelectAll.bind(this),AndNode:this.transformAnd.bind(this),OrNode:this.transformOr.bind(this),ValueNode:this.transformValue.bind(this),ValueListNode:this.transformValueList.bind(this),PrimitiveValueListNode:this.transformPrimitiveValueList.bind(this),ParensNode:this.transformParens.bind(this),JoinNode:this.transformJoin.bind(this),OperatorNode:this.transformOperator.bind(this),WhereNode:this.transformWhere.bind(this),InsertQueryNode:this.transformInsertQuery.bind(this),DeleteQueryNode:this.transformDeleteQuery.bind(this),ReturningNode:this.transformReturning.bind(this),CreateTableNode:this.transformCreateTable.bind(this),AddColumnNode:this.transformAddColumn.bind(this),ColumnDefinitionNode:this.transformColumnDefinition.bind(this),DropTableNode:this.transformDropTable.bind(this),DataTypeNode:this.transformDataType.bind(this),OrderByNode:this.transformOrderBy.bind(this),OrderByItemNode:this.transformOrderByItem.bind(this),GroupByNode:this.transformGroupBy.bind(this),GroupByItemNode:this.transformGroupByItem.bind(this),UpdateQueryNode:this.transformUpdateQuery.bind(this),ColumnUpdateNode:this.transformColumnUpdate.bind(this),LimitNode:this.transformLimit.bind(this),OffsetNode:this.transformOffset.bind(this),OnConflictNode:this.transformOnConflict.bind(this),OnDuplicateKeyNode:this.transformOnDuplicateKey.bind(this),CreateIndexNode:this.transformCreateIndex.bind(this),DropIndexNode:this.transformDropIndex.bind(this),ListNode:this.transformList.bind(this),PrimaryKeyConstraintNode:this.transformPrimaryKeyConstraint.bind(this),UniqueConstraintNode:this.transformUniqueConstraint.bind(this),ReferencesNode:this.transformReferences.bind(this),CheckConstraintNode:this.transformCheckConstraint.bind(this),WithNode:this.transformWith.bind(this),CommonTableExpressionNode:this.transformCommonTableExpression.bind(this),CommonTableExpressionNameNode:this.transformCommonTableExpressionName.bind(this),HavingNode:this.transformHaving.bind(this),CreateSchemaNode:this.transformCreateSchema.bind(this),DropSchemaNode:this.transformDropSchema.bind(this),AlterTableNode:this.transformAlterTable.bind(this),DropColumnNode:this.transformDropColumn.bind(this),RenameColumnNode:this.transformRenameColumn.bind(this),AlterColumnNode:this.transformAlterColumn.bind(this),ModifyColumnNode:this.transformModifyColumn.bind(this),AddConstraintNode:this.transformAddConstraint.bind(this),DropConstraintNode:this.transformDropConstraint.bind(this),RenameConstraintNode:this.transformRenameConstraint.bind(this),ForeignKeyConstraintNode:this.transformForeignKeyConstraint.bind(this),CreateViewNode:this.transformCreateView.bind(this),RefreshMaterializedViewNode:this.transformRefreshMaterializedView.bind(this),DropViewNode:this.transformDropView.bind(this),GeneratedNode:this.transformGenerated.bind(this),DefaultValueNode:this.transformDefaultValue.bind(this),OnNode:this.transformOn.bind(this),ValuesNode:this.transformValues.bind(this),SelectModifierNode:this.transformSelectModifier.bind(this),CreateTypeNode:this.transformCreateType.bind(this),DropTypeNode:this.transformDropType.bind(this),ExplainNode:this.transformExplain.bind(this),DefaultInsertValueNode:this.transformDefaultInsertValue.bind(this),AggregateFunctionNode:this.transformAggregateFunction.bind(this),OverNode:this.transformOver.bind(this),PartitionByNode:this.transformPartitionBy.bind(this),PartitionByItemNode:this.transformPartitionByItem.bind(this),SetOperationNode:this.transformSetOperation.bind(this),BinaryOperationNode:this.transformBinaryOperation.bind(this),UnaryOperationNode:this.transformUnaryOperation.bind(this),UsingNode:this.transformUsing.bind(this),FunctionNode:this.transformFunction.bind(this),CaseNode:this.transformCase.bind(this),WhenNode:this.transformWhen.bind(this),JSONReferenceNode:this.transformJSONReference.bind(this),JSONPathNode:this.transformJSONPath.bind(this),JSONPathLegNode:this.transformJSONPathLeg.bind(this),JSONOperatorChainNode:this.transformJSONOperatorChain.bind(this),TupleNode:this.transformTuple.bind(this),MergeQueryNode:this.transformMergeQuery.bind(this),MatchedNode:this.transformMatched.bind(this),AddIndexNode:this.transformAddIndex.bind(this),CastNode:this.transformCast.bind(this),FetchNode:this.transformFetch.bind(this),TopNode:this.transformTop.bind(this),OutputNode:this.transformOutput.bind(this),OrActionNode:this.transformOrAction.bind(this),CollateNode:this.transformCollate.bind(this),AlterTypeNode:this.transformAlterType.bind(this),AddValueNode:this.transformAddValue.bind(this),RenameValueNode:this.transformRenameValue.bind(this)});transformNode(e,r){if(!e)return e;this.nodeStack.push(e);let t=this.transformNodeImpl(e,r);return this.nodeStack.pop(),(0,W.freeze)(t)}transformNodeImpl(e,r){return this.#i[e.kind](e,r)}transformNodeList(e,r){return e?(0,W.freeze)(e.map(e=>this.transformNode(e,r))):e}transformSelectQuery(e,r){return{kind:"SelectQueryNode",from:this.transformNode(e.from,r),selections:this.transformNodeList(e.selections,r),distinctOn:this.transformNodeList(e.distinctOn,r),joins:this.transformNodeList(e.joins,r),groupBy:this.transformNode(e.groupBy,r),orderBy:this.transformNode(e.orderBy,r),where:this.transformNode(e.where,r),frontModifiers:this.transformNodeList(e.frontModifiers,r),endModifiers:this.transformNodeList(e.endModifiers,r),limit:this.transformNode(e.limit,r),offset:this.transformNode(e.offset,r),with:this.transformNode(e.with,r),having:this.transformNode(e.having,r),explain:this.transformNode(e.explain,r),setOperations:this.transformNodeList(e.setOperations,r),fetch:this.transformNode(e.fetch,r),top:this.transformNode(e.top,r)}}transformSelection(e,r){return{kind:"SelectionNode",selection:this.transformNode(e.selection,r)}}transformColumn(e,r){return{kind:"ColumnNode",column:this.transformNode(e.column,r)}}transformAlias(e,r){return{kind:"AliasNode",node:this.transformNode(e.node,r),alias:this.transformNode(e.alias,r)}}transformTable(e,r){return{kind:"TableNode",table:this.transformNode(e.table,r)}}transformFrom(e,r){return{kind:"FromNode",froms:this.transformNodeList(e.froms,r)}}transformReference(e,r){return{kind:"ReferenceNode",column:this.transformNode(e.column,r),table:this.transformNode(e.table,r)}}transformAnd(e,r){return{kind:"AndNode",left:this.transformNode(e.left,r),right:this.transformNode(e.right,r)}}transformOr(e,r){return{kind:"OrNode",left:this.transformNode(e.left,r),right:this.transformNode(e.right,r)}}transformValueList(e,r){return{kind:"ValueListNode",values:this.transformNodeList(e.values,r)}}transformParens(e,r){return{kind:"ParensNode",node:this.transformNode(e.node,r)}}transformJoin(e,r){return{kind:"JoinNode",joinType:e.joinType,table:this.transformNode(e.table,r),on:this.transformNode(e.on,r)}}transformRaw(e,r){return{kind:"RawNode",sqlFragments:(0,W.freeze)([...e.sqlFragments]),parameters:this.transformNodeList(e.parameters,r)}}transformWhere(e,r){return{kind:"WhereNode",where:this.transformNode(e.where,r)}}transformInsertQuery(e,r){return{kind:"InsertQueryNode",into:this.transformNode(e.into,r),columns:this.transformNodeList(e.columns,r),values:this.transformNode(e.values,r),returning:this.transformNode(e.returning,r),onConflict:this.transformNode(e.onConflict,r),onDuplicateKey:this.transformNode(e.onDuplicateKey,r),endModifiers:this.transformNodeList(e.endModifiers,r),with:this.transformNode(e.with,r),orAction:this.transformNode(e.orAction,r),replace:e.replace,explain:this.transformNode(e.explain,r),defaultValues:e.defaultValues,top:this.transformNode(e.top,r),output:this.transformNode(e.output,r)}}transformValues(e,r){return{kind:"ValuesNode",values:this.transformNodeList(e.values,r)}}transformDeleteQuery(e,r){return{kind:"DeleteQueryNode",from:this.transformNode(e.from,r),using:this.transformNode(e.using,r),joins:this.transformNodeList(e.joins,r),where:this.transformNode(e.where,r),returning:this.transformNode(e.returning,r),endModifiers:this.transformNodeList(e.endModifiers,r),with:this.transformNode(e.with,r),orderBy:this.transformNode(e.orderBy,r),limit:this.transformNode(e.limit,r),explain:this.transformNode(e.explain,r),top:this.transformNode(e.top,r),output:this.transformNode(e.output,r)}}transformReturning(e,r){return{kind:"ReturningNode",selections:this.transformNodeList(e.selections,r)}}transformCreateTable(e,r){return{kind:"CreateTableNode",table:this.transformNode(e.table,r),columns:this.transformNodeList(e.columns,r),constraints:this.transformNodeList(e.constraints,r),indexes:this.transformNodeList(e.indexes,r),temporary:e.temporary,ifNotExists:e.ifNotExists,onCommit:e.onCommit,frontModifiers:this.transformNodeList(e.frontModifiers,r),endModifiers:this.transformNodeList(e.endModifiers,r),selectQuery:this.transformNode(e.selectQuery,r)}}transformColumnDefinition(e,r){return{kind:"ColumnDefinitionNode",column:this.transformNode(e.column,r),dataType:this.transformNode(e.dataType,r),references:this.transformNode(e.references,r),primaryKey:e.primaryKey,autoIncrement:e.autoIncrement,unique:e.unique,notNull:e.notNull,unsigned:e.unsigned,defaultTo:this.transformNode(e.defaultTo,r),check:this.transformNode(e.check,r),generated:this.transformNode(e.generated,r),frontModifiers:this.transformNodeList(e.frontModifiers,r),endModifiers:this.transformNodeList(e.endModifiers,r),nullsNotDistinct:e.nullsNotDistinct,identity:e.identity,ifNotExists:e.ifNotExists}}transformAddColumn(e,r){return{kind:"AddColumnNode",column:this.transformNode(e.column,r)}}transformDropTable(e,r){return{kind:"DropTableNode",table:this.transformNode(e.table,r),ifExists:e.ifExists,cascade:e.cascade,temporary:e.temporary}}transformOrderBy(e,r){return{kind:"OrderByNode",items:this.transformNodeList(e.items,r)}}transformOrderByItem(e,r){return{kind:"OrderByItemNode",orderBy:this.transformNode(e.orderBy,r),direction:this.transformNode(e.direction,r),collation:this.transformNode(e.collation,r),nulls:e.nulls}}transformGroupBy(e,r){return{kind:"GroupByNode",items:this.transformNodeList(e.items,r)}}transformGroupByItem(e,r){return{kind:"GroupByItemNode",groupBy:this.transformNode(e.groupBy,r)}}transformUpdateQuery(e,r){return{kind:"UpdateQueryNode",table:this.transformNode(e.table,r),from:this.transformNode(e.from,r),joins:this.transformNodeList(e.joins,r),where:this.transformNode(e.where,r),updates:this.transformNodeList(e.updates,r),returning:this.transformNode(e.returning,r),endModifiers:this.transformNodeList(e.endModifiers,r),with:this.transformNode(e.with,r),explain:this.transformNode(e.explain,r),limit:this.transformNode(e.limit,r),top:this.transformNode(e.top,r),output:this.transformNode(e.output,r),orderBy:this.transformNode(e.orderBy,r)}}transformColumnUpdate(e,r){return{kind:"ColumnUpdateNode",column:this.transformNode(e.column,r),value:this.transformNode(e.value,r)}}transformLimit(e,r){return{kind:"LimitNode",limit:this.transformNode(e.limit,r)}}transformOffset(e,r){return{kind:"OffsetNode",offset:this.transformNode(e.offset,r)}}transformOnConflict(e,r){return{kind:"OnConflictNode",columns:this.transformNodeList(e.columns,r),constraint:this.transformNode(e.constraint,r),indexExpression:this.transformNode(e.indexExpression,r),indexWhere:this.transformNode(e.indexWhere,r),updates:this.transformNodeList(e.updates,r),updateWhere:this.transformNode(e.updateWhere,r),doNothing:e.doNothing}}transformOnDuplicateKey(e,r){return{kind:"OnDuplicateKeyNode",updates:this.transformNodeList(e.updates,r)}}transformCreateIndex(e,r){return{kind:"CreateIndexNode",name:this.transformNode(e.name,r),table:this.transformNode(e.table,r),columns:this.transformNodeList(e.columns,r),unique:e.unique,using:this.transformNode(e.using,r),ifNotExists:e.ifNotExists,where:this.transformNode(e.where,r),nullsNotDistinct:e.nullsNotDistinct}}transformList(e,r){return{kind:"ListNode",items:this.transformNodeList(e.items,r)}}transformDropIndex(e,r){return{kind:"DropIndexNode",name:this.transformNode(e.name,r),table:this.transformNode(e.table,r),ifExists:e.ifExists,cascade:e.cascade}}transformPrimaryKeyConstraint(e,r){return{kind:"PrimaryKeyConstraintNode",columns:this.transformNodeList(e.columns,r),name:this.transformNode(e.name,r),deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred}}transformUniqueConstraint(e,r){return{kind:"UniqueConstraintNode",columns:this.transformNodeList(e.columns,r),name:this.transformNode(e.name,r),nullsNotDistinct:e.nullsNotDistinct,deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred}}transformForeignKeyConstraint(e,r){return{kind:"ForeignKeyConstraintNode",columns:this.transformNodeList(e.columns,r),references:this.transformNode(e.references,r),name:this.transformNode(e.name,r),onDelete:e.onDelete,onUpdate:e.onUpdate,deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred}}transformSetOperation(e,r){return{kind:"SetOperationNode",operator:e.operator,expression:this.transformNode(e.expression,r),all:e.all}}transformReferences(e,r){return{kind:"ReferencesNode",table:this.transformNode(e.table,r),columns:this.transformNodeList(e.columns,r),onDelete:e.onDelete,onUpdate:e.onUpdate}}transformCheckConstraint(e,r){return{kind:"CheckConstraintNode",expression:this.transformNode(e.expression,r),name:this.transformNode(e.name,r)}}transformWith(e,r){return{kind:"WithNode",expressions:this.transformNodeList(e.expressions,r),recursive:e.recursive}}transformCommonTableExpression(e,r){return{kind:"CommonTableExpressionNode",name:this.transformNode(e.name,r),materialized:e.materialized,expression:this.transformNode(e.expression,r)}}transformCommonTableExpressionName(e,r){return{kind:"CommonTableExpressionNameNode",table:this.transformNode(e.table,r),columns:this.transformNodeList(e.columns,r)}}transformHaving(e,r){return{kind:"HavingNode",having:this.transformNode(e.having,r)}}transformCreateSchema(e,r){return{kind:"CreateSchemaNode",schema:this.transformNode(e.schema,r),ifNotExists:e.ifNotExists}}transformDropSchema(e,r){return{kind:"DropSchemaNode",schema:this.transformNode(e.schema,r),ifExists:e.ifExists,cascade:e.cascade}}transformAlterTable(e,r){return{kind:"AlterTableNode",table:this.transformNode(e.table,r),renameTo:this.transformNode(e.renameTo,r),setSchema:this.transformNode(e.setSchema,r),columnAlterations:this.transformNodeList(e.columnAlterations,r),addConstraint:this.transformNode(e.addConstraint,r),dropConstraint:this.transformNode(e.dropConstraint,r),renameConstraint:this.transformNode(e.renameConstraint,r),addIndex:this.transformNode(e.addIndex,r),dropIndex:this.transformNode(e.dropIndex,r)}}transformDropColumn(e,r){return{kind:"DropColumnNode",column:this.transformNode(e.column,r),ifExists:e.ifExists}}transformRenameColumn(e,r){return{kind:"RenameColumnNode",column:this.transformNode(e.column,r),renameTo:this.transformNode(e.renameTo,r)}}transformAlterColumn(e,r){return{kind:"AlterColumnNode",column:this.transformNode(e.column,r),dataType:this.transformNode(e.dataType,r),dataTypeExpression:this.transformNode(e.dataTypeExpression,r),setDefault:this.transformNode(e.setDefault,r),dropDefault:e.dropDefault,setNotNull:e.setNotNull,dropNotNull:e.dropNotNull}}transformModifyColumn(e,r){return{kind:"ModifyColumnNode",column:this.transformNode(e.column,r)}}transformAddConstraint(e,r){return{kind:"AddConstraintNode",constraint:this.transformNode(e.constraint,r)}}transformDropConstraint(e,r){return{kind:"DropConstraintNode",constraintName:this.transformNode(e.constraintName,r),ifExists:e.ifExists,modifier:e.modifier}}transformRenameConstraint(e,r){return{kind:"RenameConstraintNode",oldName:this.transformNode(e.oldName,r),newName:this.transformNode(e.newName,r)}}transformCreateView(e,r){return{kind:"CreateViewNode",name:this.transformNode(e.name,r),temporary:e.temporary,orReplace:e.orReplace,ifNotExists:e.ifNotExists,materialized:e.materialized,columns:this.transformNodeList(e.columns,r),as:this.transformNode(e.as,r)}}transformRefreshMaterializedView(e,r){return{kind:"RefreshMaterializedViewNode",name:this.transformNode(e.name,r),concurrently:e.concurrently,withNoData:e.withNoData}}transformDropView(e,r){return{kind:"DropViewNode",name:this.transformNode(e.name,r),ifExists:e.ifExists,materialized:e.materialized,cascade:e.cascade}}transformGenerated(e,r){return{kind:"GeneratedNode",byDefault:e.byDefault,always:e.always,identity:e.identity,stored:e.stored,expression:this.transformNode(e.expression,r)}}transformDefaultValue(e,r){return{kind:"DefaultValueNode",defaultValue:this.transformNode(e.defaultValue,r)}}transformOn(e,r){return{kind:"OnNode",on:this.transformNode(e.on,r)}}transformSelectModifier(e,r){return{kind:"SelectModifierNode",modifier:e.modifier,rawModifier:this.transformNode(e.rawModifier,r),of:this.transformNodeList(e.of,r)}}transformCreateType(e,r){return{kind:"CreateTypeNode",name:this.transformNode(e.name,r),enum:this.transformNode(e.enum,r)}}transformDropType(e,r){return{kind:"DropTypeNode",name:this.transformNode(e.name,r),additionalNames:this.transformNodeList(e.additionalNames,r),cascade:e.cascade,ifExists:e.ifExists}}transformExplain(e,r){return{kind:"ExplainNode",format:e.format,options:this.transformNode(e.options,r)}}transformSchemableIdentifier(e,r){return{kind:"SchemableIdentifierNode",schema:this.transformNode(e.schema,r),identifier:this.transformNode(e.identifier,r)}}transformAggregateFunction(e,r){return{kind:"AggregateFunctionNode",func:e.func,aggregated:this.transformNodeList(e.aggregated,r),distinct:e.distinct,orderBy:this.transformNode(e.orderBy,r),withinGroup:this.transformNode(e.withinGroup,r),filter:this.transformNode(e.filter,r),over:this.transformNode(e.over,r)}}transformOver(e,r){return{kind:"OverNode",orderBy:this.transformNode(e.orderBy,r),partitionBy:this.transformNode(e.partitionBy,r)}}transformPartitionBy(e,r){return{kind:"PartitionByNode",items:this.transformNodeList(e.items,r)}}transformPartitionByItem(e,r){return{kind:"PartitionByItemNode",partitionBy:this.transformNode(e.partitionBy,r)}}transformBinaryOperation(e,r){return{kind:"BinaryOperationNode",leftOperand:this.transformNode(e.leftOperand,r),operator:this.transformNode(e.operator,r),rightOperand:this.transformNode(e.rightOperand,r)}}transformUnaryOperation(e,r){return{kind:"UnaryOperationNode",operator:this.transformNode(e.operator,r),operand:this.transformNode(e.operand,r)}}transformUsing(e,r){return{kind:"UsingNode",tables:this.transformNodeList(e.tables,r)}}transformFunction(e,r){return{kind:"FunctionNode",func:e.func,arguments:this.transformNodeList(e.arguments,r)}}transformCase(e,r){return{kind:"CaseNode",value:this.transformNode(e.value,r),when:this.transformNodeList(e.when,r),else:this.transformNode(e.else,r),isStatement:e.isStatement}}transformWhen(e,r){return{kind:"WhenNode",condition:this.transformNode(e.condition,r),result:this.transformNode(e.result,r)}}transformJSONReference(e,r){return{kind:"JSONReferenceNode",reference:this.transformNode(e.reference,r),traversal:this.transformNode(e.traversal,r)}}transformJSONPath(e,r){return{kind:"JSONPathNode",inOperator:this.transformNode(e.inOperator,r),pathLegs:this.transformNodeList(e.pathLegs,r)}}transformJSONPathLeg(e,r){return{kind:"JSONPathLegNode",type:e.type,value:e.value}}transformJSONOperatorChain(e,r){return{kind:"JSONOperatorChainNode",operator:this.transformNode(e.operator,r),values:this.transformNodeList(e.values,r)}}transformTuple(e,r){return{kind:"TupleNode",values:this.transformNodeList(e.values,r)}}transformMergeQuery(e,r){return{kind:"MergeQueryNode",into:this.transformNode(e.into,r),using:this.transformNode(e.using,r),whens:this.transformNodeList(e.whens,r),with:this.transformNode(e.with,r),top:this.transformNode(e.top,r),endModifiers:this.transformNodeList(e.endModifiers,r),output:this.transformNode(e.output,r),returning:this.transformNode(e.returning,r)}}transformMatched(e,r){return{kind:"MatchedNode",not:e.not,bySource:e.bySource}}transformAddIndex(e,r){return{kind:"AddIndexNode",name:this.transformNode(e.name,r),columns:this.transformNodeList(e.columns,r),unique:e.unique,using:this.transformNode(e.using,r),ifNotExists:e.ifNotExists}}transformCast(e,r){return{kind:"CastNode",expression:this.transformNode(e.expression,r),dataType:this.transformNode(e.dataType,r)}}transformFetch(e,r){return{kind:"FetchNode",rowCount:this.transformNode(e.rowCount,r),modifier:e.modifier}}transformTop(e,r){return{kind:"TopNode",expression:e.expression,modifiers:e.modifiers}}transformOutput(e,r){return{kind:"OutputNode",selections:this.transformNodeList(e.selections,r)}}transformAlterType(e,r){return{kind:"AlterTypeNode",name:this.transformNode(e.name,r),addValue:this.transformNode(e.addValue,r),renameTo:this.transformNode(e.renameTo,r),renameValue:this.transformNode(e.renameValue,r),setSchema:this.transformNode(e.setSchema,r)}}transformAddValue(e,r){return{kind:"AddValueNode",value:this.transformNode(e.value,r),ifNotExists:e.ifNotExists,isBefore:e.isBefore,neighborValue:this.transformNode(e.neighborValue,r)}}transformRenameValue(e,r){return{kind:"RenameValueNode",oldValue:this.transformNode(e.oldValue,r),newValue:this.transformNode(e.newValue,r)}}transformDataType(e,r){return e}transformSelectAll(e,r){return e}transformIdentifier(e,r){return e}transformValue(e,r){return e}transformPrimitiveValueList(e,r){return e}transformOperator(e,r){return e}transformDefaultInsertValue(e,r){return e}transformOrAction(e,r){return e}transformCollate(e,r){return e}}e.s(["OperationNodeTransformer",0,b],18264);let q={AlterTableNode:!0,AlterTypeNode:!0,CreateIndexNode:!0,CreateSchemaNode:!0,CreateTableNode:!0,CreateTypeNode:!0,CreateViewNode:!0,DeleteQueryNode:!0,DropIndexNode:!0,DropSchemaNode:!0,DropTableNode:!0,DropTypeNode:!0,RefreshMaterializedViewNode:!0,DropViewNode:!0,InsertQueryNode:!0,RawNode:!0,SelectQueryNode:!0,UpdateQueryNode:!0,MergeQueryNode:!0};var z=e.i(15196),S=e.i(39328),k=e.i(76413);let E=(0,W.freeze)({json_agg:!0,to_json:!0});class I extends b{#n;#s=new Set;#a=new Set;constructor(e){super(),this.#n=e}transformNodeImpl(e,r){if(!((0,W.isObject)(e)&&(0,W.isString)(e.kind))||!0!==q[e.kind])return super.transformNodeImpl(e,r);let t=this.#d(e);for(let e of t)this.#a.add(e);let o=this.#u(e);for(let e of o)this.#s.add(e);let i=super.transformNodeImpl(e,r);for(let e of o)this.#s.delete(e);for(let e of t)this.#a.delete(e);return i}transformSchemableIdentifier(e,r){let t=super.transformSchemableIdentifier(e,r);return t.schema||!this.#s.has(e.identifier.name)?t:{...t,schema:O.IdentifierNode.create(this.#n)}}transformReferences(e,r){let t=super.transformReferences(e,r);return t.table.table.schema?t:{...t,table:S.TableNode.createWithSchema(this.#n,t.table.table.identifier.name)}}transformAggregateFunction(e,r){return{...super.transformAggregateFunction({...e,aggregated:[]},r),aggregated:this.#p(e,r,"aggregated")}}transformFunction(e,r){return{...super.transformFunction({...e,arguments:[]},r),arguments:this.#p(e,r,"arguments")}}transformSelectModifier(e,r){return{...super.transformSelectModifier({...e,of:void 0},r),of:e.of?.map(e=>S.TableNode.is(e)&&!e.table.schema?{...e,table:this.transformIdentifier(e.table.identifier,r)}:this.transformNode(e,r))}}#p(e,r,t){return E[e.func]?e[t].map(e=>!S.TableNode.is(e)||e.table.schema?this.transformNode(e,r):{...e,table:this.transformIdentifier(e.table.identifier,r)}):this.transformNodeList(e[t],r)}#u(e){let r=new Set;if("name"in e&&e.name&&z.SchemableIdentifierNode.is(e.name)&&this.#l(e.name,r),"from"in e&&e.from)for(let t of e.from.froms)this.#h(t,r);if("into"in e&&e.into&&this.#h(e.into,r),"table"in e&&e.table&&this.#h(e.table,r),"joins"in e&&e.joins)for(let t of e.joins)this.#h(t.table,r);return"using"in e&&e.using&&(i.JoinNode.is(e.using)?this.#h(e.using.table,r):this.#h(e.using,r)),r}#d(e){let r=new Set;return"with"in e&&e.with&&this.#c(e.with,r),r}#h(e,r){if(S.TableNode.is(e))return this.#l(e.table,r);if(t.AliasNode.is(e)&&S.TableNode.is(e.node))return this.#l(e.node.table,r);if(x.ListNode.is(e)){for(let t of e.items)this.#h(t,r);return}if(k.UsingNode.is(e)){for(let t of e.tables)this.#h(t,r);return}}#l(e,r){let t=e.identifier.name;this.#s.has(t)||this.#a.has(t)||r.add(t)}#c(e,r){for(let t of e.expressions){let e=t.name.table.table.identifier.name;this.#a.has(e)||r.add(e)}}}class v{#f;constructor(e){this.#f=new I(e)}transformQuery(e){return this.#f.transformNode(e.node,e.queryId)}async transformResult(e){return e.result}}e.s(["WithSchemaPlugin",0,v],62926);var C=e.i(31461),B=e.i(19285),Q=e.i(22350),T=e.i(89737);let R=(0,W.freeze)({is:e=>"MatchedNode"===e.kind,create:(e,r=!1)=>(0,W.freeze)({kind:"MatchedNode",not:e,bySource:r})});var A=e.i(52369),L=e.i(3731),F=e.i(54860);function V(e,r,t){return F.WhenNode.create((0,n.parseFilterList)([R.create(!e.isMatched,e.bySource),...r&&r.length>0?[3===r.length&&t?(0,n.parseReferentialBinaryOperation)(r[0],r[1],r[2]):(0,n.parseValueBinaryOperationOrExpression)(r)]:[]],"and",!1))}function M(e){return(0,W.isString)(e)?L.RawNode.create([e],[]):(0,A.isOperationNodeSource)(e)?e.toOperationNode():e}var D=e.i(8882);class J{#N;#m;#y;constructor(){this.#N=new Promise((e,r)=>{this.#y=r,this.#m=e})}get promise(){return this.#N}resolve=e=>{this.#m?.(e),this.#m=this.#y=void 0};reject=e=>{this.#y?.(e),this.#y=this.#m=void 0}}async function P(e,r){let t=new J,o=new J;return e.provideConnection(async e=>(t.resolve(e),await o.promise),r).catch(e=>t.reject(e)),(0,W.freeze)({connection:await t.promise,release:o.resolve})}function U(e="ignore query",r,t){if("ignore query"!==e){if("cancel query"===e){let t=r.cancelQuery;return t||j(e,r.killSession?"kill session":void 0),t.bind(r)}if("kill session"===e){let t=r.killSession;return t||j(e,r.cancelQuery?"cancel query":void 0),t.bind(r)}throw t(),Error(`Unexpected \`inflightQueryAbortStrategy\`: "${e}"`)}}function j(e,r){throw Error(`This dialect doesn't support \`inflightQueryAbortStrategy\` "${e}". Use "ignore query"${r?` or "${r}"`:""} instead.`)}function $(e,r,t){e?.aborted&&(t?.(),G(e.reason,r))}function G(e,r){var t,o;throw t=e,o=r,null===t||"object"!=typeof t||Object.isFrozen(t)||Object.defineProperty(t,"__kysely_timing__",{configurable:!0,enumerable:!1,value:o,writable:!1}),e}e.s(["Deferred",0,J],55505),e.s(["provideControlledConnection",0,P],742);let K={};async function _(e,r,t,o){if(!r)return e;$(r,`before ${t}`,o);let{promise:i,resolve:n}=new J,s=()=>n(K);r.addEventListener("abort",s);try{$(r,`before ${t}`,o);let n=await Promise.race([e,i]);if(n!==K)return n;o?.(),G(r.reason,`during ${t}`)}finally{r.removeEventListener("abort",s),n(K)}}function H(e){return r=>console.error(`\`${e}\` failed in the background after abortion: ${(0,W.getMessage)(r)}`)}e.s(["ABORTED",0,K,"assertNotAborted",0,$,"getInflightQueryAbortHandler",0,U,"printBackgroundFail",0,H,"throwReasonWithTiming",0,G,"waitOrAbort",0,_],47007);let X=(0,W.freeze)([]);class Y{#w;constructor(e=X){this.#w=e}get plugins(){return this.#w}transformQuery(e,r){for(let t of this.#w){let o=t.transformQuery({node:e,queryId:r});if(o.kind===e.kind)e=o;else throw Error(`KyselyPlugin.transformQuery must return a node of the same kind that was given to it. The plugin was given a ${e.kind} but it returned a ${o.kind}`)}return e}async executeQuery(e,r){let{inflightQueryAbortStrategy:t="ignore query",signal:o}=r||{};if(!o){let t=await this.provideConnection(async r=>await r.executeQuery(e),r);return await this.#g(t,e.queryId)}$(o,"before query execution"),r=(0,W.freeze)({signal:o});let{connection:i,release:n}=await P(this,r),s=this.provideConnection.bind(this),{promise:a,resolve:d}=new J,u=()=>d(K);o.addEventListener("abort",u,{once:!0});try{$(o,"before query execution",n);let d=U(t,i,n);if(d&&i.collectSessionInfo){$(o,"before query execution",n);let e=i.collectSessionInfo();await Promise.race([a,e]).catch(e=>{throw n(),e})===K&&(e.catch(H("collectSessionInfo")).finally(n),G(o.reason,"before query execution"))}let u=i.executeQuery(e,r),p=await Promise.race([a,u]).catch(e=>{throw n(),e});p===K?(Promise.allSettled([u.catch(H("query")),d?.(s).catch(H("inflightQueryAbortHandler"))]).finally(n),G(o.reason,"during query execution")):n();let l=this.#g(p,e.queryId,r),h=await Promise.race([a,l]);return h===K&&(l.catch(H("plugins.transformResult")),G(o.reason,"during result transformation")),h}finally{d(K),o.removeEventListener("abort",u)}}async *stream(e,r,t){let o,i,{signal:n}=t||{};if(!n){let{connection:o,release:i}=await P(this);try{for await(let i of o.streamQuery(e,r))yield await this.#g(i,e.queryId,t)}finally{i()}return}t=(0,W.freeze)({signal:n}),$(n,"before connection acquisition");let{connection:s,release:a}=await P(this,t),{promise:d,resolve:u}=new J,p=()=>u(K);n.addEventListener("abort",p,{once:!0}),$(n,"before query streaming",a);let{queryId:l}=e;try{for(o=s.streamQuery(e,r,t);;){$(n,"during query streaming");let e=o.next(),r=await Promise.race([d,e]);if(r===K&&(i=e.catch(H("iterator.next")),G(n.reason,"during query streaming")),r.done)break;let s=this.#g(r.value,l,t),a=await Promise.race([d,s]);a===K&&(i=s.catch(H("plugins.transformResult")),G(n.reason,"during result transformation")),yield a}}finally{u(K),n.removeEventListener("abort",p);let e=(o?.return?.()||Promise.resolve()).finally(()=>i).finally(a);i||await e}}async #g(e,r,t){let{signal:o}=t||{};for(let t of this.#w)e=await t.transformResult((0,W.freeze)({queryId:r,result:e,signal:o}));return e}}e.s(["QueryExecutorBase",0,Y],95776);class Z extends Y{get adapter(){throw Error("this query cannot be compiled to SQL")}compileQuery(){throw Error("this query cannot be compiled to SQL")}provideConnection(){throw Error("this query cannot be executed")}withConnectionProvider(){throw Error("this query cannot have a connection provider")}withPlugin(e){return new Z([...this.plugins,e])}withPlugins(e){return new Z([...this.plugins,...e])}withPluginAtFront(e){return new Z([e,...this.plugins])}withoutPlugins(){return new Z([])}}let ee=new Z;e.s(["NOOP_QUERY_EXECUTOR",0,ee],97078);class er{numChangedRows;constructor(e){this.numChangedRows=e}}var et=e.i(98149);class eo{#r;constructor(e){this.#r=(0,W.freeze)(e)}modifyEnd(e){return new eo({...this.#r,queryNode:Q.QueryNode.cloneWithEndModifier(this.#r.queryNode,e.toOperationNode())})}top(e,r){return new eo({...this.#r,queryNode:Q.QueryNode.cloneWithTop(this.#r.queryNode,(0,D.parseTop)(e,r))})}using(...e){return new ei({...this.#r,queryNode:B.MergeQueryNode.cloneWithUsing(this.#r.queryNode,el("Using",e))})}returning(e){return new eo({...this.#r,queryNode:Q.QueryNode.cloneWithReturning(this.#r.queryNode,(0,C.parseSelectArg)(e))})}returningAll(e){return new eo({...this.#r,queryNode:Q.QueryNode.cloneWithReturning(this.#r.queryNode,(0,C.parseSelectAll)(e))})}output(e){return new eo({...this.#r,queryNode:Q.QueryNode.cloneWithOutput(this.#r.queryNode,(0,C.parseSelectArg)(e))})}outputAll(e){return new eo({...this.#r,queryNode:Q.QueryNode.cloneWithOutput(this.#r.queryNode,(0,C.parseSelectAll)(e))})}}class ei{#r;constructor(e){this.#r=(0,W.freeze)(e)}modifyEnd(e){return new ei({...this.#r,queryNode:Q.QueryNode.cloneWithEndModifier(this.#r.queryNode,e.toOperationNode())})}top(e,r){return new ei({...this.#r,queryNode:Q.QueryNode.cloneWithTop(this.#r.queryNode,(0,D.parseTop)(e,r))})}whenMatched(){return this.#O([])}whenMatchedAnd(...e){return this.#O(e)}whenMatchedAndRef(e,r,t){return this.#O([e,r,t],!0)}#O(e,r){return new en({...this.#r,queryNode:B.MergeQueryNode.cloneWithWhen(this.#r.queryNode,V({isMatched:!0},e,r))})}whenNotMatched(){return this.#x([])}whenNotMatchedAnd(...e){return this.#x(e)}whenNotMatchedAndRef(e,r,t){return this.#x([e,r,t],!0)}whenNotMatchedBySource(){return this.#x([],!1,!0)}whenNotMatchedBySourceAnd(...e){return this.#x(e,!1,!0)}whenNotMatchedBySourceAndRef(e,r,t){return this.#x([e,r,t],!0,!0)}returning(e){return new ei({...this.#r,queryNode:Q.QueryNode.cloneWithReturning(this.#r.queryNode,(0,C.parseSelectArg)(e))})}returningAll(e){return new ei({...this.#r,queryNode:Q.QueryNode.cloneWithReturning(this.#r.queryNode,(0,C.parseSelectAll)(e))})}output(e){return new ei({...this.#r,queryNode:Q.QueryNode.cloneWithOutput(this.#r.queryNode,(0,C.parseSelectArg)(e))})}outputAll(e){return new ei({...this.#r,queryNode:Q.QueryNode.cloneWithOutput(this.#r.queryNode,(0,C.parseSelectAll)(e))})}#x(e,r=!1,t=!1){let o={...this.#r,queryNode:B.MergeQueryNode.cloneWithWhen(this.#r.queryNode,V({isMatched:!1,bySource:t},e,r))};return new(t?en:es)(o)}$call(e){return e(this)}$if(e,r){return e?r(this):new ei({...this.#r})}toOperationNode(){return this.#r.executor.transformQuery(this.#r.queryNode,this.#r.queryId)}compile(){return this.#r.executor.compileQuery(this.toOperationNode(),this.#r.queryId)}async execute(e){let r=this.compile(),t=await this.#r.executor.executeQuery(r,e),{adapter:o}=this.#r.executor,i=r.query;return i.returning&&o.supportsReturning||i.output&&o.supportsOutput?t.rows:[new er(t.numAffectedRows)]}async executeTakeFirst(e){let[r]=await this.execute(e);return r}async executeTakeFirstOrThrow(e){"function"==typeof e&&(e={errorConstructor:e});let r=await this.executeTakeFirst(e);if(void 0===r){let r=e?.errorConstructor??et.NoResultError;throw(0,et.isNoResultErrorConstructor)(r)?new r(this.toOperationNode()):r(this.toOperationNode())}return r}}class en{#r;constructor(e){this.#r=(0,W.freeze)(e)}thenDelete(){return new ei({...this.#r,queryNode:B.MergeQueryNode.cloneWithThen(this.#r.queryNode,M("delete"))})}thenDoNothing(){return new ei({...this.#r,queryNode:B.MergeQueryNode.cloneWithThen(this.#r.queryNode,M("do nothing"))})}thenUpdate(e){return new ei({...this.#r,queryNode:B.MergeQueryNode.cloneWithThen(this.#r.queryNode,M(e(new l.UpdateQueryBuilder({queryId:this.#r.queryId,executor:ee,queryNode:N.UpdateQueryNode.createWithoutTable()}))))})}thenUpdateSet(...e){return this.thenUpdate(r=>r.set(...e))}}class es{#r;constructor(e){this.#r=(0,W.freeze)(e)}thenDoNothing(){return new ei({...this.#r,queryNode:B.MergeQueryNode.cloneWithThen(this.#r.queryNode,M("do nothing"))})}thenInsertValues(e){let[r,t]=(0,T.parseInsertExpression)(e);return new ei({...this.#r,queryNode:B.MergeQueryNode.cloneWithThen(this.#r.queryNode,M(c.InsertQueryNode.cloneWith(c.InsertQueryNode.createWithoutInto(),{columns:r,values:t})))})}}class ea{#r;constructor(e){this.#r=(0,W.freeze)(e)}selectFrom(e){return eB({queryId:(0,g.createQueryId)(),executor:this.#r.executor,queryNode:f.SelectQueryNode.createFrom((0,m.parseTableExpressionOrList)(e),this.#r.withNode)})}selectNoFrom(e){return eB({queryId:(0,g.createQueryId)(),executor:this.#r.executor,queryNode:f.SelectQueryNode.cloneWithSelections(f.SelectQueryNode.create(this.#r.withNode),(0,C.parseSelectArg)(e))})}insertInto(e){return new u.InsertQueryBuilder({queryId:(0,g.createQueryId)(),executor:this.#r.executor,queryNode:c.InsertQueryNode.create((0,m.parseTable)(e),this.#r.withNode)})}replaceInto(e){return new u.InsertQueryBuilder({queryId:(0,g.createQueryId)(),executor:this.#r.executor,queryNode:c.InsertQueryNode.create((0,m.parseTable)(e),this.#r.withNode,!0)})}deleteFrom(e){return new p.DeleteQueryBuilder({queryId:(0,g.createQueryId)(),executor:this.#r.executor,queryNode:h.DeleteQueryNode.create((0,m.parseTableExpressionOrList)(e),this.#r.withNode)})}updateTable(e){return new l.UpdateQueryBuilder({queryId:(0,g.createQueryId)(),executor:this.#r.executor,queryNode:N.UpdateQueryNode.create((0,m.parseTableExpressionOrList)(e),this.#r.withNode)})}mergeInto(e){return new eo({queryId:(0,g.createQueryId)(),executor:this.#r.executor,queryNode:B.MergeQueryNode.create((0,m.parseAliasedTable)(e),this.#r.withNode)})}with(e,r){let t=(0,y.parseCommonTableExpression)(e,r);return new ea({...this.#r,withNode:this.#r.withNode?w.WithNode.cloneWithExpression(this.#r.withNode,t):w.WithNode.create(t)})}withRecursive(e,r){let t=(0,y.parseCommonTableExpression)(e,r);return new ea({...this.#r,withNode:this.#r.withNode?w.WithNode.cloneWithExpression(this.#r.withNode,t):w.WithNode.create(t,{recursive:!0})})}withPlugin(e){return new ea({...this.#r,executor:this.#r.executor.withPlugin(e)})}withoutPlugins(){return new ea({...this.#r,executor:this.#r.executor.withoutPlugins()})}withSchema(e){return new ea({...this.#r,executor:this.#r.executor.withPluginAtFront(new v(e))})}}function ed(){return new ea({executor:ee})}function eu(e,r){return new a.JoinBuilder({joinNode:i.JoinNode.create(e,(0,m.parseTableExpression)(r))})}function ep(){return new d.OverBuilder({overNode:s.OverNode.create()})}function el(e,r){var t,o,s,a,d,u,p,l;if(3===r.length){return t=e,o=r[0],s=r[1],a=r[2],i.JoinNode.createWithOn(t,(0,m.parseTableExpression)(o),(0,n.parseReferentialBinaryOperation)(s,"=",a))}if(2===r.length){return d=e,u=r[0],(0,r[1])(eu(d,u)).toOperationNode()}if(1===r.length){return p=e,l=r[0],i.JoinNode.create(p,(0,m.parseTableExpression)(l))}throw Error("not implemented")}var eh=e.i(19834),ec=e.i(66511),ef=e.i(992);let eN=(0,W.freeze)({is:e=>"OffsetNode"===e.kind,create:e=>(0,W.freeze)({kind:"OffsetNode",offset:e})}),em=(0,W.freeze)({is:e=>"GroupByItemNode"===e.kind,create:e=>(0,W.freeze)({kind:"GroupByItemNode",groupBy:e})});var ey=e.i(71731),ew=e.i(87981),eg=e.i(85381);function eO(e,r,t){return(0,W.isFunction)(r)&&(r=r((0,ey.createExpressionBuilder)())),(0,W.isReadonlyArray)(r)||(r=[r]),r.map(r=>ew.SetOperationNode.create(e,(0,eg.parseExpression)(r),t))}e.s(["ExpressionWrapper",()=>eq],85569);var ex=e.i(39001),eW=e.i(3392),eb=e.i(56802);class eq{#W;constructor(e){this.#W=e}get expressionType(){}as(e){return new ez(this,e)}or(...e){return new eS(eW.OrNode.create(this.#W,(0,n.parseValueBinaryOperationOrExpression)(e)))}and(...e){return new ek(ex.AndNode.create(this.#W,(0,n.parseValueBinaryOperationOrExpression)(e)))}$castTo(){return new eq(this.#W)}$notNull(){return new eq(this.#W)}toOperationNode(){return this.#W}}class ez{#b;#q;constructor(e,r){this.#b=e,this.#q=r}get expression(){return this.#b}get alias(){return this.#q}toOperationNode(){return t.AliasNode.create(this.#b.toOperationNode(),(0,A.isOperationNodeSource)(this.#q)?this.#q.toOperationNode():O.IdentifierNode.create(this.#q))}}class eS{#W;constructor(e){this.#W=e}get expressionType(){}as(e){return new ez(this,e)}or(...e){return new eS(eW.OrNode.create(this.#W,(0,n.parseValueBinaryOperationOrExpression)(e)))}$castTo(){return new eS(this.#W)}toOperationNode(){return eb.ParensNode.create(this.#W)}}class ek{#W;constructor(e){this.#W=e}get expressionType(){}as(e){return new ez(this,e)}and(...e){return new ek(ex.AndNode.create(this.#W,(0,n.parseValueBinaryOperationOrExpression)(e)))}$castTo(){return new ek(this.#W)}toOperationNode(){return eb.ParensNode.create(this.#W)}}var eE=e.i(43097),eI=e.i(84480);let ev=(0,W.freeze)({is:e=>"FetchNode"===e.kind,create:(e,r)=>({kind:"FetchNode",rowCount:eI.ValueNode.create(e),modifier:r})});class eC{#r;constructor(e){this.#r=(0,W.freeze)(e)}get expressionType(){}get isSelectQueryBuilder(){return!0}where(...e){return new r({...this.#r,queryNode:Q.QueryNode.cloneWithWhere(this.#r.queryNode,(0,n.parseValueBinaryOperationOrExpression)(e))})}whereRef(e,t,o){return new r({...this.#r,queryNode:Q.QueryNode.cloneWithWhere(this.#r.queryNode,(0,n.parseReferentialBinaryOperation)(e,t,o))})}having(...e){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithHaving(this.#r.queryNode,(0,n.parseValueBinaryOperationOrExpression)(e))})}havingRef(e,t,o){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithHaving(this.#r.queryNode,(0,n.parseReferentialBinaryOperation)(e,t,o))})}select(e){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithSelections(this.#r.queryNode,(0,C.parseSelectArg)(e))})}distinctOn(e){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithDistinctOn(this.#r.queryNode,(0,eh.parseReferenceExpressionOrList)(e))})}modifyFront(e){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithFrontModifier(this.#r.queryNode,o.SelectModifierNode.createWithExpression(e.toOperationNode()))})}modifyEnd(e){return new r({...this.#r,queryNode:Q.QueryNode.cloneWithEndModifier(this.#r.queryNode,o.SelectModifierNode.createWithExpression(e.toOperationNode()))})}distinct(){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithFrontModifier(this.#r.queryNode,o.SelectModifierNode.create("Distinct"))})}forUpdate(e){return new r({...this.#r,queryNode:Q.QueryNode.cloneWithEndModifier(this.#r.queryNode,o.SelectModifierNode.create("ForUpdate",e?(0,W.asArray)(e).map(m.parseTable):void 0))})}forShare(e){return new r({...this.#r,queryNode:Q.QueryNode.cloneWithEndModifier(this.#r.queryNode,o.SelectModifierNode.create("ForShare",e?(0,W.asArray)(e).map(m.parseTable):void 0))})}forKeyShare(e){return new r({...this.#r,queryNode:Q.QueryNode.cloneWithEndModifier(this.#r.queryNode,o.SelectModifierNode.create("ForKeyShare",e?(0,W.asArray)(e).map(m.parseTable):void 0))})}forNoKeyUpdate(e){return new r({...this.#r,queryNode:Q.QueryNode.cloneWithEndModifier(this.#r.queryNode,o.SelectModifierNode.create("ForNoKeyUpdate",e?(0,W.asArray)(e).map(m.parseTable):void 0))})}skipLocked(){return new r({...this.#r,queryNode:Q.QueryNode.cloneWithEndModifier(this.#r.queryNode,o.SelectModifierNode.create("SkipLocked"))})}noWait(){return new r({...this.#r,queryNode:Q.QueryNode.cloneWithEndModifier(this.#r.queryNode,o.SelectModifierNode.create("NoWait"))})}selectAll(e){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithSelections(this.#r.queryNode,(0,C.parseSelectAll)(e))})}innerJoin(...e){return this.#t("InnerJoin",e)}leftJoin(...e){return this.#t("LeftJoin",e)}rightJoin(...e){return this.#t("RightJoin",e)}fullJoin(...e){return this.#t("FullJoin",e)}crossJoin(...e){return this.#t("CrossJoin",e)}innerJoinLateral(...e){return this.#t("LateralInnerJoin",e)}leftJoinLateral(...e){return this.#t("LateralLeftJoin",e)}crossJoinLateral(...e){return this.#t("LateralCrossJoin",e)}crossApply(...e){return this.#t("CrossApply",e)}outerApply(...e){return this.#t("OuterApply",e)}#t(e,t){return new r({...this.#r,queryNode:Q.QueryNode.cloneWithJoin(this.#r.queryNode,el(e,t))})}orderBy(...e){return new r({...this.#r,queryNode:Q.QueryNode.cloneWithOrderByItems(this.#r.queryNode,(0,ec.parseOrderBy)(e))})}groupBy(e){var t;return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithGroupByItems(this.#r.queryNode,(t=e,t=(0,W.isFunction)(t)?t((0,ey.expressionBuilder)()):t,(0,eh.parseReferenceExpressionOrList)(t).map(em.create)))})}limit(e){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithLimit(this.#r.queryNode,ef.LimitNode.create((0,eE.parseValueExpression)(e)))})}offset(e){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithOffset(this.#r.queryNode,eN.create((0,eE.parseValueExpression)(e)))})}fetch(e,t="only"){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithFetch(this.#r.queryNode,function(e,r){var t;if(!(0,W.isNumber)(e)&&!(0,W.isBigInt)(e))throw Error(`Invalid fetch row count: ${e}`);if("only"!==(t=r)&&"with ties"!==t)throw Error(`Invalid fetch modifier: ${r}`);return ev.create(e,r)}(e,t))})}top(e,t){return new r({...this.#r,queryNode:Q.QueryNode.cloneWithTop(this.#r.queryNode,(0,D.parseTop)(e,t))})}union(e){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithSetOperations(this.#r.queryNode,eO("union",e,!1))})}unionAll(e){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithSetOperations(this.#r.queryNode,eO("union",e,!0))})}intersect(e){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithSetOperations(this.#r.queryNode,eO("intersect",e,!1))})}intersectAll(e){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithSetOperations(this.#r.queryNode,eO("intersect",e,!0))})}except(e){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithSetOperations(this.#r.queryNode,eO("except",e,!1))})}exceptAll(e){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithSetOperations(this.#r.queryNode,eO("except",e,!0))})}as(e){return new eQ(this,e)}clearSelect(){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithoutSelections(this.#r.queryNode)})}clearWhere(){return new r({...this.#r,queryNode:Q.QueryNode.cloneWithoutWhere(this.#r.queryNode)})}clearLimit(){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithoutLimit(this.#r.queryNode)})}clearOffset(){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithoutOffset(this.#r.queryNode)})}clearOrderBy(){return new r({...this.#r,queryNode:Q.QueryNode.cloneWithoutOrderBy(this.#r.queryNode)})}clearGroupBy(){return new r({...this.#r,queryNode:f.SelectQueryNode.cloneWithoutGroupBy(this.#r.queryNode)})}$call(e){return e(this)}$if(e,t){return e?t(this):new r({...this.#r})}$castTo(){return new r(this.#r)}$narrowType(){return new r(this.#r)}$assertType(){return new r(this.#r)}$asTuple(){return new eq(this.toOperationNode())}$asScalar(){return new eq(this.toOperationNode())}withPlugin(e){return new r({...this.#r,executor:this.#r.executor.withPlugin(e)})}toOperationNode(){return this.#r.executor.transformQuery(this.#r.queryNode,this.#r.queryId)}compile(){return this.#r.executor.compileQuery(this.toOperationNode(),this.#r.queryId)}async execute(e){let r=this.compile();return(await this.#r.executor.executeQuery(r,e)).rows}async executeTakeFirst(e){let[r]=await this.execute(e);return r}async executeTakeFirstOrThrow(e){"function"==typeof e&&(e={errorConstructor:e});let r=await this.executeTakeFirst(e);if(void 0===r){let r=e?.errorConstructor??et.NoResultError;throw(0,et.isNoResultErrorConstructor)(r)?new r(this.toOperationNode()):r(this.toOperationNode())}return r}async *stream(e){"object"!=typeof e&&(e={chunkSize:e});let r=this.compile();for await(let t of this.#r.executor.stream(r,e.chunkSize??100,e))yield*t.rows}async explain(e,t){let o=new r({...this.#r,queryNode:Q.QueryNode.cloneWithExplain(this.#r.queryNode,e,t)});return await o.execute()}}function eB(e){return new eC(e)}r=eC;class eQ{#z;#q;constructor(e,r){this.#z=e,this.#q=r}get expression(){return this.#z}get alias(){return this.#q}get isAliasedSelectQueryBuilder(){return!0}toOperationNode(){return t.AliasNode.create(this.#z.toOperationNode(),O.IdentifierNode.create(this.#q))}}e.s(["createFunctionModule",()=>eM],72127);var eT=e.i(79685),eR=e.i(3329);let eA=(0,W.freeze)({is:e=>"AggregateFunctionNode"===e.kind,create:(e,r=[])=>(0,W.freeze)({kind:"AggregateFunctionNode",func:e,aggregated:r}),cloneWithDistinct:e=>(0,W.freeze)({...e,distinct:!0}),cloneWithOrderBy(e,r,t=!1){let o=t?"withinGroup":"orderBy";return(0,W.freeze)({...e,[o]:e[o]?eR.OrderByNode.cloneWithItems(e[o],r):eR.OrderByNode.create(r)})},cloneWithFilter:(e,r)=>(0,W.freeze)({...e,filter:e.filter?eT.WhereNode.cloneWithOperation(e.filter,"And",r):eT.WhereNode.create(r)}),cloneWithOrFilter:(e,r)=>(0,W.freeze)({...e,filter:e.filter?eT.WhereNode.cloneWithOperation(e.filter,"Or",r):eT.WhereNode.create(r)}),cloneWithOver:(e,r)=>(0,W.freeze)({...e,over:r})}),eL=(0,W.freeze)({is:e=>"FunctionNode"===e.kind,create:(e,r)=>(0,W.freeze)({kind:"FunctionNode",func:e,arguments:r})});class eF{#r;constructor(e){this.#r=(0,W.freeze)(e)}get expressionType(){}as(e){return new eV(this,e)}distinct(){return new eF({...this.#r,aggregateFunctionNode:eA.cloneWithDistinct(this.#r.aggregateFunctionNode)})}orderBy(...e){return new eF({...this.#r,aggregateFunctionNode:Q.QueryNode.cloneWithOrderByItems(this.#r.aggregateFunctionNode,(0,ec.parseOrderBy)(e))})}clearOrderBy(){return new eF({...this.#r,aggregateFunctionNode:Q.QueryNode.cloneWithoutOrderBy(this.#r.aggregateFunctionNode)})}withinGroupOrderBy(...e){return new eF({...this.#r,aggregateFunctionNode:eA.cloneWithOrderBy(this.#r.aggregateFunctionNode,(0,ec.parseOrderBy)(e),!0)})}filterWhere(...e){return new eF({...this.#r,aggregateFunctionNode:eA.cloneWithFilter(this.#r.aggregateFunctionNode,(0,n.parseValueBinaryOperationOrExpression)(e))})}filterWhereRef(e,r,t){return new eF({...this.#r,aggregateFunctionNode:eA.cloneWithFilter(this.#r.aggregateFunctionNode,(0,n.parseReferentialBinaryOperation)(e,r,t))})}over(e){let r=ep();return new eF({...this.#r,aggregateFunctionNode:eA.cloneWithOver(this.#r.aggregateFunctionNode,(e?e(r):r).toOperationNode())})}$call(e){return e(this)}$castTo(){return new eF(this.#r)}$notNull(){return new eF(this.#r)}toOperationNode(){return this.#r.aggregateFunctionNode}}class eV{#S;#q;constructor(e,r){this.#S=e,this.#q=r}get expression(){return this.#S}get alias(){return this.#q}toOperationNode(){return t.AliasNode.create(this.#S.toOperationNode(),O.IdentifierNode.create(this.#q))}}function eM(){let e=(e,r)=>new eq(eL.create(e,(0,eh.parseReferenceExpressionOrList)(r??[]))),r=(e,r)=>new eF({aggregateFunctionNode:eA.create(e,r?(0,eh.parseReferenceExpressionOrList)(r):void 0)});return Object.assign(e,{agg:r,avg:e=>r("avg",[e]),coalesce:(...r)=>e("coalesce",r),count:e=>r("count",[e]),countAll:e=>new eF({aggregateFunctionNode:eA.create("count",(0,C.parseSelectAll)(e))}),max:e=>r("max",[e]),min:e=>r("min",[e]),sum:e=>r("sum",[e]),any:r=>e("any",[r]),jsonAgg:e=>new eF({aggregateFunctionNode:eA.create("json_agg",[(0,W.isString)(e)?(0,m.parseTable)(e):e.toOperationNode()])}),toJson:e=>new eq(eL.create("to_json",[(0,W.isString)(e)?(0,m.parseTable)(e):e.toOperationNode()]))})}e.s(["parseUnaryOperation",()=>eP],12365);var eD=e.i(36662);let eJ=(0,W.freeze)({is:e=>"UnaryOperationNode"===e.kind,create:(e,r)=>(0,W.freeze)({kind:"UnaryOperationNode",operator:e,operand:r})});function eP(e,r){if((0,eD.isUnaryOperator)(e))return eJ.create(eD.OperatorNode.create(e),(0,eh.parseReferenceExpression)(r));throw Error(`invalid unary operator ${JSON.stringify(e)}`)}e.s(["CaseBuilder",()=>ej],70420);let eU=(0,W.freeze)({is:e=>"CaseNode"===e.kind,create:e=>(0,W.freeze)({kind:"CaseNode",value:e}),cloneWithWhen:(e,r)=>(0,W.freeze)({...e,when:(0,W.freeze)(e.when?[...e.when,r]:[r])}),cloneWithThen:(e,r)=>(0,W.freeze)({...e,when:e.when?(0,W.freeze)([...e.when.slice(0,-1),F.WhenNode.cloneWithResult(e.when[e.when.length-1],r)]):void 0}),cloneWith:(e,r)=>(0,W.freeze)({...e,...r})});e.s(["CaseNode",0,eU],81442);class ej{#r;constructor(e){this.#r=(0,W.freeze)(e)}when(...e){return new e$({...this.#r,node:eU.cloneWithWhen(this.#r.node,F.WhenNode.create((0,n.parseValueBinaryOperationOrExpression)(e)))})}whenRef(e,r,t){return new e$({...this.#r,node:eU.cloneWithWhen(this.#r.node,F.WhenNode.create((0,n.parseReferentialBinaryOperation)(e,r,t)))})}}class e${#r;constructor(e){this.#r=(0,W.freeze)(e)}then(e){return new eG({...this.#r,node:eU.cloneWithThen(this.#r.node,(0,eE.isSafeImmediateValue)(e)?(0,eE.parseSafeImmediateValue)(e):(0,eE.parseValueExpression)(e))})}thenRef(e){return new eG({...this.#r,node:eU.cloneWithThen(this.#r.node,(0,eh.parseReferenceExpression)(e))})}}class eG{#r;constructor(e){this.#r=(0,W.freeze)(e)}when(...e){return new e$({...this.#r,node:eU.cloneWithWhen(this.#r.node,F.WhenNode.create((0,n.parseValueBinaryOperationOrExpression)(e)))})}whenRef(e,r,t){return new e$({...this.#r,node:eU.cloneWithWhen(this.#r.node,F.WhenNode.create((0,n.parseReferentialBinaryOperation)(e,r,t)))})}else(e){return new eK({...this.#r,node:eU.cloneWith(this.#r.node,{else:(0,eE.isSafeImmediateValue)(e)?(0,eE.parseSafeImmediateValue)(e):(0,eE.parseValueExpression)(e)})})}elseRef(e){return new eK({...this.#r,node:eU.cloneWith(this.#r.node,{else:(0,eh.parseReferenceExpression)(e)})})}end(){return new eq(eU.cloneWith(this.#r.node,{isStatement:!1}))}endCase(){return new eq(eU.cloneWith(this.#r.node,{isStatement:!0}))}}class eK{#r;constructor(e){this.#r=(0,W.freeze)(e)}end(){return new eq(eU.cloneWith(this.#r.node,{isStatement:!1}))}endCase(){return new eq(eU.cloneWith(this.#r.node,{isStatement:!0}))}}},83835,e=>{"use strict";var r=e.i(5292);let t=(0,r.freeze)({is:e=>"JSONPathLegNode"===e.kind,create:(e,t)=>(0,r.freeze)({kind:"JSONPathLegNode",type:e,value:t})});e.s(["JSONPathLegNode",0,t])},85381,16745,71731,e=>{"use strict";e.s(["isExpressionOrFactory",()=>J,"parseAliasedExpression",()=>D,"parseExpression",()=>M],85381);var r=e.i(69372),t=e.i(52369);e.s(["createExpressionBuilder",()=>F,"expressionBuilder",()=>V],71731);var o=e.i(22284),i=e.i(34067),n=e.i(27952),s=e.i(15249),a=e.i(72127),d=e.i(19834),u=e.i(23669),p=e.i(56802),l=e.i(85569),h=e.i(36662),c=e.i(12365),f=e.i(43097),N=e.i(97078),m=e.i(70420),y=e.i(81442),w=e.i(5292),g=e.i(77373),O=e.i(55514),x=e.i(55e3),W=e.i(83835),b=e.i(5114),q=e.i(17708),z=e.i(84480);let S=/^#-\d+$/;class k{#W;constructor(e){this.#W=e}at(e){if("number"!=typeof e&&"string"!=typeof e||"number"==typeof e&&!Number.isInteger(e)||"string"==typeof e&&"last"!==e&&!S.test(e))throw Error(`Unexpected index value in .at(...): ${e}`);return this.#k("ArrayLocation",e)}key(e){return this.#k("Member",e)}#k(e,r){return new E(q.JSONReferenceNode.is(this.#W)?q.JSONReferenceNode.cloneWithTraversal(this.#W,b.JSONPathNode.is(this.#W.traversal)?b.JSONPathNode.cloneWithLeg(this.#W.traversal,W.JSONPathLegNode.create(e,r)):x.JSONOperatorChainNode.cloneWithValue(this.#W.traversal,z.ValueNode.createImmediate(r))):b.JSONPathNode.cloneWithLeg(this.#W,W.JSONPathLegNode.create(e,r)))}}class E extends k{#W;constructor(e){super(e),this.#W=e}get expressionType(){}as(e){return new I(this,e)}$castTo(){return new E(this.#W)}$notNull(){return new E(this.#W)}toOperationNode(){return this.#W}}class I{#E;#q;constructor(e,r){this.#E=e,this.#q=r}get expression(){return this.#E}get alias(){return this.#q}toOperationNode(){return g.AliasNode.create(this.#E.toOperationNode(),(0,t.isOperationNodeSource)(this.#q)?this.#q.toOperationNode():O.IdentifierNode.create(this.#q))}}var v=e.i(87974),C=e.i(39001);let B=(0,w.freeze)({is:e=>"TupleNode"===e.kind,create:e=>(0,w.freeze)({kind:"TupleNode",values:(0,w.freeze)(e)})}),Q=(0,w.freeze)({bigint:!0,bigserial:!0,binary:!0,blob:!0,boolean:!0,bytea:!0,char:!0,date:!0,datemultirange:!0,daterange:!0,datetime:!0,datetime2:!0,decimal:!0,"double precision":!0,float4:!0,float8:!0,int2:!0,int4:!0,int4multirange:!0,int4range:!0,int8:!0,int8multirange:!0,int8range:!0,integer:!0,json:!0,jsonb:!0,numeric:!0,nummultirange:!0,numrange:!0,real:!0,serial:!0,smallint:!0,text:!0,time:!0,timestamp:!0,timestamptz:!0,timetz:!0,tsmultirange:!0,tsrange:!0,tstzmultirange:!0,tstzrange:!0,uuid:!0,varbinary:!0,varchar:!0}),T=(0,w.freeze)([/^varchar\(\d+\)$/,/^char\(\d+\)$/,/^decimal\(\d+, \d+\)$/,/^numeric\(\d+, \d+\)$/,/^binary\(\d+\)$/,/^datetime\(\d+\)$/,/^time\(\d+\)$/,/^timetz\(\d+\)$/,/^timestamp\(\d+\)$/,/^timestamptz\(\d+\)$/,/^datetime2\(\d+\)$/,/^varbinary\(\d+\)$/]),R=(0,w.freeze)({is:e=>"DataTypeNode"===e.kind,create:e=>(0,w.freeze)({kind:"DataTypeNode",dataType:e})});function A(e){if((0,t.isOperationNodeSource)(e))return e.toOperationNode();if(Q[e]||T.some(r=>r.test(e)))return R.create(e);throw Error(`invalid column data type ${JSON.stringify(e)}`)}e.s(["parseDataTypeExpression",0,A],16745);let L=(0,w.freeze)({is:e=>"CastNode"===e.kind,create:(e,r)=>(0,w.freeze)({kind:"CastNode",expression:e,dataType:r})});function F(e=N.NOOP_QUERY_EXECUTOR){function r(e,r){return new l.ExpressionWrapper((0,c.parseUnaryOperation)(e,r))}let t=Object.assign(function(e,r,t){return new l.ExpressionWrapper((0,u.parseValueBinaryOperation)(e,r,t))},{fn:void 0,eb:void 0,selectFrom:r=>(0,o.createSelectQueryBuilder)({queryId:(0,s.createQueryId)(),executor:e,queryNode:i.SelectQueryNode.createFrom((0,n.parseTableExpressionOrList)(r))}),case:e=>new m.CaseBuilder({node:y.CaseNode.create((0,w.isUndefined)(e)?void 0:(0,d.parseReferenceExpression)(e))}),ref:(e,r)=>(0,w.isUndefined)(r)?new l.ExpressionWrapper((0,d.parseStringReference)(e)):new k((0,d.parseJSONReference)(e,r)),jsonPath:()=>new k(b.JSONPathNode.create()),table:e=>new l.ExpressionWrapper((0,n.parseTable)(e)),val:e=>new l.ExpressionWrapper((0,f.parseValueExpression)(e)),refTuple:(...e)=>new l.ExpressionWrapper(B.create(e.map(d.parseReferenceExpression))),tuple:(...e)=>new l.ExpressionWrapper(B.create(e.map(f.parseValueExpression))),lit:e=>new l.ExpressionWrapper((0,f.parseSafeImmediateValue)(e)),unary:r,not:e=>r("not",e),exists:e=>r("exists",e),neg:e=>r("-",e),between:(e,r,t)=>new l.ExpressionWrapper(v.BinaryOperationNode.create((0,d.parseReferenceExpression)(e),h.OperatorNode.create("between"),C.AndNode.create((0,f.parseValueExpression)(r),(0,f.parseValueExpression)(t)))),betweenSymmetric:(e,r,t)=>new l.ExpressionWrapper(v.BinaryOperationNode.create((0,d.parseReferenceExpression)(e),h.OperatorNode.create("between symmetric"),C.AndNode.create((0,f.parseValueExpression)(r),(0,f.parseValueExpression)(t)))),and:e=>new l.ExpressionWrapper((0,w.isReadonlyArray)(e)?(0,u.parseFilterList)(e,"and"):(0,u.parseFilterObject)(e,"and")),or:e=>new l.ExpressionWrapper((0,w.isReadonlyArray)(e)?(0,u.parseFilterList)(e,"or"):(0,u.parseFilterObject)(e,"or")),parens(...e){let r=(0,u.parseValueBinaryOperationOrExpression)(e);return new l.ExpressionWrapper(p.ParensNode.is(r)?r:p.ParensNode.create(r))},cast:(e,r)=>new l.ExpressionWrapper(L.create((0,d.parseReferenceExpression)(e),A(r)))});return t.fn=(0,a.createFunctionModule)(),t.eb=t,t}function V(e){return F()}function M(e){if((0,t.isOperationNodeSource)(e))return e.toOperationNode();if((0,w.isFunction)(e))return e(F()).toOperationNode();throw Error(`invalid expression: ${JSON.stringify(e)}`)}function D(e){if((0,t.isOperationNodeSource)(e))return e.toOperationNode();if((0,w.isFunction)(e))return e(F()).toOperationNode();throw Error(`invalid aliased expression: ${JSON.stringify(e)}`)}function J(e){return(0,r.isExpression)(e)||(0,r.isAliasedExpression)(e)||(0,w.isFunction)(e)}},27952,821,e=>{"use strict";e.s(["parseAliasedTable",()=>h,"parseTable",()=>c,"parseTableExpression",()=>l,"parseTableExpressionOrList",()=>p],27952);var r=e.i(5292),t=e.i(77373),o=e.i(39328),i=e.i(85381),n=e.i(55514);e.s(["DynamicTableBuilder",()=>a,"isAliasedDynamicTableBuilder",()=>u],821);var s=e.i(52369);class a{#I;get table(){return this.#I}constructor(e){this.#I=e}as(e){return new d(this.#I,e)}}class d{#I;#q;get table(){return this.#I}get alias(){return this.#q}constructor(e,r){this.#I=e,this.#q=r}toOperationNode(){return t.AliasNode.create(c(this.#I),n.IdentifierNode.create(this.#q))}}function u(e){return(0,r.isObject)(e)&&(0,s.isOperationNodeSource)(e)&&(0,r.isString)(e.table)&&(0,r.isString)(e.alias)}function p(e){return(0,r.isReadonlyArray)(e)?e.map(e=>l(e)):[l(e)]}function l(e){return(0,r.isString)(e)?h(e):u(e)?e.toOperationNode():(0,i.parseAliasedExpression)(e)}function h(e){let r=" as ";if(!e.includes(r))return c(e);{let[o,i]=e.split(r).map(f);return t.AliasNode.create(c(o),n.IdentifierNode.create(i))}}function c(e){if(!e.includes("."))return o.TableNode.create(e);{let[r,t]=e.split(".").map(f);return o.TableNode.createWithSchema(r,t)}}function f(e){return e.trim()}},29401,e=>{"use strict";var r=e.i(55514),t=e.i(52369),o=e.i(3731),i=e.i(84480),n=e.i(19834),s=e.i(27952),a=e.i(43097),d=e.i(15249),u=e.i(77373),p=e.i(5292),l=e.i(97078);class h{#r;constructor(e){this.#r=(0,p.freeze)(e)}get expressionType(){}get isRawBuilder(){return!0}as(e){return new f(this,e)}$castTo(){return new h({...this.#r})}$notNull(){return new h(this.#r)}withPlugin(e){return new h({...this.#r,plugins:void 0!==this.#r.plugins?(0,p.freeze)([...this.#r.plugins,e]):(0,p.freeze)([e])})}toOperationNode(){return this.#v(this.#C())}compile(e){return this.#B(this.#C(e))}async execute(e,r){let t=this.#C(e);return t.executeQuery(this.#B(t),r)}#C(e){let r=void 0!==e?e.getExecutor():l.NOOP_QUERY_EXECUTOR;return void 0!==this.#r.plugins?r.withPlugins(this.#r.plugins):r}#v(e){return e.transformQuery(this.#r.rawNode,this.#r.queryId)}#B(e){return e.compileQuery(this.#v(e),this.#r.queryId)}}function c(e){return new h(e)}class f{#Q;#q;constructor(e,r){this.#Q=e,this.#q=r}get expression(){return this.#Q}get alias(){return this.#q}get rawBuilder(){return this.#Q}toOperationNode(){return u.AliasNode.create(this.#Q.toOperationNode(),(0,t.isOperationNodeSource)(this.#q)?this.#q.toOperationNode():r.IdentifierNode.create(this.#q))}}let N=Object.assign((e,...r)=>c({queryId:(0,d.createQueryId)(),rawNode:o.RawNode.create(e,r?.map(m)??[])}),{ref:e=>c({queryId:(0,d.createQueryId)(),rawNode:o.RawNode.createWithChild((0,n.parseStringReference)(e))}),val:e=>c({queryId:(0,d.createQueryId)(),rawNode:o.RawNode.createWithChild((0,a.parseValueExpression)(e))}),table:e=>c({queryId:(0,d.createQueryId)(),rawNode:o.RawNode.createWithChild((0,s.parseTable)(e))}),id(...e){let t=Array(e.length+1).fill(".");return t[0]="",t[t.length-1]="",c({queryId:(0,d.createQueryId)(),rawNode:o.RawNode.create(t,e.map(r.IdentifierNode.create))})},lit:e=>c({queryId:(0,d.createQueryId)(),rawNode:o.RawNode.createWithChild(i.ValueNode.createImmediate(e))}),raw:e=>c({queryId:(0,d.createQueryId)(),rawNode:o.RawNode.createWithSql(e)}),join(e,r=N`, `){let t=Array(Math.max(2*e.length-1,0)),i=r.toOperationNode();for(let r=0;r<e.length;++r)t[2*r]=m(e[r]),r!==e.length-1&&(t[2*r+1]=i);return c({queryId:(0,d.createQueryId)(),rawNode:o.RawNode.createWithChildren(t)})}});function m(e){return(0,t.isOperationNodeSource)(e)?e.toOperationNode():(0,a.parseValueExpression)(e)}e.s(["sql",0,N],29401)},50162,e=>{"use strict";var r=e.i(3731),t=e.i(5292),o=e.i(15249);let i=(0,t.freeze)({raw:(e,i=[])=>(0,t.freeze)({sql:e,query:r.RawNode.createWithSql(e),parameters:(0,t.freeze)(i),queryId:(0,o.createQueryId)()})});e.s(["CompiledQuery",0,i])}];
2
2
 
3
3
  //# sourceMappingURL=0m4a_kysely_dist_095p8vu._.js.map
@@ -0,0 +1,3 @@
1
+ module.exports=[53635,s=>{"use strict";s.s([])}];
2
+
3
+ //# sourceMappingURL=0ssw__next-internal_server_app_%28dashboard%29_api_v1_open-targets_route_actions_1z-vd4m.js.map
@@ -0,0 +1,3 @@
1
+ module.exports=[41460,s=>{"use strict";s.s([])}];
2
+
3
+ //# sourceMappingURL=1jcg_server_app_%28dashboard%29_api_v1_boxes_%5Bid%5D_open_route_actions_1agwl8h.js.map
@@ -0,0 +1,3 @@
1
+ module.exports=[64993,s=>{"use strict";s.s([])}];
2
+
3
+ //# sourceMappingURL=1jcg_server_app_%28dashboard%29_api_v1_boxes_%5Bid%5D_rename_route_actions_0mf3a9p.js.map