@leanspec/ui 0.2.5-dev.20251120072524 → 0.2.5-dev.20251120093243

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 (338) hide show
  1. package/.next/standalone/packages/ui/.next/BUILD_ID +1 -1
  2. package/.next/standalone/packages/ui/.next/app-path-routes-manifest.json +9 -0
  3. package/.next/standalone/packages/ui/.next/build-manifest.json +7 -6
  4. package/.next/standalone/packages/ui/.next/prerender-manifest.json +28 -3
  5. package/.next/standalone/packages/ui/.next/routes-manifest.json +71 -0
  6. package/.next/standalone/packages/ui/.next/server/app/_global-error/page/build-manifest.json +5 -4
  7. package/.next/standalone/packages/ui/.next/server/app/_global-error/page.js +1 -1
  8. package/.next/standalone/packages/ui/.next/server/app/_global-error/page.js.nft.json +1 -1
  9. package/.next/standalone/packages/ui/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  10. package/.next/standalone/packages/ui/.next/server/app/_global-error.html +2 -2
  11. package/.next/standalone/packages/ui/.next/server/app/_global-error.rsc +1 -1
  12. package/.next/standalone/packages/ui/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  13. package/.next/standalone/packages/ui/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  14. package/.next/standalone/packages/ui/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  15. package/.next/standalone/packages/ui/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  16. package/.next/standalone/packages/ui/.next/server/app/_not-found/page/build-manifest.json +5 -4
  17. package/.next/standalone/packages/ui/.next/server/app/_not-found/page.js +2 -2
  18. package/.next/standalone/packages/ui/.next/server/app/_not-found/page.js.nft.json +1 -1
  19. package/.next/standalone/packages/ui/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  20. package/.next/standalone/packages/ui/.next/server/app/_not-found.html +2 -2
  21. package/.next/standalone/packages/ui/.next/server/app/_not-found.rsc +20 -19
  22. package/.next/standalone/packages/ui/.next/server/app/_not-found.segments/_full.segment.rsc +20 -19
  23. package/.next/standalone/packages/ui/.next/server/app/_not-found.segments/_index.segment.rsc +26 -25
  24. package/.next/standalone/packages/ui/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +3 -3
  25. package/.next/standalone/packages/ui/.next/server/app/_not-found.segments/_not-found.segment.rsc +3 -3
  26. package/.next/standalone/packages/ui/.next/server/app/_not-found.segments/_tree.segment.rsc +5 -5
  27. package/.next/standalone/packages/ui/.next/server/app/api/local-projects/[id]/route.js +2 -3
  28. package/.next/standalone/packages/ui/.next/server/app/api/local-projects/[id]/route.js.nft.json +1 -1
  29. package/.next/standalone/packages/ui/.next/server/app/api/local-projects/discover/route.js +2 -3
  30. package/.next/standalone/packages/ui/.next/server/app/api/local-projects/discover/route.js.nft.json +1 -1
  31. package/.next/standalone/packages/ui/.next/server/app/api/local-projects/list-directory/route/app-paths-manifest.json +3 -0
  32. package/.next/standalone/packages/ui/.next/server/app/api/local-projects/list-directory/route/build-manifest.json +11 -0
  33. package/.next/standalone/packages/ui/.next/server/app/api/local-projects/list-directory/route/server-reference-manifest.json +4 -0
  34. package/.next/standalone/packages/ui/.next/server/app/api/local-projects/list-directory/route.js +6 -0
  35. package/.next/standalone/packages/ui/.next/server/app/api/local-projects/list-directory/route.js.map +5 -0
  36. package/.next/standalone/packages/ui/.next/server/app/api/local-projects/list-directory/route.js.nft.json +1 -0
  37. package/.next/standalone/packages/ui/.next/server/app/api/local-projects/list-directory/route_client-reference-manifest.js +2 -0
  38. package/.next/standalone/packages/ui/.next/server/app/api/local-projects/route.js +2 -3
  39. package/.next/standalone/packages/ui/.next/server/app/api/local-projects/route.js.nft.json +1 -1
  40. package/.next/standalone/packages/ui/.next/server/app/api/projects/[id]/route/app-paths-manifest.json +3 -0
  41. package/.next/standalone/packages/ui/.next/server/app/api/projects/[id]/route/build-manifest.json +11 -0
  42. package/.next/standalone/packages/ui/.next/server/app/api/projects/[id]/route/server-reference-manifest.json +4 -0
  43. package/.next/standalone/packages/ui/.next/server/app/api/projects/[id]/route.js +8 -0
  44. package/.next/standalone/packages/ui/.next/server/app/api/projects/[id]/route.js.map +5 -0
  45. package/.next/standalone/packages/ui/.next/server/app/api/projects/[id]/route.js.nft.json +1 -0
  46. package/.next/standalone/packages/ui/.next/server/app/api/projects/[id]/route_client-reference-manifest.js +2 -0
  47. package/.next/standalone/packages/ui/.next/server/app/api/projects/[id]/specs/[spec]/route/app-paths-manifest.json +3 -0
  48. package/.next/standalone/packages/ui/.next/server/app/api/projects/[id]/specs/[spec]/route/build-manifest.json +11 -0
  49. package/.next/standalone/packages/ui/.next/server/app/api/projects/[id]/specs/[spec]/route/server-reference-manifest.json +4 -0
  50. package/.next/standalone/packages/ui/.next/server/app/api/projects/[id]/specs/[spec]/route.js +9 -0
  51. package/.next/standalone/packages/ui/.next/server/app/api/projects/[id]/specs/[spec]/route.js.map +5 -0
  52. package/.next/standalone/packages/ui/.next/server/app/api/projects/[id]/specs/[spec]/route.js.nft.json +1 -0
  53. package/.next/standalone/packages/ui/.next/server/app/api/projects/[id]/specs/[spec]/route_client-reference-manifest.js +2 -0
  54. package/.next/standalone/packages/ui/.next/server/app/api/projects/[id]/specs/[spec]/status/route/app-paths-manifest.json +3 -0
  55. package/.next/standalone/packages/ui/.next/server/app/api/projects/[id]/specs/[spec]/status/route/build-manifest.json +11 -0
  56. package/.next/standalone/packages/ui/.next/server/app/api/projects/[id]/specs/[spec]/status/route/server-reference-manifest.json +4 -0
  57. package/.next/standalone/packages/ui/.next/server/app/api/projects/[id]/specs/[spec]/status/route.js +8 -0
  58. package/.next/standalone/packages/ui/.next/server/app/api/projects/[id]/specs/[spec]/status/route.js.map +5 -0
  59. package/.next/standalone/packages/ui/.next/server/app/api/projects/[id]/specs/[spec]/status/route.js.nft.json +1 -0
  60. package/.next/standalone/packages/ui/.next/server/app/api/projects/[id]/specs/[spec]/status/route_client-reference-manifest.js +2 -0
  61. package/.next/standalone/packages/ui/.next/server/app/api/projects/[id]/specs/route.js +4 -3
  62. package/.next/standalone/packages/ui/.next/server/app/api/projects/[id]/specs/route.js.nft.json +1 -1
  63. package/.next/standalone/packages/ui/.next/server/app/api/projects/[id]/stats/route/app-paths-manifest.json +3 -0
  64. package/.next/standalone/packages/ui/.next/server/app/api/projects/[id]/stats/route/build-manifest.json +11 -0
  65. package/.next/standalone/packages/ui/.next/server/app/api/projects/[id]/stats/route/server-reference-manifest.json +4 -0
  66. package/.next/standalone/packages/ui/.next/server/app/api/projects/[id]/stats/route.js +8 -0
  67. package/.next/standalone/packages/ui/.next/server/app/api/projects/[id]/stats/route.js.map +5 -0
  68. package/.next/standalone/packages/ui/.next/server/app/api/projects/[id]/stats/route.js.nft.json +1 -0
  69. package/.next/standalone/packages/ui/.next/server/app/api/projects/[id]/stats/route_client-reference-manifest.js +2 -0
  70. package/.next/standalone/packages/ui/.next/server/app/api/projects/route.js +2 -2
  71. package/.next/standalone/packages/ui/.next/server/app/api/projects/route.js.nft.json +1 -1
  72. package/.next/standalone/packages/ui/.next/server/app/api/revalidate/route.js +3 -4
  73. package/.next/standalone/packages/ui/.next/server/app/api/revalidate/route.js.nft.json +1 -1
  74. package/.next/standalone/packages/ui/.next/server/app/api/specs/[id]/dependency-graph/route.js +3 -4
  75. package/.next/standalone/packages/ui/.next/server/app/api/specs/[id]/dependency-graph/route.js.nft.json +1 -1
  76. package/.next/standalone/packages/ui/.next/server/app/api/specs/[id]/route.js +3 -4
  77. package/.next/standalone/packages/ui/.next/server/app/api/specs/[id]/route.js.nft.json +1 -1
  78. package/.next/standalone/packages/ui/.next/server/app/api/specs/[id]/status/route.js +3 -4
  79. package/.next/standalone/packages/ui/.next/server/app/api/specs/[id]/status/route.js.nft.json +1 -1
  80. package/.next/standalone/packages/ui/.next/server/app/api/specs/[id]/subspecs/[file]/route.js +3 -4
  81. package/.next/standalone/packages/ui/.next/server/app/api/specs/[id]/subspecs/[file]/route.js.nft.json +1 -1
  82. package/.next/standalone/packages/ui/.next/server/app/api/stats/route.js +3 -4
  83. package/.next/standalone/packages/ui/.next/server/app/api/stats/route.js.nft.json +1 -1
  84. package/.next/standalone/packages/ui/.next/server/app/page/build-manifest.json +5 -4
  85. package/.next/standalone/packages/ui/.next/server/app/page.js +2 -2
  86. package/.next/standalone/packages/ui/.next/server/app/page.js.nft.json +1 -1
  87. package/.next/standalone/packages/ui/.next/server/app/page_client-reference-manifest.js +1 -1
  88. package/.next/standalone/packages/ui/.next/server/app/projects/[projectId]/page/app-paths-manifest.json +3 -0
  89. package/.next/standalone/packages/ui/.next/server/app/projects/[projectId]/page/build-manifest.json +18 -0
  90. package/.next/standalone/packages/ui/.next/server/app/projects/[projectId]/page/next-font-manifest.json +6 -0
  91. package/.next/standalone/packages/ui/.next/server/app/projects/[projectId]/page/react-loadable-manifest.json +1 -0
  92. package/.next/standalone/packages/ui/.next/server/app/projects/[projectId]/page/server-reference-manifest.json +4 -0
  93. package/.next/standalone/packages/ui/.next/server/app/projects/[projectId]/page.js +21 -0
  94. package/.next/standalone/packages/ui/.next/server/app/projects/[projectId]/page.js.map +5 -0
  95. package/.next/standalone/packages/ui/.next/server/app/projects/[projectId]/page.js.nft.json +1 -0
  96. package/.next/standalone/packages/ui/.next/server/app/projects/[projectId]/page_client-reference-manifest.js +2 -0
  97. package/.next/standalone/packages/ui/.next/server/app/projects/[projectId]/specs/[specId]/page/app-paths-manifest.json +3 -0
  98. package/.next/standalone/packages/ui/.next/server/app/projects/[projectId]/specs/[specId]/page/build-manifest.json +18 -0
  99. package/.next/standalone/packages/ui/.next/server/app/projects/[projectId]/specs/[specId]/page/next-font-manifest.json +6 -0
  100. package/.next/standalone/packages/ui/.next/server/app/projects/[projectId]/specs/[specId]/page/react-loadable-manifest.json +1 -0
  101. package/.next/standalone/packages/ui/.next/server/app/projects/[projectId]/specs/[specId]/page/server-reference-manifest.json +4 -0
  102. package/.next/standalone/packages/ui/.next/server/app/projects/[projectId]/specs/[specId]/page.js +21 -0
  103. package/.next/standalone/packages/ui/.next/server/app/projects/[projectId]/specs/[specId]/page.js.map +5 -0
  104. package/.next/standalone/packages/ui/.next/server/app/projects/[projectId]/specs/[specId]/page.js.nft.json +1 -0
  105. package/.next/standalone/packages/ui/.next/server/app/projects/[projectId]/specs/[specId]/page_client-reference-manifest.js +2 -0
  106. package/.next/standalone/packages/ui/.next/server/app/projects/[projectId]/specs/page/app-paths-manifest.json +3 -0
  107. package/.next/standalone/packages/ui/.next/server/app/projects/[projectId]/specs/page/build-manifest.json +18 -0
  108. package/.next/standalone/packages/ui/.next/server/app/projects/[projectId]/specs/page/next-font-manifest.json +6 -0
  109. package/.next/standalone/packages/ui/.next/server/app/projects/[projectId]/specs/page/react-loadable-manifest.json +1 -0
  110. package/.next/standalone/packages/ui/.next/server/app/projects/[projectId]/specs/page/server-reference-manifest.json +4 -0
  111. package/.next/standalone/packages/ui/.next/server/app/projects/[projectId]/specs/page.js +20 -0
  112. package/.next/standalone/packages/ui/.next/server/app/projects/[projectId]/specs/page.js.map +5 -0
  113. package/.next/standalone/packages/ui/.next/server/app/projects/[projectId]/specs/page.js.nft.json +1 -0
  114. package/.next/standalone/packages/ui/.next/server/app/projects/[projectId]/specs/page_client-reference-manifest.js +2 -0
  115. package/.next/standalone/packages/ui/.next/server/app/projects/page/app-paths-manifest.json +3 -0
  116. package/.next/standalone/packages/ui/.next/server/app/projects/page/build-manifest.json +18 -0
  117. package/.next/standalone/packages/ui/.next/server/app/projects/page/next-font-manifest.json +6 -0
  118. package/.next/standalone/packages/ui/.next/server/app/projects/page/react-loadable-manifest.json +1 -0
  119. package/.next/standalone/packages/ui/.next/server/app/projects/page/server-reference-manifest.json +4 -0
  120. package/.next/standalone/packages/ui/.next/server/app/projects/page.js +19 -0
  121. package/.next/standalone/packages/ui/.next/server/app/projects/page.js.map +5 -0
  122. package/.next/standalone/packages/ui/.next/server/app/projects/page.js.nft.json +1 -0
  123. package/.next/standalone/packages/ui/.next/server/app/projects/page_client-reference-manifest.js +2 -0
  124. package/.next/standalone/packages/ui/.next/server/app/projects.html +2 -0
  125. package/.next/standalone/packages/ui/.next/server/app/projects.meta +14 -0
  126. package/.next/standalone/packages/ui/.next/server/app/projects.rsc +34 -0
  127. package/.next/standalone/packages/ui/.next/server/app/projects.segments/_full.segment.rsc +34 -0
  128. package/.next/standalone/packages/ui/.next/server/app/projects.segments/_index.segment.rsc +27 -0
  129. package/.next/standalone/packages/ui/.next/server/app/projects.segments/_tree.segment.rsc +9 -0
  130. package/.next/standalone/packages/ui/.next/server/app/projects.segments/projects/__PAGE__.segment.rsc +9 -0
  131. package/.next/standalone/packages/ui/.next/server/app/projects.segments/projects.segment.rsc +4 -0
  132. package/.next/standalone/packages/ui/.next/server/app/specs/[id]/page/build-manifest.json +5 -4
  133. package/.next/standalone/packages/ui/.next/server/app/specs/[id]/page.js +4 -4
  134. package/.next/standalone/packages/ui/.next/server/app/specs/[id]/page.js.nft.json +1 -1
  135. package/.next/standalone/packages/ui/.next/server/app/specs/[id]/page_client-reference-manifest.js +1 -1
  136. package/.next/standalone/packages/ui/.next/server/app/specs/page/build-manifest.json +5 -4
  137. package/.next/standalone/packages/ui/.next/server/app/specs/page.js +2 -2
  138. package/.next/standalone/packages/ui/.next/server/app/specs/page.js.nft.json +1 -1
  139. package/.next/standalone/packages/ui/.next/server/app/specs/page_client-reference-manifest.js +1 -1
  140. package/.next/standalone/packages/ui/.next/server/app/stats/page/build-manifest.json +5 -4
  141. package/.next/standalone/packages/ui/.next/server/app/stats/page.js +2 -2
  142. package/.next/standalone/packages/ui/.next/server/app/stats/page.js.nft.json +1 -1
  143. package/.next/standalone/packages/ui/.next/server/app/stats/page_client-reference-manifest.js +1 -1
  144. package/.next/standalone/packages/ui/.next/server/app-paths-manifest.json +9 -0
  145. package/.next/standalone/packages/ui/.next/server/chunks/6681a__next-internal_server_app_api_projects_[id]_specs_[spec]_route_actions_d018d9e0.js +3 -0
  146. package/.next/standalone/packages/ui/.next/server/chunks/730ea_ui__next-internal_server_app_api_projects_[id]_stats_route_actions_a0bb04a8.js +3 -0
  147. package/.next/standalone/packages/ui/.next/server/chunks/[root-of-the-server]__0fbfea15._.js +3 -0
  148. package/.next/standalone/packages/ui/.next/server/chunks/[root-of-the-server]__126dea7b._.js +3 -0
  149. package/.next/standalone/packages/ui/.next/server/chunks/[root-of-the-server]__1f037512._.js +3 -0
  150. package/.next/standalone/packages/ui/.next/server/chunks/[root-of-the-server]__3559376c._.js +21 -0
  151. package/.next/standalone/packages/ui/.next/server/chunks/[root-of-the-server]__548e27d4._.js +3 -0
  152. package/.next/standalone/packages/ui/.next/server/chunks/{[root-of-the-server]__d293d769._.js → [root-of-the-server]__65667b70._.js} +2 -2
  153. package/.next/standalone/packages/ui/.next/server/chunks/[root-of-the-server]__675a763e._.js +3 -0
  154. package/.next/standalone/packages/ui/.next/server/chunks/{[root-of-the-server]__c83721f3._.js → [root-of-the-server]__803d07f0._.js} +2 -2
  155. package/.next/standalone/packages/ui/.next/server/chunks/[root-of-the-server]__8075fe29._.js +3 -0
  156. package/.next/standalone/packages/ui/.next/server/chunks/[root-of-the-server]__8233e09b._.js +3 -0
  157. package/.next/standalone/packages/ui/.next/server/chunks/[root-of-the-server]__84cdc14a._.js +3 -0
  158. package/.next/standalone/packages/ui/.next/server/chunks/[root-of-the-server]__9ce722b4._.js +3 -0
  159. package/.next/standalone/packages/ui/.next/server/chunks/[root-of-the-server]__a2d7cbed._.js +3 -0
  160. package/.next/standalone/packages/ui/.next/server/chunks/[root-of-the-server]__aa677b0d._.js +3 -0
  161. package/.next/standalone/packages/ui/.next/server/chunks/[root-of-the-server]__ac744182._.js +3 -0
  162. package/.next/standalone/packages/ui/.next/server/chunks/[root-of-the-server]__bb9fca84._.js +4 -0
  163. package/.next/standalone/packages/ui/.next/server/chunks/{[root-of-the-server]__fad83967._.js → [root-of-the-server]__bdc3963a._.js} +2 -2
  164. package/.next/standalone/packages/ui/.next/server/chunks/{[root-of-the-server]__57791a48._.js → [root-of-the-server]__f5c6d6b8._.js} +2 -2
  165. package/.next/standalone/packages/ui/.next/server/chunks/[root-of-the-server]__fb91986f._.js +3 -0
  166. package/.next/standalone/packages/ui/.next/server/chunks/f825c_server_app_api_local-projects_list-directory_route_actions_d620ec1a.js +3 -0
  167. package/.next/standalone/packages/ui/.next/server/chunks/f825c_server_app_api_projects_[id]_specs_[spec]_status_route_actions_e9f1bdc5.js +3 -0
  168. package/.next/standalone/packages/ui/.next/server/chunks/packages_ui__next-internal_server_app_api_projects_[id]_route_actions_bff49675.js +3 -0
  169. package/.next/standalone/packages/ui/.next/server/chunks/packages_ui_src_lib_db_index_ts_556307fa._.js +64 -5
  170. package/.next/standalone/packages/ui/.next/server/chunks/packages_ui_src_lib_specs_sources_database-source_ts_0bd881ee._.js +3 -0
  171. package/.next/standalone/packages/ui/.next/server/chunks/packages_ui_src_lib_specs_sources_database-source_ts_baa0160d._.js +3 -0
  172. package/.next/standalone/packages/ui/.next/server/chunks/ssr/38a22_sonner_dist_index_mjs_207730fe._.js +3 -0
  173. package/.next/standalone/packages/ui/.next/server/chunks/ssr/6e9bd_next_dist_7af75658._.js +3 -0
  174. package/.next/standalone/packages/ui/.next/server/chunks/ssr/{_a5b58449._.js → 6e9bd_next_dist_df5dcbe9._.js} +2 -2
  175. package/.next/standalone/packages/ui/.next/server/chunks/ssr/730ea_ui__next-internal_server_app_projects_[projectId]_specs_page_actions_82e32fe4.js +3 -0
  176. package/.next/standalone/packages/ui/.next/server/chunks/ssr/[root-of-the-server]__01bfc8ff._.js +3 -0
  177. package/.next/standalone/packages/ui/.next/server/chunks/ssr/[root-of-the-server]__1d0c2012._.js +1 -1
  178. package/.next/standalone/packages/ui/.next/server/chunks/ssr/[root-of-the-server]__4ec37765._.js +3 -0
  179. package/.next/standalone/packages/ui/.next/server/chunks/ssr/{[root-of-the-server]__1af33d49._.js → [root-of-the-server]__50122e7e._.js} +2 -2
  180. package/.next/standalone/packages/ui/.next/server/chunks/ssr/{[root-of-the-server]__34ab4950._.js → [root-of-the-server]__5382b397._.js} +2 -2
  181. package/.next/standalone/packages/ui/.next/server/chunks/ssr/[root-of-the-server]__73f60f12._.js +7 -0
  182. package/.next/standalone/packages/ui/.next/server/chunks/ssr/[root-of-the-server]__88a691ee._.js +3 -0
  183. package/.next/standalone/packages/ui/.next/server/chunks/ssr/[root-of-the-server]__a7ae8552._.js +7 -0
  184. package/.next/standalone/packages/ui/.next/server/chunks/ssr/[root-of-the-server]__bdbbba01._.js +3 -0
  185. package/.next/standalone/packages/ui/.next/server/chunks/ssr/[root-of-the-server]__c592f5d1._.js +3 -0
  186. package/.next/standalone/packages/ui/.next/server/chunks/ssr/[root-of-the-server]__cc589a54._.js +3 -0
  187. package/.next/standalone/packages/ui/.next/server/chunks/ssr/[root-of-the-server]__ec5b96a5._.js +3 -0
  188. package/.next/standalone/packages/ui/.next/server/chunks/ssr/{[root-of-the-server]__cbbbfb5d._.js → [root-of-the-server]__fd80e4dd._.js} +2 -2
  189. package/.next/standalone/packages/ui/.next/server/chunks/ssr/_000dd317._.js +1 -1
  190. package/.next/standalone/packages/ui/.next/server/chunks/ssr/_196b5a83._.js +3 -0
  191. package/.next/standalone/packages/ui/.next/server/chunks/ssr/_39562b2a._.js +4 -0
  192. package/.next/standalone/packages/ui/.next/server/chunks/ssr/_3b617676._.js +1 -1
  193. package/.next/standalone/packages/ui/.next/server/chunks/ssr/_4129cc0f._.js +3 -0
  194. package/.next/standalone/packages/ui/.next/server/chunks/ssr/_6174313a._.js +3 -0
  195. package/.next/standalone/packages/ui/.next/server/chunks/ssr/_6e4dd8b6._.js +3 -0
  196. package/.next/standalone/packages/ui/.next/server/chunks/ssr/_85effc18._.js +4 -0
  197. package/.next/standalone/packages/ui/.next/server/chunks/ssr/_ad8c1e99._.js +1 -1
  198. package/.next/standalone/packages/ui/.next/server/chunks/ssr/_bae6d2b8._.js +4 -0
  199. package/.next/standalone/packages/ui/.next/server/chunks/ssr/_c2f54661._.js +5 -0
  200. package/.next/standalone/packages/ui/.next/server/chunks/ssr/_fdd7780b._.js +4 -0
  201. package/.next/standalone/packages/ui/.next/server/chunks/ssr/f825c_server_app_projects_[projectId]_specs_[specId]_page_actions_22d9c35e.js +3 -0
  202. package/.next/standalone/packages/ui/.next/server/chunks/ssr/node_modules__pnpm_af9d3830._.js +3 -0
  203. package/.next/standalone/packages/ui/.next/server/chunks/ssr/packages_ui__next-internal_server_app_projects_[projectId]_page_actions_f2986585.js +3 -0
  204. package/.next/standalone/packages/ui/.next/server/chunks/ssr/packages_ui__next-internal_server_app_projects_page_actions_715940ea.js +3 -0
  205. package/.next/standalone/packages/ui/.next/server/chunks/ssr/packages_ui_src_app_projects_[projectId]_be242d6c._.js +3 -0
  206. package/.next/standalone/packages/ui/.next/server/chunks/ssr/packages_ui_src_app_projects_[projectId]_project-context-syncer_tsx_7954ea3b._.js +3 -0
  207. package/.next/standalone/packages/ui/.next/server/chunks/ssr/packages_ui_src_app_projects_page_tsx_6e166c8e._.js +3 -0
  208. package/.next/standalone/packages/ui/.next/server/chunks/ssr/packages_ui_src_app_specs_specs-client_tsx_0bb8f8f8._.js +1 -1
  209. package/.next/standalone/packages/ui/.next/server/chunks/ssr/packages_ui_src_components_ui_select_tsx_7e21d40f._.js +3 -0
  210. package/.next/standalone/packages/ui/.next/server/chunks/ssr/packages_ui_src_lib_specs_sources_database-source_ts_f7186c2a._.js +60 -1
  211. package/.next/standalone/packages/ui/.next/server/middleware-build-manifest.js +5 -4
  212. package/.next/standalone/packages/ui/.next/server/pages/404.html +2 -2
  213. package/.next/standalone/packages/ui/.next/server/pages/500.html +2 -2
  214. package/.next/standalone/packages/ui/.next/server/server-reference-manifest.js +1 -1
  215. package/.next/standalone/packages/ui/.next/server/server-reference-manifest.json +1 -1
  216. package/.next/standalone/packages/ui/.next/static/chunks/07f48b316e895080.js +1 -0
  217. package/.next/standalone/packages/ui/.next/static/chunks/0a7be410b438418a.js +1 -0
  218. package/.next/standalone/packages/ui/.next/static/chunks/1089ca88f6bef846.js +1 -0
  219. package/.next/standalone/packages/ui/.next/static/chunks/17471c87082c392c.js +5 -0
  220. package/.next/standalone/packages/ui/.next/static/chunks/220ba5cb8fe4dd69.js +1 -0
  221. package/.next/standalone/packages/ui/.next/static/chunks/35ccd3286e538bd2.js +1 -0
  222. package/.next/standalone/packages/ui/.next/static/chunks/571033caca823138.js +1 -0
  223. package/.next/standalone/packages/ui/.next/static/chunks/5a6fc30cd64085b4.css +1 -0
  224. package/.next/standalone/packages/ui/.next/static/chunks/5c2072ad938de8ed.js +1 -0
  225. package/.next/standalone/packages/ui/.next/static/chunks/843e1dfdc28e1385.js +1 -0
  226. package/.next/standalone/packages/ui/.next/static/chunks/9dad7fd31627df80.js +1 -0
  227. package/.next/standalone/packages/ui/.next/static/chunks/{c3d4d07de959ecf1.js → a055d4b2866ff8d4.js} +1 -1
  228. package/.next/standalone/packages/ui/.next/static/chunks/afb7c5a4255f4081.js +3 -0
  229. package/.next/standalone/packages/ui/.next/static/chunks/{c557ac675be79771.js → b760a3a9c2c8be28.js} +1 -1
  230. package/.next/standalone/packages/ui/.next/static/chunks/dcdd95180149fa10.js +1 -0
  231. package/.next/standalone/packages/ui/.next/static/chunks/ebd89051637b9a47.js +4 -0
  232. package/.next/standalone/packages/ui/.next/static/chunks/f9db24028d8c058e.js +1 -0
  233. package/.next/standalone/packages/ui/.next/static/chunks/fb640f50455ba34f.js +1 -0
  234. package/.next/standalone/packages/ui/.next/static/chunks/turbopack-b9690cacbf9fe48c.js +3 -0
  235. package/.next/standalone/packages/ui/bin/ui.js +17 -7
  236. package/.next/standalone/packages/ui/package.json +2 -1
  237. package/.next/standalone/packages/ui/src/app/api/local-projects/list-directory/route.ts +38 -0
  238. package/.next/standalone/packages/ui/src/app/api/projects/[id]/route.ts +97 -0
  239. package/.next/standalone/packages/ui/src/app/api/projects/[id]/specs/[spec]/route.ts +38 -0
  240. package/.next/standalone/packages/ui/src/app/api/projects/[id]/specs/[spec]/status/route.ts +97 -0
  241. package/.next/standalone/packages/ui/src/app/api/projects/[id]/specs/route.ts +7 -0
  242. package/.next/standalone/packages/ui/src/app/api/projects/[id]/stats/route.ts +19 -0
  243. package/.next/standalone/packages/ui/src/app/api/projects/route.ts +48 -1
  244. package/.next/standalone/packages/ui/src/app/dashboard-client.tsx +67 -6
  245. package/.next/standalone/packages/ui/src/app/layout.tsx +11 -8
  246. package/.next/standalone/packages/ui/src/app/not-found.tsx +1 -1
  247. package/.next/standalone/packages/ui/src/app/projects/[projectId]/layout.tsx +18 -0
  248. package/.next/standalone/packages/ui/src/app/projects/[projectId]/page.tsx +10 -0
  249. package/.next/standalone/packages/ui/src/app/projects/[projectId]/project-context-syncer.tsx +16 -0
  250. package/.next/standalone/packages/ui/src/app/projects/[projectId]/specs/[specId]/page.tsx +34 -0
  251. package/.next/standalone/packages/ui/src/app/projects/[projectId]/specs/page.tsx +20 -0
  252. package/.next/standalone/packages/ui/src/app/projects/page.tsx +156 -0
  253. package/.next/standalone/packages/ui/src/app/specs/specs-client.tsx +7 -2
  254. package/.next/standalone/packages/ui/src/components/create-project-dialog.tsx +139 -0
  255. package/.next/standalone/packages/ui/src/components/directory-picker.tsx +191 -0
  256. package/.next/standalone/packages/ui/src/components/main-sidebar.tsx +4 -0
  257. package/.next/standalone/packages/ui/src/components/project-switcher.tsx +105 -196
  258. package/.next/standalone/packages/ui/src/components/ui/dropdown-menu.tsx +200 -0
  259. package/.next/standalone/packages/ui/src/components/ui/popover.tsx +31 -0
  260. package/.next/standalone/packages/ui/src/contexts/project-context.tsx +10 -6
  261. package/.next/standalone/packages/ui/src/lib/db/index.ts +100 -0
  262. package/.next/standalone/packages/ui/src/lib/projects/registry.ts +77 -3
  263. package/.next/standalone/packages/ui/src/lib/specs/sources/multi-project-source.ts +4 -4
  264. package/.next/standalone/packages/ui/tsconfig.tsbuildinfo +1 -1
  265. package/.next/static/chunks/07f48b316e895080.js +1 -0
  266. package/.next/static/chunks/0a7be410b438418a.js +1 -0
  267. package/.next/static/chunks/1089ca88f6bef846.js +1 -0
  268. package/.next/static/chunks/17471c87082c392c.js +5 -0
  269. package/.next/static/chunks/220ba5cb8fe4dd69.js +1 -0
  270. package/.next/static/chunks/35ccd3286e538bd2.js +1 -0
  271. package/.next/static/chunks/571033caca823138.js +1 -0
  272. package/.next/static/chunks/5a6fc30cd64085b4.css +1 -0
  273. package/.next/static/chunks/5c2072ad938de8ed.js +1 -0
  274. package/.next/static/chunks/843e1dfdc28e1385.js +1 -0
  275. package/.next/static/chunks/9dad7fd31627df80.js +1 -0
  276. package/.next/static/chunks/{c3d4d07de959ecf1.js → a055d4b2866ff8d4.js} +1 -1
  277. package/.next/static/chunks/afb7c5a4255f4081.js +3 -0
  278. package/.next/static/chunks/{c557ac675be79771.js → b760a3a9c2c8be28.js} +1 -1
  279. package/.next/static/chunks/dcdd95180149fa10.js +1 -0
  280. package/.next/static/chunks/ebd89051637b9a47.js +4 -0
  281. package/.next/static/chunks/f9db24028d8c058e.js +1 -0
  282. package/.next/static/chunks/fb640f50455ba34f.js +1 -0
  283. package/.next/static/chunks/turbopack-b9690cacbf9fe48c.js +3 -0
  284. package/bin/ui.js +17 -7
  285. package/package.json +2 -1
  286. package/.next/standalone/packages/ui/.next/server/chunks/[root-of-the-server]__175bef84._.js +0 -3
  287. package/.next/standalone/packages/ui/.next/server/chunks/[root-of-the-server]__4b3c3001._.js +0 -21
  288. package/.next/standalone/packages/ui/.next/server/chunks/[root-of-the-server]__4b77d48f._.js +0 -3
  289. package/.next/standalone/packages/ui/.next/server/chunks/[root-of-the-server]__60b6d106._.js +0 -3
  290. package/.next/standalone/packages/ui/.next/server/chunks/[root-of-the-server]__a627840f._.js +0 -3
  291. package/.next/standalone/packages/ui/.next/server/chunks/[root-of-the-server]__beb134c0._.js +0 -3
  292. package/.next/standalone/packages/ui/.next/server/chunks/[root-of-the-server]__c6689757._.js +0 -3
  293. package/.next/standalone/packages/ui/.next/server/chunks/[root-of-the-server]__c8a20942._.js +0 -3
  294. package/.next/standalone/packages/ui/.next/server/chunks/[root-of-the-server]__cd1fb0a2._.js +0 -4
  295. package/.next/standalone/packages/ui/.next/server/chunks/[root-of-the-server]__dfa71dcd._.js +0 -3
  296. package/.next/standalone/packages/ui/.next/server/chunks/[root-of-the-server]__e9ba3fa9._.js +0 -3
  297. package/.next/standalone/packages/ui/.next/server/chunks/ecee3_js-yaml_dist_js-yaml_mjs_0775f118._.js +0 -3
  298. package/.next/standalone/packages/ui/.next/server/chunks/ssr/[root-of-the-server]__a9d7fd42._.js +0 -3
  299. package/.next/standalone/packages/ui/.next/server/chunks/ssr/[root-of-the-server]__b2fe773d._.js +0 -3
  300. package/.next/standalone/packages/ui/.next/server/chunks/ssr/[root-of-the-server]__b3633d6e._.js +0 -3
  301. package/.next/standalone/packages/ui/.next/server/chunks/ssr/[root-of-the-server]__e79a982a._.js +0 -7
  302. package/.next/standalone/packages/ui/.next/server/chunks/ssr/[root-of-the-server]__ff03fc1e._.js +0 -7
  303. package/.next/standalone/packages/ui/.next/server/chunks/ssr/_66209e84._.js +0 -3
  304. package/.next/standalone/packages/ui/.next/server/chunks/ssr/_6cd9a5e0._.js +0 -3
  305. package/.next/standalone/packages/ui/.next/server/chunks/ssr/_b483c9fe._.js +0 -3
  306. package/.next/standalone/packages/ui/.next/server/chunks/ssr/_b5040d31._.js +0 -5
  307. package/.next/standalone/packages/ui/.next/server/chunks/ssr/node_modules__pnpm_9710705b._.js +0 -3
  308. package/.next/standalone/packages/ui/.next/server/chunks/ssr/node_modules__pnpm_b8ff10b9._.js +0 -3
  309. package/.next/standalone/packages/ui/.next/static/chunks/093ea4b175adb770.js +0 -1
  310. package/.next/standalone/packages/ui/.next/static/chunks/5f97d665a4d9dc62.js +0 -3
  311. package/.next/standalone/packages/ui/.next/static/chunks/9b7b7024c39c5f99.js +0 -1
  312. package/.next/standalone/packages/ui/.next/static/chunks/aa47b212786d8695.js +0 -1
  313. package/.next/standalone/packages/ui/.next/static/chunks/ae04dcd433be6dab.js +0 -1
  314. package/.next/standalone/packages/ui/.next/static/chunks/c0576ccd1437ac5e.css +0 -1
  315. package/.next/standalone/packages/ui/.next/static/chunks/c0fe4c94c7282ac0.js +0 -4
  316. package/.next/standalone/packages/ui/.next/static/chunks/c61cbb6a0ba3b6ab.js +0 -1
  317. package/.next/standalone/packages/ui/.next/static/chunks/d79bf953f0dfb650.js +0 -1
  318. package/.next/standalone/packages/ui/.next/static/chunks/e50fb8d0b728cd35.js +0 -5
  319. package/.next/standalone/packages/ui/.next/static/chunks/e6e238dbf1d3e740.js +0 -1
  320. package/.next/standalone/packages/ui/.next/static/chunks/turbopack-9cc79aa1b34ffcbe.js +0 -3
  321. package/.next/static/chunks/093ea4b175adb770.js +0 -1
  322. package/.next/static/chunks/5f97d665a4d9dc62.js +0 -3
  323. package/.next/static/chunks/9b7b7024c39c5f99.js +0 -1
  324. package/.next/static/chunks/aa47b212786d8695.js +0 -1
  325. package/.next/static/chunks/ae04dcd433be6dab.js +0 -1
  326. package/.next/static/chunks/c0576ccd1437ac5e.css +0 -1
  327. package/.next/static/chunks/c0fe4c94c7282ac0.js +0 -4
  328. package/.next/static/chunks/c61cbb6a0ba3b6ab.js +0 -1
  329. package/.next/static/chunks/d79bf953f0dfb650.js +0 -1
  330. package/.next/static/chunks/e50fb8d0b728cd35.js +0 -5
  331. package/.next/static/chunks/e6e238dbf1d3e740.js +0 -1
  332. package/.next/static/chunks/turbopack-9cc79aa1b34ffcbe.js +0 -3
  333. /package/.next/standalone/packages/ui/.next/static/{fMRsihZys1Dhy9qQRwNrc → T1wNN9JmkdwBabQsqL-tC}/_buildManifest.js +0 -0
  334. /package/.next/standalone/packages/ui/.next/static/{fMRsihZys1Dhy9qQRwNrc → T1wNN9JmkdwBabQsqL-tC}/_clientMiddlewareManifest.json +0 -0
  335. /package/.next/standalone/packages/ui/.next/static/{fMRsihZys1Dhy9qQRwNrc → T1wNN9JmkdwBabQsqL-tC}/_ssgManifest.js +0 -0
  336. /package/.next/static/{fMRsihZys1Dhy9qQRwNrc → T1wNN9JmkdwBabQsqL-tC}/_buildManifest.js +0 -0
  337. /package/.next/static/{fMRsihZys1Dhy9qQRwNrc → T1wNN9JmkdwBabQsqL-tC}/_clientMiddlewareManifest.json +0 -0
  338. /package/.next/static/{fMRsihZys1Dhy9qQRwNrc → T1wNN9JmkdwBabQsqL-tC}/_ssgManifest.js +0 -0
@@ -1,15 +1,74 @@
1
- module.exports=[5271,22124,79174,31585,e=>{"use strict";let t,i;var s,r=e.i(25372);let n=Symbol.for("drizzle:entityKind");function a(e,t){if(!e||"object"!=typeof e)return!1;if(e instanceof t)return!0;if(!Object.prototype.hasOwnProperty.call(t,n))throw Error(`Class "${t.name??"<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let i=Object.getPrototypeOf(e).constructor;if(i)for(;i;){if(n in i&&i[n]===t[n])return!0;i=Object.getPrototypeOf(i)}return!1}Symbol.for("drizzle:hasOwnEntityKind");class l{static [n]="ConsoleLogWriter";write(e){console.log(e)}}class o{static [n]="DefaultLogger";writer;constructor(e){this.writer=e?.writer??new l}logQuery(e,t){let i=t.map(e=>{try{return JSON.stringify(e)}catch{return String(e)}}),s=i.length?` -- params: [${i.join(", ")}]`:"";this.writer.write(`Query: ${e}${s}`)}}class u{static [n]="NoopLogger";logQuery(){}}let c=Symbol.for("drizzle:Name"),h=Symbol.for("drizzle:Schema"),d=Symbol.for("drizzle:Columns"),f=Symbol.for("drizzle:ExtraConfigColumns"),m=Symbol.for("drizzle:OriginalName"),g=Symbol.for("drizzle:BaseName"),p=Symbol.for("drizzle:IsAlias"),y=Symbol.for("drizzle:ExtraConfigBuilder"),b=Symbol.for("drizzle:IsDrizzleTable");class S{static [n]="Table";static Symbol={Name:c,Schema:h,OriginalName:m,Columns:d,ExtraConfigColumns:f,BaseName:g,IsAlias:p,ExtraConfigBuilder:y};[c];[m];[h];[d];[f];[g];[p]=!1;[b]=!0;[y]=void 0;constructor(e,t,i){this[c]=this[m]=e,this[h]=t,this[g]=i}}function w(e){return`${e[h]??"public"}.${e[c]}`}class v{constructor(e,t){this.table=e,this.config=t,this.name=t.name,this.keyAsName=t.keyAsName,this.notNull=t.notNull,this.default=t.default,this.defaultFn=t.defaultFn,this.onUpdateFn=t.onUpdateFn,this.hasDefault=t.hasDefault,this.primary=t.primaryKey,this.isUnique=t.isUnique,this.uniqueName=t.uniqueName,this.uniqueType=t.uniqueType,this.dataType=t.dataType,this.columnType=t.columnType,this.generated=t.generated,this.generatedIdentity=t.generatedIdentity}static [n]="Column";name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;config;mapFromDriverValue(e){return e}mapToDriverValue(e){return e}shouldDisableInsert(){return void 0!==this.config.generated&&"byDefault"!==this.config.generated.type}}class T{static [n]="ColumnBuilder";config;constructor(e,t,i){this.config={name:e,keyAsName:""===e,notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:t,columnType:i,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default(e){return this.config.default=e,this.config.hasDefault=!0,this}$defaultFn(e){return this.config.defaultFn=e,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn(e){return this.config.onUpdateFn=e,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName(e){""===this.config.name&&(this.config.name=e)}}class ${static [n]="PgForeignKeyBuilder";reference;_onUpdate="no action";_onDelete="no action";constructor(e,t){this.reference=()=>{let{name:t,columns:i,foreignColumns:s}=e();return{name:t,columns:i,foreignTable:s[0].table,foreignColumns:s}},t&&(this._onUpdate=t.onUpdate,this._onDelete=t.onDelete)}onUpdate(e){return this._onUpdate=void 0===e?"no action":e,this}onDelete(e){return this._onDelete=void 0===e?"no action":e,this}build(e){return new x(e,this)}}class x{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}static [n]="PgForeignKey";reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:i}=this.reference(),s=t.map(e=>e.name),r=i.map(e=>e.name),n=[this.table[c],...s,i[0].table[c],...r];return e??`${n.join("_")}_fk`}}function N(e,...t){return e(...t)}function Q(e,t){return`${e[c]}_${t.join("_")}_unique`}class P{constructor(e,t){this.name=t,this.columns=e}static [n]="PgUniqueConstraintBuilder";columns;nullsNotDistinctConfig=!1;nullsNotDistinct(){return this.nullsNotDistinctConfig=!0,this}build(e){return new B(e,this.columns,this.nullsNotDistinctConfig,this.name)}}class L{static [n]="PgUniqueOnConstraintBuilder";name;constructor(e){this.name=e}on(...e){return new P(e,this.name)}}class B{constructor(e,t,i,s){this.table=e,this.columns=t,this.name=s??Q(this.table,this.columns.map(e=>e.name)),this.nullsNotDistinct=i}static [n]="PgUniqueConstraint";columns;name;nullsNotDistinct=!1;getName(){return this.name}}function C(e,t,i){for(let s=t;s<e.length;s++){let r=e[s];if("\\"===r){s++;continue}if('"'===r)return[e.slice(t,s).replace(/\\/g,""),s+1];if(!i&&(","===r||"}"===r))return[e.slice(t,s).replace(/\\/g,""),s]}return[e.slice(t).replace(/\\/g,""),e.length]}class q extends T{foreignKeyConfigs=[];static [n]="PgColumnBuilder";array(e){return new F(this.config.name,this,e)}references(e,t={}){return this.foreignKeyConfigs.push({ref:e,actions:t}),this}unique(e,t){return this.config.isUnique=!0,this.config.uniqueName=e,this.config.uniqueType=t?.nulls,this}generatedAlwaysAs(e){return this.config.generated={as:e,type:"always",mode:"stored"},this}buildForeignKeys(e,t){return this.foreignKeyConfigs.map(({ref:i,actions:s})=>N((i,s)=>{let r=new $(()=>({columns:[e],foreignColumns:[i()]}));return s.onUpdate&&r.onUpdate(s.onUpdate),s.onDelete&&r.onDelete(s.onDelete),r.build(t)},i,s))}buildExtraConfigColumn(e){return new _(e,this.config)}}class D extends v{constructor(e,t){t.uniqueName||(t.uniqueName=Q(e,[t.name])),super(e,t),this.table=e}static [n]="PgColumn"}class _ extends D{static [n]="ExtraConfigColumn";getSQLType(){return this.getSQLType()}indexConfig={order:this.config.order??"asc",nulls:this.config.nulls??"last",opClass:this.config.opClass};defaultConfig={order:"asc",nulls:"last",opClass:void 0};asc(){return this.indexConfig.order="asc",this}desc(){return this.indexConfig.order="desc",this}nullsFirst(){return this.indexConfig.nulls="first",this}nullsLast(){return this.indexConfig.nulls="last",this}op(e){return this.indexConfig.opClass=e,this}}class O{static [n]="IndexedColumn";constructor(e,t,i,s){this.name=e,this.keyAsName=t,this.type=i,this.indexConfig=s}name;keyAsName;type;indexConfig}class F extends q{static [n]="PgArrayBuilder";constructor(e,t,i){super(e,"array","PgArray"),this.config.baseBuilder=t,this.config.size=i}build(e){let t=this.config.baseBuilder.build(e);return new j(e,this.config,t)}}class j extends D{constructor(e,t,i,s){super(e,t),this.baseColumn=i,this.range=s,this.size=t.size}size;static [n]="PgArray";getSQLType(){return`${this.baseColumn.getSQLType()}[${"number"==typeof this.size?this.size:""}]`}mapFromDriverValue(e){return"string"==typeof e&&(e=function(e){let[t]=function e(t,i=0){let s=[],r=i,n=!1;for(;r<t.length;){let a=t[r];if(","===a){(n||r===i)&&s.push(""),n=!0,r++;continue}if(n=!1,"\\"===a){r+=2;continue}if('"'===a){let[e,i]=C(t,r+1,!0);s.push(e),r=i;continue}if("}"===a)return[s,r+1];if("{"===a){let[i,n]=e(t,r+1);s.push(i),r=n;continue}let[l,o]=C(t,r,!1);s.push(l),r=o}return[s,r]}(e,1);return t}(e)),e.map(e=>this.baseColumn.mapFromDriverValue(e))}mapToDriverValue(e,t=!1){let i=e.map(e=>null===e?null:a(this.baseColumn,j)?this.baseColumn.mapToDriverValue(e,!0):this.baseColumn.mapToDriverValue(e));return t?i:function e(t){return`{${t.map(t=>Array.isArray(t)?e(t):"string"==typeof t?`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`${t}`).join(",")}}`}(i)}}let A=Symbol.for("drizzle:isPgEnum");class I extends q{static [n]="PgEnumColumnBuilder";constructor(e,t){super(e,"string","PgEnumColumn"),this.config.enum=t}build(e){return new V(e,this.config)}}class V extends D{static [n]="PgEnumColumn";enum=this.config.enum;enumValues=this.config.enum.enumValues;constructor(e,t){super(e,t),this.enum=t.enum}getSQLType(){return this.enum.enumName}}class z{static [n]="Subquery";constructor(e,t,i,s=!1){this._={brand:"Subquery",sql:e,selectedFields:t,alias:i,isWith:s}}}class E extends z{static [n]="WithSubquery"}let R=(e,s)=>t?(i||(i=t.trace.getTracer("drizzle-orm","0.38.4")),N((t,i)=>i.startActiveSpan(e,e=>{try{return s(e)}catch(i){throw e.setStatus({code:t.SpanStatusCode.ERROR,message:i instanceof Error?i.message:"Unknown error"}),i}finally{e.end()}}),t,i)):s(),U=Symbol.for("drizzle:ViewBaseConfig");class M{static [n]="FakePrimitiveParam"}function k(e){return null!=e&&"function"==typeof e.getSQL}class K{static [n]="StringChunk";value;constructor(e){this.value=Array.isArray(e)?e:[e]}getSQL(){return new J([this])}}class J{constructor(e){this.queryChunks=e}static [n]="SQL";decoder=G;shouldInlineParams=!1;append(e){return this.queryChunks.push(...e.queryChunks),this}toQuery(e){return R("drizzle.buildSQL",t=>{let i=this.buildQueryFromSourceParams(this.queryChunks,e);return t?.setAttributes({"drizzle.query.text":i.sql,"drizzle.query.params":JSON.stringify(i.params)}),i})}buildQueryFromSourceParams(e,t){let i=Object.assign({},t,{inlineParams:t.inlineParams||this.shouldInlineParams,paramStartIndex:t.paramStartIndex||{value:0}}),{casing:s,escapeName:r,escapeParam:n,prepareTyping:l,inlineParams:o,paramStartIndex:u}=i;var c=e.map(e=>{if(a(e,K))return{sql:e.value.join(""),params:[]};if(a(e,W))return{sql:r(e.value),params:[]};if(void 0===e)return{sql:"",params:[]};if(Array.isArray(e)){let t=[new K("(")];for(let[i,s]of e.entries())t.push(s),i<e.length-1&&t.push(new K(", "));return t.push(new K(")")),this.buildQueryFromSourceParams(t,i)}if(a(e,J))return this.buildQueryFromSourceParams(e.queryChunks,{...i,inlineParams:o||e.shouldInlineParams});if(a(e,S)){let t=e[S.Symbol.Schema],i=e[S.Symbol.Name];return{sql:void 0===t?r(i):r(t)+"."+r(i),params:[]}}if(a(e,v)){let i=s.getColumnCasing(e);if("indexes"===t.invokeSource)return{sql:r(i),params:[]};let n=e.table[S.Symbol.Schema];return{sql:e.table[p]||void 0===n?r(e.table[S.Symbol.Name])+"."+r(i):r(n)+"."+r(e.table[S.Symbol.Name])+"."+r(i),params:[]}}if(a(e,er)){let t=e[U].schema,i=e[U].name;return{sql:void 0===t?r(i):r(t)+"."+r(i),params:[]}}if(a(e,H)){if(a(e.value,et))return{sql:n(u.value++,e),params:[e],typings:["none"]};let t=null===e.value?null:e.encoder.mapToDriverValue(e.value);if(a(t,J))return this.buildQueryFromSourceParams([t],i);if(o)return{sql:this.mapInlineParam(t,i),params:[]};let s=["none"];return l&&(s=[l(e.encoder)]),{sql:n(u.value++,t),params:[t],typings:s}}return a(e,et)?{sql:n(u.value++,e),params:[e],typings:["none"]}:a(e,J.Aliased)&&void 0!==e.fieldAlias?{sql:r(e.fieldAlias),params:[]}:a(e,z)?e._.isWith?{sql:r(e._.alias),params:[]}:this.buildQueryFromSourceParams([new K("("),e._.sql,new K(") "),new W(e._.alias)],i):e&&"function"==typeof e&&A in e&&!0===e[A]?e.schema?{sql:r(e.schema)+"."+r(e.enumName),params:[]}:{sql:r(e.enumName),params:[]}:k(e)?e.shouldOmitSQLParens?.()?this.buildQueryFromSourceParams([e.getSQL()],i):this.buildQueryFromSourceParams([new K("("),e.getSQL(),new K(")")],i):o?{sql:this.mapInlineParam(e,i),params:[]}:{sql:n(u.value++,e),params:[e],typings:["none"]}});let h={sql:"",params:[]};for(let e of c)h.sql+=e.sql,h.params.push(...e.params),e.typings?.length&&(h.typings||(h.typings=[]),h.typings.push(...e.typings));return h}mapInlineParam(e,{escapeString:t}){if(null===e)return"null";if("number"==typeof e||"boolean"==typeof e)return e.toString();if("string"==typeof e)return t(e);if("object"==typeof e){let i=e.toString();return"[object Object]"===i?t(JSON.stringify(e)):t(i)}throw Error("Unexpected param value: "+e)}getSQL(){return this}as(e){return void 0===e?this:new J.Aliased(this,e)}mapWith(e){return this.decoder="function"==typeof e?{mapFromDriverValue:e}:e,this}inlineParams(){return this.shouldInlineParams=!0,this}if(e){return e?this:void 0}}class W{constructor(e){this.value=e}static [n]="Name";brand;getSQL(){return new J([this])}}let G={mapFromDriverValue:e=>e},Y={mapToDriverValue:e=>e};({...G,...Y});class H{constructor(e,t=Y){this.value=e,this.encoder=t}static [n]="Param";brand;getSQL(){return new J([this])}}function Z(e,...t){let i=[];for(let[s,r]of((t.length>0||e.length>0&&""!==e[0])&&i.push(new K(e[0])),t.entries()))i.push(r,new K(e[s+1]));return new J(i)}(s=Z||(Z={})).empty=function(){return new J([])},s.fromList=function(e){return new J(e)},s.raw=function(e){return new J([new K(e)])},s.join=function(e,t){let i=[];for(let[s,r]of e.entries())s>0&&void 0!==t&&i.push(t),i.push(r);return new J(i)},s.identifier=function(e){return new W(e)},s.placeholder=function(e){return new et(e)},s.param=function(e,t){return new H(e,t)};var X=J||(J={});class ee{constructor(e,t){this.sql=e,this.fieldAlias=t}static [n]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new ee(this.sql,this.fieldAlias)}}X.Aliased=ee;class et{constructor(e){this.name=e}static [n]="Placeholder";getSQL(){return new J([this])}}function ei(e,t){return e.map(e=>{if(a(e,et)){if(!(e.name in t))throw Error(`No value for placeholder "${e.name}" was provided`);return t[e.name]}if(a(e,H)&&a(e.value,et)){if(!(e.value.name in t))throw Error(`No value for placeholder "${e.value.name}" was provided`);return e.encoder.mapToDriverValue(t[e.value.name])}return e})}let es=Symbol.for("drizzle:IsDrizzleView");class er{static [n]="View";[U];[es]=!0;constructor({name:e,schema:t,selectedFields:i,query:s}){this[U]={name:e,originalName:e,schema:t,selectedFields:i,query:s,isExisting:!s,isAlias:!1}}getSQL(){return new J([this])}}function en(e,t,i){let s={},r=e.reduce((e,{path:r,field:n},l)=>{let o;o=a(n,v)?n:a(n,J)?n.decoder:n.sql.decoder;let u=e;for(let[e,h]of r.entries())if(e<r.length-1)h in u||(u[h]={}),u=u[h];else{let e=t[l],d=u[h]=null===e?null:o.mapFromDriverValue(e);if(i&&a(n,v)&&2===r.length){let e=r[0];e in s?"string"==typeof s[e]&&s[e]!==n.table[c]&&(s[e]=!1):s[e]=null===d&&n.table[c]}}return e},{});if(i&&Object.keys(s).length>0)for(let[e,t]of Object.entries(s))"string"!=typeof t||i[t]||(r[e]=null);return r}function ea(e,t){return Object.entries(e).reduce((e,[i,s])=>{if("string"!=typeof i)return e;let r=t?[...t,i]:[i];return a(s,v)||a(s,J)||a(s,J.Aliased)?e.push({path:r,field:s}):a(s,S)?e.push(...ea(s[S.Symbol.Columns],r)):e.push(...ea(s,r)),e},[])}function el(e,t){let i=Object.keys(e),s=Object.keys(t);if(i.length!==s.length)return!1;for(let[e,t]of i.entries())if(t!==s[e])return!1;return!0}function eo(e,t){let i=Object.entries(t).filter(([,e])=>void 0!==e).map(([t,i])=>a(i,J)||a(i,v)?[t,i]:[t,new H(i,e[S.Symbol.Columns][t])]);if(0===i.length)throw Error("No values to set");return Object.fromEntries(i)}function eu(e){return a(e,z)?e._.alias:a(e,er)?e[U].name:a(e,J)?void 0:e[S.Symbol.IsAlias]?e[S.Symbol.Name]:e[S.Symbol.BaseName]}function ec(e,t){return{name:"string"==typeof e&&e.length>0?e:"",config:"object"==typeof e?e:t}}v.prototype.getSQL=function(){return new J([this])},S.prototype.getSQL=function(){return new J([this])},z.prototype.getSQL=function(){return new J([this])};class eh extends q{static [n]="PgIntColumnBaseBuilder";generatedAlwaysAsIdentity(e){if(e){let{name:t,...i}=e;this.config.generatedIdentity={type:"always",sequenceName:t,sequenceOptions:i}}else this.config.generatedIdentity={type:"always"};return this.config.hasDefault=!0,this.config.notNull=!0,this}generatedByDefaultAsIdentity(e){if(e){let{name:t,...i}=e;this.config.generatedIdentity={type:"byDefault",sequenceName:t,sequenceOptions:i}}else this.config.generatedIdentity={type:"byDefault"};return this.config.hasDefault=!0,this.config.notNull=!0,this}}class ed extends eh{static [n]="PgBigInt53Builder";constructor(e){super(e,"number","PgBigInt53")}build(e){return new ef(e,this.config)}}class ef extends D{static [n]="PgBigInt53";getSQLType(){return"bigint"}mapFromDriverValue(e){return"number"==typeof e?e:Number(e)}}class em extends eh{static [n]="PgBigInt64Builder";constructor(e){super(e,"bigint","PgBigInt64")}build(e){return new eg(e,this.config)}}class eg extends D{static [n]="PgBigInt64";getSQLType(){return"bigint"}mapFromDriverValue(e){return BigInt(e)}}class ep extends q{static [n]="PgBigSerial53Builder";constructor(e){super(e,"number","PgBigSerial53"),this.config.hasDefault=!0,this.config.notNull=!0}build(e){return new ey(e,this.config)}}class ey extends D{static [n]="PgBigSerial53";getSQLType(){return"bigserial"}mapFromDriverValue(e){return"number"==typeof e?e:Number(e)}}class eb extends q{static [n]="PgBigSerial64Builder";constructor(e){super(e,"bigint","PgBigSerial64"),this.config.hasDefault=!0}build(e){return new eS(e,this.config)}}class eS extends D{static [n]="PgBigSerial64";getSQLType(){return"bigserial"}mapFromDriverValue(e){return BigInt(e)}}class ew extends q{static [n]="PgBooleanBuilder";constructor(e){super(e,"boolean","PgBoolean")}build(e){return new ev(e,this.config)}}class ev extends D{static [n]="PgBoolean";getSQLType(){return"boolean"}}class eT extends q{static [n]="PgCharBuilder";constructor(e,t){super(e,"string","PgChar"),this.config.length=t.length,this.config.enumValues=t.enum}build(e){return new e$(e,this.config)}}class e$ extends D{static [n]="PgChar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return void 0===this.length?"char":`char(${this.length})`}}class ex extends q{static [n]="PgCidrBuilder";constructor(e){super(e,"string","PgCidr")}build(e){return new eN(e,this.config)}}class eN extends D{static [n]="PgCidr";getSQLType(){return"cidr"}}class eQ extends q{static [n]="PgCustomColumnBuilder";constructor(e,t,i){super(e,"custom","PgCustomColumn"),this.config.fieldConfig=t,this.config.customTypeParams=i}build(e){return new eP(e,this.config)}}class eP extends D{static [n]="PgCustomColumn";sqlName;mapTo;mapFrom;constructor(e,t){super(e,t),this.sqlName=t.customTypeParams.dataType(t.fieldConfig),this.mapTo=t.customTypeParams.toDriver,this.mapFrom=t.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue(e){return"function"==typeof this.mapFrom?this.mapFrom(e):e}mapToDriverValue(e){return"function"==typeof this.mapTo?this.mapTo(e):e}}class eL extends q{static [n]="PgDateColumnBaseBuilder";defaultNow(){return this.default(Z`now()`)}}class eB extends eL{static [n]="PgDateBuilder";constructor(e){super(e,"date","PgDate")}build(e){return new eC(e,this.config)}}class eC extends D{static [n]="PgDate";getSQLType(){return"date"}mapFromDriverValue(e){return new Date(e)}mapToDriverValue(e){return e.toISOString()}}class eq extends eL{static [n]="PgDateStringBuilder";constructor(e){super(e,"string","PgDateString")}build(e){return new eD(e,this.config)}}class eD extends D{static [n]="PgDateString";getSQLType(){return"date"}}class e_ extends q{static [n]="PgDoublePrecisionBuilder";constructor(e){super(e,"number","PgDoublePrecision")}build(e){return new eO(e,this.config)}}class eO extends D{static [n]="PgDoublePrecision";getSQLType(){return"double precision"}mapFromDriverValue(e){return"string"==typeof e?Number.parseFloat(e):e}}class eF extends q{static [n]="PgInetBuilder";constructor(e){super(e,"string","PgInet")}build(e){return new ej(e,this.config)}}class ej extends D{static [n]="PgInet";getSQLType(){return"inet"}}class eA extends eh{static [n]="PgIntegerBuilder";constructor(e){super(e,"number","PgInteger")}build(e){return new eI(e,this.config)}}class eI extends D{static [n]="PgInteger";getSQLType(){return"integer"}mapFromDriverValue(e){return"string"==typeof e?Number.parseInt(e):e}}class eV extends q{static [n]="PgIntervalBuilder";constructor(e,t){super(e,"string","PgInterval"),this.config.intervalConfig=t}build(e){return new ez(e,this.config)}}class ez extends D{static [n]="PgInterval";fields=this.config.intervalConfig.fields;precision=this.config.intervalConfig.precision;getSQLType(){let e=this.fields?` ${this.fields}`:"",t=this.precision?`(${this.precision})`:"";return`interval${e}${t}`}}class eE extends q{static [n]="PgJsonBuilder";constructor(e){super(e,"json","PgJson")}build(e){return new eR(e,this.config)}}class eR extends D{static [n]="PgJson";constructor(e,t){super(e,t)}getSQLType(){return"json"}mapToDriverValue(e){return JSON.stringify(e)}mapFromDriverValue(e){if("string"==typeof e)try{return JSON.parse(e)}catch{}return e}}class eU extends q{static [n]="PgJsonbBuilder";constructor(e){super(e,"json","PgJsonb")}build(e){return new eM(e,this.config)}}class eM extends D{static [n]="PgJsonb";constructor(e,t){super(e,t)}getSQLType(){return"jsonb"}mapToDriverValue(e){return JSON.stringify(e)}mapFromDriverValue(e){if("string"==typeof e)try{return JSON.parse(e)}catch{}return e}}class ek extends q{static [n]="PgLineBuilder";constructor(e){super(e,"array","PgLine")}build(e){return new eK(e,this.config)}}class eK extends D{static [n]="PgLine";getSQLType(){return"line"}mapFromDriverValue(e){let[t,i,s]=e.slice(1,-1).split(",");return[Number.parseFloat(t),Number.parseFloat(i),Number.parseFloat(s)]}mapToDriverValue(e){return`{${e[0]},${e[1]},${e[2]}}`}}class eJ extends q{static [n]="PgLineABCBuilder";constructor(e){super(e,"json","PgLineABC")}build(e){return new eW(e,this.config)}}class eW extends D{static [n]="PgLineABC";getSQLType(){return"line"}mapFromDriverValue(e){let[t,i,s]=e.slice(1,-1).split(",");return{a:Number.parseFloat(t),b:Number.parseFloat(i),c:Number.parseFloat(s)}}mapToDriverValue(e){return`{${e.a},${e.b},${e.c}}`}}class eG extends q{static [n]="PgMacaddrBuilder";constructor(e){super(e,"string","PgMacaddr")}build(e){return new eY(e,this.config)}}class eY extends D{static [n]="PgMacaddr";getSQLType(){return"macaddr"}}class eH extends q{static [n]="PgMacaddr8Builder";constructor(e){super(e,"string","PgMacaddr8")}build(e){return new eZ(e,this.config)}}class eZ extends D{static [n]="PgMacaddr8";getSQLType(){return"macaddr8"}}class eX extends q{static [n]="PgNumericBuilder";constructor(e,t,i){super(e,"string","PgNumeric"),this.config.precision=t,this.config.scale=i}build(e){return new e0(e,this.config)}}class e0 extends D{static [n]="PgNumeric";precision;scale;constructor(e,t){super(e,t),this.precision=t.precision,this.scale=t.scale}getSQLType(){return void 0!==this.precision&&void 0!==this.scale?`numeric(${this.precision}, ${this.scale})`:void 0===this.precision?"numeric":`numeric(${this.precision})`}}class e1 extends q{static [n]="PgPointTupleBuilder";constructor(e){super(e,"array","PgPointTuple")}build(e){return new e2(e,this.config)}}class e2 extends D{static [n]="PgPointTuple";getSQLType(){return"point"}mapFromDriverValue(e){if("string"==typeof e){let[t,i]=e.slice(1,-1).split(",");return[Number.parseFloat(t),Number.parseFloat(i)]}return[e.x,e.y]}mapToDriverValue(e){return`(${e[0]},${e[1]})`}}class e5 extends q{static [n]="PgPointObjectBuilder";constructor(e){super(e,"json","PgPointObject")}build(e){return new e4(e,this.config)}}class e4 extends D{static [n]="PgPointObject";getSQLType(){return"point"}mapFromDriverValue(e){if("string"==typeof e){let[t,i]=e.slice(1,-1).split(",");return{x:Number.parseFloat(t),y:Number.parseFloat(i)}}return e}mapToDriverValue(e){return`(${e.x},${e.y})`}}function e3(e,t){let i=new DataView(new ArrayBuffer(8));for(let s=0;s<8;s++)i.setUint8(s,e[t+s]);return i.getFloat64(0,!0)}function e8(e){let t=function(e){let t=[];for(let i=0;i<e.length;i+=2)t.push(Number.parseInt(e.slice(i,i+2),16));return new Uint8Array(t)}(e),i=0,s=t[0];i+=1;let r=new DataView(t.buffer),n=r.getUint32(i,1===s);if(i+=4,0x20000000&n&&(r.getUint32(i,1===s),i+=4),(65535&n)==1){let e=e3(t,i),s=e3(t,i+=8);return i+=8,[e,s]}throw Error("Unsupported geometry type")}class e6 extends q{static [n]="PgGeometryBuilder";constructor(e){super(e,"array","PgGeometry")}build(e){return new e7(e,this.config)}}class e7 extends D{static [n]="PgGeometry";getSQLType(){return"geometry(point)"}mapFromDriverValue(e){return e8(e)}mapToDriverValue(e){return`point(${e[0]} ${e[1]})`}}class e9 extends q{static [n]="PgGeometryObjectBuilder";constructor(e){super(e,"json","PgGeometryObject")}build(e){return new te(e,this.config)}}class te extends D{static [n]="PgGeometryObject";getSQLType(){return"geometry(point)"}mapFromDriverValue(e){let t=e8(e);return{x:t[0],y:t[1]}}mapToDriverValue(e){return`point(${e.x} ${e.y})`}}class tt extends q{static [n]="PgRealBuilder";constructor(e,t){super(e,"number","PgReal"),this.config.length=t}build(e){return new ti(e,this.config)}}class ti extends D{static [n]="PgReal";constructor(e,t){super(e,t)}getSQLType(){return"real"}mapFromDriverValue=e=>"string"==typeof e?Number.parseFloat(e):e}class ts extends q{static [n]="PgSerialBuilder";constructor(e){super(e,"number","PgSerial"),this.config.hasDefault=!0,this.config.notNull=!0}build(e){return new tr(e,this.config)}}class tr extends D{static [n]="PgSerial";getSQLType(){return"serial"}}class tn extends eh{static [n]="PgSmallIntBuilder";constructor(e){super(e,"number","PgSmallInt")}build(e){return new ta(e,this.config)}}class ta extends D{static [n]="PgSmallInt";getSQLType(){return"smallint"}mapFromDriverValue=e=>"string"==typeof e?Number(e):e}class tl extends q{static [n]="PgSmallSerialBuilder";constructor(e){super(e,"number","PgSmallSerial"),this.config.hasDefault=!0,this.config.notNull=!0}build(e){return new to(e,this.config)}}class to extends D{static [n]="PgSmallSerial";getSQLType(){return"smallserial"}}class tu extends q{static [n]="PgTextBuilder";constructor(e,t){super(e,"string","PgText"),this.config.enumValues=t.enum}build(e){return new tc(e,this.config)}}class tc extends D{static [n]="PgText";enumValues=this.config.enumValues;getSQLType(){return"text"}}class th extends eL{constructor(e,t,i){super(e,"string","PgTime"),this.withTimezone=t,this.precision=i,this.config.withTimezone=t,this.config.precision=i}static [n]="PgTimeBuilder";build(e){return new td(e,this.config)}}class td extends D{static [n]="PgTime";withTimezone;precision;constructor(e,t){super(e,t),this.withTimezone=t.withTimezone,this.precision=t.precision}getSQLType(){let e=void 0===this.precision?"":`(${this.precision})`;return`time${e}${this.withTimezone?" with time zone":""}`}}class tf extends eL{static [n]="PgTimestampBuilder";constructor(e,t,i){super(e,"date","PgTimestamp"),this.config.withTimezone=t,this.config.precision=i}build(e){return new tm(e,this.config)}}class tm extends D{static [n]="PgTimestamp";withTimezone;precision;constructor(e,t){super(e,t),this.withTimezone=t.withTimezone,this.precision=t.precision}getSQLType(){let e=void 0===this.precision?"":` (${this.precision})`;return`timestamp${e}${this.withTimezone?" with time zone":""}`}mapFromDriverValue=e=>new Date(this.withTimezone?e:e+"+0000");mapToDriverValue=e=>e.toISOString()}class tg extends eL{static [n]="PgTimestampStringBuilder";constructor(e,t,i){super(e,"string","PgTimestampString"),this.config.withTimezone=t,this.config.precision=i}build(e){return new tp(e,this.config)}}class tp extends D{static [n]="PgTimestampString";withTimezone;precision;constructor(e,t){super(e,t),this.withTimezone=t.withTimezone,this.precision=t.precision}getSQLType(){let e=void 0===this.precision?"":`(${this.precision})`;return`timestamp${e}${this.withTimezone?" with time zone":""}`}}class ty extends q{static [n]="PgUUIDBuilder";constructor(e){super(e,"string","PgUUID")}defaultRandom(){return this.default(Z`gen_random_uuid()`)}build(e){return new tb(e,this.config)}}class tb extends D{static [n]="PgUUID";getSQLType(){return"uuid"}}class tS extends q{static [n]="PgVarcharBuilder";constructor(e,t){super(e,"string","PgVarchar"),this.config.length=t.length,this.config.enumValues=t.enum}build(e){return new tw(e,this.config)}}class tw extends D{static [n]="PgVarchar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return void 0===this.length?"varchar":`varchar(${this.length})`}}class tv extends q{static [n]="PgBinaryVectorBuilder";constructor(e,t){super(e,"string","PgBinaryVector"),this.config.dimensions=t.dimensions}build(e){return new tT(e,this.config)}}class tT extends D{static [n]="PgBinaryVector";dimensions=this.config.dimensions;getSQLType(){return`bit(${this.dimensions})`}}class t$ extends q{static [n]="PgHalfVectorBuilder";constructor(e,t){super(e,"array","PgHalfVector"),this.config.dimensions=t.dimensions}build(e){return new tx(e,this.config)}}class tx extends D{static [n]="PgHalfVector";dimensions=this.config.dimensions;getSQLType(){return`halfvec(${this.dimensions})`}mapToDriverValue(e){return JSON.stringify(e)}mapFromDriverValue(e){return e.slice(1,-1).split(",").map(e=>Number.parseFloat(e))}}class tN extends q{static [n]="PgSparseVectorBuilder";constructor(e,t){super(e,"string","PgSparseVector"),this.config.dimensions=t.dimensions}build(e){return new tQ(e,this.config)}}class tQ extends D{static [n]="PgSparseVector";dimensions=this.config.dimensions;getSQLType(){return`sparsevec(${this.dimensions})`}}class tP extends q{static [n]="PgVectorBuilder";constructor(e,t){super(e,"array","PgVector"),this.config.dimensions=t.dimensions}build(e){return new tL(e,this.config)}}class tL extends D{static [n]="PgVector";dimensions=this.config.dimensions;getSQLType(){return`vector(${this.dimensions})`}mapToDriverValue(e){return JSON.stringify(e)}mapFromDriverValue(e){return e.slice(1,-1).split(",").map(e=>Number.parseFloat(e))}}let tB=Symbol.for("drizzle:PgInlineForeignKeys"),tC=Symbol.for("drizzle:EnableRLS");class tq extends S{static [n]="PgTable";static Symbol=Object.assign({},S.Symbol,{InlineForeignKeys:tB,EnableRLS:tC});[tB]=[];[tC]=!1;[S.Symbol.ExtraConfigBuilder]=void 0}class tD{static [n]="PgPrimaryKeyBuilder";columns;name;constructor(e,t){this.columns=e,this.name=t}build(e){return new t_(e,this.columns,this.name)}}class t_{constructor(e,t,i){this.table=e,this.columns=t,this.name=i}static [n]="PgPrimaryKey";columns;name;getName(){return this.name??`${this.table[tq.Symbol.Name]}_${this.columns.map(e=>e.name).join("_")}_pk`}}function tO(e,t){return"object"!=typeof t||null===t||!("mapToDriverValue"in t)||"function"!=typeof t.mapToDriverValue||k(e)||a(e,H)||a(e,et)||a(e,v)||a(e,S)||a(e,er)?e:new H(e,t)}let tF=(e,t)=>Z`${e} = ${tO(t,e)}`,tj=(e,t)=>Z`${e} <> ${tO(t,e)}`;function tA(...e){let t=e.filter(e=>void 0!==e);if(0!==t.length)return new J(1===t.length?t:[new K("("),Z.join(t,new K(" and ")),new K(")")])}function tI(...e){let t=e.filter(e=>void 0!==e);if(0!==t.length)return new J(1===t.length?t:[new K("("),Z.join(t,new K(" or ")),new K(")")])}function tV(e){return Z`not ${e}`}let tz=(e,t)=>Z`${e} > ${tO(t,e)}`,tE=(e,t)=>Z`${e} >= ${tO(t,e)}`,tR=(e,t)=>Z`${e} < ${tO(t,e)}`,tU=(e,t)=>Z`${e} <= ${tO(t,e)}`;function tM(e,t){return Array.isArray(t)?0===t.length?Z`false`:Z`${e} in ${t.map(t=>tO(t,e))}`:Z`${e} in ${tO(t,e)}`}function tk(e,t){return Array.isArray(t)?0===t.length?Z`true`:Z`${e} not in ${t.map(t=>tO(t,e))}`:Z`${e} not in ${tO(t,e)}`}function tK(e){return Z`${e} is null`}function tJ(e){return Z`${e} is not null`}function tW(e){return Z`exists ${e}`}function tG(e){return Z`not exists ${e}`}function tY(e,t,i){return Z`${e} between ${tO(t,e)} and ${tO(i,e)}`}function tH(e,t,i){return Z`${e} not between ${tO(t,e)} and ${tO(i,e)}`}function tZ(e,t){return Z`${e} like ${t}`}function tX(e,t){return Z`${e} not like ${t}`}function t0(e,t){return Z`${e} ilike ${t}`}function t1(e,t){return Z`${e} not ilike ${t}`}function t2(e){return Z`${e} asc`}function t5(e){return Z`${e} desc`}e.s(["and",()=>tA,"between",()=>tY,"eq",()=>tF,"exists",()=>tW,"gt",()=>tz,"gte",()=>tE,"ilike",()=>t0,"inArray",()=>tM,"isNotNull",()=>tJ,"isNull",()=>tK,"like",()=>tZ,"lt",()=>tR,"lte",()=>tU,"ne",()=>tj,"not",()=>tV,"notBetween",()=>tH,"notExists",()=>tG,"notIlike",()=>t1,"notInArray",()=>tk,"notLike",()=>tX,"or",()=>tI],22124),e.s(["asc",()=>t2,"desc",()=>t5],79174);class t4{constructor(e,t,i){this.sourceTable=e,this.referencedTable=t,this.relationName=i,this.referencedTableName=t[S.Symbol.Name]}static [n]="Relation";referencedTableName;fieldName}class t3{constructor(e,t){this.table=e,this.config=t}static [n]="Relations"}class t8 extends t4{constructor(e,t,i,s){super(e,t,i?.relationName),this.config=i,this.isNullable=s}static [n]="One";withFieldName(e){let t=new t8(this.sourceTable,this.referencedTable,this.config,this.isNullable);return t.fieldName=e,t}}class t6 extends t4{constructor(e,t,i){super(e,t,i?.relationName),this.config=i}static [n]="Many";withFieldName(e){let t=new t6(this.sourceTable,this.referencedTable,this.config);return t.fieldName=e,t}}function t7(e,t){return new t3(e,e=>Object.fromEntries(Object.entries(t(e)).map(([e,t])=>[e,t.withFieldName(e)])))}function t9(e){return{one:function(t,i){return new t8(e,t,i,i?.fields.reduce((e,t)=>e&&t.notNull,!0)??!1)},many:function(t,i){return new t6(e,t,i)}}}class ie{constructor(e){this.table=e}static [n]="ColumnAliasProxyHandler";get(e,t){return"table"===t?this.table:e[t]}}class it{constructor(e,t){this.alias=e,this.replaceOriginalName=t}static [n]="TableAliasProxyHandler";get(e,t){if(t===S.Symbol.IsAlias)return!0;if(t===S.Symbol.Name||this.replaceOriginalName&&t===S.Symbol.OriginalName)return this.alias;if(t===U)return{...e[U],name:this.alias,isAlias:!0};if(t===S.Symbol.Columns){let t=e[S.Symbol.Columns];if(!t)return t;let i={};return Object.keys(t).map(s=>{i[s]=new Proxy(t[s],new ie(new Proxy(e,this)))}),i}let i=e[t];return a(i,v)?new Proxy(i,new ie(new Proxy(e,this))):i}}class ii{constructor(e){this.alias=e}static [n]="RelationTableAliasProxyHandler";get(e,t){return"sourceTable"===t?is(e.sourceTable,this.alias):e[t]}}function is(e,t){return new Proxy(e,new it(t,!1))}function ir(e,t){return new Proxy(e,new ie(new Proxy(e.table,new it(t,!1))))}function ia(e,t){return new J.Aliased(il(e.sql,t),e.fieldAlias)}function il(e,t){return Z.join(e.queryChunks.map(e=>a(e,v)?ir(e,t):a(e,J)?il(e,t):a(e,J.Aliased)?ia(e,t):e))}class io{static [n]="SelectionProxyHandler";config;constructor(e){this.config={...e}}get(e,t){if("_"===t)return{...e._,selectedFields:new Proxy(e._.selectedFields,this)};if(t===U)return{...e[U],selectedFields:new Proxy(e[U].selectedFields,this)};if("symbol"==typeof t)return e[t];let i=(a(e,z)?e._.selectedFields:a(e,er)?e[U].selectedFields:e)[t];if(a(i,J.Aliased)){if("sql"===this.config.sqlAliasedBehavior&&!i.isSelectionField)return i.sql;let e=i.clone();return e.isSelectionField=!0,e}if(a(i,J)){if("sql"===this.config.sqlBehavior)return i;throw Error(`You tried to reference "${t}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`)}return a(i,v)?this.config.alias?new Proxy(i,new ie(new Proxy(i.table,new it(this.config.alias,this.config.replaceOriginalName??!1)))):i:"object"!=typeof i||null===i?i:new Proxy(i,new io(this.config))}}function iu(e){return(e.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map(e=>e.toLowerCase()).join("_")}function ic(e){return(e.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).reduce((e,t,i)=>e+(0===i?t.toLowerCase():`${t[0].toUpperCase()}${t.slice(1)}`),"")}function ih(e){return e}class id{static [n]="CasingCache";cache={};cachedTables={};convert;constructor(e){this.convert="snake_case"===e?iu:"camelCase"===e?ic:ih}getColumnCasing(e){if(!e.keyAsName)return e.name;let t=e.table[S.Symbol.Schema]??"public",i=e.table[S.Symbol.OriginalName],s=`${t}.${i}.${e.name}`;return this.cache[s]||this.cacheTable(e.table),this.cache[s]}cacheTable(e){let t=e[S.Symbol.Schema]??"public",i=e[S.Symbol.OriginalName],s=`${t}.${i}`;if(!this.cachedTables[s]){for(let t of Object.values(e[S.Symbol.Columns])){let e=`${s}.${t.name}`;this.cache[e]=this.convert(t.name)}this.cachedTables[s]=!0}}clearCache(){this.cache={},this.cachedTables={}}}class im extends Error{static [n]="DrizzleError";constructor({message:e,cause:t}){super(e),this.name="DrizzleError",this.cause=t}}class ig extends im{static [n]="TransactionRollbackError";constructor(){super({message:"Rollback"})}}class ip{static [n]="SQLiteForeignKeyBuilder";reference;_onUpdate;_onDelete;constructor(e,t){this.reference=()=>{let{name:t,columns:i,foreignColumns:s}=e();return{name:t,columns:i,foreignTable:s[0].table,foreignColumns:s}},t&&(this._onUpdate=t.onUpdate,this._onDelete=t.onDelete)}onUpdate(e){return this._onUpdate=e,this}onDelete(e){return this._onDelete=e,this}build(e){return new iy(e,this)}}class iy{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}static [n]="SQLiteForeignKey";reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:i}=this.reference(),s=t.map(e=>e.name),r=i.map(e=>e.name),n=[this.table[c],...s,i[0].table[c],...r];return e??`${n.join("_")}_fk`}}function ib(e,t){return`${e[c]}_${t.join("_")}_unique`}class iS{constructor(e,t){this.name=t,this.columns=e}static [n]="SQLiteUniqueConstraintBuilder";columns;build(e){return new iv(e,this.columns,this.name)}}class iw{static [n]="SQLiteUniqueOnConstraintBuilder";name;constructor(e){this.name=e}on(...e){return new iS(e,this.name)}}class iv{constructor(e,t,i){this.table=e,this.columns=t,this.name=i??ib(this.table,this.columns.map(e=>e.name))}static [n]="SQLiteUniqueConstraint";columns;name;getName(){return this.name}}class iT extends T{static [n]="SQLiteColumnBuilder";foreignKeyConfigs=[];references(e,t={}){return this.foreignKeyConfigs.push({ref:e,actions:t}),this}unique(e){return this.config.isUnique=!0,this.config.uniqueName=e,this}generatedAlwaysAs(e,t){return this.config.generated={as:e,type:"always",mode:t?.mode??"virtual"},this}buildForeignKeys(e,t){return this.foreignKeyConfigs.map(({ref:i,actions:s})=>{let r;return r=new ip(()=>({columns:[e],foreignColumns:[i()]})),s.onUpdate&&r.onUpdate(s.onUpdate),s.onDelete&&r.onDelete(s.onDelete),r.build(t)})}}class i$ extends v{constructor(e,t){t.uniqueName||(t.uniqueName=ib(e,[t.name])),super(e,t),this.table=e}static [n]="SQLiteColumn"}class ix extends iT{static [n]="SQLiteBigIntBuilder";constructor(e){super(e,"bigint","SQLiteBigInt")}build(e){return new iN(e,this.config)}}class iN extends i${static [n]="SQLiteBigInt";getSQLType(){return"blob"}mapFromDriverValue(e){return Buffer.isBuffer(e)?BigInt(e.toString()):e instanceof ArrayBuffer?BigInt(new TextDecoder().decode(e)):BigInt(String.fromCodePoint(...e))}mapToDriverValue(e){return Buffer.from(e.toString())}}class iQ extends iT{static [n]="SQLiteBlobJsonBuilder";constructor(e){super(e,"json","SQLiteBlobJson")}build(e){return new iP(e,this.config)}}class iP extends i${static [n]="SQLiteBlobJson";getSQLType(){return"blob"}mapFromDriverValue(e){return Buffer.isBuffer(e)?JSON.parse(e.toString()):e instanceof ArrayBuffer?JSON.parse(new TextDecoder().decode(e)):JSON.parse(String.fromCodePoint(...e))}mapToDriverValue(e){return Buffer.from(JSON.stringify(e))}}class iL extends iT{static [n]="SQLiteBlobBufferBuilder";constructor(e){super(e,"buffer","SQLiteBlobBuffer")}build(e){return new iB(e,this.config)}}class iB extends i${static [n]="SQLiteBlobBuffer";getSQLType(){return"blob"}}function iC(e,t){let{name:i,config:s}=ec(e,t);return s?.mode==="json"?new iQ(i):s?.mode==="bigint"?new ix(i):new iL(i)}class iq extends iT{static [n]="SQLiteCustomColumnBuilder";constructor(e,t,i){super(e,"custom","SQLiteCustomColumn"),this.config.fieldConfig=t,this.config.customTypeParams=i}build(e){return new iD(e,this.config)}}class iD extends i${static [n]="SQLiteCustomColumn";sqlName;mapTo;mapFrom;constructor(e,t){super(e,t),this.sqlName=t.customTypeParams.dataType(t.fieldConfig),this.mapTo=t.customTypeParams.toDriver,this.mapFrom=t.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue(e){return"function"==typeof this.mapFrom?this.mapFrom(e):e}mapToDriverValue(e){return"function"==typeof this.mapTo?this.mapTo(e):e}}function i_(e){return(t,i)=>{let{name:s,config:r}=ec(t,i);return new iq(s,r,e)}}class iO extends iT{static [n]="SQLiteBaseIntegerBuilder";constructor(e,t,i){super(e,t,i),this.config.autoIncrement=!1}primaryKey(e){return e?.autoIncrement&&(this.config.autoIncrement=!0),this.config.hasDefault=!0,super.primaryKey()}}class iF extends i${static [n]="SQLiteBaseInteger";autoIncrement=this.config.autoIncrement;getSQLType(){return"integer"}}class ij extends iO{static [n]="SQLiteIntegerBuilder";constructor(e){super(e,"number","SQLiteInteger")}build(e){return new iA(e,this.config)}}class iA extends iF{static [n]="SQLiteInteger"}class iI extends iO{static [n]="SQLiteTimestampBuilder";constructor(e,t){super(e,"date","SQLiteTimestamp"),this.config.mode=t}defaultNow(){return this.default(Z`(cast((julianday('now') - 2440587.5)*86400000 as integer))`)}build(e){return new iV(e,this.config)}}class iV extends iF{static [n]="SQLiteTimestamp";mode=this.config.mode;mapFromDriverValue(e){return new Date("timestamp"===this.config.mode?1e3*e:e)}mapToDriverValue(e){let t=e.getTime();return"timestamp"===this.config.mode?Math.floor(t/1e3):t}}class iz extends iO{static [n]="SQLiteBooleanBuilder";constructor(e,t){super(e,"boolean","SQLiteBoolean"),this.config.mode=t}build(e){return new iE(e,this.config)}}class iE extends iF{static [n]="SQLiteBoolean";mode=this.config.mode;mapFromDriverValue(e){return 1===Number(e)}mapToDriverValue(e){return+!!e}}function iR(e,t){let{name:i,config:s}=ec(e,t);return s?.mode==="timestamp"||s?.mode==="timestamp_ms"?new iI(i,s.mode):s?.mode==="boolean"?new iz(i,s.mode):new ij(i)}class iU extends iT{static [n]="SQLiteNumericBuilder";constructor(e){super(e,"string","SQLiteNumeric")}build(e){return new iM(e,this.config)}}class iM extends i${static [n]="SQLiteNumeric";getSQLType(){return"numeric"}}function ik(e){return new iU(e??"")}class iK extends iT{static [n]="SQLiteRealBuilder";constructor(e){super(e,"number","SQLiteReal")}build(e){return new iJ(e,this.config)}}class iJ extends i${static [n]="SQLiteReal";getSQLType(){return"real"}}function iW(e){return new iK(e??"")}class iG extends iT{static [n]="SQLiteTextBuilder";constructor(e,t){super(e,"string","SQLiteText"),this.config.enumValues=t.enum,this.config.length=t.length}build(e){return new iY(e,this.config)}}class iY extends i${static [n]="SQLiteText";enumValues=this.config.enumValues;length=this.config.length;constructor(e,t){super(e,t)}getSQLType(){return`text${this.config.length?`(${this.config.length})`:""}`}}class iH extends iT{static [n]="SQLiteTextJsonBuilder";constructor(e){super(e,"json","SQLiteTextJson")}build(e){return new iZ(e,this.config)}}class iZ extends i${static [n]="SQLiteTextJson";getSQLType(){return"text"}mapFromDriverValue(e){return JSON.parse(e)}mapToDriverValue(e){return JSON.stringify(e)}}function iX(e,t={}){let{name:i,config:s}=ec(e,t);return"json"===s.mode?new iH(i):new iG(i,s)}let i0=Symbol.for("drizzle:SQLiteInlineForeignKeys");class i1 extends S{static [n]="SQLiteTable";static Symbol=Object.assign({},S.Symbol,{InlineForeignKeys:i0});[S.Symbol.Columns];[i0]=[];[S.Symbol.ExtraConfigBuilder]=void 0}let i2=(e,t,i)=>(function(e,t,i,s,r=e){let n=new i1(e,void 0,r),a=Object.fromEntries(Object.entries("function"==typeof t?t({blob:iC,customType:i_,integer:iR,numeric:ik,real:iW,text:iX}):t).map(([e,t])=>{t.setName(e);let i=t.build(n);return n[i0].push(...t.buildForeignKeys(i,n)),[e,i]})),l=Object.assign(n,a);return l[S.Symbol.Columns]=a,l[S.Symbol.ExtraConfigColumns]=a,i&&(l[i1.Symbol.ExtraConfigBuilder]=i),l})(e,t,i);class i5 extends er{static [n]="SQLiteViewBase"}class i4{static [n]="SQLiteDialect";casing;constructor(e){this.casing=new id(e?.casing)}escapeName(e){return`"${e}"`}escapeParam(e){return"?"}escapeString(e){return`'${e.replace(/'/g,"''")}'`}buildWithCTE(e){if(!e?.length)return;let t=[Z`with `];for(let[i,s]of e.entries())t.push(Z`${Z.identifier(s._.alias)} as (${s._.sql})`),i<e.length-1&&t.push(Z`, `);return t.push(Z` `),Z.join(t)}buildDeleteQuery({table:e,where:t,returning:i,withList:s,limit:r,orderBy:n}){let a=this.buildWithCTE(s),l=i?Z` returning ${this.buildSelection(i,{isSingleTable:!0})}`:void 0,o=t?Z` where ${t}`:void 0,u=this.buildOrderBy(n),c=this.buildLimit(r);return Z`${a}delete from ${e}${o}${l}${u}${c}`}buildUpdateSet(e,t){let i=e[S.Symbol.Columns],s=Object.keys(i).filter(e=>void 0!==t[e]||i[e]?.onUpdateFn!==void 0),r=s.length;return Z.join(s.flatMap((e,s)=>{let n=i[e],a=t[e]??Z.param(n.onUpdateFn(),n),l=Z`${Z.identifier(this.casing.getColumnCasing(n))} = ${a}`;return s<r-1?[l,Z.raw(", ")]:[l]}))}buildUpdateQuery({table:e,set:t,where:i,returning:s,withList:r,joins:n,from:a,limit:l,orderBy:o}){let u=this.buildWithCTE(r),c=this.buildUpdateSet(e,t),h=a&&Z.join([Z.raw(" from "),this.buildFromTable(a)]),d=this.buildJoins(n),f=s?Z` returning ${this.buildSelection(s,{isSingleTable:!0})}`:void 0,m=i?Z` where ${i}`:void 0,g=this.buildOrderBy(o),p=this.buildLimit(l);return Z`${u}update ${e} set ${c}${h}${d}${m}${f}${g}${p}`}buildSelection(e,{isSingleTable:t=!1}={}){let i=e.length,s=e.flatMap(({field:e},s)=>{let r=[];if(a(e,J.Aliased)&&e.isSelectionField)r.push(Z.identifier(e.fieldAlias));else if(a(e,J.Aliased)||a(e,J)){let i=a(e,J.Aliased)?e.sql:e;t?r.push(new J(i.queryChunks.map(e=>a(e,v)?Z.identifier(this.casing.getColumnCasing(e)):e))):r.push(i),a(e,J.Aliased)&&r.push(Z` as ${Z.identifier(e.fieldAlias)}`)}else if(a(e,v)){let i=e.table[S.Symbol.Name];t?r.push(Z.identifier(this.casing.getColumnCasing(e))):r.push(Z`${Z.identifier(i)}.${Z.identifier(this.casing.getColumnCasing(e))}`)}return s<i-1&&r.push(Z`, `),r});return Z.join(s)}buildJoins(e){if(!e||0===e.length)return;let t=[];if(e)for(let[i,s]of e.entries()){0===i&&t.push(Z` `);let r=s.table;if(a(r,i1)){let e=r[i1.Symbol.Name],i=r[i1.Symbol.Schema],n=r[i1.Symbol.OriginalName],a=e===n?void 0:s.alias;t.push(Z`${Z.raw(s.joinType)} join ${i?Z`${Z.identifier(i)}.`:void 0}${Z.identifier(n)}${a&&Z` ${Z.identifier(a)}`} on ${s.on}`)}else t.push(Z`${Z.raw(s.joinType)} join ${r} on ${s.on}`);i<e.length-1&&t.push(Z` `)}return Z.join(t)}buildLimit(e){return"object"==typeof e||"number"==typeof e&&e>=0?Z` limit ${e}`:void 0}buildOrderBy(e){let t=[];if(e)for(let[i,s]of e.entries())t.push(s),i<e.length-1&&t.push(Z`, `);return t.length>0?Z` order by ${Z.join(t)}`:void 0}buildFromTable(e){return a(e,S)&&e[S.Symbol.OriginalName]!==e[S.Symbol.Name]?Z`${Z.identifier(e[S.Symbol.OriginalName])} ${Z.identifier(e[S.Symbol.Name])}`:e}buildSelectQuery({withList:e,fields:t,fieldsFlat:i,where:s,having:r,table:n,joins:l,orderBy:o,groupBy:u,limit:h,offset:d,distinct:f,setOperators:m}){let g=i??ea(t);for(let e of g){let t;if(a(e.field,v)&&e.field.table[c]!==(a(n,z)?n._.alias:a(n,i5)?n[U].name:a(n,J)?void 0:n[c])&&(t=e.field.table,!l?.some(({alias:e})=>e===(t[S.Symbol.IsAlias]?t[c]:t[S.Symbol.BaseName])))){let t=e.field.table[c];throw Error(`Your "${e.path.join("->")}" field references a column "${t}"."${e.field.name}", but the table "${t}" is not part of the query! Did you forget to join it?`)}}let p=!l||0===l.length,y=this.buildWithCTE(e),b=f?Z` distinct`:void 0,w=this.buildSelection(g,{isSingleTable:p}),T=this.buildFromTable(n),$=this.buildJoins(l),x=s?Z` where ${s}`:void 0,N=r?Z` having ${r}`:void 0,Q=[];if(u)for(let[e,t]of u.entries())Q.push(t),e<u.length-1&&Q.push(Z`, `);let P=Q.length>0?Z` group by ${Z.join(Q)}`:void 0,L=this.buildOrderBy(o),B=this.buildLimit(h),C=d?Z` offset ${d}`:void 0,q=Z`${y}select${b} ${w} from ${T}${$}${x}${P}${N}${L}${B}${C}`;return m.length>0?this.buildSetOperations(q,m):q}buildSetOperations(e,t){let[i,...s]=t;if(!i)throw Error("Cannot pass undefined values to any set operator");return 0===s.length?this.buildSetOperationQuery({leftSelect:e,setOperator:i}):this.buildSetOperations(this.buildSetOperationQuery({leftSelect:e,setOperator:i}),s)}buildSetOperationQuery({leftSelect:e,setOperator:{type:t,isAll:i,rightSelect:s,limit:r,orderBy:n,offset:l}}){let o,u=Z`${e.getSQL()} `,c=Z`${s.getSQL()}`;if(n&&n.length>0){let e=[];for(let t of n)if(a(t,i$))e.push(Z.identifier(t.name));else if(a(t,J)){for(let e=0;e<t.queryChunks.length;e++){let i=t.queryChunks[e];a(i,i$)&&(t.queryChunks[e]=Z.identifier(this.casing.getColumnCasing(i)))}e.push(Z`${t}`)}else e.push(Z`${t}`);o=Z` order by ${Z.join(e,Z`, `)}`}let h="object"==typeof r||"number"==typeof r&&r>=0?Z` limit ${r}`:void 0,d=Z.raw(`${t} ${i?"all ":""}`),f=l?Z` offset ${l}`:void 0;return Z`${u}${d}${c}${o}${h}${f}`}buildInsertQuery({table:e,values:t,onConflict:i,returning:s,withList:r,select:n}){let l=[],o=Object.entries(e[S.Symbol.Columns]).filter(([e,t])=>!t.shouldDisableInsert()),u=o.map(([,e])=>Z.identifier(this.casing.getColumnCasing(e)));if(n)a(t,J)?l.push(t):l.push(t.getSQL());else for(let[e,i]of(l.push(Z.raw("values ")),t.entries())){let s=[];for(let[e,t]of o){let r=i[e];if(void 0===r||a(r,H)&&void 0===r.value){let e;if(null!==t.default&&void 0!==t.default)e=a(t.default,J)?t.default:Z.param(t.default,t);else if(void 0!==t.defaultFn){let i=t.defaultFn();e=a(i,J)?i:Z.param(i,t)}else if(t.default||void 0===t.onUpdateFn)e=Z`null`;else{let i=t.onUpdateFn();e=a(i,J)?i:Z.param(i,t)}s.push(e)}else s.push(r)}l.push(s),e<t.length-1&&l.push(Z`, `)}let c=this.buildWithCTE(r),h=Z.join(l),d=s?Z` returning ${this.buildSelection(s,{isSingleTable:!0})}`:void 0,f=i?Z` on conflict ${i}`:void 0;return Z`${c}insert into ${e} ${u} ${h}${f}${d}`}sqlToQuery(e,t){return e.toQuery({casing:this.casing,escapeName:this.escapeName,escapeParam:this.escapeParam,escapeString:this.escapeString,invokeSource:t})}buildRelationalQuery({fullSchema:e,schema:t,tableNamesMap:i,table:s,tableConfig:r,queryConfig:n,tableAlias:l,nestedQueryRelation:o,joinOn:u}){let c,h=[],d,f,m=[],g,p=[];if(!0===n)h=Object.entries(r.columns).map(([e,t])=>({dbKey:t.name,tsKey:e,field:ir(t,l),relationTableTsKey:void 0,isJson:!1,selection:[]}));else{let s=Object.fromEntries(Object.entries(r.columns).map(([e,t])=>[e,ir(t,l)]));if(n.where){let e="function"==typeof n.where?n.where(s,{and:tA,between:tY,eq:tF,exists:tW,gt:tz,gte:tE,ilike:t0,inArray:tM,isNull:tK,isNotNull:tJ,like:tZ,lt:tR,lte:tU,ne:tj,not:tV,notBetween:tH,notExists:tG,notLike:tX,notIlike:t1,notInArray:tk,or:tI,sql:Z}):n.where;g=e&&il(e,l)}let o=[],u=[];if(n.columns){let e=!1;for(let[t,i]of Object.entries(n.columns))void 0!==i&&t in r.columns&&(e||!0!==i||(e=!0),u.push(t));u.length>0&&(u=e?u.filter(e=>n.columns?.[e]===!0):Object.keys(r.columns).filter(e=>!u.includes(e)))}else u=Object.keys(r.columns);for(let e of u){let t=r.columns[e];o.push({tsKey:e,value:t})}let c=[];if(n.with&&(c=Object.entries(n.with).filter(e=>!!e[1]).map(([e,t])=>({tsKey:e,queryConfig:t,relation:r.relations[e]}))),n.extras)for(let[e,t]of Object.entries("function"==typeof n.extras?n.extras(s,{sql:Z}):n.extras))o.push({tsKey:e,value:ia(t,l)});for(let{tsKey:e,value:t}of o)h.push({dbKey:a(t,J.Aliased)?t.fieldAlias:r.columns[e].name,tsKey:e,field:a(t,v)?ir(t,l):t,relationTableTsKey:void 0,isJson:!1,selection:[]});let p="function"==typeof n.orderBy?n.orderBy(s,{sql:Z,asc:t2,desc:t5}):n.orderBy??[];for(let{tsKey:s,queryConfig:r,relation:o}of(Array.isArray(p)||(p=[p]),m=p.map(e=>a(e,v)?ir(e,l):il(e,l)),d=n.limit,f=n.offset,c)){let n=function(e,t,i){if(a(i,t8)&&i.config)return{fields:i.config.fields,references:i.config.references};let s=t[w(i.referencedTable)];if(!s)throw Error(`Table "${i.referencedTable[S.Symbol.Name]}" not found in schema`);let r=e[s];if(!r)throw Error(`Table "${s}" not found in schema`);let n=i.sourceTable,l=t[w(n)];if(!l)throw Error(`Table "${n[S.Symbol.Name]}" not found in schema`);let o=[];for(let e of Object.values(r.relations))(i.relationName&&i!==e&&e.relationName===i.relationName||!i.relationName&&e.referencedTable===i.sourceTable)&&o.push(e);if(o.length>1)throw i.relationName?Error(`There are multiple relations with name "${i.relationName}" in table "${s}"`):Error(`There are multiple relations between "${s}" and "${i.sourceTable[S.Symbol.Name]}". Please specify relation name`);if(o[0]&&a(o[0],t8)&&o[0].config)return{fields:o[0].config.references,references:o[0].config.fields};throw Error(`There is not enough information to infer relation "${l}.${i.fieldName}"`)}(t,i,o),u=i[w(o.referencedTable)],c=`${l}_${s}`,d=tA(...n.fields.map((e,t)=>tF(ir(n.references[t],c),ir(e,l)))),f=this.buildRelationalQuery({fullSchema:e,schema:t,tableNamesMap:i,table:e[u],tableConfig:t[u],queryConfig:a(o,t8)?!0===r?{limit:1}:{...r,limit:1}:r,tableAlias:c,joinOn:d,nestedQueryRelation:o}),m=Z`(${f.sql})`.as(s);h.push({dbKey:s,tsKey:s,field:m,relationTableTsKey:u,isJson:!0,selection:f.selection})}}if(0===h.length)throw new im({message:`No fields selected for table "${r.tsName}" ("${l}"). You need to have at least one item in "columns", "with" or "extras". If you need to select all columns, omit the "columns" key or set it to undefined.`});if(g=tA(u,g),o){let e=Z`json_array(${Z.join(h.map(({field:e})=>a(e,i$)?Z.identifier(this.casing.getColumnCasing(e)):a(e,J.Aliased)?e.sql:e),Z`, `)})`;a(o,t6)&&(e=Z`coalesce(json_group_array(${e}), json_array())`);let t=[{dbKey:"data",tsKey:"data",field:e.as("data"),isJson:!0,relationTableTsKey:r.tsName,selection:h}];void 0!==d||void 0!==f||m.length>0?(c=this.buildSelectQuery({table:is(s,l),fields:{},fieldsFlat:[{path:[],field:Z.raw("*")}],where:g,limit:d,offset:f,orderBy:m,setOperators:[]}),g=void 0,d=void 0,f=void 0,m=void 0):c=is(s,l),c=this.buildSelectQuery({table:a(c,i1)?c:new z(c,{},l),fields:{},fieldsFlat:t.map(({field:e})=>({path:[],field:a(e,v)?ir(e,l):e})),joins:p,where:g,limit:d,offset:f,orderBy:m,setOperators:[]})}else c=this.buildSelectQuery({table:is(s,l),fields:{},fieldsFlat:h.map(({field:e})=>({path:[],field:a(e,v)?ir(e,l):e})),joins:p,where:g,limit:d,offset:f,orderBy:m,setOperators:[]});return{tableTsKey:r.tsName,sql:c,selection:h}}}class i3 extends i4{static [n]="SQLiteSyncDialect";migrate(e,t,i){let s=void 0===i||"string"==typeof i?"__drizzle_migrations":i.migrationsTable??"__drizzle_migrations",r=Z`
2
- CREATE TABLE IF NOT EXISTS ${Z.identifier(s)} (
1
+ module.exports=[5271,22124,79174,31585,e=>{"use strict";let t,i;var s,r=e.i(25372);let n=Symbol.for("drizzle:entityKind");function a(e,t){if(!e||"object"!=typeof e)return!1;if(e instanceof t)return!0;if(!Object.prototype.hasOwnProperty.call(t,n))throw Error(`Class "${t.name??"<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let i=Object.getPrototypeOf(e).constructor;if(i)for(;i;){if(n in i&&i[n]===t[n])return!0;i=Object.getPrototypeOf(i)}return!1}Symbol.for("drizzle:hasOwnEntityKind");class l{static [n]="ConsoleLogWriter";write(e){console.log(e)}}class o{static [n]="DefaultLogger";writer;constructor(e){this.writer=e?.writer??new l}logQuery(e,t){let i=t.map(e=>{try{return JSON.stringify(e)}catch{return String(e)}}),s=i.length?` -- params: [${i.join(", ")}]`:"";this.writer.write(`Query: ${e}${s}`)}}class u{static [n]="NoopLogger";logQuery(){}}let c=Symbol.for("drizzle:Name"),h=Symbol.for("drizzle:Schema"),d=Symbol.for("drizzle:Columns"),m=Symbol.for("drizzle:ExtraConfigColumns"),f=Symbol.for("drizzle:OriginalName"),p=Symbol.for("drizzle:BaseName"),g=Symbol.for("drizzle:IsAlias"),y=Symbol.for("drizzle:ExtraConfigBuilder"),b=Symbol.for("drizzle:IsDrizzleTable");class S{static [n]="Table";static Symbol={Name:c,Schema:h,OriginalName:f,Columns:d,ExtraConfigColumns:m,BaseName:p,IsAlias:g,ExtraConfigBuilder:y};[c];[f];[h];[d];[m];[p];[g]=!1;[b]=!0;[y]=void 0;constructor(e,t,i){this[c]=this[f]=e,this[h]=t,this[p]=i}}function w(e){return`${e[h]??"public"}.${e[c]}`}class T{constructor(e,t){this.table=e,this.config=t,this.name=t.name,this.keyAsName=t.keyAsName,this.notNull=t.notNull,this.default=t.default,this.defaultFn=t.defaultFn,this.onUpdateFn=t.onUpdateFn,this.hasDefault=t.hasDefault,this.primary=t.primaryKey,this.isUnique=t.isUnique,this.uniqueName=t.uniqueName,this.uniqueType=t.uniqueType,this.dataType=t.dataType,this.columnType=t.columnType,this.generated=t.generated,this.generatedIdentity=t.generatedIdentity}static [n]="Column";name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;config;mapFromDriverValue(e){return e}mapToDriverValue(e){return e}shouldDisableInsert(){return void 0!==this.config.generated&&"byDefault"!==this.config.generated.type}}class N{static [n]="ColumnBuilder";config;constructor(e,t,i){this.config={name:e,keyAsName:""===e,notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:t,columnType:i,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default(e){return this.config.default=e,this.config.hasDefault=!0,this}$defaultFn(e){return this.config.defaultFn=e,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn(e){return this.config.onUpdateFn=e,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName(e){""===this.config.name&&(this.config.name=e)}}class v{static [n]="PgForeignKeyBuilder";reference;_onUpdate="no action";_onDelete="no action";constructor(e,t){this.reference=()=>{let{name:t,columns:i,foreignColumns:s}=e();return{name:t,columns:i,foreignTable:s[0].table,foreignColumns:s}},t&&(this._onUpdate=t.onUpdate,this._onDelete=t.onDelete)}onUpdate(e){return this._onUpdate=void 0===e?"no action":e,this}onDelete(e){return this._onDelete=void 0===e?"no action":e,this}build(e){return new L(e,this)}}class L{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}static [n]="PgForeignKey";reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:i}=this.reference(),s=t.map(e=>e.name),r=i.map(e=>e.name),n=[this.table[c],...s,i[0].table[c],...r];return e??`${n.join("_")}_fk`}}function x(e,...t){return e(...t)}function $(e,t){return`${e[c]}_${t.join("_")}_unique`}class Q{constructor(e,t){this.name=t,this.columns=e}static [n]="PgUniqueConstraintBuilder";columns;nullsNotDistinctConfig=!1;nullsNotDistinct(){return this.nullsNotDistinctConfig=!0,this}build(e){return new C(e,this.columns,this.nullsNotDistinctConfig,this.name)}}class P{static [n]="PgUniqueOnConstraintBuilder";name;constructor(e){this.name=e}on(...e){return new Q(e,this.name)}}class C{constructor(e,t,i,s){this.table=e,this.columns=t,this.name=s??$(this.table,this.columns.map(e=>e.name)),this.nullsNotDistinct=i}static [n]="PgUniqueConstraint";columns;name;nullsNotDistinct=!1;getName(){return this.name}}function E(e,t,i){for(let s=t;s<e.length;s++){let r=e[s];if("\\"===r){s++;continue}if('"'===r)return[e.slice(t,s).replace(/\\/g,""),s+1];if(!i&&(","===r||"}"===r))return[e.slice(t,s).replace(/\\/g,""),s]}return[e.slice(t).replace(/\\/g,""),e.length]}class B extends N{foreignKeyConfigs=[];static [n]="PgColumnBuilder";array(e){return new O(this.config.name,this,e)}references(e,t={}){return this.foreignKeyConfigs.push({ref:e,actions:t}),this}unique(e,t){return this.config.isUnique=!0,this.config.uniqueName=e,this.config.uniqueType=t?.nulls,this}generatedAlwaysAs(e){return this.config.generated={as:e,type:"always",mode:"stored"},this}buildForeignKeys(e,t){return this.foreignKeyConfigs.map(({ref:i,actions:s})=>x((i,s)=>{let r=new v(()=>({columns:[e],foreignColumns:[i()]}));return s.onUpdate&&r.onUpdate(s.onUpdate),s.onDelete&&r.onDelete(s.onDelete),r.build(t)},i,s))}buildExtraConfigColumn(e){return new q(e,this.config)}}class _ extends T{constructor(e,t){t.uniqueName||(t.uniqueName=$(e,[t.name])),super(e,t),this.table=e}static [n]="PgColumn"}class q extends _{static [n]="ExtraConfigColumn";getSQLType(){return this.getSQLType()}indexConfig={order:this.config.order??"asc",nulls:this.config.nulls??"last",opClass:this.config.opClass};defaultConfig={order:"asc",nulls:"last",opClass:void 0};asc(){return this.indexConfig.order="asc",this}desc(){return this.indexConfig.order="desc",this}nullsFirst(){return this.indexConfig.nulls="first",this}nullsLast(){return this.indexConfig.nulls="last",this}op(e){return this.indexConfig.opClass=e,this}}class D{static [n]="IndexedColumn";constructor(e,t,i,s){this.name=e,this.keyAsName=t,this.type=i,this.indexConfig=s}name;keyAsName;type;indexConfig}class O extends B{static [n]="PgArrayBuilder";constructor(e,t,i){super(e,"array","PgArray"),this.config.baseBuilder=t,this.config.size=i}build(e){let t=this.config.baseBuilder.build(e);return new A(e,this.config,t)}}class A extends _{constructor(e,t,i,s){super(e,t),this.baseColumn=i,this.range=s,this.size=t.size}size;static [n]="PgArray";getSQLType(){return`${this.baseColumn.getSQLType()}[${"number"==typeof this.size?this.size:""}]`}mapFromDriverValue(e){return"string"==typeof e&&(e=function(e){let[t]=function e(t,i=0){let s=[],r=i,n=!1;for(;r<t.length;){let a=t[r];if(","===a){(n||r===i)&&s.push(""),n=!0,r++;continue}if(n=!1,"\\"===a){r+=2;continue}if('"'===a){let[e,i]=E(t,r+1,!0);s.push(e),r=i;continue}if("}"===a)return[s,r+1];if("{"===a){let[i,n]=e(t,r+1);s.push(i),r=n;continue}let[l,o]=E(t,r,!1);s.push(l),r=o}return[s,r]}(e,1);return t}(e)),e.map(e=>this.baseColumn.mapFromDriverValue(e))}mapToDriverValue(e,t=!1){let i=e.map(e=>null===e?null:a(this.baseColumn,A)?this.baseColumn.mapToDriverValue(e,!0):this.baseColumn.mapToDriverValue(e));return t?i:function e(t){return`{${t.map(t=>Array.isArray(t)?e(t):"string"==typeof t?`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`${t}`).join(",")}}`}(i)}}let F=Symbol.for("drizzle:isPgEnum");class j extends B{static [n]="PgEnumColumnBuilder";constructor(e,t){super(e,"string","PgEnumColumn"),this.config.enum=t}build(e){return new I(e,this.config)}}class I extends _{static [n]="PgEnumColumn";enum=this.config.enum;enumValues=this.config.enum.enumValues;constructor(e,t){super(e,t),this.enum=t.enum}getSQLType(){return this.enum.enumName}}class R{static [n]="Subquery";constructor(e,t,i,s=!1){this._={brand:"Subquery",sql:e,selectedFields:t,alias:i,isWith:s}}}class V extends R{static [n]="WithSubquery"}let U=(e,s)=>t?(i||(i=t.trace.getTracer("drizzle-orm","0.38.4")),x((t,i)=>i.startActiveSpan(e,e=>{try{return s(e)}catch(i){throw e.setStatus({code:t.SpanStatusCode.ERROR,message:i instanceof Error?i.message:"Unknown error"}),i}finally{e.end()}}),t,i)):s(),z=Symbol.for("drizzle:ViewBaseConfig");class M{static [n]="FakePrimitiveParam"}function K(e){return null!=e&&"function"==typeof e.getSQL}class k{static [n]="StringChunk";value;constructor(e){this.value=Array.isArray(e)?e:[e]}getSQL(){return new J([this])}}class J{constructor(e){this.queryChunks=e}static [n]="SQL";decoder=G;shouldInlineParams=!1;append(e){return this.queryChunks.push(...e.queryChunks),this}toQuery(e){return U("drizzle.buildSQL",t=>{let i=this.buildQueryFromSourceParams(this.queryChunks,e);return t?.setAttributes({"drizzle.query.text":i.sql,"drizzle.query.params":JSON.stringify(i.params)}),i})}buildQueryFromSourceParams(e,t){let i=Object.assign({},t,{inlineParams:t.inlineParams||this.shouldInlineParams,paramStartIndex:t.paramStartIndex||{value:0}}),{casing:s,escapeName:r,escapeParam:n,prepareTyping:l,inlineParams:o,paramStartIndex:u}=i;var c=e.map(e=>{if(a(e,k))return{sql:e.value.join(""),params:[]};if(a(e,X))return{sql:r(e.value),params:[]};if(void 0===e)return{sql:"",params:[]};if(Array.isArray(e)){let t=[new k("(")];for(let[i,s]of e.entries())t.push(s),i<e.length-1&&t.push(new k(", "));return t.push(new k(")")),this.buildQueryFromSourceParams(t,i)}if(a(e,J))return this.buildQueryFromSourceParams(e.queryChunks,{...i,inlineParams:o||e.shouldInlineParams});if(a(e,S)){let t=e[S.Symbol.Schema],i=e[S.Symbol.Name];return{sql:void 0===t?r(i):r(t)+"."+r(i),params:[]}}if(a(e,T)){let i=s.getColumnCasing(e);if("indexes"===t.invokeSource)return{sql:r(i),params:[]};let n=e.table[S.Symbol.Schema];return{sql:e.table[g]||void 0===n?r(e.table[S.Symbol.Name])+"."+r(i):r(n)+"."+r(e.table[S.Symbol.Name])+"."+r(i),params:[]}}if(a(e,er)){let t=e[z].schema,i=e[z].name;return{sql:void 0===t?r(i):r(t)+"."+r(i),params:[]}}if(a(e,Y)){if(a(e.value,et))return{sql:n(u.value++,e),params:[e],typings:["none"]};let t=null===e.value?null:e.encoder.mapToDriverValue(e.value);if(a(t,J))return this.buildQueryFromSourceParams([t],i);if(o)return{sql:this.mapInlineParam(t,i),params:[]};let s=["none"];return l&&(s=[l(e.encoder)]),{sql:n(u.value++,t),params:[t],typings:s}}return a(e,et)?{sql:n(u.value++,e),params:[e],typings:["none"]}:a(e,J.Aliased)&&void 0!==e.fieldAlias?{sql:r(e.fieldAlias),params:[]}:a(e,R)?e._.isWith?{sql:r(e._.alias),params:[]}:this.buildQueryFromSourceParams([new k("("),e._.sql,new k(") "),new X(e._.alias)],i):e&&"function"==typeof e&&F in e&&!0===e[F]?e.schema?{sql:r(e.schema)+"."+r(e.enumName),params:[]}:{sql:r(e.enumName),params:[]}:K(e)?e.shouldOmitSQLParens?.()?this.buildQueryFromSourceParams([e.getSQL()],i):this.buildQueryFromSourceParams([new k("("),e.getSQL(),new k(")")],i):o?{sql:this.mapInlineParam(e,i),params:[]}:{sql:n(u.value++,e),params:[e],typings:["none"]}});let h={sql:"",params:[]};for(let e of c)h.sql+=e.sql,h.params.push(...e.params),e.typings?.length&&(h.typings||(h.typings=[]),h.typings.push(...e.typings));return h}mapInlineParam(e,{escapeString:t}){if(null===e)return"null";if("number"==typeof e||"boolean"==typeof e)return e.toString();if("string"==typeof e)return t(e);if("object"==typeof e){let i=e.toString();return"[object Object]"===i?t(JSON.stringify(e)):t(i)}throw Error("Unexpected param value: "+e)}getSQL(){return this}as(e){return void 0===e?this:new J.Aliased(this,e)}mapWith(e){return this.decoder="function"==typeof e?{mapFromDriverValue:e}:e,this}inlineParams(){return this.shouldInlineParams=!0,this}if(e){return e?this:void 0}}class X{constructor(e){this.value=e}static [n]="Name";brand;getSQL(){return new J([this])}}let G={mapFromDriverValue:e=>e},W={mapToDriverValue:e=>e};({...G,...W});class Y{constructor(e,t=W){this.value=e,this.encoder=t}static [n]="Param";brand;getSQL(){return new J([this])}}function H(e,...t){let i=[];for(let[s,r]of((t.length>0||e.length>0&&""!==e[0])&&i.push(new k(e[0])),t.entries()))i.push(r,new k(e[s+1]));return new J(i)}(s=H||(H={})).empty=function(){return new J([])},s.fromList=function(e){return new J(e)},s.raw=function(e){return new J([new k(e)])},s.join=function(e,t){let i=[];for(let[s,r]of e.entries())s>0&&void 0!==t&&i.push(t),i.push(r);return new J(i)},s.identifier=function(e){return new X(e)},s.placeholder=function(e){return new et(e)},s.param=function(e,t){return new Y(e,t)};var Z=J||(J={});class ee{constructor(e,t){this.sql=e,this.fieldAlias=t}static [n]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new ee(this.sql,this.fieldAlias)}}Z.Aliased=ee;class et{constructor(e){this.name=e}static [n]="Placeholder";getSQL(){return new J([this])}}function ei(e,t){return e.map(e=>{if(a(e,et)){if(!(e.name in t))throw Error(`No value for placeholder "${e.name}" was provided`);return t[e.name]}if(a(e,Y)&&a(e.value,et)){if(!(e.value.name in t))throw Error(`No value for placeholder "${e.value.name}" was provided`);return e.encoder.mapToDriverValue(t[e.value.name])}return e})}let es=Symbol.for("drizzle:IsDrizzleView");class er{static [n]="View";[z];[es]=!0;constructor({name:e,schema:t,selectedFields:i,query:s}){this[z]={name:e,originalName:e,schema:t,selectedFields:i,query:s,isExisting:!s,isAlias:!1}}getSQL(){return new J([this])}}function en(e,t,i){let s={},r=e.reduce((e,{path:r,field:n},l)=>{let o;o=a(n,T)?n:a(n,J)?n.decoder:n.sql.decoder;let u=e;for(let[e,h]of r.entries())if(e<r.length-1)h in u||(u[h]={}),u=u[h];else{let e=t[l],d=u[h]=null===e?null:o.mapFromDriverValue(e);if(i&&a(n,T)&&2===r.length){let e=r[0];e in s?"string"==typeof s[e]&&s[e]!==n.table[c]&&(s[e]=!1):s[e]=null===d&&n.table[c]}}return e},{});if(i&&Object.keys(s).length>0)for(let[e,t]of Object.entries(s))"string"!=typeof t||i[t]||(r[e]=null);return r}function ea(e,t){return Object.entries(e).reduce((e,[i,s])=>{if("string"!=typeof i)return e;let r=t?[...t,i]:[i];return a(s,T)||a(s,J)||a(s,J.Aliased)?e.push({path:r,field:s}):a(s,S)?e.push(...ea(s[S.Symbol.Columns],r)):e.push(...ea(s,r)),e},[])}function el(e,t){let i=Object.keys(e),s=Object.keys(t);if(i.length!==s.length)return!1;for(let[e,t]of i.entries())if(t!==s[e])return!1;return!0}function eo(e,t){let i=Object.entries(t).filter(([,e])=>void 0!==e).map(([t,i])=>a(i,J)||a(i,T)?[t,i]:[t,new Y(i,e[S.Symbol.Columns][t])]);if(0===i.length)throw Error("No values to set");return Object.fromEntries(i)}function eu(e){return a(e,R)?e._.alias:a(e,er)?e[z].name:a(e,J)?void 0:e[S.Symbol.IsAlias]?e[S.Symbol.Name]:e[S.Symbol.BaseName]}function ec(e,t){return{name:"string"==typeof e&&e.length>0?e:"",config:"object"==typeof e?e:t}}T.prototype.getSQL=function(){return new J([this])},S.prototype.getSQL=function(){return new J([this])},R.prototype.getSQL=function(){return new J([this])};class eh extends B{static [n]="PgIntColumnBaseBuilder";generatedAlwaysAsIdentity(e){if(e){let{name:t,...i}=e;this.config.generatedIdentity={type:"always",sequenceName:t,sequenceOptions:i}}else this.config.generatedIdentity={type:"always"};return this.config.hasDefault=!0,this.config.notNull=!0,this}generatedByDefaultAsIdentity(e){if(e){let{name:t,...i}=e;this.config.generatedIdentity={type:"byDefault",sequenceName:t,sequenceOptions:i}}else this.config.generatedIdentity={type:"byDefault"};return this.config.hasDefault=!0,this.config.notNull=!0,this}}class ed extends eh{static [n]="PgBigInt53Builder";constructor(e){super(e,"number","PgBigInt53")}build(e){return new em(e,this.config)}}class em extends _{static [n]="PgBigInt53";getSQLType(){return"bigint"}mapFromDriverValue(e){return"number"==typeof e?e:Number(e)}}class ef extends eh{static [n]="PgBigInt64Builder";constructor(e){super(e,"bigint","PgBigInt64")}build(e){return new ep(e,this.config)}}class ep extends _{static [n]="PgBigInt64";getSQLType(){return"bigint"}mapFromDriverValue(e){return BigInt(e)}}class eg extends B{static [n]="PgBigSerial53Builder";constructor(e){super(e,"number","PgBigSerial53"),this.config.hasDefault=!0,this.config.notNull=!0}build(e){return new ey(e,this.config)}}class ey extends _{static [n]="PgBigSerial53";getSQLType(){return"bigserial"}mapFromDriverValue(e){return"number"==typeof e?e:Number(e)}}class eb extends B{static [n]="PgBigSerial64Builder";constructor(e){super(e,"bigint","PgBigSerial64"),this.config.hasDefault=!0}build(e){return new eS(e,this.config)}}class eS extends _{static [n]="PgBigSerial64";getSQLType(){return"bigserial"}mapFromDriverValue(e){return BigInt(e)}}class ew extends B{static [n]="PgBooleanBuilder";constructor(e){super(e,"boolean","PgBoolean")}build(e){return new eT(e,this.config)}}class eT extends _{static [n]="PgBoolean";getSQLType(){return"boolean"}}class eN extends B{static [n]="PgCharBuilder";constructor(e,t){super(e,"string","PgChar"),this.config.length=t.length,this.config.enumValues=t.enum}build(e){return new ev(e,this.config)}}class ev extends _{static [n]="PgChar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return void 0===this.length?"char":`char(${this.length})`}}class eL extends B{static [n]="PgCidrBuilder";constructor(e){super(e,"string","PgCidr")}build(e){return new ex(e,this.config)}}class ex extends _{static [n]="PgCidr";getSQLType(){return"cidr"}}class e$ extends B{static [n]="PgCustomColumnBuilder";constructor(e,t,i){super(e,"custom","PgCustomColumn"),this.config.fieldConfig=t,this.config.customTypeParams=i}build(e){return new eQ(e,this.config)}}class eQ extends _{static [n]="PgCustomColumn";sqlName;mapTo;mapFrom;constructor(e,t){super(e,t),this.sqlName=t.customTypeParams.dataType(t.fieldConfig),this.mapTo=t.customTypeParams.toDriver,this.mapFrom=t.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue(e){return"function"==typeof this.mapFrom?this.mapFrom(e):e}mapToDriverValue(e){return"function"==typeof this.mapTo?this.mapTo(e):e}}class eP extends B{static [n]="PgDateColumnBaseBuilder";defaultNow(){return this.default(H`now()`)}}class eC extends eP{static [n]="PgDateBuilder";constructor(e){super(e,"date","PgDate")}build(e){return new eE(e,this.config)}}class eE extends _{static [n]="PgDate";getSQLType(){return"date"}mapFromDriverValue(e){return new Date(e)}mapToDriverValue(e){return e.toISOString()}}class eB extends eP{static [n]="PgDateStringBuilder";constructor(e){super(e,"string","PgDateString")}build(e){return new e_(e,this.config)}}class e_ extends _{static [n]="PgDateString";getSQLType(){return"date"}}class eq extends B{static [n]="PgDoublePrecisionBuilder";constructor(e){super(e,"number","PgDoublePrecision")}build(e){return new eD(e,this.config)}}class eD extends _{static [n]="PgDoublePrecision";getSQLType(){return"double precision"}mapFromDriverValue(e){return"string"==typeof e?Number.parseFloat(e):e}}class eO extends B{static [n]="PgInetBuilder";constructor(e){super(e,"string","PgInet")}build(e){return new eA(e,this.config)}}class eA extends _{static [n]="PgInet";getSQLType(){return"inet"}}class eF extends eh{static [n]="PgIntegerBuilder";constructor(e){super(e,"number","PgInteger")}build(e){return new ej(e,this.config)}}class ej extends _{static [n]="PgInteger";getSQLType(){return"integer"}mapFromDriverValue(e){return"string"==typeof e?Number.parseInt(e):e}}class eI extends B{static [n]="PgIntervalBuilder";constructor(e,t){super(e,"string","PgInterval"),this.config.intervalConfig=t}build(e){return new eR(e,this.config)}}class eR extends _{static [n]="PgInterval";fields=this.config.intervalConfig.fields;precision=this.config.intervalConfig.precision;getSQLType(){let e=this.fields?` ${this.fields}`:"",t=this.precision?`(${this.precision})`:"";return`interval${e}${t}`}}class eV extends B{static [n]="PgJsonBuilder";constructor(e){super(e,"json","PgJson")}build(e){return new eU(e,this.config)}}class eU extends _{static [n]="PgJson";constructor(e,t){super(e,t)}getSQLType(){return"json"}mapToDriverValue(e){return JSON.stringify(e)}mapFromDriverValue(e){if("string"==typeof e)try{return JSON.parse(e)}catch{}return e}}class ez extends B{static [n]="PgJsonbBuilder";constructor(e){super(e,"json","PgJsonb")}build(e){return new eM(e,this.config)}}class eM extends _{static [n]="PgJsonb";constructor(e,t){super(e,t)}getSQLType(){return"jsonb"}mapToDriverValue(e){return JSON.stringify(e)}mapFromDriverValue(e){if("string"==typeof e)try{return JSON.parse(e)}catch{}return e}}class eK extends B{static [n]="PgLineBuilder";constructor(e){super(e,"array","PgLine")}build(e){return new ek(e,this.config)}}class ek extends _{static [n]="PgLine";getSQLType(){return"line"}mapFromDriverValue(e){let[t,i,s]=e.slice(1,-1).split(",");return[Number.parseFloat(t),Number.parseFloat(i),Number.parseFloat(s)]}mapToDriverValue(e){return`{${e[0]},${e[1]},${e[2]}}`}}class eJ extends B{static [n]="PgLineABCBuilder";constructor(e){super(e,"json","PgLineABC")}build(e){return new eX(e,this.config)}}class eX extends _{static [n]="PgLineABC";getSQLType(){return"line"}mapFromDriverValue(e){let[t,i,s]=e.slice(1,-1).split(",");return{a:Number.parseFloat(t),b:Number.parseFloat(i),c:Number.parseFloat(s)}}mapToDriverValue(e){return`{${e.a},${e.b},${e.c}}`}}class eG extends B{static [n]="PgMacaddrBuilder";constructor(e){super(e,"string","PgMacaddr")}build(e){return new eW(e,this.config)}}class eW extends _{static [n]="PgMacaddr";getSQLType(){return"macaddr"}}class eY extends B{static [n]="PgMacaddr8Builder";constructor(e){super(e,"string","PgMacaddr8")}build(e){return new eH(e,this.config)}}class eH extends _{static [n]="PgMacaddr8";getSQLType(){return"macaddr8"}}class eZ extends B{static [n]="PgNumericBuilder";constructor(e,t,i){super(e,"string","PgNumeric"),this.config.precision=t,this.config.scale=i}build(e){return new e0(e,this.config)}}class e0 extends _{static [n]="PgNumeric";precision;scale;constructor(e,t){super(e,t),this.precision=t.precision,this.scale=t.scale}getSQLType(){return void 0!==this.precision&&void 0!==this.scale?`numeric(${this.precision}, ${this.scale})`:void 0===this.precision?"numeric":`numeric(${this.precision})`}}class e1 extends B{static [n]="PgPointTupleBuilder";constructor(e){super(e,"array","PgPointTuple")}build(e){return new e2(e,this.config)}}class e2 extends _{static [n]="PgPointTuple";getSQLType(){return"point"}mapFromDriverValue(e){if("string"==typeof e){let[t,i]=e.slice(1,-1).split(",");return[Number.parseFloat(t),Number.parseFloat(i)]}return[e.x,e.y]}mapToDriverValue(e){return`(${e[0]},${e[1]})`}}class e5 extends B{static [n]="PgPointObjectBuilder";constructor(e){super(e,"json","PgPointObject")}build(e){return new e4(e,this.config)}}class e4 extends _{static [n]="PgPointObject";getSQLType(){return"point"}mapFromDriverValue(e){if("string"==typeof e){let[t,i]=e.slice(1,-1).split(",");return{x:Number.parseFloat(t),y:Number.parseFloat(i)}}return e}mapToDriverValue(e){return`(${e.x},${e.y})`}}function e3(e,t){let i=new DataView(new ArrayBuffer(8));for(let s=0;s<8;s++)i.setUint8(s,e[t+s]);return i.getFloat64(0,!0)}function e8(e){let t=function(e){let t=[];for(let i=0;i<e.length;i+=2)t.push(Number.parseInt(e.slice(i,i+2),16));return new Uint8Array(t)}(e),i=0,s=t[0];i+=1;let r=new DataView(t.buffer),n=r.getUint32(i,1===s);if(i+=4,0x20000000&n&&(r.getUint32(i,1===s),i+=4),(65535&n)==1){let e=e3(t,i),s=e3(t,i+=8);return i+=8,[e,s]}throw Error("Unsupported geometry type")}class e6 extends B{static [n]="PgGeometryBuilder";constructor(e){super(e,"array","PgGeometry")}build(e){return new e7(e,this.config)}}class e7 extends _{static [n]="PgGeometry";getSQLType(){return"geometry(point)"}mapFromDriverValue(e){return e8(e)}mapToDriverValue(e){return`point(${e[0]} ${e[1]})`}}class e9 extends B{static [n]="PgGeometryObjectBuilder";constructor(e){super(e,"json","PgGeometryObject")}build(e){return new te(e,this.config)}}class te extends _{static [n]="PgGeometryObject";getSQLType(){return"geometry(point)"}mapFromDriverValue(e){let t=e8(e);return{x:t[0],y:t[1]}}mapToDriverValue(e){return`point(${e.x} ${e.y})`}}class tt extends B{static [n]="PgRealBuilder";constructor(e,t){super(e,"number","PgReal"),this.config.length=t}build(e){return new ti(e,this.config)}}class ti extends _{static [n]="PgReal";constructor(e,t){super(e,t)}getSQLType(){return"real"}mapFromDriverValue=e=>"string"==typeof e?Number.parseFloat(e):e}class ts extends B{static [n]="PgSerialBuilder";constructor(e){super(e,"number","PgSerial"),this.config.hasDefault=!0,this.config.notNull=!0}build(e){return new tr(e,this.config)}}class tr extends _{static [n]="PgSerial";getSQLType(){return"serial"}}class tn extends eh{static [n]="PgSmallIntBuilder";constructor(e){super(e,"number","PgSmallInt")}build(e){return new ta(e,this.config)}}class ta extends _{static [n]="PgSmallInt";getSQLType(){return"smallint"}mapFromDriverValue=e=>"string"==typeof e?Number(e):e}class tl extends B{static [n]="PgSmallSerialBuilder";constructor(e){super(e,"number","PgSmallSerial"),this.config.hasDefault=!0,this.config.notNull=!0}build(e){return new to(e,this.config)}}class to extends _{static [n]="PgSmallSerial";getSQLType(){return"smallserial"}}class tu extends B{static [n]="PgTextBuilder";constructor(e,t){super(e,"string","PgText"),this.config.enumValues=t.enum}build(e){return new tc(e,this.config)}}class tc extends _{static [n]="PgText";enumValues=this.config.enumValues;getSQLType(){return"text"}}class th extends eP{constructor(e,t,i){super(e,"string","PgTime"),this.withTimezone=t,this.precision=i,this.config.withTimezone=t,this.config.precision=i}static [n]="PgTimeBuilder";build(e){return new td(e,this.config)}}class td extends _{static [n]="PgTime";withTimezone;precision;constructor(e,t){super(e,t),this.withTimezone=t.withTimezone,this.precision=t.precision}getSQLType(){let e=void 0===this.precision?"":`(${this.precision})`;return`time${e}${this.withTimezone?" with time zone":""}`}}class tm extends eP{static [n]="PgTimestampBuilder";constructor(e,t,i){super(e,"date","PgTimestamp"),this.config.withTimezone=t,this.config.precision=i}build(e){return new tf(e,this.config)}}class tf extends _{static [n]="PgTimestamp";withTimezone;precision;constructor(e,t){super(e,t),this.withTimezone=t.withTimezone,this.precision=t.precision}getSQLType(){let e=void 0===this.precision?"":` (${this.precision})`;return`timestamp${e}${this.withTimezone?" with time zone":""}`}mapFromDriverValue=e=>new Date(this.withTimezone?e:e+"+0000");mapToDriverValue=e=>e.toISOString()}class tp extends eP{static [n]="PgTimestampStringBuilder";constructor(e,t,i){super(e,"string","PgTimestampString"),this.config.withTimezone=t,this.config.precision=i}build(e){return new tg(e,this.config)}}class tg extends _{static [n]="PgTimestampString";withTimezone;precision;constructor(e,t){super(e,t),this.withTimezone=t.withTimezone,this.precision=t.precision}getSQLType(){let e=void 0===this.precision?"":`(${this.precision})`;return`timestamp${e}${this.withTimezone?" with time zone":""}`}}class ty extends B{static [n]="PgUUIDBuilder";constructor(e){super(e,"string","PgUUID")}defaultRandom(){return this.default(H`gen_random_uuid()`)}build(e){return new tb(e,this.config)}}class tb extends _{static [n]="PgUUID";getSQLType(){return"uuid"}}class tS extends B{static [n]="PgVarcharBuilder";constructor(e,t){super(e,"string","PgVarchar"),this.config.length=t.length,this.config.enumValues=t.enum}build(e){return new tw(e,this.config)}}class tw extends _{static [n]="PgVarchar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return void 0===this.length?"varchar":`varchar(${this.length})`}}class tT extends B{static [n]="PgBinaryVectorBuilder";constructor(e,t){super(e,"string","PgBinaryVector"),this.config.dimensions=t.dimensions}build(e){return new tN(e,this.config)}}class tN extends _{static [n]="PgBinaryVector";dimensions=this.config.dimensions;getSQLType(){return`bit(${this.dimensions})`}}class tv extends B{static [n]="PgHalfVectorBuilder";constructor(e,t){super(e,"array","PgHalfVector"),this.config.dimensions=t.dimensions}build(e){return new tL(e,this.config)}}class tL extends _{static [n]="PgHalfVector";dimensions=this.config.dimensions;getSQLType(){return`halfvec(${this.dimensions})`}mapToDriverValue(e){return JSON.stringify(e)}mapFromDriverValue(e){return e.slice(1,-1).split(",").map(e=>Number.parseFloat(e))}}class tx extends B{static [n]="PgSparseVectorBuilder";constructor(e,t){super(e,"string","PgSparseVector"),this.config.dimensions=t.dimensions}build(e){return new t$(e,this.config)}}class t$ extends _{static [n]="PgSparseVector";dimensions=this.config.dimensions;getSQLType(){return`sparsevec(${this.dimensions})`}}class tQ extends B{static [n]="PgVectorBuilder";constructor(e,t){super(e,"array","PgVector"),this.config.dimensions=t.dimensions}build(e){return new tP(e,this.config)}}class tP extends _{static [n]="PgVector";dimensions=this.config.dimensions;getSQLType(){return`vector(${this.dimensions})`}mapToDriverValue(e){return JSON.stringify(e)}mapFromDriverValue(e){return e.slice(1,-1).split(",").map(e=>Number.parseFloat(e))}}let tC=Symbol.for("drizzle:PgInlineForeignKeys"),tE=Symbol.for("drizzle:EnableRLS");class tB extends S{static [n]="PgTable";static Symbol=Object.assign({},S.Symbol,{InlineForeignKeys:tC,EnableRLS:tE});[tC]=[];[tE]=!1;[S.Symbol.ExtraConfigBuilder]=void 0}class t_{static [n]="PgPrimaryKeyBuilder";columns;name;constructor(e,t){this.columns=e,this.name=t}build(e){return new tq(e,this.columns,this.name)}}class tq{constructor(e,t,i){this.table=e,this.columns=t,this.name=i}static [n]="PgPrimaryKey";columns;name;getName(){return this.name??`${this.table[tB.Symbol.Name]}_${this.columns.map(e=>e.name).join("_")}_pk`}}function tD(e,t){return"object"!=typeof t||null===t||!("mapToDriverValue"in t)||"function"!=typeof t.mapToDriverValue||K(e)||a(e,Y)||a(e,et)||a(e,T)||a(e,S)||a(e,er)?e:new Y(e,t)}let tO=(e,t)=>H`${e} = ${tD(t,e)}`,tA=(e,t)=>H`${e} <> ${tD(t,e)}`;function tF(...e){let t=e.filter(e=>void 0!==e);if(0!==t.length)return new J(1===t.length?t:[new k("("),H.join(t,new k(" and ")),new k(")")])}function tj(...e){let t=e.filter(e=>void 0!==e);if(0!==t.length)return new J(1===t.length?t:[new k("("),H.join(t,new k(" or ")),new k(")")])}function tI(e){return H`not ${e}`}let tR=(e,t)=>H`${e} > ${tD(t,e)}`,tV=(e,t)=>H`${e} >= ${tD(t,e)}`,tU=(e,t)=>H`${e} < ${tD(t,e)}`,tz=(e,t)=>H`${e} <= ${tD(t,e)}`;function tM(e,t){return Array.isArray(t)?0===t.length?H`false`:H`${e} in ${t.map(t=>tD(t,e))}`:H`${e} in ${tD(t,e)}`}function tK(e,t){return Array.isArray(t)?0===t.length?H`true`:H`${e} not in ${t.map(t=>tD(t,e))}`:H`${e} not in ${tD(t,e)}`}function tk(e){return H`${e} is null`}function tJ(e){return H`${e} is not null`}function tX(e){return H`exists ${e}`}function tG(e){return H`not exists ${e}`}function tW(e,t,i){return H`${e} between ${tD(t,e)} and ${tD(i,e)}`}function tY(e,t,i){return H`${e} not between ${tD(t,e)} and ${tD(i,e)}`}function tH(e,t){return H`${e} like ${t}`}function tZ(e,t){return H`${e} not like ${t}`}function t0(e,t){return H`${e} ilike ${t}`}function t1(e,t){return H`${e} not ilike ${t}`}function t2(e){return H`${e} asc`}function t5(e){return H`${e} desc`}e.s(["and",()=>tF,"between",()=>tW,"eq",()=>tO,"exists",()=>tX,"gt",()=>tR,"gte",()=>tV,"ilike",()=>t0,"inArray",()=>tM,"isNotNull",()=>tJ,"isNull",()=>tk,"like",()=>tH,"lt",()=>tU,"lte",()=>tz,"ne",()=>tA,"not",()=>tI,"notBetween",()=>tY,"notExists",()=>tG,"notIlike",()=>t1,"notInArray",()=>tK,"notLike",()=>tZ,"or",()=>tj],22124),e.s(["asc",()=>t2,"desc",()=>t5],79174);class t4{constructor(e,t,i){this.sourceTable=e,this.referencedTable=t,this.relationName=i,this.referencedTableName=t[S.Symbol.Name]}static [n]="Relation";referencedTableName;fieldName}class t3{constructor(e,t){this.table=e,this.config=t}static [n]="Relations"}class t8 extends t4{constructor(e,t,i,s){super(e,t,i?.relationName),this.config=i,this.isNullable=s}static [n]="One";withFieldName(e){let t=new t8(this.sourceTable,this.referencedTable,this.config,this.isNullable);return t.fieldName=e,t}}class t6 extends t4{constructor(e,t,i){super(e,t,i?.relationName),this.config=i}static [n]="Many";withFieldName(e){let t=new t6(this.sourceTable,this.referencedTable,this.config);return t.fieldName=e,t}}function t7(e,t){return new t3(e,e=>Object.fromEntries(Object.entries(t(e)).map(([e,t])=>[e,t.withFieldName(e)])))}function t9(e){return{one:function(t,i){return new t8(e,t,i,i?.fields.reduce((e,t)=>e&&t.notNull,!0)??!1)},many:function(t,i){return new t6(e,t,i)}}}class ie{constructor(e){this.table=e}static [n]="ColumnAliasProxyHandler";get(e,t){return"table"===t?this.table:e[t]}}class it{constructor(e,t){this.alias=e,this.replaceOriginalName=t}static [n]="TableAliasProxyHandler";get(e,t){if(t===S.Symbol.IsAlias)return!0;if(t===S.Symbol.Name||this.replaceOriginalName&&t===S.Symbol.OriginalName)return this.alias;if(t===z)return{...e[z],name:this.alias,isAlias:!0};if(t===S.Symbol.Columns){let t=e[S.Symbol.Columns];if(!t)return t;let i={};return Object.keys(t).map(s=>{i[s]=new Proxy(t[s],new ie(new Proxy(e,this)))}),i}let i=e[t];return a(i,T)?new Proxy(i,new ie(new Proxy(e,this))):i}}class ii{constructor(e){this.alias=e}static [n]="RelationTableAliasProxyHandler";get(e,t){return"sourceTable"===t?is(e.sourceTable,this.alias):e[t]}}function is(e,t){return new Proxy(e,new it(t,!1))}function ir(e,t){return new Proxy(e,new ie(new Proxy(e.table,new it(t,!1))))}function ia(e,t){return new J.Aliased(il(e.sql,t),e.fieldAlias)}function il(e,t){return H.join(e.queryChunks.map(e=>a(e,T)?ir(e,t):a(e,J)?il(e,t):a(e,J.Aliased)?ia(e,t):e))}class io{static [n]="SelectionProxyHandler";config;constructor(e){this.config={...e}}get(e,t){if("_"===t)return{...e._,selectedFields:new Proxy(e._.selectedFields,this)};if(t===z)return{...e[z],selectedFields:new Proxy(e[z].selectedFields,this)};if("symbol"==typeof t)return e[t];let i=(a(e,R)?e._.selectedFields:a(e,er)?e[z].selectedFields:e)[t];if(a(i,J.Aliased)){if("sql"===this.config.sqlAliasedBehavior&&!i.isSelectionField)return i.sql;let e=i.clone();return e.isSelectionField=!0,e}if(a(i,J)){if("sql"===this.config.sqlBehavior)return i;throw Error(`You tried to reference "${t}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`)}return a(i,T)?this.config.alias?new Proxy(i,new ie(new Proxy(i.table,new it(this.config.alias,this.config.replaceOriginalName??!1)))):i:"object"!=typeof i||null===i?i:new Proxy(i,new io(this.config))}}function iu(e){return(e.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map(e=>e.toLowerCase()).join("_")}function ic(e){return(e.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).reduce((e,t,i)=>e+(0===i?t.toLowerCase():`${t[0].toUpperCase()}${t.slice(1)}`),"")}function ih(e){return e}class id{static [n]="CasingCache";cache={};cachedTables={};convert;constructor(e){this.convert="snake_case"===e?iu:"camelCase"===e?ic:ih}getColumnCasing(e){if(!e.keyAsName)return e.name;let t=e.table[S.Symbol.Schema]??"public",i=e.table[S.Symbol.OriginalName],s=`${t}.${i}.${e.name}`;return this.cache[s]||this.cacheTable(e.table),this.cache[s]}cacheTable(e){let t=e[S.Symbol.Schema]??"public",i=e[S.Symbol.OriginalName],s=`${t}.${i}`;if(!this.cachedTables[s]){for(let t of Object.values(e[S.Symbol.Columns])){let e=`${s}.${t.name}`;this.cache[e]=this.convert(t.name)}this.cachedTables[s]=!0}}clearCache(){this.cache={},this.cachedTables={}}}class im extends Error{static [n]="DrizzleError";constructor({message:e,cause:t}){super(e),this.name="DrizzleError",this.cause=t}}class ip extends im{static [n]="TransactionRollbackError";constructor(){super({message:"Rollback"})}}class ig{static [n]="SQLiteForeignKeyBuilder";reference;_onUpdate;_onDelete;constructor(e,t){this.reference=()=>{let{name:t,columns:i,foreignColumns:s}=e();return{name:t,columns:i,foreignTable:s[0].table,foreignColumns:s}},t&&(this._onUpdate=t.onUpdate,this._onDelete=t.onDelete)}onUpdate(e){return this._onUpdate=e,this}onDelete(e){return this._onDelete=e,this}build(e){return new iy(e,this)}}class iy{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}static [n]="SQLiteForeignKey";reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:i}=this.reference(),s=t.map(e=>e.name),r=i.map(e=>e.name),n=[this.table[c],...s,i[0].table[c],...r];return e??`${n.join("_")}_fk`}}function ib(e,t){return`${e[c]}_${t.join("_")}_unique`}class iS{constructor(e,t){this.name=t,this.columns=e}static [n]="SQLiteUniqueConstraintBuilder";columns;build(e){return new iT(e,this.columns,this.name)}}class iw{static [n]="SQLiteUniqueOnConstraintBuilder";name;constructor(e){this.name=e}on(...e){return new iS(e,this.name)}}class iT{constructor(e,t,i){this.table=e,this.columns=t,this.name=i??ib(this.table,this.columns.map(e=>e.name))}static [n]="SQLiteUniqueConstraint";columns;name;getName(){return this.name}}class iN extends N{static [n]="SQLiteColumnBuilder";foreignKeyConfigs=[];references(e,t={}){return this.foreignKeyConfigs.push({ref:e,actions:t}),this}unique(e){return this.config.isUnique=!0,this.config.uniqueName=e,this}generatedAlwaysAs(e,t){return this.config.generated={as:e,type:"always",mode:t?.mode??"virtual"},this}buildForeignKeys(e,t){return this.foreignKeyConfigs.map(({ref:i,actions:s})=>{let r;return r=new ig(()=>({columns:[e],foreignColumns:[i()]})),s.onUpdate&&r.onUpdate(s.onUpdate),s.onDelete&&r.onDelete(s.onDelete),r.build(t)})}}class iv extends T{constructor(e,t){t.uniqueName||(t.uniqueName=ib(e,[t.name])),super(e,t),this.table=e}static [n]="SQLiteColumn"}class iL extends iN{static [n]="SQLiteBigIntBuilder";constructor(e){super(e,"bigint","SQLiteBigInt")}build(e){return new ix(e,this.config)}}class ix extends iv{static [n]="SQLiteBigInt";getSQLType(){return"blob"}mapFromDriverValue(e){return Buffer.isBuffer(e)?BigInt(e.toString()):e instanceof ArrayBuffer?BigInt(new TextDecoder().decode(e)):BigInt(String.fromCodePoint(...e))}mapToDriverValue(e){return Buffer.from(e.toString())}}class i$ extends iN{static [n]="SQLiteBlobJsonBuilder";constructor(e){super(e,"json","SQLiteBlobJson")}build(e){return new iQ(e,this.config)}}class iQ extends iv{static [n]="SQLiteBlobJson";getSQLType(){return"blob"}mapFromDriverValue(e){return Buffer.isBuffer(e)?JSON.parse(e.toString()):e instanceof ArrayBuffer?JSON.parse(new TextDecoder().decode(e)):JSON.parse(String.fromCodePoint(...e))}mapToDriverValue(e){return Buffer.from(JSON.stringify(e))}}class iP extends iN{static [n]="SQLiteBlobBufferBuilder";constructor(e){super(e,"buffer","SQLiteBlobBuffer")}build(e){return new iC(e,this.config)}}class iC extends iv{static [n]="SQLiteBlobBuffer";getSQLType(){return"blob"}}function iE(e,t){let{name:i,config:s}=ec(e,t);return s?.mode==="json"?new i$(i):s?.mode==="bigint"?new iL(i):new iP(i)}class iB extends iN{static [n]="SQLiteCustomColumnBuilder";constructor(e,t,i){super(e,"custom","SQLiteCustomColumn"),this.config.fieldConfig=t,this.config.customTypeParams=i}build(e){return new i_(e,this.config)}}class i_ extends iv{static [n]="SQLiteCustomColumn";sqlName;mapTo;mapFrom;constructor(e,t){super(e,t),this.sqlName=t.customTypeParams.dataType(t.fieldConfig),this.mapTo=t.customTypeParams.toDriver,this.mapFrom=t.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue(e){return"function"==typeof this.mapFrom?this.mapFrom(e):e}mapToDriverValue(e){return"function"==typeof this.mapTo?this.mapTo(e):e}}function iq(e){return(t,i)=>{let{name:s,config:r}=ec(t,i);return new iB(s,r,e)}}class iD extends iN{static [n]="SQLiteBaseIntegerBuilder";constructor(e,t,i){super(e,t,i),this.config.autoIncrement=!1}primaryKey(e){return e?.autoIncrement&&(this.config.autoIncrement=!0),this.config.hasDefault=!0,super.primaryKey()}}class iO extends iv{static [n]="SQLiteBaseInteger";autoIncrement=this.config.autoIncrement;getSQLType(){return"integer"}}class iA extends iD{static [n]="SQLiteIntegerBuilder";constructor(e){super(e,"number","SQLiteInteger")}build(e){return new iF(e,this.config)}}class iF extends iO{static [n]="SQLiteInteger"}class ij extends iD{static [n]="SQLiteTimestampBuilder";constructor(e,t){super(e,"date","SQLiteTimestamp"),this.config.mode=t}defaultNow(){return this.default(H`(cast((julianday('now') - 2440587.5)*86400000 as integer))`)}build(e){return new iI(e,this.config)}}class iI extends iO{static [n]="SQLiteTimestamp";mode=this.config.mode;mapFromDriverValue(e){return new Date("timestamp"===this.config.mode?1e3*e:e)}mapToDriverValue(e){let t=e.getTime();return"timestamp"===this.config.mode?Math.floor(t/1e3):t}}class iR extends iD{static [n]="SQLiteBooleanBuilder";constructor(e,t){super(e,"boolean","SQLiteBoolean"),this.config.mode=t}build(e){return new iV(e,this.config)}}class iV extends iO{static [n]="SQLiteBoolean";mode=this.config.mode;mapFromDriverValue(e){return 1===Number(e)}mapToDriverValue(e){return+!!e}}function iU(e,t){let{name:i,config:s}=ec(e,t);return s?.mode==="timestamp"||s?.mode==="timestamp_ms"?new ij(i,s.mode):s?.mode==="boolean"?new iR(i,s.mode):new iA(i)}class iz extends iN{static [n]="SQLiteNumericBuilder";constructor(e){super(e,"string","SQLiteNumeric")}build(e){return new iM(e,this.config)}}class iM extends iv{static [n]="SQLiteNumeric";getSQLType(){return"numeric"}}function iK(e){return new iz(e??"")}class ik extends iN{static [n]="SQLiteRealBuilder";constructor(e){super(e,"number","SQLiteReal")}build(e){return new iJ(e,this.config)}}class iJ extends iv{static [n]="SQLiteReal";getSQLType(){return"real"}}function iX(e){return new ik(e??"")}class iG extends iN{static [n]="SQLiteTextBuilder";constructor(e,t){super(e,"string","SQLiteText"),this.config.enumValues=t.enum,this.config.length=t.length}build(e){return new iW(e,this.config)}}class iW extends iv{static [n]="SQLiteText";enumValues=this.config.enumValues;length=this.config.length;constructor(e,t){super(e,t)}getSQLType(){return`text${this.config.length?`(${this.config.length})`:""}`}}class iY extends iN{static [n]="SQLiteTextJsonBuilder";constructor(e){super(e,"json","SQLiteTextJson")}build(e){return new iH(e,this.config)}}class iH extends iv{static [n]="SQLiteTextJson";getSQLType(){return"text"}mapFromDriverValue(e){return JSON.parse(e)}mapToDriverValue(e){return JSON.stringify(e)}}function iZ(e,t={}){let{name:i,config:s}=ec(e,t);return"json"===s.mode?new iY(i):new iG(i,s)}let i0=Symbol.for("drizzle:SQLiteInlineForeignKeys");class i1 extends S{static [n]="SQLiteTable";static Symbol=Object.assign({},S.Symbol,{InlineForeignKeys:i0});[S.Symbol.Columns];[i0]=[];[S.Symbol.ExtraConfigBuilder]=void 0}let i2=(e,t,i)=>(function(e,t,i,s,r=e){let n=new i1(e,void 0,r),a=Object.fromEntries(Object.entries("function"==typeof t?t({blob:iE,customType:iq,integer:iU,numeric:iK,real:iX,text:iZ}):t).map(([e,t])=>{t.setName(e);let i=t.build(n);return n[i0].push(...t.buildForeignKeys(i,n)),[e,i]})),l=Object.assign(n,a);return l[S.Symbol.Columns]=a,l[S.Symbol.ExtraConfigColumns]=a,i&&(l[i1.Symbol.ExtraConfigBuilder]=i),l})(e,t,i);class i5 extends er{static [n]="SQLiteViewBase"}class i4{static [n]="SQLiteDialect";casing;constructor(e){this.casing=new id(e?.casing)}escapeName(e){return`"${e}"`}escapeParam(e){return"?"}escapeString(e){return`'${e.replace(/'/g,"''")}'`}buildWithCTE(e){if(!e?.length)return;let t=[H`with `];for(let[i,s]of e.entries())t.push(H`${H.identifier(s._.alias)} as (${s._.sql})`),i<e.length-1&&t.push(H`, `);return t.push(H` `),H.join(t)}buildDeleteQuery({table:e,where:t,returning:i,withList:s,limit:r,orderBy:n}){let a=this.buildWithCTE(s),l=i?H` returning ${this.buildSelection(i,{isSingleTable:!0})}`:void 0,o=t?H` where ${t}`:void 0,u=this.buildOrderBy(n),c=this.buildLimit(r);return H`${a}delete from ${e}${o}${l}${u}${c}`}buildUpdateSet(e,t){let i=e[S.Symbol.Columns],s=Object.keys(i).filter(e=>void 0!==t[e]||i[e]?.onUpdateFn!==void 0),r=s.length;return H.join(s.flatMap((e,s)=>{let n=i[e],a=t[e]??H.param(n.onUpdateFn(),n),l=H`${H.identifier(this.casing.getColumnCasing(n))} = ${a}`;return s<r-1?[l,H.raw(", ")]:[l]}))}buildUpdateQuery({table:e,set:t,where:i,returning:s,withList:r,joins:n,from:a,limit:l,orderBy:o}){let u=this.buildWithCTE(r),c=this.buildUpdateSet(e,t),h=a&&H.join([H.raw(" from "),this.buildFromTable(a)]),d=this.buildJoins(n),m=s?H` returning ${this.buildSelection(s,{isSingleTable:!0})}`:void 0,f=i?H` where ${i}`:void 0,p=this.buildOrderBy(o),g=this.buildLimit(l);return H`${u}update ${e} set ${c}${h}${d}${f}${m}${p}${g}`}buildSelection(e,{isSingleTable:t=!1}={}){let i=e.length,s=e.flatMap(({field:e},s)=>{let r=[];if(a(e,J.Aliased)&&e.isSelectionField)r.push(H.identifier(e.fieldAlias));else if(a(e,J.Aliased)||a(e,J)){let i=a(e,J.Aliased)?e.sql:e;t?r.push(new J(i.queryChunks.map(e=>a(e,T)?H.identifier(this.casing.getColumnCasing(e)):e))):r.push(i),a(e,J.Aliased)&&r.push(H` as ${H.identifier(e.fieldAlias)}`)}else if(a(e,T)){let i=e.table[S.Symbol.Name];t?r.push(H.identifier(this.casing.getColumnCasing(e))):r.push(H`${H.identifier(i)}.${H.identifier(this.casing.getColumnCasing(e))}`)}return s<i-1&&r.push(H`, `),r});return H.join(s)}buildJoins(e){if(!e||0===e.length)return;let t=[];if(e)for(let[i,s]of e.entries()){0===i&&t.push(H` `);let r=s.table;if(a(r,i1)){let e=r[i1.Symbol.Name],i=r[i1.Symbol.Schema],n=r[i1.Symbol.OriginalName],a=e===n?void 0:s.alias;t.push(H`${H.raw(s.joinType)} join ${i?H`${H.identifier(i)}.`:void 0}${H.identifier(n)}${a&&H` ${H.identifier(a)}`} on ${s.on}`)}else t.push(H`${H.raw(s.joinType)} join ${r} on ${s.on}`);i<e.length-1&&t.push(H` `)}return H.join(t)}buildLimit(e){return"object"==typeof e||"number"==typeof e&&e>=0?H` limit ${e}`:void 0}buildOrderBy(e){let t=[];if(e)for(let[i,s]of e.entries())t.push(s),i<e.length-1&&t.push(H`, `);return t.length>0?H` order by ${H.join(t)}`:void 0}buildFromTable(e){return a(e,S)&&e[S.Symbol.OriginalName]!==e[S.Symbol.Name]?H`${H.identifier(e[S.Symbol.OriginalName])} ${H.identifier(e[S.Symbol.Name])}`:e}buildSelectQuery({withList:e,fields:t,fieldsFlat:i,where:s,having:r,table:n,joins:l,orderBy:o,groupBy:u,limit:h,offset:d,distinct:m,setOperators:f}){let p=i??ea(t);for(let e of p){let t;if(a(e.field,T)&&e.field.table[c]!==(a(n,R)?n._.alias:a(n,i5)?n[z].name:a(n,J)?void 0:n[c])&&(t=e.field.table,!l?.some(({alias:e})=>e===(t[S.Symbol.IsAlias]?t[c]:t[S.Symbol.BaseName])))){let t=e.field.table[c];throw Error(`Your "${e.path.join("->")}" field references a column "${t}"."${e.field.name}", but the table "${t}" is not part of the query! Did you forget to join it?`)}}let g=!l||0===l.length,y=this.buildWithCTE(e),b=m?H` distinct`:void 0,w=this.buildSelection(p,{isSingleTable:g}),N=this.buildFromTable(n),v=this.buildJoins(l),L=s?H` where ${s}`:void 0,x=r?H` having ${r}`:void 0,$=[];if(u)for(let[e,t]of u.entries())$.push(t),e<u.length-1&&$.push(H`, `);let Q=$.length>0?H` group by ${H.join($)}`:void 0,P=this.buildOrderBy(o),C=this.buildLimit(h),E=d?H` offset ${d}`:void 0,B=H`${y}select${b} ${w} from ${N}${v}${L}${Q}${x}${P}${C}${E}`;return f.length>0?this.buildSetOperations(B,f):B}buildSetOperations(e,t){let[i,...s]=t;if(!i)throw Error("Cannot pass undefined values to any set operator");return 0===s.length?this.buildSetOperationQuery({leftSelect:e,setOperator:i}):this.buildSetOperations(this.buildSetOperationQuery({leftSelect:e,setOperator:i}),s)}buildSetOperationQuery({leftSelect:e,setOperator:{type:t,isAll:i,rightSelect:s,limit:r,orderBy:n,offset:l}}){let o,u=H`${e.getSQL()} `,c=H`${s.getSQL()}`;if(n&&n.length>0){let e=[];for(let t of n)if(a(t,iv))e.push(H.identifier(t.name));else if(a(t,J)){for(let e=0;e<t.queryChunks.length;e++){let i=t.queryChunks[e];a(i,iv)&&(t.queryChunks[e]=H.identifier(this.casing.getColumnCasing(i)))}e.push(H`${t}`)}else e.push(H`${t}`);o=H` order by ${H.join(e,H`, `)}`}let h="object"==typeof r||"number"==typeof r&&r>=0?H` limit ${r}`:void 0,d=H.raw(`${t} ${i?"all ":""}`),m=l?H` offset ${l}`:void 0;return H`${u}${d}${c}${o}${h}${m}`}buildInsertQuery({table:e,values:t,onConflict:i,returning:s,withList:r,select:n}){let l=[],o=Object.entries(e[S.Symbol.Columns]).filter(([e,t])=>!t.shouldDisableInsert()),u=o.map(([,e])=>H.identifier(this.casing.getColumnCasing(e)));if(n)a(t,J)?l.push(t):l.push(t.getSQL());else for(let[e,i]of(l.push(H.raw("values ")),t.entries())){let s=[];for(let[e,t]of o){let r=i[e];if(void 0===r||a(r,Y)&&void 0===r.value){let e;if(null!==t.default&&void 0!==t.default)e=a(t.default,J)?t.default:H.param(t.default,t);else if(void 0!==t.defaultFn){let i=t.defaultFn();e=a(i,J)?i:H.param(i,t)}else if(t.default||void 0===t.onUpdateFn)e=H`null`;else{let i=t.onUpdateFn();e=a(i,J)?i:H.param(i,t)}s.push(e)}else s.push(r)}l.push(s),e<t.length-1&&l.push(H`, `)}let c=this.buildWithCTE(r),h=H.join(l),d=s?H` returning ${this.buildSelection(s,{isSingleTable:!0})}`:void 0,m=i?H` on conflict ${i}`:void 0;return H`${c}insert into ${e} ${u} ${h}${m}${d}`}sqlToQuery(e,t){return e.toQuery({casing:this.casing,escapeName:this.escapeName,escapeParam:this.escapeParam,escapeString:this.escapeString,invokeSource:t})}buildRelationalQuery({fullSchema:e,schema:t,tableNamesMap:i,table:s,tableConfig:r,queryConfig:n,tableAlias:l,nestedQueryRelation:o,joinOn:u}){let c,h=[],d,m,f=[],p,g=[];if(!0===n)h=Object.entries(r.columns).map(([e,t])=>({dbKey:t.name,tsKey:e,field:ir(t,l),relationTableTsKey:void 0,isJson:!1,selection:[]}));else{let s=Object.fromEntries(Object.entries(r.columns).map(([e,t])=>[e,ir(t,l)]));if(n.where){let e="function"==typeof n.where?n.where(s,{and:tF,between:tW,eq:tO,exists:tX,gt:tR,gte:tV,ilike:t0,inArray:tM,isNull:tk,isNotNull:tJ,like:tH,lt:tU,lte:tz,ne:tA,not:tI,notBetween:tY,notExists:tG,notLike:tZ,notIlike:t1,notInArray:tK,or:tj,sql:H}):n.where;p=e&&il(e,l)}let o=[],u=[];if(n.columns){let e=!1;for(let[t,i]of Object.entries(n.columns))void 0!==i&&t in r.columns&&(e||!0!==i||(e=!0),u.push(t));u.length>0&&(u=e?u.filter(e=>n.columns?.[e]===!0):Object.keys(r.columns).filter(e=>!u.includes(e)))}else u=Object.keys(r.columns);for(let e of u){let t=r.columns[e];o.push({tsKey:e,value:t})}let c=[];if(n.with&&(c=Object.entries(n.with).filter(e=>!!e[1]).map(([e,t])=>({tsKey:e,queryConfig:t,relation:r.relations[e]}))),n.extras)for(let[e,t]of Object.entries("function"==typeof n.extras?n.extras(s,{sql:H}):n.extras))o.push({tsKey:e,value:ia(t,l)});for(let{tsKey:e,value:t}of o)h.push({dbKey:a(t,J.Aliased)?t.fieldAlias:r.columns[e].name,tsKey:e,field:a(t,T)?ir(t,l):t,relationTableTsKey:void 0,isJson:!1,selection:[]});let g="function"==typeof n.orderBy?n.orderBy(s,{sql:H,asc:t2,desc:t5}):n.orderBy??[];for(let{tsKey:s,queryConfig:r,relation:o}of(Array.isArray(g)||(g=[g]),f=g.map(e=>a(e,T)?ir(e,l):il(e,l)),d=n.limit,m=n.offset,c)){let n=function(e,t,i){if(a(i,t8)&&i.config)return{fields:i.config.fields,references:i.config.references};let s=t[w(i.referencedTable)];if(!s)throw Error(`Table "${i.referencedTable[S.Symbol.Name]}" not found in schema`);let r=e[s];if(!r)throw Error(`Table "${s}" not found in schema`);let n=i.sourceTable,l=t[w(n)];if(!l)throw Error(`Table "${n[S.Symbol.Name]}" not found in schema`);let o=[];for(let e of Object.values(r.relations))(i.relationName&&i!==e&&e.relationName===i.relationName||!i.relationName&&e.referencedTable===i.sourceTable)&&o.push(e);if(o.length>1)throw i.relationName?Error(`There are multiple relations with name "${i.relationName}" in table "${s}"`):Error(`There are multiple relations between "${s}" and "${i.sourceTable[S.Symbol.Name]}". Please specify relation name`);if(o[0]&&a(o[0],t8)&&o[0].config)return{fields:o[0].config.references,references:o[0].config.fields};throw Error(`There is not enough information to infer relation "${l}.${i.fieldName}"`)}(t,i,o),u=i[w(o.referencedTable)],c=`${l}_${s}`,d=tF(...n.fields.map((e,t)=>tO(ir(n.references[t],c),ir(e,l)))),m=this.buildRelationalQuery({fullSchema:e,schema:t,tableNamesMap:i,table:e[u],tableConfig:t[u],queryConfig:a(o,t8)?!0===r?{limit:1}:{...r,limit:1}:r,tableAlias:c,joinOn:d,nestedQueryRelation:o}),f=H`(${m.sql})`.as(s);h.push({dbKey:s,tsKey:s,field:f,relationTableTsKey:u,isJson:!0,selection:m.selection})}}if(0===h.length)throw new im({message:`No fields selected for table "${r.tsName}" ("${l}"). You need to have at least one item in "columns", "with" or "extras". If you need to select all columns, omit the "columns" key or set it to undefined.`});if(p=tF(u,p),o){let e=H`json_array(${H.join(h.map(({field:e})=>a(e,iv)?H.identifier(this.casing.getColumnCasing(e)):a(e,J.Aliased)?e.sql:e),H`, `)})`;a(o,t6)&&(e=H`coalesce(json_group_array(${e}), json_array())`);let t=[{dbKey:"data",tsKey:"data",field:e.as("data"),isJson:!0,relationTableTsKey:r.tsName,selection:h}];void 0!==d||void 0!==m||f.length>0?(c=this.buildSelectQuery({table:is(s,l),fields:{},fieldsFlat:[{path:[],field:H.raw("*")}],where:p,limit:d,offset:m,orderBy:f,setOperators:[]}),p=void 0,d=void 0,m=void 0,f=void 0):c=is(s,l),c=this.buildSelectQuery({table:a(c,i1)?c:new R(c,{},l),fields:{},fieldsFlat:t.map(({field:e})=>({path:[],field:a(e,T)?ir(e,l):e})),joins:g,where:p,limit:d,offset:m,orderBy:f,setOperators:[]})}else c=this.buildSelectQuery({table:is(s,l),fields:{},fieldsFlat:h.map(({field:e})=>({path:[],field:a(e,T)?ir(e,l):e})),joins:g,where:p,limit:d,offset:m,orderBy:f,setOperators:[]});return{tableTsKey:r.tsName,sql:c,selection:h}}}class i3 extends i4{static [n]="SQLiteSyncDialect";migrate(e,t,i){let s=void 0===i||"string"==typeof i?"__drizzle_migrations":i.migrationsTable??"__drizzle_migrations",r=H`
2
+ CREATE TABLE IF NOT EXISTS ${H.identifier(s)} (
3
3
  id SERIAL PRIMARY KEY,
4
4
  hash text NOT NULL,
5
5
  created_at numeric
6
6
  )
7
- `;t.run(r);let n=t.values(Z`SELECT id, hash, created_at FROM ${Z.identifier(s)} ORDER BY created_at DESC LIMIT 1`)[0]??void 0;t.run(Z`BEGIN`);try{for(let i of e)if(!n||Number(n[2])<i.folderMillis){for(let e of i.sql)t.run(Z.raw(e));t.run(Z`INSERT INTO ${Z.identifier(s)} ("hash", "created_at") VALUES(${i.hash}, ${i.folderMillis})`)}t.run(Z`COMMIT`)}catch(e){throw t.run(Z`ROLLBACK`),e}}}class i8 extends i4{static [n]="SQLiteAsyncDialect";async migrate(e,t,i){let s=void 0===i||"string"==typeof i?"__drizzle_migrations":i.migrationsTable??"__drizzle_migrations",r=Z`
8
- CREATE TABLE IF NOT EXISTS ${Z.identifier(s)} (
7
+ `;t.run(r);let n=t.values(H`SELECT id, hash, created_at FROM ${H.identifier(s)} ORDER BY created_at DESC LIMIT 1`)[0]??void 0;t.run(H`BEGIN`);try{for(let i of e)if(!n||Number(n[2])<i.folderMillis){for(let e of i.sql)t.run(H.raw(e));t.run(H`INSERT INTO ${H.identifier(s)} ("hash", "created_at") VALUES(${i.hash}, ${i.folderMillis})`)}t.run(H`COMMIT`)}catch(e){throw t.run(H`ROLLBACK`),e}}}class i8 extends i4{static [n]="SQLiteAsyncDialect";async migrate(e,t,i){let s=void 0===i||"string"==typeof i?"__drizzle_migrations":i.migrationsTable??"__drizzle_migrations",r=H`
8
+ CREATE TABLE IF NOT EXISTS ${H.identifier(s)} (
9
9
  id SERIAL PRIMARY KEY,
10
10
  hash text NOT NULL,
11
11
  created_at numeric
12
12
  )
13
- `;await t.run(r);let n=(await t.values(Z`SELECT id, hash, created_at FROM ${Z.identifier(s)} ORDER BY created_at DESC LIMIT 1`))[0]??void 0;await t.transaction(async t=>{for(let i of e)if(!n||Number(n[2])<i.folderMillis){for(let e of i.sql)await t.run(Z.raw(e));await t.run(Z`INSERT INTO ${Z.identifier(s)} ("hash", "created_at") VALUES(${i.hash}, ${i.folderMillis})`)}})}}class i6{static [n]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}}class i7{static [n]="QueryPromise";[Symbol.toStringTag]="QueryPromise";catch(e){return this.then(void 0,e)}finally(e){return this.then(t=>(e?.(),t),t=>{throw e?.(),t})}then(e,t){return this.execute().then(e,t)}}class i9{static [n]="SQLiteSelectBuilder";fields;session;dialect;withList;distinct;constructor(e){this.fields=e.fields,this.session=e.session,this.dialect=e.dialect,this.withList=e.withList,this.distinct=e.distinct}from(e){let t,i=!!this.fields;return t=this.fields?this.fields:a(e,z)?Object.fromEntries(Object.keys(e._.selectedFields).map(t=>[t,e[t]])):a(e,i5)?e[U].selectedFields:a(e,J)?{}:e[S.Symbol.Columns],new st({table:e,fields:t,isPartialSelect:i,session:this.session,dialect:this.dialect,withList:this.withList,distinct:this.distinct})}}class se extends i6{static [n]="SQLiteSelectQueryBuilder";_;config;joinsNotNullableMap;tableName;isPartialSelect;session;dialect;constructor({table:e,fields:t,isPartialSelect:i,session:s,dialect:r,withList:n,distinct:a}){super(),this.config={withList:n,table:e,fields:{...t},distinct:a,setOperators:[]},this.isPartialSelect=i,this.session=s,this.dialect=r,this._={selectedFields:t},this.tableName=eu(e),this.joinsNotNullableMap="string"==typeof this.tableName?{[this.tableName]:!0}:{}}createJoin(e){return(t,i)=>{let s=this.tableName,r=eu(t);if("string"==typeof r&&this.config.joins?.some(e=>e.alias===r))throw Error(`Alias "${r}" is already used in this query`);if(!this.isPartialSelect&&(1===Object.keys(this.joinsNotNullableMap).length&&"string"==typeof s&&(this.config.fields={[s]:this.config.fields}),"string"==typeof r&&!a(t,J))){let e=a(t,z)?t._.selectedFields:a(t,er)?t[U].selectedFields:t[S.Symbol.Columns];this.config.fields[r]=e}if("function"==typeof i&&(i=i(new Proxy(this.config.fields,new io({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.joins||(this.config.joins=[]),this.config.joins.push({on:i,table:t,joinType:e,alias:r}),"string"==typeof r)switch(e){case"left":this.joinsNotNullableMap[r]=!1;break;case"right":this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([e])=>[e,!1])),this.joinsNotNullableMap[r]=!0;break;case"inner":this.joinsNotNullableMap[r]=!0;break;case"full":this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([e])=>[e,!1])),this.joinsNotNullableMap[r]=!1}return this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");createSetOperator(e,t){return i=>{let s="function"==typeof i?i(ss()):i;if(!el(this.getSelectedFields(),s.getSelectedFields()))throw Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return this.config.setOperators.push({type:e,isAll:t,rightSelect:s}),this}}union=this.createSetOperator("union",!1);unionAll=this.createSetOperator("union",!0);intersect=this.createSetOperator("intersect",!1);except=this.createSetOperator("except",!1);addSetOperators(e){return this.config.setOperators.push(...e),this}where(e){return"function"==typeof e&&(e=e(new Proxy(this.config.fields,new io({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.where=e,this}having(e){return"function"==typeof e&&(e=e(new Proxy(this.config.fields,new io({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.having=e,this}groupBy(...e){if("function"==typeof e[0]){let t=e[0](new Proxy(this.config.fields,new io({sqlAliasedBehavior:"alias",sqlBehavior:"sql"})));this.config.groupBy=Array.isArray(t)?t:[t]}else this.config.groupBy=e;return this}orderBy(...e){if("function"==typeof e[0]){let t=e[0](new Proxy(this.config.fields,new io({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),i=Array.isArray(t)?t:[t];this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=i:this.config.orderBy=i}else this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=e:this.config.orderBy=e;return this}limit(e){return this.config.setOperators.length>0?this.config.setOperators.at(-1).limit=e:this.config.limit=e,this}offset(e){return this.config.setOperators.length>0?this.config.setOperators.at(-1).offset=e:this.config.offset=e,this}getSQL(){return this.dialect.buildSelectQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}as(e){return new Proxy(new z(this.getSQL(),this.config.fields,e),new io({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}getSelectedFields(){return new Proxy(this.config.fields,new io({alias:this.tableName,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}$dynamic(){return this}}class st extends se{static [n]="SQLiteSelect";_prepare(e=!0){if(!this.session)throw Error("Cannot execute a query on a query builder. Please use a database instance instead.");let t=ea(this.config.fields),i=this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),t,"all",!0);return i.joinsNotNullableMap=this.joinsNotNullableMap,i}prepare(){return this._prepare(!1)}run=e=>this._prepare().run(e);all=e=>this._prepare().all(e);get=e=>this._prepare().get(e);values=e=>this._prepare().values(e);async execute(){return this.all()}}for(let e of[i7])for(let t of Object.getOwnPropertyNames(e.prototype))"constructor"!==t&&Object.defineProperty(st.prototype,t,Object.getOwnPropertyDescriptor(e.prototype,t)||Object.create(null));function si(e,t){return(i,s,...r)=>{let n=[s,...r].map(i=>({type:e,isAll:t,rightSelect:i}));for(let e of n)if(!el(i.getSelectedFields(),e.rightSelect.getSelectedFields()))throw Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return i.addSetOperators(n)}}let ss=()=>({union:sr,unionAll:sn,intersect:sa,except:sl}),sr=si("union",!1),sn=si("union",!0),sa=si("intersect",!1),sl=si("except",!1);class so{static [n]="SQLiteQueryBuilder";dialect;dialectConfig;constructor(e){this.dialect=a(e,i4)?e:void 0,this.dialectConfig=a(e,i4)?void 0:e}$with(e){let t=this;return{as:i=>("function"==typeof i&&(i=i(t)),new Proxy(new E(i.getSQL(),i.getSelectedFields(),e,!0),new io({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"})))}}with(...e){let t=this;return{select:function(i){return new i9({fields:i??void 0,session:void 0,dialect:t.getDialect(),withList:e})},selectDistinct:function(i){return new i9({fields:i??void 0,session:void 0,dialect:t.getDialect(),withList:e,distinct:!0})}}}select(e){return new i9({fields:e??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct(e){return new i9({fields:e??void 0,session:void 0,dialect:this.getDialect(),distinct:!0})}getDialect(){return this.dialect||(this.dialect=new i3(this.dialectConfig)),this.dialect}}class su extends i7{constructor(e,t,i,s){super(),this.table=e,this.session=t,this.dialect=i,this.config={table:e,withList:s}}static [n]="SQLiteDelete";config;where(e){return this.config.where=e,this}orderBy(...e){if("function"==typeof e[0]){let t=e[0](new Proxy(this.config.table[S.Symbol.Columns],new io({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),i=Array.isArray(t)?t:[t];this.config.orderBy=i}else this.config.orderBy=e;return this}limit(e){return this.config.limit=e,this}returning(e=this.table[i1.Symbol.Columns]){return this.config.returning=ea(e),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e=!0){return this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",!0)}prepare(){return this._prepare(!1)}run=e=>this._prepare().run(e);all=e=>this._prepare().all(e);get=e=>this._prepare().get(e);values=e=>this._prepare().values(e);async execute(e){return this._prepare().execute(e)}$dynamic(){return this}}class sc{constructor(e,t,i,s){this.table=e,this.session=t,this.dialect=i,this.withList=s}static [n]="SQLiteInsertBuilder";values(e){if(0===(e=Array.isArray(e)?e:[e]).length)throw Error("values() must be called with at least one value");let t=e.map(e=>{let t={},i=this.table[S.Symbol.Columns];for(let s of Object.keys(e)){let r=e[s];t[s]=a(r,J)?r:new H(r,i[s])}return t});return new sh(this.table,t,this.session,this.dialect,this.withList)}select(e){let t="function"==typeof e?e(new so):e;if(!a(t,J)&&!el(this.table[d],t._.selectedFields))throw Error("Insert select error: selected fields are not the same or are in a different order compared to the table definition");return new sh(this.table,t,this.session,this.dialect,this.withList,!0)}}class sh extends i7{constructor(e,t,i,s,r,n){super(),this.session=i,this.dialect=s,this.config={table:e,values:t,withList:r,select:n}}static [n]="SQLiteInsert";config;returning(e=this.config.table[i1.Symbol.Columns]){return this.config.returning=ea(e),this}onConflictDoNothing(e={}){if(void 0===e.target)this.config.onConflict=Z`do nothing`;else{let t=Array.isArray(e.target)?Z`${e.target}`:Z`${[e.target]}`,i=e.where?Z` where ${e.where}`:Z``;this.config.onConflict=Z`${t} do nothing${i}`}return this}onConflictDoUpdate(e){if(e.where&&(e.targetWhere||e.setWhere))throw Error('You cannot use both "where" and "targetWhere"/"setWhere" at the same time - "where" is deprecated, use "targetWhere" or "setWhere" instead.');let t=e.where?Z` where ${e.where}`:void 0,i=e.targetWhere?Z` where ${e.targetWhere}`:void 0,s=e.setWhere?Z` where ${e.setWhere}`:void 0,r=Array.isArray(e.target)?Z`${e.target}`:Z`${[e.target]}`,n=this.dialect.buildUpdateSet(this.config.table,eo(this.config.table,e.set));return this.config.onConflict=Z`${r}${i} do update set ${n}${t}${s}`,this}getSQL(){return this.dialect.buildInsertQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e=!0){return this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",!0)}prepare(){return this._prepare(!1)}run=e=>this._prepare().run(e);all=e=>this._prepare().all(e);get=e=>this._prepare().get(e);values=e=>this._prepare().values(e);async execute(){return this.config.returning?this.all():this.run()}$dynamic(){return this}}class sd{constructor(e,t,i,s){this.table=e,this.session=t,this.dialect=i,this.withList=s}static [n]="SQLiteUpdateBuilder";set(e){return new sf(this.table,eo(this.table,e),this.session,this.dialect,this.withList)}}class sf extends i7{constructor(e,t,i,s,r){super(),this.session=i,this.dialect=s,this.config={set:t,table:e,withList:r,joins:[]}}static [n]="SQLiteUpdate";config;from(e){return this.config.from=e,this}createJoin(e){return(t,i)=>{let s=eu(t);if("string"==typeof s&&this.config.joins.some(e=>e.alias===s))throw Error(`Alias "${s}" is already used in this query`);if("function"==typeof i){let e=this.config.from?a(t,i1)?t[S.Symbol.Columns]:a(t,z)?t._.selectedFields:a(t,i5)?t[U].selectedFields:void 0:void 0;i=i(new Proxy(this.config.table[S.Symbol.Columns],new io({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})),e&&new Proxy(e,new io({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))}return this.config.joins.push({on:i,table:t,joinType:e,alias:s}),this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");where(e){return this.config.where=e,this}orderBy(...e){if("function"==typeof e[0]){let t=e[0](new Proxy(this.config.table[S.Symbol.Columns],new io({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),i=Array.isArray(t)?t:[t];this.config.orderBy=i}else this.config.orderBy=e;return this}limit(e){return this.config.limit=e,this}returning(e=this.config.table[i1.Symbol.Columns]){return this.config.returning=ea(e),this}getSQL(){return this.dialect.buildUpdateQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e=!0){return this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",!0)}prepare(){return this._prepare(!1)}run=e=>this._prepare().run(e);all=e=>this._prepare().all(e);get=e=>this._prepare().get(e);values=e=>this._prepare().values(e);async execute(){return this.config.returning?this.all():this.run()}$dynamic(){return this}}class sm extends J{constructor(e){super(sm.buildEmbeddedCount(e.source,e.filters).queryChunks),this.params=e,this.session=e.session,this.sql=sm.buildCount(e.source,e.filters)}sql;static [n]="SQLiteCountBuilderAsync";[Symbol.toStringTag]="SQLiteCountBuilderAsync";session;static buildEmbeddedCount(e,t){return Z`(select count(*) from ${e}${Z.raw(" where ").if(t)}${t})`}static buildCount(e,t){return Z`select count(*) from ${e}${Z.raw(" where ").if(t)}${t}`}then(e,t){return Promise.resolve(this.session.count(this.sql)).then(e,t)}catch(e){return this.then(void 0,e)}finally(e){return this.then(t=>(e?.(),t),t=>{throw e?.(),t})}}class sg{constructor(e,t,i,s,r,n,a,l){this.mode=e,this.fullSchema=t,this.schema=i,this.tableNamesMap=s,this.table=r,this.tableConfig=n,this.dialect=a,this.session=l}static [n]="SQLiteAsyncRelationalQueryBuilder";findMany(e){return"sync"===this.mode?new sy(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e||{},"many"):new sp(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e||{},"many")}findFirst(e){return"sync"===this.mode?new sy(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},"first"):new sp(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},"first")}}class sp extends i7{constructor(e,t,i,s,r,n,a,l,o){super(),this.fullSchema=e,this.schema=t,this.tableNamesMap=i,this.table=s,this.tableConfig=r,this.dialect=n,this.session=a,this.config=l,this.mode=o}static [n]="SQLiteAsyncRelationalQuery";mode;getSQL(){return this.dialect.buildRelationalQuery({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName}).sql}_prepare(e=!1){let{query:t,builtQuery:i}=this._toSQL();return this.session[e?"prepareOneTimeQuery":"prepareQuery"](i,void 0,"first"===this.mode?"get":"all",!0,(e,i)=>{let s=e.map(e=>(function e(t,i,s,r,n=e=>e){let l={};for(let[o,u]of r.entries())if(u.isJson){let r=i.relations[u.tsKey],c=s[o],h="string"==typeof c?JSON.parse(c):c;l[u.tsKey]=a(r,t8)?h&&e(t,t[u.relationTableTsKey],h,u.selection,n):h.map(i=>e(t,t[u.relationTableTsKey],i,u.selection,n))}else{let e,t=n(s[o]),i=u.field;e=a(i,v)?i:a(i,J)?i.decoder:i.sql.decoder,l[u.tsKey]=null===t?null:e.mapFromDriverValue(t)}return l})(this.schema,this.tableConfig,e,t.selection,i));return"first"===this.mode?s[0]:s})}prepare(){return this._prepare(!1)}_toSQL(){let e=this.dialect.buildRelationalQuery({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName}),t=this.dialect.sqlToQuery(e.sql);return{query:e,builtQuery:t}}toSQL(){return this._toSQL().builtQuery}executeRaw(){return"first"===this.mode?this._prepare(!1).get():this._prepare(!1).all()}async execute(){return this.executeRaw()}}class sy extends sp{static [n]="SQLiteSyncRelationalQuery";sync(){return this.executeRaw()}}class sb extends i7{constructor(e,t,i,s,r){super(),this.execute=e,this.getSQL=t,this.dialect=s,this.mapBatchResult=r,this.config={action:i}}static [n]="SQLiteRaw";config;getQuery(){return{...this.dialect.sqlToQuery(this.getSQL()),method:this.config.action}}mapResult(e,t){return t?this.mapBatchResult(e):e}_prepare(){return this}isResponseInArrayMode(){return!1}}class sS{constructor(e,t,i,s){this.resultKind=e,this.dialect=t,this.session=i,this._=s?{schema:s.schema,fullSchema:s.fullSchema,tableNamesMap:s.tableNamesMap}:{schema:void 0,fullSchema:{},tableNamesMap:{}},this.query={};const r=this.query;if(this._.schema)for(const[n,a]of Object.entries(this._.schema))r[n]=new sg(e,s.fullSchema,this._.schema,this._.tableNamesMap,s.fullSchema[n],a,t,i)}static [n]="BaseSQLiteDatabase";query;$with(e){let t=this;return{as:i=>("function"==typeof i&&(i=i(new so(t.dialect))),new Proxy(new E(i.getSQL(),i.getSelectedFields(),e,!0),new io({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"})))}}$count(e,t){return new sm({source:e,filters:t,session:this.session})}with(...e){let t=this;return{select:function(i){return new i9({fields:i??void 0,session:t.session,dialect:t.dialect,withList:e})},selectDistinct:function(i){return new i9({fields:i??void 0,session:t.session,dialect:t.dialect,withList:e,distinct:!0})},update:function(i){return new sd(i,t.session,t.dialect,e)},insert:function(i){return new sc(i,t.session,t.dialect,e)},delete:function(i){return new su(i,t.session,t.dialect,e)}}}select(e){return new i9({fields:e??void 0,session:this.session,dialect:this.dialect})}selectDistinct(e){return new i9({fields:e??void 0,session:this.session,dialect:this.dialect,distinct:!0})}update(e){return new sd(e,this.session,this.dialect)}insert(e){return new sc(e,this.session,this.dialect)}delete(e){return new su(e,this.session,this.dialect)}run(e){let t="string"==typeof e?Z.raw(e):e.getSQL();return"async"===this.resultKind?new sb(async()=>this.session.run(t),()=>t,"run",this.dialect,this.session.extractRawRunValueFromBatchResult.bind(this.session)):this.session.run(t)}all(e){let t="string"==typeof e?Z.raw(e):e.getSQL();return"async"===this.resultKind?new sb(async()=>this.session.all(t),()=>t,"all",this.dialect,this.session.extractRawAllValueFromBatchResult.bind(this.session)):this.session.all(t)}get(e){let t="string"==typeof e?Z.raw(e):e.getSQL();return"async"===this.resultKind?new sb(async()=>this.session.get(t),()=>t,"get",this.dialect,this.session.extractRawGetValueFromBatchResult.bind(this.session)):this.session.get(t)}values(e){let t="string"==typeof e?Z.raw(e):e.getSQL();return"async"===this.resultKind?new sb(async()=>this.session.values(t),()=>t,"values",this.dialect,this.session.extractRawValuesValueFromBatchResult.bind(this.session)):this.session.values(t)}transaction(e,t){return this.session.transaction(e,t)}}class sw extends i7{constructor(e){super(),this.resultCb=e}static [n]="ExecuteResultSync";async execute(){return this.resultCb()}sync(){return this.resultCb()}}class sv{constructor(e,t,i){this.mode=e,this.executeMethod=t,this.query=i}static [n]="PreparedQuery";joinsNotNullableMap;getQuery(){return this.query}mapRunResult(e,t){return e}mapAllResult(e,t){throw Error("Not implemented")}mapGetResult(e,t){throw Error("Not implemented")}execute(e){return"async"===this.mode?this[this.executeMethod](e):new sw(()=>this[this.executeMethod](e))}mapResult(e,t){switch(this.executeMethod){case"run":return this.mapRunResult(e,t);case"all":return this.mapAllResult(e,t);case"get":return this.mapGetResult(e,t)}}}class sT{constructor(e){this.dialect=e}static [n]="SQLiteSession";prepareOneTimeQuery(e,t,i,s){return this.prepareQuery(e,t,i,s)}run(e){let t=this.dialect.sqlToQuery(e);try{return this.prepareOneTimeQuery(t,void 0,"run",!1).run()}catch(e){throw new im({cause:e,message:`Failed to run the query '${t.sql}'`})}}extractRawRunValueFromBatchResult(e){return e}all(e){return this.prepareOneTimeQuery(this.dialect.sqlToQuery(e),void 0,"run",!1).all()}extractRawAllValueFromBatchResult(e){throw Error("Not implemented")}get(e){return this.prepareOneTimeQuery(this.dialect.sqlToQuery(e),void 0,"run",!1).get()}extractRawGetValueFromBatchResult(e){throw Error("Not implemented")}values(e){return this.prepareOneTimeQuery(this.dialect.sqlToQuery(e),void 0,"run",!1).values()}async count(e){return(await this.values(e))[0][0]}extractRawValuesValueFromBatchResult(e){throw Error("Not implemented")}}class s$ extends sS{constructor(e,t,i,s,r=0){super(e,t,i,s),this.schema=s,this.nestedIndex=r}static [n]="SQLiteTransaction";rollback(){throw new ig}}class sx extends sT{constructor(e,t,i,s={}){super(t),this.client=e,this.schema=i,this.logger=s.logger??new u}static [n]="BetterSQLiteSession";logger;prepareQuery(e,t,i,s,r){return new sQ(this.client.prepare(e.sql),e,this.logger,t,i,s,r)}transaction(e,t={}){let i=new sN("sync",this.dialect,this,this.schema);return this.client.transaction(e)[t.behavior??"deferred"](i)}}class sN extends s${static [n]="BetterSQLiteTransaction";transaction(e){let t=`sp${this.nestedIndex}`,i=new sN("sync",this.dialect,this.session,this.schema,this.nestedIndex+1);this.session.run(Z.raw(`savepoint ${t}`));try{let s=e(i);return this.session.run(Z.raw(`release savepoint ${t}`)),s}catch(e){throw this.session.run(Z.raw(`rollback to savepoint ${t}`)),e}}}class sQ extends sv{constructor(e,t,i,s,r,n,a){super("sync",r,t),this.stmt=e,this.logger=i,this.fields=s,this._isResponseInArrayMode=n,this.customResultMapper=a}static [n]="BetterSQLitePreparedQuery";run(e){let t=ei(this.query.params,e??{});return this.logger.logQuery(this.query.sql,t),this.stmt.run(...t)}all(e){let{fields:t,joinsNotNullableMap:i,query:s,logger:r,stmt:n,customResultMapper:a}=this;if(!t&&!a){let t=ei(s.params,e??{});return r.logQuery(s.sql,t),n.all(...t)}let l=this.values(e);return a?a(l):l.map(e=>en(t,e,i))}get(e){let t=ei(this.query.params,e??{});this.logger.logQuery(this.query.sql,t);let{fields:i,stmt:s,joinsNotNullableMap:r,customResultMapper:n}=this;if(!i&&!n)return s.get(...t);let a=s.raw().get(...t);if(a)return n?n([a]):en(i,a,r)}values(e){let t=ei(this.query.params,e??{});return this.logger.logQuery(this.query.sql,t),this.stmt.raw().all(...t)}isResponseInArrayMode(){return this._isResponseInArrayMode}}class sP extends sS{static [n]="BetterSQLite3Database"}function sL(e,t={}){let i,s,r=new i3({casing:t.casing});if(!0===t.logger?i=new o:!1!==t.logger&&(i=t.logger),t.schema){let e=function(e,t){1===Object.keys(e).length&&"default"in e&&!a(e.default,S)&&(e=e.default);let i={},s={},r={};for(let[n,l]of Object.entries(e))if(a(l,S)){let e=w(l),t=s[e];for(let s of(i[e]=n,r[n]={tsName:n,dbName:l[S.Symbol.Name],schema:l[S.Symbol.Schema],columns:l[S.Symbol.Columns],relations:t?.relations??{},primaryKey:t?.primaryKey??[]},Object.values(l[S.Symbol.Columns])))s.primary&&r[n].primaryKey.push(s);let o=l[S.Symbol.ExtraConfigBuilder]?.(l[S.Symbol.ExtraConfigColumns]);if(o)for(let e of Object.values(o))a(e,tD)&&r[n].primaryKey.push(...e.columns)}else if(a(l,t3)){let e,n=w(l.table),a=i[n];for(let[i,o]of Object.entries(l.config(t(l.table))))if(a){let t=r[a];t.relations[i]=o,e&&t.primaryKey.push(...e)}else n in s||(s[n]={relations:{},primaryKey:e}),s[n].relations[i]=o}return{tables:r,tableNamesMap:i}}(t.schema,t9);s={fullSchema:t.schema,schema:e.tables,tableNamesMap:e.tableNamesMap}}let n=new sx(e,r,s,{logger:i}),l=new sP("sync",r,n,s);return l.$client=e,l}function sB(...e){if(void 0===e[0]||"string"==typeof e[0])return sL(void 0===e[0]?new r.default:new r.default(e[0]),e[1]);if(function(e){if("object"!=typeof e||null===e||"Object"!==e.constructor.name)return!1;if("logger"in e){let t=typeof e.logger;return"boolean"===t||"object"===t&&"function"==typeof e.logger.logQuery||"undefined"===t}if("schema"in e){let t=typeof e.logger;return"object"===t||"undefined"===t}if("casing"in e){let t=typeof e.logger;return"string"===t||"undefined"===t}if("mode"in e)return"default"===e.mode&&"planetscale"===e.mode&&void 0===e.mode;if("connection"in e){let t=typeof e.connection;return"string"===t||"object"===t||"undefined"===t}if("client"in e){let t=typeof e.client;return"object"===t||"function"===t||"undefined"===t}return 0===Object.keys(e).length}(e[0])){let{connection:t,client:i,...s}=e[0];if(i)return sL(i,s);if("object"==typeof t){let{source:e,...i}=t;return sL(new r.default(e,i),s)}return sL(new r.default(t),s)}return sL(e[0],e[1])}(sB||(sB={})).mock=function(e){return sL({},e)};class sC{constructor(e,t){this.name=e,this.unique=t}static [n]="SQLiteIndexBuilderOn";on(...e){return new sq(this.name,e,this.unique)}}class sq{static [n]="SQLiteIndexBuilder";config;constructor(e,t,i){this.config={name:e,columns:t,unique:i,where:void 0}}where(e){return this.config.where=e,this}build(e){return new sD(this.config,e)}}class sD{static [n]="SQLiteIndex";config;constructor(e,t){this.config={...e,table:t}}}let s_=i2("projects",{id:iX("id").primaryKey(),githubOwner:iX("github_owner").notNull(),githubRepo:iX("github_repo").notNull(),displayName:iX("display_name"),description:iX("description"),homepageUrl:iX("homepage_url"),stars:iR("stars").default(0),isPublic:iR("is_public",{mode:"boolean"}).default(!0),isFeatured:iR("is_featured",{mode:"boolean"}).default(!1),lastSyncedAt:iR("last_synced_at",{mode:"timestamp"}),createdAt:iR("created_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date),updatedAt:iR("updated_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)}),sO=i2("specs",{id:iX("id").primaryKey(),projectId:iX("project_id").notNull().references(()=>s_.id,{onDelete:"cascade"}),specNumber:iR("spec_number"),specName:iX("spec_name").notNull(),title:iX("title"),status:iX("status",{enum:["planned","in-progress","complete","archived"]}),priority:iX("priority",{enum:["low","medium","high","critical"]}),tags:iX("tags"),assignee:iX("assignee"),contentMd:iX("content_md").notNull(),contentHtml:iX("content_html"),createdAt:iR("created_at",{mode:"timestamp"}),updatedAt:iR("updated_at",{mode:"timestamp"}),completedAt:iR("completed_at",{mode:"timestamp"}),filePath:iX("file_path").notNull(),githubUrl:iX("github_url"),syncedAt:iR("synced_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)},e=>({uniqueSpecNumber:new sC("unique_spec_number",!0).on(e.projectId,e.specNumber)})),sF=i2("spec_relationships",{id:iX("id").primaryKey(),specId:iX("spec_id").notNull().references(()=>sO.id,{onDelete:"cascade"}),relatedSpecId:iX("related_spec_id").notNull().references(()=>sO.id,{onDelete:"cascade"}),relationshipType:iX("relationship_type",{enum:["depends_on","related"]}).notNull(),createdAt:iR("created_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)}),sj=i2("sync_logs",{id:iX("id").primaryKey(),projectId:iX("project_id").notNull().references(()=>s_.id,{onDelete:"cascade"}),status:iX("status",{enum:["pending","running","success","failed"]}).notNull(),specsAdded:iR("specs_added").default(0),specsUpdated:iR("specs_updated").default(0),specsDeleted:iR("specs_deleted").default(0),errorMessage:iX("error_message"),startedAt:iR("started_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date),completedAt:iR("completed_at",{mode:"timestamp"}),durationMs:iR("duration_ms")}),sA=t7(s_,({many:e})=>({specs:e(sO),syncLogs:e(sj)})),sI=t7(sO,({one:e,many:t})=>({project:e(s_,{fields:[sO.projectId],references:[s_.id]}),dependencies:t(sF,{relationName:"spec"}),dependents:t(sF,{relationName:"relatedSpec"})})),sV=t7(sF,({one:e})=>({spec:e(sO,{fields:[sF.specId],references:[sO.id],relationName:"spec"}),relatedSpec:e(sO,{fields:[sF.relatedSpecId],references:[sO.id],relationName:"relatedSpec"})})),sz=t7(sj,({one:e})=>({project:e(s_,{fields:[sj.projectId],references:[s_.id]})}));e.s(["projects",0,s_,"projectsRelations",0,sA,"specRelationships",0,sF,"specRelationshipsRelations",0,sV,"specs",0,sO,"specsRelations",0,sI,"syncLogs",0,sj,"syncLogsRelations",0,sz],65239);var sE=e.i(65239),sR=e.i(14747);let sU=null,sM=null,sk=new Proxy({},{get:(e,t,i)=>Reflect.get(function(){if(!sU){let e=process.env.DATABASE_PATH||(0,sR.join)(process.cwd(),"leanspec.db");sM=new r.default(e),sU=sB(sM,{schema:sE})}return sU}(),t,i)});e.s(["db",0,sk],5271),e.s(["schema",0,sE],31585)}];
13
+ `;await t.run(r);let n=(await t.values(H`SELECT id, hash, created_at FROM ${H.identifier(s)} ORDER BY created_at DESC LIMIT 1`))[0]??void 0;await t.transaction(async t=>{for(let i of e)if(!n||Number(n[2])<i.folderMillis){for(let e of i.sql)await t.run(H.raw(e));await t.run(H`INSERT INTO ${H.identifier(s)} ("hash", "created_at") VALUES(${i.hash}, ${i.folderMillis})`)}})}}class i6{static [n]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}}class i7{static [n]="QueryPromise";[Symbol.toStringTag]="QueryPromise";catch(e){return this.then(void 0,e)}finally(e){return this.then(t=>(e?.(),t),t=>{throw e?.(),t})}then(e,t){return this.execute().then(e,t)}}class i9{static [n]="SQLiteSelectBuilder";fields;session;dialect;withList;distinct;constructor(e){this.fields=e.fields,this.session=e.session,this.dialect=e.dialect,this.withList=e.withList,this.distinct=e.distinct}from(e){let t,i=!!this.fields;return t=this.fields?this.fields:a(e,R)?Object.fromEntries(Object.keys(e._.selectedFields).map(t=>[t,e[t]])):a(e,i5)?e[z].selectedFields:a(e,J)?{}:e[S.Symbol.Columns],new st({table:e,fields:t,isPartialSelect:i,session:this.session,dialect:this.dialect,withList:this.withList,distinct:this.distinct})}}class se extends i6{static [n]="SQLiteSelectQueryBuilder";_;config;joinsNotNullableMap;tableName;isPartialSelect;session;dialect;constructor({table:e,fields:t,isPartialSelect:i,session:s,dialect:r,withList:n,distinct:a}){super(),this.config={withList:n,table:e,fields:{...t},distinct:a,setOperators:[]},this.isPartialSelect=i,this.session=s,this.dialect=r,this._={selectedFields:t},this.tableName=eu(e),this.joinsNotNullableMap="string"==typeof this.tableName?{[this.tableName]:!0}:{}}createJoin(e){return(t,i)=>{let s=this.tableName,r=eu(t);if("string"==typeof r&&this.config.joins?.some(e=>e.alias===r))throw Error(`Alias "${r}" is already used in this query`);if(!this.isPartialSelect&&(1===Object.keys(this.joinsNotNullableMap).length&&"string"==typeof s&&(this.config.fields={[s]:this.config.fields}),"string"==typeof r&&!a(t,J))){let e=a(t,R)?t._.selectedFields:a(t,er)?t[z].selectedFields:t[S.Symbol.Columns];this.config.fields[r]=e}if("function"==typeof i&&(i=i(new Proxy(this.config.fields,new io({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.joins||(this.config.joins=[]),this.config.joins.push({on:i,table:t,joinType:e,alias:r}),"string"==typeof r)switch(e){case"left":this.joinsNotNullableMap[r]=!1;break;case"right":this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([e])=>[e,!1])),this.joinsNotNullableMap[r]=!0;break;case"inner":this.joinsNotNullableMap[r]=!0;break;case"full":this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([e])=>[e,!1])),this.joinsNotNullableMap[r]=!1}return this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");createSetOperator(e,t){return i=>{let s="function"==typeof i?i(ss()):i;if(!el(this.getSelectedFields(),s.getSelectedFields()))throw Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return this.config.setOperators.push({type:e,isAll:t,rightSelect:s}),this}}union=this.createSetOperator("union",!1);unionAll=this.createSetOperator("union",!0);intersect=this.createSetOperator("intersect",!1);except=this.createSetOperator("except",!1);addSetOperators(e){return this.config.setOperators.push(...e),this}where(e){return"function"==typeof e&&(e=e(new Proxy(this.config.fields,new io({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.where=e,this}having(e){return"function"==typeof e&&(e=e(new Proxy(this.config.fields,new io({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.having=e,this}groupBy(...e){if("function"==typeof e[0]){let t=e[0](new Proxy(this.config.fields,new io({sqlAliasedBehavior:"alias",sqlBehavior:"sql"})));this.config.groupBy=Array.isArray(t)?t:[t]}else this.config.groupBy=e;return this}orderBy(...e){if("function"==typeof e[0]){let t=e[0](new Proxy(this.config.fields,new io({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),i=Array.isArray(t)?t:[t];this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=i:this.config.orderBy=i}else this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=e:this.config.orderBy=e;return this}limit(e){return this.config.setOperators.length>0?this.config.setOperators.at(-1).limit=e:this.config.limit=e,this}offset(e){return this.config.setOperators.length>0?this.config.setOperators.at(-1).offset=e:this.config.offset=e,this}getSQL(){return this.dialect.buildSelectQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}as(e){return new Proxy(new R(this.getSQL(),this.config.fields,e),new io({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}getSelectedFields(){return new Proxy(this.config.fields,new io({alias:this.tableName,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}$dynamic(){return this}}class st extends se{static [n]="SQLiteSelect";_prepare(e=!0){if(!this.session)throw Error("Cannot execute a query on a query builder. Please use a database instance instead.");let t=ea(this.config.fields),i=this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),t,"all",!0);return i.joinsNotNullableMap=this.joinsNotNullableMap,i}prepare(){return this._prepare(!1)}run=e=>this._prepare().run(e);all=e=>this._prepare().all(e);get=e=>this._prepare().get(e);values=e=>this._prepare().values(e);async execute(){return this.all()}}for(let e of[i7])for(let t of Object.getOwnPropertyNames(e.prototype))"constructor"!==t&&Object.defineProperty(st.prototype,t,Object.getOwnPropertyDescriptor(e.prototype,t)||Object.create(null));function si(e,t){return(i,s,...r)=>{let n=[s,...r].map(i=>({type:e,isAll:t,rightSelect:i}));for(let e of n)if(!el(i.getSelectedFields(),e.rightSelect.getSelectedFields()))throw Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return i.addSetOperators(n)}}let ss=()=>({union:sr,unionAll:sn,intersect:sa,except:sl}),sr=si("union",!1),sn=si("union",!0),sa=si("intersect",!1),sl=si("except",!1);class so{static [n]="SQLiteQueryBuilder";dialect;dialectConfig;constructor(e){this.dialect=a(e,i4)?e:void 0,this.dialectConfig=a(e,i4)?void 0:e}$with(e){let t=this;return{as:i=>("function"==typeof i&&(i=i(t)),new Proxy(new V(i.getSQL(),i.getSelectedFields(),e,!0),new io({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"})))}}with(...e){let t=this;return{select:function(i){return new i9({fields:i??void 0,session:void 0,dialect:t.getDialect(),withList:e})},selectDistinct:function(i){return new i9({fields:i??void 0,session:void 0,dialect:t.getDialect(),withList:e,distinct:!0})}}}select(e){return new i9({fields:e??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct(e){return new i9({fields:e??void 0,session:void 0,dialect:this.getDialect(),distinct:!0})}getDialect(){return this.dialect||(this.dialect=new i3(this.dialectConfig)),this.dialect}}class su extends i7{constructor(e,t,i,s){super(),this.table=e,this.session=t,this.dialect=i,this.config={table:e,withList:s}}static [n]="SQLiteDelete";config;where(e){return this.config.where=e,this}orderBy(...e){if("function"==typeof e[0]){let t=e[0](new Proxy(this.config.table[S.Symbol.Columns],new io({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),i=Array.isArray(t)?t:[t];this.config.orderBy=i}else this.config.orderBy=e;return this}limit(e){return this.config.limit=e,this}returning(e=this.table[i1.Symbol.Columns]){return this.config.returning=ea(e),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e=!0){return this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",!0)}prepare(){return this._prepare(!1)}run=e=>this._prepare().run(e);all=e=>this._prepare().all(e);get=e=>this._prepare().get(e);values=e=>this._prepare().values(e);async execute(e){return this._prepare().execute(e)}$dynamic(){return this}}class sc{constructor(e,t,i,s){this.table=e,this.session=t,this.dialect=i,this.withList=s}static [n]="SQLiteInsertBuilder";values(e){if(0===(e=Array.isArray(e)?e:[e]).length)throw Error("values() must be called with at least one value");let t=e.map(e=>{let t={},i=this.table[S.Symbol.Columns];for(let s of Object.keys(e)){let r=e[s];t[s]=a(r,J)?r:new Y(r,i[s])}return t});return new sh(this.table,t,this.session,this.dialect,this.withList)}select(e){let t="function"==typeof e?e(new so):e;if(!a(t,J)&&!el(this.table[d],t._.selectedFields))throw Error("Insert select error: selected fields are not the same or are in a different order compared to the table definition");return new sh(this.table,t,this.session,this.dialect,this.withList,!0)}}class sh extends i7{constructor(e,t,i,s,r,n){super(),this.session=i,this.dialect=s,this.config={table:e,values:t,withList:r,select:n}}static [n]="SQLiteInsert";config;returning(e=this.config.table[i1.Symbol.Columns]){return this.config.returning=ea(e),this}onConflictDoNothing(e={}){if(void 0===e.target)this.config.onConflict=H`do nothing`;else{let t=Array.isArray(e.target)?H`${e.target}`:H`${[e.target]}`,i=e.where?H` where ${e.where}`:H``;this.config.onConflict=H`${t} do nothing${i}`}return this}onConflictDoUpdate(e){if(e.where&&(e.targetWhere||e.setWhere))throw Error('You cannot use both "where" and "targetWhere"/"setWhere" at the same time - "where" is deprecated, use "targetWhere" or "setWhere" instead.');let t=e.where?H` where ${e.where}`:void 0,i=e.targetWhere?H` where ${e.targetWhere}`:void 0,s=e.setWhere?H` where ${e.setWhere}`:void 0,r=Array.isArray(e.target)?H`${e.target}`:H`${[e.target]}`,n=this.dialect.buildUpdateSet(this.config.table,eo(this.config.table,e.set));return this.config.onConflict=H`${r}${i} do update set ${n}${t}${s}`,this}getSQL(){return this.dialect.buildInsertQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e=!0){return this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",!0)}prepare(){return this._prepare(!1)}run=e=>this._prepare().run(e);all=e=>this._prepare().all(e);get=e=>this._prepare().get(e);values=e=>this._prepare().values(e);async execute(){return this.config.returning?this.all():this.run()}$dynamic(){return this}}class sd{constructor(e,t,i,s){this.table=e,this.session=t,this.dialect=i,this.withList=s}static [n]="SQLiteUpdateBuilder";set(e){return new sm(this.table,eo(this.table,e),this.session,this.dialect,this.withList)}}class sm extends i7{constructor(e,t,i,s,r){super(),this.session=i,this.dialect=s,this.config={set:t,table:e,withList:r,joins:[]}}static [n]="SQLiteUpdate";config;from(e){return this.config.from=e,this}createJoin(e){return(t,i)=>{let s=eu(t);if("string"==typeof s&&this.config.joins.some(e=>e.alias===s))throw Error(`Alias "${s}" is already used in this query`);if("function"==typeof i){let e=this.config.from?a(t,i1)?t[S.Symbol.Columns]:a(t,R)?t._.selectedFields:a(t,i5)?t[z].selectedFields:void 0:void 0;i=i(new Proxy(this.config.table[S.Symbol.Columns],new io({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})),e&&new Proxy(e,new io({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))}return this.config.joins.push({on:i,table:t,joinType:e,alias:s}),this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");where(e){return this.config.where=e,this}orderBy(...e){if("function"==typeof e[0]){let t=e[0](new Proxy(this.config.table[S.Symbol.Columns],new io({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),i=Array.isArray(t)?t:[t];this.config.orderBy=i}else this.config.orderBy=e;return this}limit(e){return this.config.limit=e,this}returning(e=this.config.table[i1.Symbol.Columns]){return this.config.returning=ea(e),this}getSQL(){return this.dialect.buildUpdateQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e=!0){return this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",!0)}prepare(){return this._prepare(!1)}run=e=>this._prepare().run(e);all=e=>this._prepare().all(e);get=e=>this._prepare().get(e);values=e=>this._prepare().values(e);async execute(){return this.config.returning?this.all():this.run()}$dynamic(){return this}}class sf extends J{constructor(e){super(sf.buildEmbeddedCount(e.source,e.filters).queryChunks),this.params=e,this.session=e.session,this.sql=sf.buildCount(e.source,e.filters)}sql;static [n]="SQLiteCountBuilderAsync";[Symbol.toStringTag]="SQLiteCountBuilderAsync";session;static buildEmbeddedCount(e,t){return H`(select count(*) from ${e}${H.raw(" where ").if(t)}${t})`}static buildCount(e,t){return H`select count(*) from ${e}${H.raw(" where ").if(t)}${t}`}then(e,t){return Promise.resolve(this.session.count(this.sql)).then(e,t)}catch(e){return this.then(void 0,e)}finally(e){return this.then(t=>(e?.(),t),t=>{throw e?.(),t})}}class sp{constructor(e,t,i,s,r,n,a,l){this.mode=e,this.fullSchema=t,this.schema=i,this.tableNamesMap=s,this.table=r,this.tableConfig=n,this.dialect=a,this.session=l}static [n]="SQLiteAsyncRelationalQueryBuilder";findMany(e){return"sync"===this.mode?new sy(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e||{},"many"):new sg(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e||{},"many")}findFirst(e){return"sync"===this.mode?new sy(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},"first"):new sg(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},"first")}}class sg extends i7{constructor(e,t,i,s,r,n,a,l,o){super(),this.fullSchema=e,this.schema=t,this.tableNamesMap=i,this.table=s,this.tableConfig=r,this.dialect=n,this.session=a,this.config=l,this.mode=o}static [n]="SQLiteAsyncRelationalQuery";mode;getSQL(){return this.dialect.buildRelationalQuery({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName}).sql}_prepare(e=!1){let{query:t,builtQuery:i}=this._toSQL();return this.session[e?"prepareOneTimeQuery":"prepareQuery"](i,void 0,"first"===this.mode?"get":"all",!0,(e,i)=>{let s=e.map(e=>(function e(t,i,s,r,n=e=>e){let l={};for(let[o,u]of r.entries())if(u.isJson){let r=i.relations[u.tsKey],c=s[o],h="string"==typeof c?JSON.parse(c):c;l[u.tsKey]=a(r,t8)?h&&e(t,t[u.relationTableTsKey],h,u.selection,n):h.map(i=>e(t,t[u.relationTableTsKey],i,u.selection,n))}else{let e,t=n(s[o]),i=u.field;e=a(i,T)?i:a(i,J)?i.decoder:i.sql.decoder,l[u.tsKey]=null===t?null:e.mapFromDriverValue(t)}return l})(this.schema,this.tableConfig,e,t.selection,i));return"first"===this.mode?s[0]:s})}prepare(){return this._prepare(!1)}_toSQL(){let e=this.dialect.buildRelationalQuery({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName}),t=this.dialect.sqlToQuery(e.sql);return{query:e,builtQuery:t}}toSQL(){return this._toSQL().builtQuery}executeRaw(){return"first"===this.mode?this._prepare(!1).get():this._prepare(!1).all()}async execute(){return this.executeRaw()}}class sy extends sg{static [n]="SQLiteSyncRelationalQuery";sync(){return this.executeRaw()}}class sb extends i7{constructor(e,t,i,s,r){super(),this.execute=e,this.getSQL=t,this.dialect=s,this.mapBatchResult=r,this.config={action:i}}static [n]="SQLiteRaw";config;getQuery(){return{...this.dialect.sqlToQuery(this.getSQL()),method:this.config.action}}mapResult(e,t){return t?this.mapBatchResult(e):e}_prepare(){return this}isResponseInArrayMode(){return!1}}class sS{constructor(e,t,i,s){this.resultKind=e,this.dialect=t,this.session=i,this._=s?{schema:s.schema,fullSchema:s.fullSchema,tableNamesMap:s.tableNamesMap}:{schema:void 0,fullSchema:{},tableNamesMap:{}},this.query={};const r=this.query;if(this._.schema)for(const[n,a]of Object.entries(this._.schema))r[n]=new sp(e,s.fullSchema,this._.schema,this._.tableNamesMap,s.fullSchema[n],a,t,i)}static [n]="BaseSQLiteDatabase";query;$with(e){let t=this;return{as:i=>("function"==typeof i&&(i=i(new so(t.dialect))),new Proxy(new V(i.getSQL(),i.getSelectedFields(),e,!0),new io({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"})))}}$count(e,t){return new sf({source:e,filters:t,session:this.session})}with(...e){let t=this;return{select:function(i){return new i9({fields:i??void 0,session:t.session,dialect:t.dialect,withList:e})},selectDistinct:function(i){return new i9({fields:i??void 0,session:t.session,dialect:t.dialect,withList:e,distinct:!0})},update:function(i){return new sd(i,t.session,t.dialect,e)},insert:function(i){return new sc(i,t.session,t.dialect,e)},delete:function(i){return new su(i,t.session,t.dialect,e)}}}select(e){return new i9({fields:e??void 0,session:this.session,dialect:this.dialect})}selectDistinct(e){return new i9({fields:e??void 0,session:this.session,dialect:this.dialect,distinct:!0})}update(e){return new sd(e,this.session,this.dialect)}insert(e){return new sc(e,this.session,this.dialect)}delete(e){return new su(e,this.session,this.dialect)}run(e){let t="string"==typeof e?H.raw(e):e.getSQL();return"async"===this.resultKind?new sb(async()=>this.session.run(t),()=>t,"run",this.dialect,this.session.extractRawRunValueFromBatchResult.bind(this.session)):this.session.run(t)}all(e){let t="string"==typeof e?H.raw(e):e.getSQL();return"async"===this.resultKind?new sb(async()=>this.session.all(t),()=>t,"all",this.dialect,this.session.extractRawAllValueFromBatchResult.bind(this.session)):this.session.all(t)}get(e){let t="string"==typeof e?H.raw(e):e.getSQL();return"async"===this.resultKind?new sb(async()=>this.session.get(t),()=>t,"get",this.dialect,this.session.extractRawGetValueFromBatchResult.bind(this.session)):this.session.get(t)}values(e){let t="string"==typeof e?H.raw(e):e.getSQL();return"async"===this.resultKind?new sb(async()=>this.session.values(t),()=>t,"values",this.dialect,this.session.extractRawValuesValueFromBatchResult.bind(this.session)):this.session.values(t)}transaction(e,t){return this.session.transaction(e,t)}}class sw extends i7{constructor(e){super(),this.resultCb=e}static [n]="ExecuteResultSync";async execute(){return this.resultCb()}sync(){return this.resultCb()}}class sT{constructor(e,t,i){this.mode=e,this.executeMethod=t,this.query=i}static [n]="PreparedQuery";joinsNotNullableMap;getQuery(){return this.query}mapRunResult(e,t){return e}mapAllResult(e,t){throw Error("Not implemented")}mapGetResult(e,t){throw Error("Not implemented")}execute(e){return"async"===this.mode?this[this.executeMethod](e):new sw(()=>this[this.executeMethod](e))}mapResult(e,t){switch(this.executeMethod){case"run":return this.mapRunResult(e,t);case"all":return this.mapAllResult(e,t);case"get":return this.mapGetResult(e,t)}}}class sN{constructor(e){this.dialect=e}static [n]="SQLiteSession";prepareOneTimeQuery(e,t,i,s){return this.prepareQuery(e,t,i,s)}run(e){let t=this.dialect.sqlToQuery(e);try{return this.prepareOneTimeQuery(t,void 0,"run",!1).run()}catch(e){throw new im({cause:e,message:`Failed to run the query '${t.sql}'`})}}extractRawRunValueFromBatchResult(e){return e}all(e){return this.prepareOneTimeQuery(this.dialect.sqlToQuery(e),void 0,"run",!1).all()}extractRawAllValueFromBatchResult(e){throw Error("Not implemented")}get(e){return this.prepareOneTimeQuery(this.dialect.sqlToQuery(e),void 0,"run",!1).get()}extractRawGetValueFromBatchResult(e){throw Error("Not implemented")}values(e){return this.prepareOneTimeQuery(this.dialect.sqlToQuery(e),void 0,"run",!1).values()}async count(e){return(await this.values(e))[0][0]}extractRawValuesValueFromBatchResult(e){throw Error("Not implemented")}}class sv extends sS{constructor(e,t,i,s,r=0){super(e,t,i,s),this.schema=s,this.nestedIndex=r}static [n]="SQLiteTransaction";rollback(){throw new ip}}class sL extends sN{constructor(e,t,i,s={}){super(t),this.client=e,this.schema=i,this.logger=s.logger??new u}static [n]="BetterSQLiteSession";logger;prepareQuery(e,t,i,s,r){return new s$(this.client.prepare(e.sql),e,this.logger,t,i,s,r)}transaction(e,t={}){let i=new sx("sync",this.dialect,this,this.schema);return this.client.transaction(e)[t.behavior??"deferred"](i)}}class sx extends sv{static [n]="BetterSQLiteTransaction";transaction(e){let t=`sp${this.nestedIndex}`,i=new sx("sync",this.dialect,this.session,this.schema,this.nestedIndex+1);this.session.run(H.raw(`savepoint ${t}`));try{let s=e(i);return this.session.run(H.raw(`release savepoint ${t}`)),s}catch(e){throw this.session.run(H.raw(`rollback to savepoint ${t}`)),e}}}class s$ extends sT{constructor(e,t,i,s,r,n,a){super("sync",r,t),this.stmt=e,this.logger=i,this.fields=s,this._isResponseInArrayMode=n,this.customResultMapper=a}static [n]="BetterSQLitePreparedQuery";run(e){let t=ei(this.query.params,e??{});return this.logger.logQuery(this.query.sql,t),this.stmt.run(...t)}all(e){let{fields:t,joinsNotNullableMap:i,query:s,logger:r,stmt:n,customResultMapper:a}=this;if(!t&&!a){let t=ei(s.params,e??{});return r.logQuery(s.sql,t),n.all(...t)}let l=this.values(e);return a?a(l):l.map(e=>en(t,e,i))}get(e){let t=ei(this.query.params,e??{});this.logger.logQuery(this.query.sql,t);let{fields:i,stmt:s,joinsNotNullableMap:r,customResultMapper:n}=this;if(!i&&!n)return s.get(...t);let a=s.raw().get(...t);if(a)return n?n([a]):en(i,a,r)}values(e){let t=ei(this.query.params,e??{});return this.logger.logQuery(this.query.sql,t),this.stmt.raw().all(...t)}isResponseInArrayMode(){return this._isResponseInArrayMode}}class sQ extends sS{static [n]="BetterSQLite3Database"}function sP(e,t={}){let i,s,r=new i3({casing:t.casing});if(!0===t.logger?i=new o:!1!==t.logger&&(i=t.logger),t.schema){let e=function(e,t){1===Object.keys(e).length&&"default"in e&&!a(e.default,S)&&(e=e.default);let i={},s={},r={};for(let[n,l]of Object.entries(e))if(a(l,S)){let e=w(l),t=s[e];for(let s of(i[e]=n,r[n]={tsName:n,dbName:l[S.Symbol.Name],schema:l[S.Symbol.Schema],columns:l[S.Symbol.Columns],relations:t?.relations??{},primaryKey:t?.primaryKey??[]},Object.values(l[S.Symbol.Columns])))s.primary&&r[n].primaryKey.push(s);let o=l[S.Symbol.ExtraConfigBuilder]?.(l[S.Symbol.ExtraConfigColumns]);if(o)for(let e of Object.values(o))a(e,t_)&&r[n].primaryKey.push(...e.columns)}else if(a(l,t3)){let e,n=w(l.table),a=i[n];for(let[i,o]of Object.entries(l.config(t(l.table))))if(a){let t=r[a];t.relations[i]=o,e&&t.primaryKey.push(...e)}else n in s||(s[n]={relations:{},primaryKey:e}),s[n].relations[i]=o}return{tables:r,tableNamesMap:i}}(t.schema,t9);s={fullSchema:t.schema,schema:e.tables,tableNamesMap:e.tableNamesMap}}let n=new sL(e,r,s,{logger:i}),l=new sQ("sync",r,n,s);return l.$client=e,l}function sC(...e){if(void 0===e[0]||"string"==typeof e[0])return sP(void 0===e[0]?new r.default:new r.default(e[0]),e[1]);if(function(e){if("object"!=typeof e||null===e||"Object"!==e.constructor.name)return!1;if("logger"in e){let t=typeof e.logger;return"boolean"===t||"object"===t&&"function"==typeof e.logger.logQuery||"undefined"===t}if("schema"in e){let t=typeof e.logger;return"object"===t||"undefined"===t}if("casing"in e){let t=typeof e.logger;return"string"===t||"undefined"===t}if("mode"in e)return"default"===e.mode&&"planetscale"===e.mode&&void 0===e.mode;if("connection"in e){let t=typeof e.connection;return"string"===t||"object"===t||"undefined"===t}if("client"in e){let t=typeof e.client;return"object"===t||"function"===t||"undefined"===t}return 0===Object.keys(e).length}(e[0])){let{connection:t,client:i,...s}=e[0];if(i)return sP(i,s);if("object"==typeof t){let{source:e,...i}=t;return sP(new r.default(e,i),s)}return sP(new r.default(t),s)}return sP(e[0],e[1])}(sC||(sC={})).mock=function(e){return sP({},e)};class sE{constructor(e,t){this.name=e,this.unique=t}static [n]="SQLiteIndexBuilderOn";on(...e){return new sB(this.name,e,this.unique)}}class sB{static [n]="SQLiteIndexBuilder";config;constructor(e,t,i){this.config={name:e,columns:t,unique:i,where:void 0}}where(e){return this.config.where=e,this}build(e){return new s_(this.config,e)}}class s_{static [n]="SQLiteIndex";config;constructor(e,t){this.config={...e,table:t}}}let sq=i2("projects",{id:iZ("id").primaryKey(),githubOwner:iZ("github_owner").notNull(),githubRepo:iZ("github_repo").notNull(),displayName:iZ("display_name"),description:iZ("description"),homepageUrl:iZ("homepage_url"),stars:iU("stars").default(0),isPublic:iU("is_public",{mode:"boolean"}).default(!0),isFeatured:iU("is_featured",{mode:"boolean"}).default(!1),lastSyncedAt:iU("last_synced_at",{mode:"timestamp"}),createdAt:iU("created_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date),updatedAt:iU("updated_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)}),sD=i2("specs",{id:iZ("id").primaryKey(),projectId:iZ("project_id").notNull().references(()=>sq.id,{onDelete:"cascade"}),specNumber:iU("spec_number"),specName:iZ("spec_name").notNull(),title:iZ("title"),status:iZ("status",{enum:["planned","in-progress","complete","archived"]}),priority:iZ("priority",{enum:["low","medium","high","critical"]}),tags:iZ("tags"),assignee:iZ("assignee"),contentMd:iZ("content_md").notNull(),contentHtml:iZ("content_html"),createdAt:iU("created_at",{mode:"timestamp"}),updatedAt:iU("updated_at",{mode:"timestamp"}),completedAt:iU("completed_at",{mode:"timestamp"}),filePath:iZ("file_path").notNull(),githubUrl:iZ("github_url"),syncedAt:iU("synced_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)},e=>({uniqueSpecNumber:new sE("unique_spec_number",!0).on(e.projectId,e.specNumber)})),sO=i2("spec_relationships",{id:iZ("id").primaryKey(),specId:iZ("spec_id").notNull().references(()=>sD.id,{onDelete:"cascade"}),relatedSpecId:iZ("related_spec_id").notNull().references(()=>sD.id,{onDelete:"cascade"}),relationshipType:iZ("relationship_type",{enum:["depends_on","related"]}).notNull(),createdAt:iU("created_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date)}),sA=i2("sync_logs",{id:iZ("id").primaryKey(),projectId:iZ("project_id").notNull().references(()=>sq.id,{onDelete:"cascade"}),status:iZ("status",{enum:["pending","running","success","failed"]}).notNull(),specsAdded:iU("specs_added").default(0),specsUpdated:iU("specs_updated").default(0),specsDeleted:iU("specs_deleted").default(0),errorMessage:iZ("error_message"),startedAt:iU("started_at",{mode:"timestamp"}).notNull().$defaultFn(()=>new Date),completedAt:iU("completed_at",{mode:"timestamp"}),durationMs:iU("duration_ms")}),sF=t7(sq,({many:e})=>({specs:e(sD),syncLogs:e(sA)})),sj=t7(sD,({one:e,many:t})=>({project:e(sq,{fields:[sD.projectId],references:[sq.id]}),dependencies:t(sO,{relationName:"spec"}),dependents:t(sO,{relationName:"relatedSpec"})})),sI=t7(sO,({one:e})=>({spec:e(sD,{fields:[sO.specId],references:[sD.id],relationName:"spec"}),relatedSpec:e(sD,{fields:[sO.relatedSpecId],references:[sD.id],relationName:"relatedSpec"})})),sR=t7(sA,({one:e})=>({project:e(sq,{fields:[sA.projectId],references:[sq.id]})}));e.s(["projects",0,sq,"projectsRelations",0,sF,"specRelationships",0,sO,"specRelationshipsRelations",0,sI,"specs",0,sD,"specsRelations",0,sj,"syncLogs",0,sA,"syncLogsRelations",0,sR],65239);var sV=e.i(65239),sU=e.i(14747);let sz=null,sM=null,sK=new Proxy({},{get:(e,t,i)=>Reflect.get(function(){if(!sz){let e=process.env.DATABASE_PATH||(0,sU.join)(process.cwd(),"leanspec.db");(function(e){e.pragma("foreign_keys = ON");let t=t=>!!e.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name = ?").get(t);t("projects")||e.exec(`
14
+ CREATE TABLE IF NOT EXISTS "projects" (
15
+ "id" TEXT PRIMARY KEY NOT NULL,
16
+ "github_owner" TEXT NOT NULL,
17
+ "github_repo" TEXT NOT NULL,
18
+ "display_name" TEXT,
19
+ "description" TEXT,
20
+ "homepage_url" TEXT,
21
+ "stars" INTEGER DEFAULT 0,
22
+ "is_public" INTEGER DEFAULT 1,
23
+ "is_featured" INTEGER DEFAULT 0,
24
+ "last_synced_at" INTEGER,
25
+ "created_at" INTEGER NOT NULL,
26
+ "updated_at" INTEGER NOT NULL
27
+ );
28
+ `),t("specs")||e.exec(`
29
+ CREATE TABLE IF NOT EXISTS "specs" (
30
+ "id" TEXT PRIMARY KEY NOT NULL,
31
+ "project_id" TEXT NOT NULL REFERENCES "projects"("id") ON DELETE CASCADE,
32
+ "spec_number" INTEGER,
33
+ "spec_name" TEXT NOT NULL,
34
+ "title" TEXT,
35
+ "status" TEXT,
36
+ "priority" TEXT,
37
+ "tags" TEXT,
38
+ "assignee" TEXT,
39
+ "content_md" TEXT NOT NULL,
40
+ "content_html" TEXT,
41
+ "created_at" INTEGER,
42
+ "updated_at" INTEGER,
43
+ "completed_at" INTEGER,
44
+ "file_path" TEXT NOT NULL,
45
+ "github_url" TEXT,
46
+ "synced_at" INTEGER NOT NULL
47
+ );
48
+ `),t("spec_relationships")||e.exec(`
49
+ CREATE TABLE IF NOT EXISTS "spec_relationships" (
50
+ "id" TEXT PRIMARY KEY NOT NULL,
51
+ "spec_id" TEXT NOT NULL REFERENCES "specs"("id") ON DELETE CASCADE,
52
+ "related_spec_id" TEXT NOT NULL REFERENCES "specs"("id") ON DELETE CASCADE,
53
+ "relationship_type" TEXT NOT NULL,
54
+ "created_at" INTEGER NOT NULL
55
+ );
56
+ `),t("sync_logs")||e.exec(`
57
+ CREATE TABLE IF NOT EXISTS "sync_logs" (
58
+ "id" TEXT PRIMARY KEY NOT NULL,
59
+ "project_id" TEXT NOT NULL REFERENCES "projects"("id") ON DELETE CASCADE,
60
+ "status" TEXT NOT NULL,
61
+ "specs_added" INTEGER DEFAULT 0,
62
+ "specs_updated" INTEGER DEFAULT 0,
63
+ "specs_deleted" INTEGER DEFAULT 0,
64
+ "error_message" TEXT,
65
+ "started_at" INTEGER NOT NULL,
66
+ "completed_at" INTEGER,
67
+ "duration_ms" INTEGER
68
+ );
69
+ `),e.prepare("SELECT name FROM sqlite_master WHERE type='index' AND name = ?").get("unique_spec_number")||e.exec(`
70
+ CREATE UNIQUE INDEX IF NOT EXISTS "unique_spec_number"
71
+ ON "specs" ("project_id", "spec_number");
72
+ `)})(sM=new r.default(e)),sz=sC(sM,{schema:sV})}return sz}(),t,i)});e.s(["db",0,sK],5271),e.s(["schema",0,sV],31585)}];
14
73
 
15
74
  //# sourceMappingURL=packages_ui_src_lib_db_index_ts_556307fa._.js.map
@@ -0,0 +1,3 @@
1
+ module.exports=[14430,e=>{e.v(s=>Promise.all(["server/chunks/[root-of-the-server]__f06435b0._.js","server/chunks/packages_ui_src_lib_db_index_ts_556307fa._.js"].map(s=>e.l(s))).then(()=>s(18146)))}];
2
+
3
+ //# sourceMappingURL=packages_ui_src_lib_specs_sources_database-source_ts_0bd881ee._.js.map
@@ -0,0 +1,3 @@
1
+ module.exports=[18146,e=>{"use strict";var s=e.i(5271),c=e.i(31585),t=e.i(22124);class a{async getAllSpecs(e){let a=e?s.db.select().from(c.schema.specs).where((0,t.eq)(c.schema.specs.projectId,e)):s.db.select().from(c.schema.specs);return await a.orderBy(c.schema.specs.specNumber)}async getSpec(e,a){if(!a)return null;let r=parseInt(e.split("-")[0],10);if(isNaN(r))return null;let l=await s.db.select().from(c.schema.specs).where((0,t.and)((0,t.eq)(c.schema.specs.projectId,a),(0,t.eq)(c.schema.specs.specNumber,r))).limit(1);return l.length>0?l[0]:null}async getSpecsByStatus(e,a){let r=[(0,t.eq)(c.schema.specs.status,e)];return a&&r.push((0,t.eq)(c.schema.specs.projectId,a)),await s.db.select().from(c.schema.specs).where((0,t.and)(...r)).orderBy(c.schema.specs.specNumber)}async searchSpecs(e,s){let c=await this.getAllSpecs(s),t=e.toLowerCase();return c.filter(e=>e.specName.toLowerCase().includes(t)||e.title?.toLowerCase().includes(t)||e.contentMd.toLowerCase().includes(t))}invalidateCache(){}}e.s(["DatabaseSource",()=>a])}];
2
+
3
+ //# sourceMappingURL=packages_ui_src_lib_specs_sources_database-source_ts_baa0160d._.js.map
@@ -0,0 +1,3 @@
1
+ module.exports=[56916,a=>{"use strict";var b=a.i(36883),c=a.i(90073);let d=Array(12).fill(0),e=({visible:a,className:c})=>b.default.createElement("div",{className:["sonner-loading-wrapper",c].filter(Boolean).join(" "),"data-visible":a},b.default.createElement("div",{className:"sonner-spinner"},d.map((a,c)=>b.default.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${c}`})))),f=b.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.default.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),g=b.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},b.default.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),h=b.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.default.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),i=b.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.default.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),j=b.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},b.default.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),b.default.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),k=1,l=new class{constructor(){this.subscribe=a=>(this.subscribers.push(a),()=>{let b=this.subscribers.indexOf(a);this.subscribers.splice(b,1)}),this.publish=a=>{this.subscribers.forEach(b=>b(a))},this.addToast=a=>{this.publish(a),this.toasts=[...this.toasts,a]},this.create=a=>{var b;let{message:c,...d}=a,e="number"==typeof(null==a?void 0:a.id)||(null==(b=a.id)?void 0:b.length)>0?a.id:k++,f=this.toasts.find(a=>a.id===e),g=void 0===a.dismissible||a.dismissible;return this.dismissedToasts.has(e)&&this.dismissedToasts.delete(e),f?this.toasts=this.toasts.map(b=>b.id===e?(this.publish({...b,...a,id:e,title:c}),{...b,...a,id:e,dismissible:g,title:c}):b):this.addToast({title:c,...d,dismissible:g,id:e}),e},this.dismiss=a=>(a?(this.dismissedToasts.add(a),requestAnimationFrame(()=>this.subscribers.forEach(b=>b({id:a,dismiss:!0})))):this.toasts.forEach(a=>{this.subscribers.forEach(b=>b({id:a.id,dismiss:!0}))}),a),this.message=(a,b)=>this.create({...b,message:a}),this.error=(a,b)=>this.create({...b,message:a,type:"error"}),this.success=(a,b)=>this.create({...b,type:"success",message:a}),this.info=(a,b)=>this.create({...b,type:"info",message:a}),this.warning=(a,b)=>this.create({...b,type:"warning",message:a}),this.loading=(a,b)=>this.create({...b,type:"loading",message:a}),this.promise=(a,c)=>{let d,e;if(!c)return;void 0!==c.loading&&(e=this.create({...c,promise:a,type:"loading",message:c.loading,description:"function"!=typeof c.description?c.description:void 0}));let f=Promise.resolve(a instanceof Function?a():a),g=void 0!==e,h=f.then(async a=>{if(d=["resolve",a],b.default.isValidElement(a))g=!1,this.create({id:e,type:"default",message:a});else if(m(a)&&!a.ok){g=!1;let d="function"==typeof c.error?await c.error(`HTTP error! status: ${a.status}`):c.error,f="function"==typeof c.description?await c.description(`HTTP error! status: ${a.status}`):c.description,h="object"!=typeof d||b.default.isValidElement(d)?{message:d}:d;this.create({id:e,type:"error",description:f,...h})}else if(a instanceof Error){g=!1;let d="function"==typeof c.error?await c.error(a):c.error,f="function"==typeof c.description?await c.description(a):c.description,h="object"!=typeof d||b.default.isValidElement(d)?{message:d}:d;this.create({id:e,type:"error",description:f,...h})}else if(void 0!==c.success){g=!1;let d="function"==typeof c.success?await c.success(a):c.success,f="function"==typeof c.description?await c.description(a):c.description,h="object"!=typeof d||b.default.isValidElement(d)?{message:d}:d;this.create({id:e,type:"success",description:f,...h})}}).catch(async a=>{if(d=["reject",a],void 0!==c.error){g=!1;let d="function"==typeof c.error?await c.error(a):c.error,f="function"==typeof c.description?await c.description(a):c.description,h="object"!=typeof d||b.default.isValidElement(d)?{message:d}:d;this.create({id:e,type:"error",description:f,...h})}}).finally(()=>{g&&(this.dismiss(e),e=void 0),null==c.finally||c.finally.call(c)}),i=()=>new Promise((a,b)=>h.then(()=>"reject"===d[0]?b(d[1]):a(d[1])).catch(b));return"string"!=typeof e&&"number"!=typeof e?{unwrap:i}:Object.assign(e,{unwrap:i})},this.custom=(a,b)=>{let c=(null==b?void 0:b.id)||k++;return this.create({jsx:a(c),id:c,...b}),c},this.getActiveToasts=()=>this.toasts.filter(a=>!this.dismissedToasts.has(a.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},m=a=>a&&"object"==typeof a&&"ok"in a&&"boolean"==typeof a.ok&&"status"in a&&"number"==typeof a.status,n=Object.assign((a,b)=>{let c=(null==b?void 0:b.id)||k++;return l.addToast({title:a,...b,id:c}),c},{success:l.success,info:l.info,warning:l.warning,error:l.error,custom:l.custom,message:l.message,promise:l.promise,dismiss:l.dismiss,loading:l.loading},{getHistory:()=>l.toasts,getToasts:()=>l.getActiveToasts()});function o(a){return void 0!==a.label}function p(...a){return a.filter(Boolean).join(" ")}!function(a){if(!a||"undefined"==typeof document)return;let b=document.head||document.getElementsByTagName("head")[0],c=document.createElement("style");c.type="text/css",b.appendChild(c),c.styleSheet?c.styleSheet.cssText=a:c.appendChild(document.createTextNode(a))}("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");let q=a=>{var c,d,k,l,m,n,q,r,s,t,u,v,w;let{invert:x,toast:y,unstyled:z,interacting:A,setHeights:B,visibleToasts:C,heights:D,index:E,toasts:F,expanded:G,removeToast:H,defaultRichColors:I,closeButton:J,style:K,cancelButtonStyle:L,actionButtonStyle:M,className:N="",descriptionClassName:O="",duration:P,position:Q,gap:R,expandByDefault:S,classNames:T,icons:U,closeButtonAriaLabel:V="Close toast"}=a,[W,X]=b.default.useState(null),[Y,Z]=b.default.useState(null),[$,_]=b.default.useState(!1),[aa,ab]=b.default.useState(!1),[ac,ad]=b.default.useState(!1),[ae,af]=b.default.useState(!1),[ag,ah]=b.default.useState(!1),[ai,aj]=b.default.useState(0),[ak,al]=b.default.useState(0),am=b.default.useRef(y.duration||P||4e3),an=b.default.useRef(null),ao=b.default.useRef(null),ap=0===E,aq=E+1<=C,ar=y.type,as=!1!==y.dismissible,at=y.className||"",au=y.descriptionClassName||"",av=b.default.useMemo(()=>D.findIndex(a=>a.toastId===y.id)||0,[D,y.id]),aw=b.default.useMemo(()=>{var a;return null!=(a=y.closeButton)?a:J},[y.closeButton,J]),ax=b.default.useMemo(()=>y.duration||P||4e3,[y.duration,P]),ay=b.default.useRef(0),az=b.default.useRef(0),aA=b.default.useRef(0),aB=b.default.useRef(null),[aC,aD]=Q.split("-"),aE=b.default.useMemo(()=>D.reduce((a,b,c)=>c>=av?a:a+b.height,0),[D,av]),aF=(()=>{let[a,c]=b.default.useState(document.hidden);return b.default.useEffect(()=>{let a=()=>{c(document.hidden)};return document.addEventListener("visibilitychange",a),()=>window.removeEventListener("visibilitychange",a)},[]),a})(),aG=y.invert||x,aH="loading"===ar;az.current=b.default.useMemo(()=>av*R+aE,[av,aE]),b.default.useEffect(()=>{am.current=ax},[ax]),b.default.useEffect(()=>{_(!0)},[]),b.default.useEffect(()=>{let a=ao.current;if(a){let b=a.getBoundingClientRect().height;return al(b),B(a=>[{toastId:y.id,height:b,position:y.position},...a]),()=>B(a=>a.filter(a=>a.toastId!==y.id))}},[B,y.id]),b.default.useLayoutEffect(()=>{if(!$)return;let a=ao.current,b=a.style.height;a.style.height="auto";let c=a.getBoundingClientRect().height;a.style.height=b,al(c),B(a=>a.find(a=>a.toastId===y.id)?a.map(a=>a.toastId===y.id?{...a,height:c}:a):[{toastId:y.id,height:c,position:y.position},...a])},[$,y.title,y.description,B,y.id,y.jsx,y.action,y.cancel]);let aI=b.default.useCallback(()=>{ab(!0),aj(az.current),B(a=>a.filter(a=>a.toastId!==y.id)),setTimeout(()=>{H(y)},200)},[y,H,B,az]);b.default.useEffect(()=>{let a;if((!y.promise||"loading"!==ar)&&y.duration!==1/0&&"loading"!==y.type){if(G||A||aF){if(aA.current<ay.current){let a=new Date().getTime()-ay.current;am.current=am.current-a}aA.current=new Date().getTime()}else am.current!==1/0&&(ay.current=new Date().getTime(),a=setTimeout(()=>{null==y.onAutoClose||y.onAutoClose.call(y,y),aI()},am.current));return()=>clearTimeout(a)}},[G,A,y,ar,aF,aI]),b.default.useEffect(()=>{y.delete&&(aI(),null==y.onDismiss||y.onDismiss.call(y,y))},[aI,y.delete]);let aJ=y.icon||(null==U?void 0:U[ar])||(a=>{switch(a){case"success":return f;case"info":return h;case"warning":return g;case"error":return i;default:return null}})(ar);return b.default.createElement("li",{tabIndex:0,ref:ao,className:p(N,at,null==T?void 0:T.toast,null==y||null==(c=y.classNames)?void 0:c.toast,null==T?void 0:T.default,null==T?void 0:T[ar],null==y||null==(d=y.classNames)?void 0:d[ar]),"data-sonner-toast":"","data-rich-colors":null!=(t=y.richColors)?t:I,"data-styled":!(y.jsx||y.unstyled||z),"data-mounted":$,"data-promise":!!y.promise,"data-swiped":ag,"data-removed":aa,"data-visible":aq,"data-y-position":aC,"data-x-position":aD,"data-index":E,"data-front":ap,"data-swiping":ac,"data-dismissible":as,"data-type":ar,"data-invert":aG,"data-swipe-out":ae,"data-swipe-direction":Y,"data-expanded":!!(G||S&&$),"data-testid":y.testId,style:{"--index":E,"--toasts-before":E,"--z-index":F.length-E,"--offset":`${aa?ai:az.current}px`,"--initial-height":S?"auto":`${ak}px`,...K,...y.style},onDragEnd:()=>{ad(!1),X(null),aB.current=null},onPointerDown:a=>{2===a.button||aH||!as||(an.current=new Date,aj(az.current),a.target.setPointerCapture(a.pointerId),"BUTTON"!==a.target.tagName&&(ad(!0),aB.current={x:a.clientX,y:a.clientY}))},onPointerUp:()=>{var a,b,c,d,e;if(ae||!as)return;aB.current=null;let f=Number((null==(a=ao.current)?void 0:a.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),g=Number((null==(b=ao.current)?void 0:b.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),h=new Date().getTime()-(null==(c=an.current)?void 0:c.getTime()),i="x"===W?f:g,j=Math.abs(i)/h;if(Math.abs(i)>=45||j>.11){aj(az.current),null==y.onDismiss||y.onDismiss.call(y,y),"x"===W?Z(f>0?"right":"left"):Z(g>0?"down":"up"),aI(),af(!0);return}null==(d=ao.current)||d.style.setProperty("--swipe-amount-x","0px"),null==(e=ao.current)||e.style.setProperty("--swipe-amount-y","0px"),ah(!1),ad(!1),X(null)},onPointerMove:b=>{var c,d,e,f;if(!aB.current||!as||(null==(c=window.getSelection())?void 0:c.toString().length)>0)return;let g=b.clientY-aB.current.y,h=b.clientX-aB.current.x,i=null!=(f=a.swipeDirections)?f:function(a){let[b,c]=a.split("-"),d=[];return b&&d.push(b),c&&d.push(c),d}(Q);!W&&(Math.abs(h)>1||Math.abs(g)>1)&&X(Math.abs(h)>Math.abs(g)?"x":"y");let j={x:0,y:0},k=a=>1/(1.5+Math.abs(a)/20);if("y"===W){if(i.includes("top")||i.includes("bottom"))if(i.includes("top")&&g<0||i.includes("bottom")&&g>0)j.y=g;else{let a=g*k(g);j.y=Math.abs(a)<Math.abs(g)?a:g}}else if("x"===W&&(i.includes("left")||i.includes("right")))if(i.includes("left")&&h<0||i.includes("right")&&h>0)j.x=h;else{let a=h*k(h);j.x=Math.abs(a)<Math.abs(h)?a:h}(Math.abs(j.x)>0||Math.abs(j.y)>0)&&ah(!0),null==(d=ao.current)||d.style.setProperty("--swipe-amount-x",`${j.x}px`),null==(e=ao.current)||e.style.setProperty("--swipe-amount-y",`${j.y}px`)}},aw&&!y.jsx&&"loading"!==ar?b.default.createElement("button",{"aria-label":V,"data-disabled":aH,"data-close-button":!0,onClick:aH||!as?()=>{}:()=>{aI(),null==y.onDismiss||y.onDismiss.call(y,y)},className:p(null==T?void 0:T.closeButton,null==y||null==(k=y.classNames)?void 0:k.closeButton)},null!=(u=null==U?void 0:U.close)?u:j):null,(ar||y.icon||y.promise)&&null!==y.icon&&((null==U?void 0:U[ar])!==null||y.icon)?b.default.createElement("div",{"data-icon":"",className:p(null==T?void 0:T.icon,null==y||null==(l=y.classNames)?void 0:l.icon)},y.promise||"loading"===y.type&&!y.icon?y.icon||((null==U?void 0:U.loading)?b.default.createElement("div",{className:p(null==T?void 0:T.loader,null==y||null==(w=y.classNames)?void 0:w.loader,"sonner-loader"),"data-visible":"loading"===ar},U.loading):b.default.createElement(e,{className:p(null==T?void 0:T.loader,null==y||null==(v=y.classNames)?void 0:v.loader),visible:"loading"===ar})):null,"loading"!==y.type?aJ:null):null,b.default.createElement("div",{"data-content":"",className:p(null==T?void 0:T.content,null==y||null==(m=y.classNames)?void 0:m.content)},b.default.createElement("div",{"data-title":"",className:p(null==T?void 0:T.title,null==y||null==(n=y.classNames)?void 0:n.title)},y.jsx?y.jsx:"function"==typeof y.title?y.title():y.title),y.description?b.default.createElement("div",{"data-description":"",className:p(O,au,null==T?void 0:T.description,null==y||null==(q=y.classNames)?void 0:q.description)},"function"==typeof y.description?y.description():y.description):null),b.default.isValidElement(y.cancel)?y.cancel:y.cancel&&o(y.cancel)?b.default.createElement("button",{"data-button":!0,"data-cancel":!0,style:y.cancelButtonStyle||L,onClick:a=>{!o(y.cancel)||as&&(null==y.cancel.onClick||y.cancel.onClick.call(y.cancel,a),aI())},className:p(null==T?void 0:T.cancelButton,null==y||null==(r=y.classNames)?void 0:r.cancelButton)},y.cancel.label):null,b.default.isValidElement(y.action)?y.action:y.action&&o(y.action)?b.default.createElement("button",{"data-button":!0,"data-action":!0,style:y.actionButtonStyle||M,onClick:a=>{!o(y.action)||(null==y.action.onClick||y.action.onClick.call(y.action,a),a.defaultPrevented||aI())},className:p(null==T?void 0:T.actionButton,null==y||null==(s=y.classNames)?void 0:s.actionButton)},y.action.label):null)},r=b.default.forwardRef(function(a,d){let{id:e,invert:f,position:g="bottom-right",hotkey:h=["altKey","KeyT"],expand:i,closeButton:j,className:k,offset:m,mobileOffset:n,theme:o="light",richColors:p,duration:r,style:s,visibleToasts:t=3,toastOptions:u,dir:v="ltr",gap:w=14,icons:x,containerAriaLabel:y="Notifications"}=a,[z,A]=b.default.useState([]),B=b.default.useMemo(()=>e?z.filter(a=>a.toasterId===e):z.filter(a=>!a.toasterId),[z,e]),C=b.default.useMemo(()=>Array.from(new Set([g].concat(B.filter(a=>a.position).map(a=>a.position)))),[B,g]),[D,E]=b.default.useState([]),[F,G]=b.default.useState(!1),[H,I]=b.default.useState(!1),[J,K]=b.default.useState("system"!==o?o:"light"),L=b.default.useRef(null),M=h.join("+").replace(/Key/g,"").replace(/Digit/g,""),N=b.default.useRef(null),O=b.default.useRef(!1),P=b.default.useCallback(a=>{A(b=>{var c;return(null==(c=b.find(b=>b.id===a.id))?void 0:c.delete)||l.dismiss(a.id),b.filter(({id:b})=>b!==a.id)})},[]);return b.default.useEffect(()=>l.subscribe(a=>{a.dismiss?requestAnimationFrame(()=>{A(b=>b.map(b=>b.id===a.id?{...b,delete:!0}:b))}):setTimeout(()=>{c.default.flushSync(()=>{A(b=>{let c=b.findIndex(b=>b.id===a.id);return -1!==c?[...b.slice(0,c),{...b[c],...a},...b.slice(c+1)]:[a,...b]})})})}),[z]),b.default.useEffect(()=>{"system"!==o?K(o):"system"===o&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?K("dark"):K("light"))},[o]),b.default.useEffect(()=>{z.length<=1&&G(!1)},[z]),b.default.useEffect(()=>{let a=a=>{var b,c;h.every(b=>a[b]||a.code===b)&&(G(!0),null==(c=L.current)||c.focus()),"Escape"===a.code&&(document.activeElement===L.current||(null==(b=L.current)?void 0:b.contains(document.activeElement)))&&G(!1)};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[h]),b.default.useEffect(()=>{if(L.current)return()=>{N.current&&(N.current.focus({preventScroll:!0}),N.current=null,O.current=!1)}},[L.current]),b.default.createElement("section",{ref:d,"aria-label":`${y} ${M}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},C.map((c,d)=>{var e;let g,[h,l]=c.split("-");return B.length?b.default.createElement("ol",{key:c,dir:"auto"===v?"ltr":v,tabIndex:-1,ref:L,className:k,"data-sonner-toaster":!0,"data-sonner-theme":J,"data-y-position":h,"data-x-position":l,style:{"--front-toast-height":`${(null==(e=D[0])?void 0:e.height)||0}px`,"--width":"356px","--gap":`${w}px`,...s,...(g={},[m,n].forEach((a,b)=>{let c=1===b,d=c?"--mobile-offset":"--offset",e=c?"16px":"24px";function f(a){["top","right","bottom","left"].forEach(b=>{g[`${d}-${b}`]="number"==typeof a?`${a}px`:a})}"number"==typeof a||"string"==typeof a?f(a):"object"==typeof a?["top","right","bottom","left"].forEach(b=>{void 0===a[b]?g[`${d}-${b}`]=e:g[`${d}-${b}`]="number"==typeof a[b]?`${a[b]}px`:a[b]}):f(e)}),g)},onBlur:a=>{O.current&&!a.currentTarget.contains(a.relatedTarget)&&(O.current=!1,N.current&&(N.current.focus({preventScroll:!0}),N.current=null))},onFocus:a=>{!(a.target instanceof HTMLElement&&"false"===a.target.dataset.dismissible)&&(O.current||(O.current=!0,N.current=a.relatedTarget))},onMouseEnter:()=>G(!0),onMouseMove:()=>G(!0),onMouseLeave:()=>{H||G(!1)},onDragEnd:()=>G(!1),onPointerDown:a=>{a.target instanceof HTMLElement&&"false"===a.target.dataset.dismissible||I(!0)},onPointerUp:()=>I(!1)},B.filter(a=>!a.position&&0===d||a.position===c).map((d,e)=>{var g,h;return b.default.createElement(q,{key:d.id,icons:x,index:e,toast:d,defaultRichColors:p,duration:null!=(g=null==u?void 0:u.duration)?g:r,className:null==u?void 0:u.className,descriptionClassName:null==u?void 0:u.descriptionClassName,invert:f,visibleToasts:t,closeButton:null!=(h=null==u?void 0:u.closeButton)?h:j,interacting:H,position:c,style:null==u?void 0:u.style,unstyled:null==u?void 0:u.unstyled,classNames:null==u?void 0:u.classNames,cancelButtonStyle:null==u?void 0:u.cancelButtonStyle,actionButtonStyle:null==u?void 0:u.actionButtonStyle,closeButtonAriaLabel:null==u?void 0:u.closeButtonAriaLabel,removeToast:P,toasts:B.filter(a=>a.position==d.position),heights:D.filter(a=>a.position==d.position),setHeights:E,expandByDefault:i,gap:w,expanded:F,swipeDirections:a.swipeDirections})})):null}))});a.s(["Toaster",()=>r,"toast",()=>n])}];
2
+
3
+ //# sourceMappingURL=38a22_sonner_dist_index_mjs_207730fe._.js.map