@kyro-cms/core 0.13.5 → 0.13.6

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 (319) hide show
  1. package/dist/api-handler-graphql.cjs +1 -1
  2. package/dist/api-handler-graphql.js +2 -2
  3. package/dist/api-handler-trpc.cjs +1 -1
  4. package/dist/api-handler-trpc.js +2 -2
  5. package/dist/api-handler.cjs +1 -1
  6. package/dist/api-handler.js +1 -1
  7. package/dist/auth-session-4WJUKESW.js +1 -0
  8. package/dist/auth-session-VHUHDBCL.cjs +1 -0
  9. package/dist/bootstrap-JYAUQ52D.cjs +1 -0
  10. package/dist/bootstrap-TTMLNQM3.js +1 -0
  11. package/dist/chunk-23RSKVJP.cjs +1 -0
  12. package/dist/chunk-24W5I6SJ.cjs +2 -0
  13. package/dist/{chunk-CH4TZZI5.js → chunk-2I2AXTKY.cjs} +38 -39
  14. package/dist/chunk-34LCWI5X.cjs +1 -0
  15. package/dist/chunk-3A5UO6OQ.cjs +114 -0
  16. package/dist/chunk-3N34WXBS.js +2 -0
  17. package/dist/chunk-5BUAWCU6.js +91 -0
  18. package/dist/{chunk-7NKNSRCB.cjs → chunk-5I3BM5TV.js} +33 -32
  19. package/dist/chunk-5RBGM5N5.js +3 -0
  20. package/dist/chunk-7EY3GXRA.js +2 -0
  21. package/dist/chunk-7KTPBTH5.cjs +1 -0
  22. package/dist/chunk-A4XM33WO.js +109 -0
  23. package/dist/chunk-A7763NCF.cjs +19 -0
  24. package/dist/chunk-AQWTJGML.cjs +1 -0
  25. package/dist/chunk-CIWLQXB2.js +2 -0
  26. package/dist/chunk-DCFOVCJX.cjs +1 -0
  27. package/dist/chunk-DCKJT247.cjs +1 -0
  28. package/dist/chunk-EG4SRTYS.cjs +2 -0
  29. package/dist/chunk-FAG2645P.js +2 -0
  30. package/dist/chunk-FIVTKI25.cjs +3 -0
  31. package/dist/chunk-FU76HURF.cjs +1 -0
  32. package/dist/chunk-GDLMPZKD.cjs +2 -0
  33. package/dist/chunk-GS4CMYKS.cjs +1 -0
  34. package/dist/chunk-GTAKGVUY.js +2 -0
  35. package/dist/chunk-GWUHIIPO.cjs +132 -0
  36. package/dist/chunk-H2IJDTA2.cjs +1 -0
  37. package/dist/chunk-HACW42ZZ.cjs +108 -0
  38. package/dist/chunk-HCM2G674.cjs +20 -0
  39. package/dist/chunk-I22MSXGL.js +2 -0
  40. package/dist/chunk-IIPSXKNV.js +115 -0
  41. package/dist/{chunk-WNU76M2C.js → chunk-IIVBEZC2.js} +6 -6
  42. package/dist/chunk-JHFD3IAU.cjs +1 -0
  43. package/dist/chunk-JJY2F6NL.cjs +3 -0
  44. package/dist/chunk-JQ4V2MGJ.cjs +2 -0
  45. package/dist/chunk-JXJTFBHG.js +3 -0
  46. package/dist/chunk-KOSR7235.cjs +1 -0
  47. package/dist/chunk-KUY4QDAL.js +2 -0
  48. package/dist/chunk-LGUHXOEW.js +3 -0
  49. package/dist/chunk-LXTVMP5F.cjs +6 -0
  50. package/dist/chunk-N25DOGLQ.js +5 -0
  51. package/dist/chunk-N2BMGZIX.cjs +90 -0
  52. package/dist/chunk-N7CDHWQH.cjs +2 -0
  53. package/dist/chunk-NBBAMC2X.cjs +1 -0
  54. package/dist/chunk-NGNXOXI5.js +2 -0
  55. package/dist/chunk-O4PPZOVI.cjs +1 -0
  56. package/dist/chunk-O4RKZQYQ.js +2 -0
  57. package/dist/chunk-OJBL4CXK.cjs +2 -0
  58. package/dist/chunk-OPKZYQV7.js +3 -0
  59. package/dist/chunk-OXEJCIOA.cjs +1 -0
  60. package/dist/chunk-OXH6CANN.js +2 -0
  61. package/dist/{chunk-EQN3HDES.cjs → chunk-PW6Y5MQL.cjs} +5 -5
  62. package/dist/chunk-RLW6AQF2.js +2 -0
  63. package/dist/chunk-SBFVITY2.js +7 -0
  64. package/dist/chunk-SEJ7LMYY.js +4 -0
  65. package/dist/chunk-SZY25KAE.js +21 -0
  66. package/dist/chunk-TG5YQ4PB.cjs +4 -0
  67. package/dist/chunk-TJ6N5ZPZ.js +133 -0
  68. package/dist/chunk-V2RMDMWN.js +2 -0
  69. package/dist/chunk-V4SR7DU5.js +3 -0
  70. package/dist/chunk-VLFM66BZ.js +4 -0
  71. package/dist/chunk-VPBGZW4P.cjs +1 -0
  72. package/dist/chunk-VQWOCGJ2.cjs +1 -0
  73. package/dist/chunk-VWXHW74B.js +3 -0
  74. package/dist/chunk-W5GDZG64.js +2 -0
  75. package/dist/chunk-WLSVS3NC.js +2 -0
  76. package/dist/chunk-YLP3EKTQ.js +2 -0
  77. package/dist/chunk-YNSKDTFG.js +2 -0
  78. package/dist/chunk-YOJOVQIH.cjs +1 -0
  79. package/dist/chunk-ZE2X3FBU.js +20 -0
  80. package/dist/chunk-ZMH35QYG.js +2 -0
  81. package/dist/cli/index.cjs +53 -182
  82. package/dist/cli/index.js +54 -183
  83. package/dist/drizzle/index.cjs +1 -1
  84. package/dist/drizzle/index.js +1 -1
  85. package/dist/fields/index.cjs +1 -1
  86. package/dist/fields/index.js +1 -1
  87. package/dist/graphql/index.cjs +1 -1
  88. package/dist/graphql/index.js +1 -1
  89. package/dist/index.cjs +30 -30
  90. package/dist/index.js +31 -31
  91. package/dist/integration.cjs +1 -1
  92. package/dist/integration.js +1 -1
  93. package/dist/local-DKP43BWQ.cjs +1 -0
  94. package/dist/local-TF5ZMHWW.js +1 -0
  95. package/dist/media-M3EIZ4QS.cjs +1 -0
  96. package/dist/media-WYEILC6K.js +1 -0
  97. package/dist/mongo-auth-adapter-33M5ENM7.cjs +1 -0
  98. package/dist/mongo-auth-adapter-4ITULS2P.js +1 -0
  99. package/dist/mongodb/index.cjs +1 -1
  100. package/dist/mongodb/index.js +1 -1
  101. package/dist/nodemailer-transport-7F3VLLBW.js +1 -0
  102. package/dist/nodemailer-transport-WAPZD3SJ.cjs +1 -0
  103. package/dist/postgres-auth-adapter-7BCPXNBO.js +1 -0
  104. package/dist/postgres-auth-adapter-HMXFUM5W.cjs +1 -0
  105. package/dist/redis-adapter-2E5AWMMA.cjs +1 -0
  106. package/dist/redis-adapter-GFH74CF4.js +1 -0
  107. package/dist/rest/index.cjs +1 -1
  108. package/dist/rest/index.js +1 -1
  109. package/dist/schema-FNIDQKIJ.cjs +1 -0
  110. package/dist/schema-KD736QFN.js +1 -0
  111. package/dist/sqlite-adapter-HL53RLSN.cjs +1 -0
  112. package/dist/sqlite-adapter-TT6ZASDG.js +1 -0
  113. package/dist/templates/index.cjs +1 -1
  114. package/dist/templates/index.js +1 -1
  115. package/dist/trpc/index.cjs +1 -1
  116. package/dist/trpc/index.js +1 -1
  117. package/dist/ws/index.cjs +1 -1
  118. package/dist/ws/index.js +1 -1
  119. package/package.json +2 -10
  120. package/dist/WebhookService-CGxHtw7E.d.cts +0 -143
  121. package/dist/WebhookService-CNC1lYz7.d.ts +0 -143
  122. package/dist/auth-session-DHVGXHOH.cjs +0 -1
  123. package/dist/auth-session-O7IIH7EP.js +0 -1
  124. package/dist/base-A9AJPCG5.d.ts +0 -219
  125. package/dist/base-C6wyX2nC.d.cts +0 -219
  126. package/dist/bcryptjs-WIQSWJGK.cjs +0 -1
  127. package/dist/bcryptjs-ZEEHSMAG.js +0 -2
  128. package/dist/better-sqlite3-5IISPX34.cjs +0 -1
  129. package/dist/better-sqlite3-B34RIU4C.js +0 -2
  130. package/dist/bootstrap-PG2LGDLB.js +0 -1
  131. package/dist/bootstrap-YD3GLTWX.cjs +0 -1
  132. package/dist/bowser-SB3ZUPO4.js +0 -11
  133. package/dist/bowser-VX6B6ZSE.cjs +0 -10
  134. package/dist/chokidar-5RVQZVHP.cjs +0 -5
  135. package/dist/chokidar-BOYGRT4Q.js +0 -6
  136. package/dist/chunk-262YP5XA.cjs +0 -1
  137. package/dist/chunk-2HA6EKXX.js +0 -24
  138. package/dist/chunk-2SPWRQ5O.js +0 -122
  139. package/dist/chunk-2TYITUOC.js +0 -122
  140. package/dist/chunk-35PGCW3S.cjs +0 -1
  141. package/dist/chunk-3CIMGC2F.cjs +0 -56
  142. package/dist/chunk-3KZXF4US.js +0 -2
  143. package/dist/chunk-3NSZZCOJ.js +0 -2
  144. package/dist/chunk-3TAUNYEM.js +0 -8
  145. package/dist/chunk-3VXEK5ZW.cjs +0 -1
  146. package/dist/chunk-47CXBWMA.js +0 -2
  147. package/dist/chunk-4BMWWGJN.js +0 -384
  148. package/dist/chunk-4NTIK6DF.cjs +0 -2
  149. package/dist/chunk-6E44MQQ5.js +0 -115
  150. package/dist/chunk-6LWF5MPL.js +0 -20
  151. package/dist/chunk-6NBZDW53.js +0 -133
  152. package/dist/chunk-6TPICJ2L.js +0 -7
  153. package/dist/chunk-6YS6XLOD.cjs +0 -121
  154. package/dist/chunk-73D2PNHD.cjs +0 -7
  155. package/dist/chunk-7ACHOBWY.cjs +0 -13
  156. package/dist/chunk-7GGZA5YU.cjs +0 -2
  157. package/dist/chunk-7JWQ2PZP.cjs +0 -1
  158. package/dist/chunk-7KLEANTO.cjs +0 -1
  159. package/dist/chunk-7MNDQU6K.js +0 -8
  160. package/dist/chunk-7NH7H3WA.js +0 -10
  161. package/dist/chunk-7WMMKGEO.cjs +0 -1
  162. package/dist/chunk-ALTU3FDG.js +0 -2
  163. package/dist/chunk-BAVN7VDR.cjs +0 -1
  164. package/dist/chunk-BCEE4NBZ.cjs +0 -2
  165. package/dist/chunk-BUNLC3II.cjs +0 -1
  166. package/dist/chunk-C7QCZX7X.js +0 -2
  167. package/dist/chunk-D6SDGHY6.js +0 -2
  168. package/dist/chunk-DVWYO3KK.cjs +0 -1
  169. package/dist/chunk-EHWUALGH.cjs +0 -1
  170. package/dist/chunk-EML5FDUU.js +0 -2
  171. package/dist/chunk-EN65ZEK2.cjs +0 -2
  172. package/dist/chunk-EW424IBO.cjs +0 -1
  173. package/dist/chunk-EZIDQBXI.cjs +0 -1
  174. package/dist/chunk-F2O4QO5N.cjs +0 -383
  175. package/dist/chunk-F4ITQ6XQ.cjs +0 -3
  176. package/dist/chunk-FK2BG4HU.js +0 -3
  177. package/dist/chunk-FLMUMPDE.js +0 -2
  178. package/dist/chunk-GIS6X43A.cjs +0 -3
  179. package/dist/chunk-GNEVCEJU.cjs +0 -3
  180. package/dist/chunk-GNOSG3PK.cjs +0 -1
  181. package/dist/chunk-GQGFNTDZ.js +0 -2
  182. package/dist/chunk-GTR7JAKP.cjs +0 -3
  183. package/dist/chunk-HPIJI7TM.js +0 -3
  184. package/dist/chunk-HPYH7GTS.cjs +0 -1
  185. package/dist/chunk-HRAY65XH.js +0 -3
  186. package/dist/chunk-HTYVI2HK.cjs +0 -9
  187. package/dist/chunk-IKGVPXMK.js +0 -3
  188. package/dist/chunk-J6V573PE.cjs +0 -1
  189. package/dist/chunk-JA44K75G.js +0 -2
  190. package/dist/chunk-JRUQ5ABB.js +0 -4
  191. package/dist/chunk-JV4HJBXW.js +0 -14
  192. package/dist/chunk-KEITOXIP.js +0 -2
  193. package/dist/chunk-KMFLHGD5.cjs +0 -1
  194. package/dist/chunk-KZHXYXSH.cjs +0 -10
  195. package/dist/chunk-L3Q64RUX.js +0 -3
  196. package/dist/chunk-LEBM6ZSZ.cjs +0 -10
  197. package/dist/chunk-LKRI5X2V.cjs +0 -1
  198. package/dist/chunk-LQ3YZTPU.cjs +0 -15
  199. package/dist/chunk-LVBHOZZF.js +0 -4
  200. package/dist/chunk-LWM4WABU.js +0 -3
  201. package/dist/chunk-LY7N3UHH.cjs +0 -23
  202. package/dist/chunk-MCIZG4A3.cjs +0 -1
  203. package/dist/chunk-MDLJTZLV.cjs +0 -1
  204. package/dist/chunk-N4FXLQE3.cjs +0 -132
  205. package/dist/chunk-N5POANYV.js +0 -2
  206. package/dist/chunk-NGNJSUGL.cjs +0 -1
  207. package/dist/chunk-NRE6VKL6.cjs +0 -121
  208. package/dist/chunk-O4YE57OS.cjs +0 -6
  209. package/dist/chunk-OBYAIJVU.js +0 -11
  210. package/dist/chunk-OLRCZ6E3.js +0 -2
  211. package/dist/chunk-OOVNTOZC.cjs +0 -56
  212. package/dist/chunk-P6JITOFF.js +0 -4
  213. package/dist/chunk-PITMDQYN.cjs +0 -18
  214. package/dist/chunk-PYUWSKKP.js +0 -57
  215. package/dist/chunk-Q5TFO66G.cjs +0 -1
  216. package/dist/chunk-QO5ZWQA3.cjs +0 -74
  217. package/dist/chunk-QYN6C3FZ.cjs +0 -114
  218. package/dist/chunk-REQ622YC.js +0 -3
  219. package/dist/chunk-RPRGGGIW.js +0 -11
  220. package/dist/chunk-RVBSJ4UQ.cjs +0 -7
  221. package/dist/chunk-RYHOWZLK.js +0 -2
  222. package/dist/chunk-RYXLEFS5.js +0 -2
  223. package/dist/chunk-SBNMXQNO.cjs +0 -2
  224. package/dist/chunk-SLMIYECU.js +0 -2
  225. package/dist/chunk-SRIXRJHL.js +0 -4
  226. package/dist/chunk-TBHNE4VV.js +0 -2
  227. package/dist/chunk-TCFL3UWT.cjs +0 -2
  228. package/dist/chunk-TYQYKKWJ.js +0 -16
  229. package/dist/chunk-U6KFONKM.js +0 -2
  230. package/dist/chunk-UNYXWPLZ.cjs +0 -2
  231. package/dist/chunk-UWHWSWDE.js +0 -2
  232. package/dist/chunk-V4FAL7AG.js +0 -2
  233. package/dist/chunk-VQ53TFYA.cjs +0 -1
  234. package/dist/chunk-VRZC4TTF.cjs +0 -1
  235. package/dist/chunk-W45TLOOT.js +0 -2
  236. package/dist/chunk-WAVGRSE6.js +0 -2
  237. package/dist/chunk-WPM6LFCY.js +0 -2
  238. package/dist/chunk-WXT2XW7T.js +0 -13
  239. package/dist/chunk-X473JI7Z.js +0 -75
  240. package/dist/chunk-X6HUA6EF.cjs +0 -20
  241. package/dist/chunk-XDPLVJRO.js +0 -21
  242. package/dist/chunk-XDQVYCIR.cjs +0 -1
  243. package/dist/chunk-XFYSADHV.cjs +0 -2
  244. package/dist/chunk-XOR64WUQ.cjs +0 -19
  245. package/dist/chunk-Y2YAKDEQ.js +0 -2
  246. package/dist/chunk-YENNL5HG.js +0 -2
  247. package/dist/chunk-YGI5W4RS.js +0 -2
  248. package/dist/chunk-YIFKTA5N.js +0 -57
  249. package/dist/chunk-YUUXFD73.js +0 -19
  250. package/dist/chunk-ZAKYTBEN.js +0 -3
  251. package/dist/chunk-ZHA446FA.cjs +0 -1
  252. package/dist/chunk-ZTLGK6R4.cjs +0 -12
  253. package/dist/chunk-ZUBJ6RLQ.cjs +0 -1
  254. package/dist/client.d.cts +0 -1291
  255. package/dist/client.d.ts +0 -1291
  256. package/dist/d1-5ZQJOFDX.cjs +0 -1
  257. package/dist/d1-HPB6B253.js +0 -2
  258. package/dist/dist-es-3SSNUZST.cjs +0 -1
  259. package/dist/dist-es-64F22JL2.js +0 -2
  260. package/dist/dist-es-A5OF2STN.cjs +0 -2
  261. package/dist/dist-es-BOW5V247.cjs +0 -6
  262. package/dist/dist-es-CRIMATLL.cjs +0 -2
  263. package/dist/dist-es-DL3VLVP6.cjs +0 -1
  264. package/dist/dist-es-F2ZR55UK.js +0 -4
  265. package/dist/dist-es-IPSSZNFP.js +0 -1
  266. package/dist/dist-es-M2F7M27Y.js +0 -2
  267. package/dist/dist-es-M66JKZF5.js +0 -7
  268. package/dist/dist-es-OKLLRYI3.js +0 -2
  269. package/dist/dist-es-P25IKLBI.cjs +0 -1
  270. package/dist/dist-es-SRPWSAF4.cjs +0 -1
  271. package/dist/dist-es-SVHZDVUF.js +0 -3
  272. package/dist/dist-es-T2H2W5BX.cjs +0 -3
  273. package/dist/dist-es-WFI55HKT.js +0 -3
  274. package/dist/drizzle-orm-47ELDEM6.cjs +0 -1
  275. package/dist/drizzle-orm-XRTSOQJS.js +0 -1
  276. package/dist/event-streams-7NAWZW2I.js +0 -1
  277. package/dist/event-streams-JBMWCI2O.cjs +0 -1
  278. package/dist/fs-KWBRQ6T6.js +0 -1
  279. package/dist/fs-ZQYOJOIO.cjs +0 -1
  280. package/dist/index-NGnJpSgf.d.ts +0 -105
  281. package/dist/index-Zrg3sZ6R.d.cts +0 -105
  282. package/dist/jsonwebtoken-DFB6ZBZA.cjs +0 -8
  283. package/dist/jsonwebtoken-OD67R5JS.js +0 -9
  284. package/dist/lib-A2D63VXD.cjs +0 -1
  285. package/dist/lib-JQD2JAOO.js +0 -2
  286. package/dist/loadSso-JY4WDQPS.cjs +0 -2
  287. package/dist/loadSso-UQR6545M.js +0 -3
  288. package/dist/local-6UUGBZ4M.js +0 -1
  289. package/dist/local-ZYHV3J2K.cjs +0 -1
  290. package/dist/media-3Z6YW5J4.cjs +0 -1
  291. package/dist/media-E762GEHL.js +0 -1
  292. package/dist/mongo-auth-adapter-2H2AXDRH.cjs +0 -1
  293. package/dist/mongo-auth-adapter-YWMEOC42.js +0 -1
  294. package/dist/nodemailer-IDML4L6W.cjs +0 -53
  295. package/dist/nodemailer-NITB45SS.js +0 -54
  296. package/dist/nodemailer-transport-3VWVUBM5.cjs +0 -1
  297. package/dist/nodemailer-transport-7RHATUKL.js +0 -1
  298. package/dist/postgres-auth-adapter-QKBNXVPT.js +0 -1
  299. package/dist/postgres-auth-adapter-WMLM4UUC.cjs +0 -1
  300. package/dist/postgres-js-7YBZKGXG.cjs +0 -1
  301. package/dist/postgres-js-JLFIWOBH.js +0 -1
  302. package/dist/redis-adapter-EVK2SMKH.cjs +0 -1
  303. package/dist/redis-adapter-LY2NBSAG.js +0 -1
  304. package/dist/schema-RT6WSUYC.cjs +0 -1
  305. package/dist/schema-YFMSJK2P.js +0 -2
  306. package/dist/signin-N3T2KF5Q.js +0 -3
  307. package/dist/signin-VFBLX7EL.cjs +0 -2
  308. package/dist/sqlite-adapter-KPSISY6E.cjs +0 -1
  309. package/dist/sqlite-adapter-PI6SIY7O.js +0 -1
  310. package/dist/src-6LAUXXDM.cjs +0 -1
  311. package/dist/src-QBADSZV4.js +0 -1
  312. package/dist/sso-oidc-54BIRYR6.cjs +0 -2
  313. package/dist/sso-oidc-UB7G4END.js +0 -3
  314. package/dist/sts-WAA6I22C.js +0 -3
  315. package/dist/sts-YLXXIB3X.cjs +0 -2
  316. package/dist/types-BCOhfwHC.d.ts +0 -839
  317. package/dist/types-DxaK39ix.d.cts +0 -330
  318. package/dist/types-DxaK39ix.d.ts +0 -330
  319. package/dist/types-QglJ7PwT.d.cts +0 -839
@@ -1,23 +0,0 @@
1
- 'use strict';var chunkBUNLC3II_cjs=require('./chunk-BUNLC3II.cjs'),mn=require('os'),dn=require('fs'),Qt=require('net'),xr=require('tls'),ze=require('crypto'),ht=require('stream'),perf_hooks=require('perf_hooks');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var mn__default=/*#__PURE__*/_interopDefault(mn);var dn__default=/*#__PURE__*/_interopDefault(dn);var Qt__default=/*#__PURE__*/_interopDefault(Qt);var xr__default=/*#__PURE__*/_interopDefault(xr);var ze__default=/*#__PURE__*/_interopDefault(ze);var ht__default=/*#__PURE__*/_interopDefault(ht);chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();var Qe=new Map,nt=new Map,st=Symbol("OriginError"),Ce={},re=class extends Promise{constructor(r,n,a,i,u={}){let o,c;super((d,j)=>{o=d,c=j;}),this.tagged=Array.isArray(r.raw),this.strings=r,this.args=n,this.handler=a,this.canceller=i,this.options=u,this.state=null,this.statement=null,this.resolve=d=>(this.active=false,o(d)),this.reject=d=>(this.active=false,c(d)),this.active=false,this.cancelled=null,this.executed=false,this.signature="",this[st]=this.handler.debug?new Error:this.tagged&&Gr(this.strings);}get origin(){return (this.handler.debug?this[st].stack:this.tagged&&nt.has(this.strings)?nt.get(this.strings):nt.set(this.strings,this[st].stack).get(this.strings))||""}static get[Symbol.species](){return Promise}cancel(){return this.canceller&&(this.canceller(this),this.canceller=null)}simple(){return this.options.simple=true,this.options.prepare=false,this}async readable(){return this.simple(),this.streaming=true,this}async writable(){return this.simple(),this.streaming=true,this}cursor(r=1,n){if(this.options.simple=false,typeof r=="function"&&(n=r,r=1),this.cursorRows=r,typeof n=="function")return this.cursorFn=n,this;let a;return {[Symbol.asyncIterator]:()=>({next:()=>{if(this.executed&&!this.active)return {done:true};a&&a();let i=new Promise((u,o)=>{this.cursorFn=c=>(u({value:c,done:false}),new Promise(d=>a=d)),this.resolve=()=>(this.active=false,u({done:true})),this.reject=c=>(this.active=false,o(c));});return this.execute(),i},return(){return a&&a(Ce),{done:true}}})}}describe(){return this.options.simple=false,this.onlyDescribe=this.options.prepare=true,this}stream(){throw new Error(".stream has been renamed to .forEach")}forEach(r){return this.forEachFn=r,this.handle(),this}raw(){return this.isRaw=true,this}values(){return this.isRaw="values",this}async handle(){!this.executed&&(this.executed=true)&&await 1&&this.handler(this);}execute(){return this.handle(),this}then(){return this.handle(),super.then.apply(this,arguments)}catch(){return this.handle(),super.catch.apply(this,arguments)}finally(){return this.handle(),super.finally.apply(this,arguments)}};function Gr(e){if(Qe.has(e))return Qe.get(e);let r=Error.stackTraceLimit;return Error.stackTraceLimit=4,Qe.set(e,new Error),Error.stackTraceLimit=r,Qe.get(e)}chunkBUNLC3II_cjs.h();var Ee=class extends Error{constructor(r){super(r.message),this.name=this.constructor.name,Object.assign(this,r);}},z={connection:It,postgres:Nt,generic:Ut,notSupported:jt};function It(e,r,n){let{host:a,port:i}=n||r,u=Object.assign(new Error("write "+e+" "+(r.path||a+":"+i)),{code:e,errno:e,address:r.path||a},r.path?{}:{port:i});return Error.captureStackTrace(u,It),u}function Nt(e){let r=new Ee(e);return Error.captureStackTrace(r,Nt),r}function Ut(e,r){let n=Object.assign(new Error(e+": "+r),{code:e});return Error.captureStackTrace(n,Ut),n}function jt(e){let r=Object.assign(new Error(e+" (B) is not supported"),{code:"MESSAGE_NOT_SUPPORTED",name:e});return Error.captureStackTrace(r,jt),r}var Qr={string:{to:25,from:null,serialize:e=>""+e},number:{to:0,from:[21,23,26,700,701],serialize:e=>""+e,parse:e=>+e},json:{to:114,from:[114,3802],serialize:e=>JSON.stringify(e),parse:e=>JSON.parse(e)},boolean:{to:16,from:16,serialize:e=>e===true?"t":"f",parse:e=>e==="t"},date:{to:1184,from:[1082,1114,1184],serialize:e=>(e instanceof Date?e:new Date(e)).toISOString(),parse:e=>new Date(e)},bytea:{to:17,from:17,serialize:e=>"\\x"+Buffer.from(e).toString("hex"),parse:e=>Buffer.from(e.slice(2),"hex")}},De=class{then(){at();}catch(){at();}finally(){at();}},Te=class extends De{constructor(r){super(),this.value=Ye(r);}},ie=class extends De{constructor(r,n,a){super(),this.value=r,this.type=n,this.array=a;}},ke=class extends De{constructor(r,n){super(),this.first=r,this.rest=n;}build(r,n,a,i){let u=Hr.map(([o,c])=>({fn:c,i:r.search(o)})).sort((o,c)=>o.i-c.i).pop();return u.i===-1?ut(this.first,i):u.fn(this.first,this.rest,n,a,i)}};function Ve(e,r,n,a){let i=e instanceof ie?e.value:e;if(i===void 0&&(e instanceof ie?e.value=a.transform.undefined:i=e=a.transform.undefined,i===void 0))throw z.generic("UNDEFINED_VALUE","Undefined values are not allowed");return "$"+n.push(e instanceof ie?(r.push(e.value),e.array?e.array[e.type||Ke(e.value)]||e.type||Ft(e.value):e.type):(r.push(e),Ke(e)))}var Dt=Mt(Qr);function ct(e,r,n,a,i,u){for(let o=1;o<e.strings.length;o++)r+=lt(r,n,a,i,u)+e.strings[o],n=e.args[o];return r}function lt(e,r,n,a,i){return r instanceof ke?r.build(e,n,a,i):r instanceof re?it(r,n,a,i):r instanceof Te?r.value:r&&r[0]instanceof re?r.reduce((u,o)=>u+" "+it(o,n,a,i),""):Ve(r,n,a,i)}function it(e,r,n,a){return e.fragment=true,ct(e,e.strings[0],e.args[0],r,n,a)}function kt(e,r,n,a,i){return e.map(u=>"("+a.map(o=>lt("values",u[o],r,n,i)).join(",")+")").join(",")}function Rt(e,r,n,a,i){let u=Array.isArray(e[0]),o=r.length?r.flat():Object.keys(u?e[0]:e);return kt(u?e:[e],n,a,o,i)}function He(e,r,n,a,i){if(typeof e=="string"&&(e=[e].concat(r)),Array.isArray(e))return ut(e,i);let u;return (r.length?r.flat():Object.keys(e)).map(c=>(u=e[c],(u instanceof re?it(u,n,a,i):u instanceof Te?u.value:Ve(u,n,a,i))+" as "+Ye(i.transform.column.to?i.transform.column.to(c):c))).join(",")}var Hr=Object.entries({values:Rt,in:(...e)=>{let r=Rt(...e);return r==="()"?"(null)":r},select:He,as:He,returning:He,"\\(":He,update(e,r,n,a,i){return (r.length?r.flat():Object.keys(e)).map(u=>Ye(i.transform.column.to?i.transform.column.to(u):u)+"="+lt("values",e[u],n,a,i))},insert(e,r,n,a,i){let u=r.length?r.flat():Object.keys(Array.isArray(e)?e[0]:e);return "("+ut(u,i)+")values"+kt(Array.isArray(e)?e:[e],n,a,u,i)}}).map(([e,r])=>[new RegExp("((?:^|[\\s(])"+e+"(?:$|[\\s(]))(?![\\s\\S]*\\1)","i"),r]);function at(){throw z.generic("NOT_TAGGED_CALL","Query not called as a tagged template literal")}var Kr=Dt.serializers,Vr=Dt.parsers;function Ft(e){return Array.isArray(e)?Ft(e[0]):typeof e=="string"?1009:0}var Lt=function(e){let r=Mt(e||{});return {serializers:Object.assign({},Kr,r.serializers),parsers:Object.assign({},Vr,r.parsers)}};function Mt(e){return Object.keys(e).reduce((r,n)=>(e[n].from&&[].concat(e[n].from).forEach(a=>r.parsers[a]=e[n].parse),e[n].serialize&&(r.serializers[e[n].to]=e[n].serialize,e[n].from&&[].concat(e[n].from).forEach(a=>r.serializers[a]=e[n].serialize)),r),{parsers:{},serializers:{}})}function ut(e,{transform:{column:r}}){return e.map(n=>Ye(r.to?r.to(n):n)).join(",")}var Ye=function(r){return '"'+r.replace(/"/g,'""').replace(/\./g,'"."')+'"'},Ke=function e(r){return r instanceof ie?r.type:r instanceof Date?1184:r instanceof Uint8Array?17:r===true||r===false?16:typeof r=="bigint"?20:Array.isArray(r)?e(r[0]):0},Yr=/\\/g,Wr=/"/g;function Xr(e){return e.replace(Yr,"\\\\").replace(Wr,'\\"')}var zt=function e(r,n,a,i){if(Array.isArray(r)===false)return r;if(!r.length)return "{}";let u=r[0],o=i===1020?";":",";return Array.isArray(u)&&!u.type?"{"+r.map(c=>e(c,n,a,i)).join(o)+"}":"{"+r.map(c=>{if(c===void 0&&(c=a.transform.undefined,c===void 0))throw z.generic("UNDEFINED_VALUE","Undefined values are not allowed");return c===null?"null":'"'+Xr(n?n(c.type?c.value:c):""+c)+'"'}).join(o)+"}"},ot={i:0,char:null,str:"",quoted:false,last:0},$t=function(r,n,a){return ot.i=ot.last=0,Gt(ot,r,n,a)};function Gt(e,r,n,a){let i=[],u=a===1020?";":",";for(;e.i<r.length;e.i++){if(e.char=r[e.i],e.quoted)e.char==="\\"?e.str+=r[++e.i]:e.char==='"'?(i.push(n?n(e.str):e.str),e.str="",e.quoted=r[e.i+1]==='"',e.last=e.i+2):e.str+=e.char;else if(e.char==='"')e.quoted=true;else if(e.char==="{")e.last=++e.i,i.push(Gt(e,r,n,a));else if(e.char==="}"){e.quoted=false,e.last<e.i&&i.push(n?n(r.slice(e.last,e.i)):r.slice(e.last,e.i)),e.last=e.i+1;break}else e.char===u&&e.p!=="}"&&e.p!=='"'&&(i.push(n?n(r.slice(e.last,e.i)):r.slice(e.last,e.i)),e.last=e.i+1);e.p=e.char;}return e.last<e.i&&i.push(n?n(r.slice(e.last,e.i+1)):r.slice(e.last,e.i+1)),i}var _e=e=>{let r=e[0];for(let n=1;n<e.length;n++)r+=e[n]==="_"?e[++n].toUpperCase():e[n];return r},Se=e=>{let r=e[0].toUpperCase();for(let n=1;n<e.length;n++)r+=e[n]==="_"?e[++n].toUpperCase():e[n];return r},ve=e=>e.replace(/_/g,"-"),Fe=e=>e.replace(/([A-Z])/g,"_$1").toLowerCase(),Le=e=>(e.slice(0,1)+e.slice(1).replace(/([A-Z])/g,"_$1")).toLowerCase(),Me=e=>e.replace(/-/g,"_");function ft(e){return function r(n,a){return typeof n=="object"&&n!==null&&(a.type===114||a.type===3802)?Array.isArray(n)?n.map(i=>r(i,a)):Object.entries(n).reduce((i,[u,o])=>Object.assign(i,{[e(u)]:r(o,a)}),{}):n}}_e.column={from:_e};_e.value={from:ft(_e)};Fe.column={to:Fe};var mt={..._e};mt.column.to=Fe;Se.column={from:Se};Se.value={from:ft(Se)};Le.column={to:Le};var dt={...Se};dt.column.to=Le;ve.column={from:ve};ve.value={from:ft(ve)};Me.column={to:Me};var pt={...ve};pt.column.to=Me;chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();var ye=class extends Array{constructor(){super(),Object.defineProperties(this,{count:{value:null,writable:true},state:{value:null,writable:true},command:{value:null,writable:true},columns:{value:null,writable:true},statement:{value:null,writable:true}});}static get[Symbol.species](){return Array}};chunkBUNLC3II_cjs.h();var ne=Jr;function Jr(e=[]){let r=e.slice(),n=0;return {get length(){return r.length-n},remove:a=>{let i=r.indexOf(a);return i===-1?null:(r.splice(i,1),a)},push:a=>(r.push(a),a),shift:()=>{let a=r[n++];return n===r.length?(n=0,r=[]):r[n-1]=void 0,a}}}chunkBUNLC3II_cjs.h();var X=Buffer.allocUnsafe(256),Zr="BCcDdEFfHPpQSX".split("").reduce((e,r)=>{let n=r.charCodeAt(0);return e[r]=()=>(X[0]=n,B.i=5,B),e},{}),B=Object.assign(qr,Zr,{N:"\0",i:0,inc(e){return B.i+=e,B},str(e){let r=Buffer.byteLength(e);return We(r),B.i+=X.write(e,B.i,r,"utf8"),B},i16(e){return We(2),X.writeUInt16BE(e,B.i),B.i+=2,B},i32(e,r){return r||r===0?(X.writeUInt32BE(e,r),B):(We(4),X.writeUInt32BE(e,B.i),B.i+=4,B)},z(e){return We(e),X.fill(0,B.i,B.i+e),B.i+=e,B},raw(e){return X=Buffer.concat([X.subarray(0,B.i),e]),B.i=X.length,B},end(e=1){X.writeUInt32BE(B.i-e,e);let r=X.subarray(0,B.i);return B.i=0,X=Buffer.allocUnsafe(256),r}}),p=B;function We(e){if(X.length-B.i<e){let r=X,n=r.length;X=Buffer.allocUnsafe(n+(n>>1)+e),r.copy(X);}}function qr(){return B.i=0,B}var yt=Yt,en=1,we=p().S().end(),Kt=p().H().end(),tn=p().i32(8).i32(80877103).end(8),rn=Buffer.concat([p().E().str(p.N).i32(0).end(),we]),nn=p().D().str("S").str(p.N).end(),Ie=()=>{},sn=new Set(["FetchPreparedStatement","RevalidateCachedQuery","transformAssignedExpr"]),an={83:"severity_local",86:"severity",67:"code",77:"message",68:"detail",72:"hint",80:"position",112:"internal_position",113:"internal_query",87:"where",115:"schema_name",116:"table_name",99:"column_name",100:"data type_name",110:"constraint_name",70:"file",76:"line",82:"routine"};function Yt(e,r={},{onopen:n=Ie,onend:a=Ie,onclose:i=Ie}={}){let{sslnegotiation:u,ssl:o,max:c,user:d,host:j,port:C,database:P,parsers:b,transform:E,onnotice:R,onnotify:g,onparameter:H,max_pipeline:N,keep_alive:oe,backoff:se,target_session_attrs:ee}=e,S=ne(),pe=en++,le={pid:null,secret:null},Ae=gt(tt,e.idle_timeout),be=gt(tt,e.max_lifetime),v=gt(tr,e.connect_timeout),m=null,ue,x=null,A=new ye,J=Buffer.alloc(0),Oe=e.fetch_types,fe={},l={},y=Math.random().toString(36).slice(2),U=1,$=0,L=0,w=0,O=0,k=0,F=0,G=0,Z=null,T=null,me=false,ce=null,he=null,V=null,D=null,I=null,te=null,$e=null,xe=null,f=null,Ne=null,Y={queue:r.closed,idleTimer:Ae,connect(t){V=t,Ot();},terminate:Re,execute:Ue,cancel:Zt,end:tt,count:0,id:pe};return r.closed&&r.closed.push(Y),Y;async function Jt(){let t;try{t=e.socket?await Promise.resolve(e.socket(e)):new Qt__default.default.Socket;}catch(s){Be(s);return}return t.on("error",Be),t.on("close",Pt),t.on("drain",vt),t}async function Zt({pid:t,secret:s},h,_){try{ue=p().i32(16).i32(80877102).i32(t).i32(s).end(16),await At(),m.once("error",_),m.once("close",h);}catch(M){_(M);}}function Ue(t){if(me)return je(t,z.connection("CONNECTION_DESTROYED",e));if(I)return je(t,z.generic("COPY_IN_PROGRESS","You cannot execute queries during copy"));if(!t.cancelled)try{return t.state=le,f?S.push(t):(f=t,f.active=!0),er(t),K(qt(t))&&!t.describeFirst&&!t.cursorFn&&S.length<N&&(!t.options.onexecute||t.options.onexecute(Y))}catch(s){return S.length===0&&K(we),ae(s),true}}function qt(t){if(t.parameters.length>=65534)throw z.generic("MAX_PARAMETERS_EXCEEDED","Max number of parameters (65534) exceeded");return t.options.simple?p().Q().str(t.statement.string+p.N).end():t.describeFirst?Buffer.concat([Et(t),Kt]):t.prepare?t.prepared?Ge(t):Buffer.concat([Et(t),Ge(t)]):xt(t)}function Et(t){return Buffer.concat([Ct(t.statement.string,t.parameters,t.statement.types,t.statement.name),Mr("S",t.statement.name)])}function Ge(t){return Buffer.concat([Lr(t.parameters,t.statement.types,t.statement.name,t.cursorName),t.cursorFn?Tt("",t.cursorRows):rn])}function xt(t){return Buffer.concat([Ct(t.statement.string,t.parameters,t.statement.types),nn,Ge(t)])}function er(t){let s=[],h=[],_=ct(t,t.strings[0],t.args[0],s,h,e);!t.tagged&&t.args.forEach(M=>Ve(M,s,h,e)),t.prepare=e.prepare&&("prepare"in t.options?t.options.prepare:true),t.string=_,t.signature=t.prepare&&h+_,t.onlyDescribe&&delete l[t.signature],t.parameters=t.parameters||s,t.prepared=t.prepare&&t.signature in l,t.describeFirst=t.onlyDescribe||s.length&&!t.prepared,t.statement=t.prepared?l[t.signature]:{string:_,types:h,name:t.prepare?y+U++:""},typeof e.debug=="function"&&e.debug(pe,_,s,h);}function K(t,s){return te=te?Buffer.concat([te,t]):Buffer.from(t),s||te.length>=1024?_t(s):(T===null&&(T=setImmediate(_t)),true)}function _t(t){let s=m.write(te,t);return T!==null&&clearImmediate(T),te=T=null,s}function tr(){ae(z.connection("CONNECT_TIMEOUT",e,m)),m.destroy();}async function St(){if(u!=="direct"&&(K(tn),!await new Promise(h=>m.once("data",_=>h(_[0]===83)))&&o==="prefer"))return Pe();let t={socket:m,servername:Qt__default.default.isIP(m.host)?void 0:m.host};u==="direct"&&(t.ALPNProtocols=["postgresql"]),o==="require"||o==="allow"||o==="prefer"?t.rejectUnauthorized=false:typeof o=="object"&&Object.assign(t,o),m.removeAllListeners(),m=xr__default.default.connect(t),m.on("secureConnect",Pe),m.on("error",Be),m.on("close",Pt),m.on("drain",vt);}function vt(){!f&&n(Y);}function et(t){if(!(ce&&(ce.push(t),L-=t.length,L>0)))for(J=ce?Buffer.concat(ce,k-L):J.length===0?t:Buffer.concat([J,t],J.length+t.length);J.length>4;){if(k=J.readUInt32BE(1),k>=J.length){L=k-J.length,ce=[J];break}try{rr(J.subarray(0,k+1));}catch(s){f&&(f.cursorFn||f.describeFirst)&&K(we),ae(s);}J=J.subarray(k+1),L=0,ce=null;}}async function At(){if(me=false,fe={},m||(m=await Jt()),!!m){if(v.start(),e.socket)return o?St():Pe();if(m.on("connect",o?St:Pe),e.path)return m.connect(e.path);m.ssl=o,m.connect(C[w],j[w]),m.host=j[w],m.port=C[w],w=(w+1)%C.length;}}function Ot(){setTimeout(At,$?Math.max(0,$+F-perf_hooks.performance.now()):0);}function Pe(){try{l={},Oe=e.fetch_types,y=Math.random().toString(36).slice(2),U=1,be.start(),m.on("data",et),oe&&m.setKeepAlive&&m.setKeepAlive(!0,1e3*oe);let t=$r();K(t);}catch(t){Be(t);}}function Be(t){if(!(Y.queue===r.connecting&&e.host[O+1]))for(ae(t);S.length;)je(S.shift(),t);}function ae(t){I&&(I.destroy(t),I=null),f&&je(f,t),V&&(je(V,t),V=null);}function je(t,s){if(t.reserve)return t.reject(s);(!s||typeof s!="object")&&(s=new Error(s)),"query"in s||"parameters"in s||Object.defineProperties(s,{stack:{value:s.stack+t.origin.replace(/.*\n/,`
2
- `),enumerable:e.debug},query:{value:t.string,enumerable:e.debug},parameters:{value:t.parameters,enumerable:e.debug},args:{value:t.args,enumerable:e.debug},types:{value:t.statement&&t.statement.types,enumerable:e.debug}}),t.reject(s);}function tt(){return D||(!Y.reserved&&a(Y),!Y.reserved&&!V&&!f&&S.length===0?(Re(),new Promise(t=>m&&m.readyState!=="closed"?m.once("close",t):t())):D=new Promise(t=>$e=t))}function Re(){me=true,(I||f||V||S.length)&&Be(z.connection("CONNECTION_DESTROYED",e)),clearImmediate(T),m&&(m.removeListener("data",et),m.removeListener("connect",Pe),m.readyState==="open"&&m.end(p().X().end())),$e&&($e(),D=$e=null);}async function Pt(t){if(J=Buffer.alloc(0),L=0,ce=null,clearImmediate(T),m.removeListener("data",et),m.removeListener("connect",Pe),Ae.cancel(),be.cancel(),v.cancel(),m.removeAllListeners(),m=null,V)return Ot();!t&&(f||S.length)&&Be(z.connection("CONNECTION_CLOSED",e,m)),$=perf_hooks.performance.now(),t&&e.shared.retries++,F=(typeof se=="function"?se(e.shared.retries):se)*1e3,i(Y,z.connection("CONNECTION_CLOSED",e,m));}function rr(t,s=t[0]){(s===68?nr:s===100?Ir:s===65?Ar:s===83?sr:s===90?ar:s===67?or:s===50?Bt:s===49?ir:s===116?cr:s===84?lr:s===82?ur:s===110?gr:s===75?yr:s===69?Sr:s===115?Or:s===51?Pr:s===71?Br:s===78?Ur:s===72?Cr:s===99?Nr:s===73?jr:s===86?Rr:s===118?Dr:s===87?Tr:kr)(t);}function nr(t){let s=7,h,_,M,W=f.isRaw?new Array(f.statement.columns.length):{};for(let q=0;q<f.statement.columns.length;q++)_=f.statement.columns[q],h=t.readInt32BE(s),s+=4,M=h===-1?null:f.isRaw===true?t.subarray(s,s+=h):_.parser===void 0?t.toString("utf8",s,s+=h):_.parser.array===true?_.parser(t.toString("utf8",s+1,s+=h)):_.parser(t.toString("utf8",s,s+=h)),f.isRaw?W[q]=f.isRaw===true?M:E.value.from?E.value.from(M,_):M:W[_.name]=E.value.from?E.value.from(M,_):M;f.forEachFn?f.forEachFn(E.row.from?E.row.from(W):W,A):A[G++]=E.row.from?E.row.from(W):W;}function sr(t){let[s,h]=t.toString("utf8",5,t.length-1).split(p.N);fe[s]=h,e.parameters[s]!==h&&(e.parameters[s]=h,H&&H(s,h));}function ar(t){if(f?x?f.retried?ae(f.retried):f.prepared&&sn.has(x.routine)?vr(f,x):ae(x):f.resolve(he||A):x&&ae(x),f=he=x=null,A=new ye,v.cancel(),V){if(ee){if(!fe.in_hot_standby||!fe.default_transaction_read_only)return _r();if(Er(ee,fe))return Re()}if(Oe)return V.reserve&&(V=null),wr();V&&!V.reserve&&Ue(V),e.shared.retries=O=0,V=null;return}for(;S.length&&(f=S.shift())&&(f.active=true,f.cancelled);)Yt(e).cancel(f.state,f.cancelled.resolve,f.cancelled.reject);f||(Y.reserved?!Y.reserved.release&&t[5]===73?D?Re():(Y.reserved=null,n(Y)):Y.reserved():D?Re():n(Y));}function or(t){G=0;for(let s=t.length-1;s>0;s--)if(t[s]===32&&t[s+1]<58&&A.count===null&&(A.count=+t.toString("utf8",s+1,t.length-1)),t[s-1]>=65){A.command=t.toString("utf8",5,s),A.state=le;break}if(Ne&&(Ne(),Ne=null),A.command==="BEGIN"&&c!==1&&!Y.reserved)return ae(z.generic("UNSAFE_TRANSACTION","Only use sql.begin, sql.reserved or max: 1"));if(f.options.simple)return Bt();f.cursorFn&&(A.count&&f.cursorFn(A),K(we));}function ir(){f.parsing=false;}function Bt(){!A.statement&&(A.statement=f.statement),A.columns=f.statement.columns;}function cr(t){let s=t.readUInt16BE(5);for(let h=0;h<s;++h)!f.statement.types[h]&&(f.statement.types[h]=t.readUInt32BE(7+h*4));f.prepare&&(l[f.signature]=f.statement),f.describeFirst&&!f.onlyDescribe&&(K(Ge(f)),f.describeFirst=false);}function lr(t){A.command&&(he=he||[A],he.push(A=new ye),A.count=null,f.statement.columns=null);let s=t.readUInt16BE(5),h=7,_;f.statement.columns=Array(s);for(let M=0;M<s;++M){for(_=h;t[h++]!==0;);let W=t.readUInt32BE(h),q=t.readUInt16BE(h+4),ge=t.readUInt32BE(h+6);f.statement.columns[M]={name:E.column.from?E.column.from(t.toString("utf8",_,h-1)):t.toString("utf8",_,h-1),parser:b[ge],table:W,number:q,type:ge},h+=18;}if(A.statement=f.statement,f.onlyDescribe)return f.resolve(f.statement),K(we)}async function ur(t,s=t.readUInt32BE(5)){(s===3?fr:s===5?mr:s===10?dr:s===11?pr:s===12?hr:s!==0?Fr:Ie)(t,s);}async function fr(){let t=await rt();K(p().p().str(t).z(1).end());}async function mr(t){let s="md5"+await Vt(Buffer.concat([Buffer.from(await Vt(await rt()+d)),t.subarray(9)]));K(p().p().str(s).z(1).end());}async function dr(){xe=(await ze__default.default.randomBytes(18)).toString("base64"),p().p().str("SCRAM-SHA-256"+p.N);let t=p.i;K(p.inc(4).str("n,,n=*,r="+xe).i32(p.i-t-4,t).end());}async function pr(t){let s=t.toString("utf8",9).split(",").reduce((q,ge)=>(q[ge[0]]=ge.slice(2),q),{}),h=await ze__default.default.pbkdf2Sync(await rt(),Buffer.from(s.s,"base64"),parseInt(s.i),32,"sha256"),_=await Je(h,"Client Key"),M="n=*,r="+xe+",r="+s.r+",s="+s.s+",i="+s.i+",c=biws,r="+s.r;Z=(await Je(await Je(h,"Server Key"),M)).toString("base64");let W="c=biws,r="+s.r+",p="+cn(_,Buffer.from(await Je(await on(_),M))).toString("base64");K(p().p().str(W).end());}function hr(t){t.toString("utf8",9).split(p.N,1)[0].slice(2)!==Z&&(ae(z.generic("SASL_SIGNATURE_MISMATCH","The server did not return the correct signature")),m.destroy());}function rt(){return Promise.resolve(typeof e.pass=="function"?e.pass():e.pass)}function gr(){if(A.statement=f.statement,A.statement.columns=[],f.onlyDescribe)return f.resolve(f.statement),K(we)}function yr(t){le.pid=t.readUInt32BE(5),le.secret=t.readUInt32BE(9);}async function wr(){Oe=false,(await new re([`
3
- select b.oid, b.typarray
4
- from pg_catalog.pg_type a
5
- left join pg_catalog.pg_type b on b.oid = a.typelem
6
- where a.typcategory = 'A'
7
- group by b.oid, b.typarray
8
- order by b.oid
9
- `],[],Ue)).forEach(({oid:s,typarray:h})=>br(s,h));}function br(t,s){if(e.parsers[s]&&e.serializers[s])return;let h=e.parsers[t];e.shared.typeArrayMap[t]=s,e.parsers[s]=_=>$t(_,h,s),e.parsers[s].array=true,e.serializers[s]=_=>zt(_,e.serializers[t],e,s);}function Er(t,s){return t==="read-write"&&s.default_transaction_read_only==="on"||t==="read-only"&&s.default_transaction_read_only==="off"||t==="primary"&&s.in_hot_standby==="on"||t==="standby"&&s.in_hot_standby==="off"||t==="prefer-standby"&&s.in_hot_standby==="off"&&e.host[O]}function _r(){let t=new re([`
10
- show transaction_read_only;
11
- select pg_catalog.pg_is_in_recovery()
12
- `],[],Ue,null,{simple:true});t.resolve=([[s],[h]])=>{fe.default_transaction_read_only=s.transaction_read_only,fe.in_hot_standby=h.pg_is_in_recovery?"on":"off";},t.execute();}function Sr(t){f?((f.cursorFn||f.describeFirst)&&K(we),x=z.postgres(Xe(t))):ae(z.postgres(Xe(t)));}function vr(t,s){delete l[t.signature],t.retried=s,Ue(t);}function Ar(t){if(!g)return;let s=9;for(;t[s++]!==0;);g(t.toString("utf8",9,s-1),t.toString("utf8",s,t.length-1));}async function Or(){try{let t=await Promise.resolve(f.cursorFn(A));G=0,t===Ce?K(zr(f.portal)):(A=new ye,K(Tt("",f.cursorRows)));}catch(t){K(we),f.reject(t);}}function Pr(){A.count&&f.cursorFn(A),f.resolve(A);}function Br(){I=new ht__default.default.Writable({autoDestroy:true,write(t,s,h){m.write(p().d().raw(t).end(),h);},destroy(t,s){s(t),m.write(p().f().str(t+p.N).end()),I=null;},final(t){m.write(p().c().end()),Ne=t,I=null;}}),f.resolve(I);}function Cr(){I=new ht__default.default.Readable({read(){m.resume();}}),f.resolve(I);}function Tr(){I=new ht__default.default.Duplex({autoDestroy:true,read(){m.resume();},write(t,s,h){m.write(p().d().raw(t).end(),h);},destroy(t,s){s(t),m.write(p().f().str(t+p.N).end()),I=null;},final(t){m.write(p().c().end()),Ne=t;}}),f.resolve(I);}function Ir(t){I&&(I.push(t.subarray(5))||m.pause());}function Nr(){I&&I.push(null),I=null;}function Ur(t){R?R(Xe(t)):console.log(Xe(t));}function jr(){}function Rr(){ae(z.notSupported("FunctionCallResponse"));}function Dr(){ae(z.notSupported("NegotiateProtocolVersion"));}function kr(t){console.error("Postgres.js : Unknown Message:",t[0]);}function Fr(t,s){console.error("Postgres.js : Unknown Auth:",s);}function Lr(t,s,h="",_=""){let M,W;return p().B().str(_+p.N).str(h+p.N).i16(0).i16(t.length),t.forEach((q,ge)=>{if(q===null)return p.i32(4294967295);W=s[ge],t[ge]=q=W in e.serializers?e.serializers[W](q):""+q,M=p.i,p.inc(4).str(q).i32(p.i-M-4,M);}),p.i16(0),p.end()}function Ct(t,s,h,_=""){return p().P().str(_+p.N).str(t+p.N).i16(s.length),s.forEach((M,W)=>p.i32(h[W]||0)),p.end()}function Mr(t,s=""){return p().D().str(t).str(s+p.N).end()}function Tt(t="",s=0){return Buffer.concat([p().E().str(t+p.N).i32(s).end(),Kt])}function zr(t=""){return Buffer.concat([p().C().str("P").str(t+p.N).end(),p().S().end()])}function $r(){return ue||p().inc(4).i16(3).z(2).str(Object.entries(Object.assign({user:d,database:P,client_encoding:"UTF8"},e.connection)).filter(([,t])=>t).map(([t,s])=>t+p.N+s).join(p.N)).z(2).end(0)}}function Xe(e){let r={},n=5;for(let a=5;a<e.length-1;a++)e[a]===0&&(r[an[e[n]]]=e.toString("utf8",n+1,a),n=a+1);return r}function Vt(e){return ze__default.default.createHash("md5").update(e).digest("hex")}function Je(e,r){return ze__default.default.createHmac("sha256",e).update(r).digest()}function on(e){return ze__default.default.createHash("sha256").update(e).digest()}function cn(e,r){let n=Math.max(e.length,r.length),a=Buffer.allocUnsafe(n);for(let i=0;i<n;i++)a[i]=e[i]^r[i];return a}function gt(e,r){if(r=typeof r=="function"?r():r,!r)return {cancel:Ie,start:Ie};let n;return {cancel(){n&&(clearTimeout(n),n=null);},start(){n&&clearTimeout(n),n=setTimeout(a,r*1e3,arguments);}};function a(i){e.apply(null,i),n=null;}}chunkBUNLC3II_cjs.h();var Wt=()=>{};function wt(e,r){let n=new Map,a="postgresjs_"+Math.random().toString(36).slice(2),i={},u,o,c=false,d=P.sql=e({...r,transform:{column:{},value:{},row:{}},max:1,fetch_types:false,idle_timeout:null,max_lifetime:null,connection:{...r.connection,replication:"database"},onclose:async function(){c||(o=null,i.pid=i.secret=void 0,b(await E(d,a,r.publications)),n.forEach(g=>g.forEach(({onsubscribe:H})=>H())));},no_subscribe:true}),j=d.end,C=d.close;return d.end=async()=>(c=true,o&&await new Promise(g=>(o.once("close",g),o.end())),j()),d.close=async()=>(o&&await new Promise(g=>(o.once("close",g),o.end())),C()),P;async function P(g,H,N=Wt,oe=Wt){g=fn(g),u||(u=E(d,a,r.publications));let se={fn:H,onsubscribe:N},ee=n.has(g)?n.get(g).add(se):n.set(g,new Set([se])).get(g),S=()=>{ee.delete(se),ee.size===0&&n.delete(g);};return u.then(pe=>(b(pe),N(),o&&o.on("error",oe),{unsubscribe:S,state:i,sql:d}))}function b(g){o=g.stream,i.pid=g.state.pid,i.secret=g.state.secret;}async function E(g,H,N){if(!N)throw new Error("Missing publication names");let oe=await g.unsafe(`CREATE_REPLICATION_SLOT ${H} TEMPORARY LOGICAL pgoutput NOEXPORT_SNAPSHOT`),[se]=oe,ee=await g.unsafe(`START_REPLICATION SLOT ${H} LOGICAL ${se.consistent_point} (proto_version '1', publication_names '${N}')`).writable(),S={lsn:Buffer.concat(se.consistent_point.split("/").map(v=>Buffer.from(("00000000"+v).slice(-8),"hex")))};return ee.on("data",le),ee.on("error",pe),ee.on("close",g.close),{stream:ee,state:oe.state};function pe(v){console.error("Unexpected error during logical streaming - reconnecting",v);}function le(v){v[0]===119?un(v.subarray(25),S,g.options.parsers,Ae,r.transform):v[0]===107&&v[17]&&(S.lsn=v.subarray(1,9),be());}function Ae(v,m){let ue=m.relation.schema+"."+m.relation.table;R("*",v,m),R("*:"+ue,v,m),m.relation.keys.length&&R("*:"+ue+"="+m.relation.keys.map(x=>v[x.name]),v,m),R(m.command,v,m),R(m.command+":"+ue,v,m),m.relation.keys.length&&R(m.command+":"+ue+"="+m.relation.keys.map(x=>v[x.name]),v,m);}function be(){let v=Buffer.alloc(34);v[0]=114,v.fill(S.lsn,1),v.writeBigInt64BE(BigInt(Date.now()-Date.UTC(2e3,0,1))*BigInt(1e3),25),ee.write(v);}}function R(g,H,N){n.has(g)&&n.get(g).forEach(({fn:oe})=>oe(H,N,g));}}function ln(e){return new Date(Date.UTC(2e3,0,1)+Number(e/BigInt(1e3)))}function un(e,r,n,a,i){let u=(o,[c,d])=>(o[c.charCodeAt(0)]=d,o);Object.entries({R:o=>{let c=1,d=r[o.readUInt32BE(c)]={schema:o.toString("utf8",c+=4,c=o.indexOf(0,c))||"pg_catalog",table:o.toString("utf8",c+1,c=o.indexOf(0,c+1)),columns:Array(o.readUInt16BE(c+=2)),keys:[]};c+=2;let j=0,C;for(;c<o.length;)C=d.columns[j++]={key:o[c++],name:i.column.from?i.column.from(o.toString("utf8",c,c=o.indexOf(0,c))):o.toString("utf8",c,c=o.indexOf(0,c)),type:o.readUInt32BE(c+=1),parser:n[o.readUInt32BE(c)],atttypmod:o.readUInt32BE(c+=4)},C.key&&d.keys.push(C),c+=4;},Y:()=>{},O:()=>{},B:o=>{r.date=ln(o.readBigInt64BE(9)),r.lsn=o.subarray(1,9);},I:o=>{let c=1,d=r[o.readUInt32BE(c)],{row:j}=Ze(o,d.columns,c+=7,i);a(j,{command:"insert",relation:d});},D:o=>{let c=1,d=r[o.readUInt32BE(c)];c+=4;let j=o[c]===75;a(j||o[c]===79?Ze(o,d.columns,c+=3,i).row:null,{command:"delete",relation:d,key:j});},U:o=>{let c=1,d=r[o.readUInt32BE(c)];c+=4;let j=o[c]===75,C=j||o[c]===79?Ze(o,d.columns,c+=3,i):null;C&&(c=C.i);let{row:P}=Ze(o,d.columns,c+3,i);a(P,{command:"update",relation:d,key:j,old:C&&C.row});},T:()=>{},C:()=>{}}).reduce(u,{})[e[0]](e);}function Ze(e,r,n,a){let i,u,o,c=a.raw?new Array(r.length):{};for(let d=0;d<r.length;d++)i=e[n++],u=r[d],o=i===110?null:i===117?void 0:u.parser===void 0?e.toString("utf8",n+4,n+=4+e.readUInt32BE(n)):u.parser.array===true?u.parser(e.toString("utf8",n+5,n+=4+e.readUInt32BE(n))):u.parser(e.toString("utf8",n+4,n+=4+e.readUInt32BE(n))),a.raw?c[d]=a.raw===true?o:a.value.from?a.value.from(o,u):o:c[u.name]=a.value.from?a.value.from(o,u):o;return {i:n,row:a.row.from?a.row.from(c):c}}function fn(e){let r=e.match(/^(\*|insert|update|delete)?:?([^.]+?\.?[^=]+)?=?(.+)?/i)||[];if(!r)throw new Error("Malformed subscribe pattern: "+e);let[,n,a,i]=r;return (n||"*")+(a?":"+(a.indexOf(".")===-1?"public."+a:a):"")+(i?"="+i:"")}chunkBUNLC3II_cjs.h();function bt(e,r,n=393216){return new Promise(async(a,i)=>{await e.begin(async u=>{let o;!r&&([{oid:r}]=await u`select lo_creat(-1) as oid`);let[{fd:c}]=await u`select lo_open(${r}, ${n}) as fd`,d={writable:C,readable:j,close:()=>u`select lo_close(${c})`.then(o),tell:()=>u`select lo_tell64(${c})`,read:P=>u`select loread(${c}, ${P}) as data`,write:P=>u`select lowrite(${c}, ${P})`,truncate:P=>u`select lo_truncate64(${c}, ${P})`,seek:(P,b=0)=>u`select lo_lseek64(${c}, ${P}, ${b})`,size:()=>u`
13
- select
14
- lo_lseek64(${c}, location, 0) as position,
15
- seek.size
16
- from (
17
- select
18
- lo_lseek64($1, 0, 2) as size,
19
- tell.location
20
- from (select lo_tell64($1) as location) tell
21
- ) seek
22
- `};return a(d),new Promise(async P=>o=P);async function j({highWaterMark:P=2048*8,start:b=0,end:E=1/0}={}){let R=E-b;return b&&await d.seek(b),new ht__default.default.Readable({highWaterMark:P,async read(g){let H=g>R?g-R:g;R-=g;let[{data:N}]=await d.read(H);this.push(N),N.length<g&&this.push(null);}})}async function C({highWaterMark:P=2048*8,start:b=0}={}){return b&&await d.seek(b),new ht__default.default.Writable({highWaterMark:P,write(E,R,g){d.write(E).then(()=>g(),g);}})}}).catch(i);})}Object.assign(qe,{PostgresError:Ee,toPascal:Se,pascal:dt,toCamel:_e,camel:mt,toKebab:ve,kebab:pt,fromPascal:Le,fromCamel:Fe,fromKebab:Me,BigInt:{to:20,from:[20],parse:e=>BigInt(e),serialize:e=>e.toString()}});var cs=qe;function qe(e,r){let n=pn(e,r),a=n.no_subscribe||wt(qe,{...n}),i=false,u=ne(),o=ne(),c=ne(),d=ne(),j=ne(),C=ne(),P=ne(),b=ne(),E={connecting:o,closed:d},R=[...Array(n.max)].map(()=>yt(n,E,{onopen:Oe,onend:J,onclose:fe})),g=H(Ae);return Object.assign(g,{get parameters(){return n.parameters},largeObject:bt.bind(null,g),subscribe:a,CLOSE:Ce,END:Ce,PostgresError:Ee,options:n,reserve:se,listen:N,begin:ee,close:ue,end:m}),g;function H(l){return l.debug=n.debug,Object.entries(n.types).reduce((w,[O,k])=>(w[O]=F=>new ie(F,k.to),w),y),Object.assign(U,{types:y,typed:y,unsafe:$,notify:oe,array:le,json:pe,file:L}),U;function y(w,O){return new ie(w,O)}function U(w,...O){return w&&Array.isArray(w.raw)?new re(w,O,l,v):typeof w=="string"&&!O.length?new Te(n.transform.column.to?n.transform.column.to(w):w):new ke(w,O)}function $(w,O=[],k={}){return arguments.length===2&&!Array.isArray(O)&&(k=O,O=[]),new re([w],O,l,v,{prepare:false,...k,simple:"simple"in k?k.simple:O.length===0})}function L(w,O=[],k={}){return arguments.length===2&&!Array.isArray(O)&&(k=O,O=[]),new re([],O,G=>{dn__default.default.readFile(w,"utf8",(Z,T)=>{if(Z)return G.reject(Z);G.strings=[T],l(G);});},v,{...k,simple:"simple"in k?k.simple:O.length===0})}}async function N(l,y,U){let $={fn:y,onlisten:U},L=N.sql||(N.sql=qe({...n,max:1,idle_timeout:null,max_lifetime:null,fetch_types:false,onclose(){Object.entries(N.channels).forEach(([G,{listeners:Z}])=>{delete N.channels[G],Promise.all(Z.map(T=>N(G,T.fn,T.onlisten).catch(()=>{})));});},onnotify(G,Z){G in N.channels&&N.channels[G].listeners.forEach(T=>T.fn(Z));}})),w=N.channels||(N.channels={});if(l in w){w[l].listeners.push($);let G=await w[l].result;return $.onlisten&&$.onlisten(),{state:G.state,unlisten:F}}w[l]={result:L`listen ${L.unsafe('"'+l.replace(/"/g,'""')+'"')}`,listeners:[$]};let k=await w[l].result;return $.onlisten&&$.onlisten(),{state:k.state,unlisten:F};async function F(){if(l in w&&(w[l].listeners=w[l].listeners.filter(G=>G!==$),!w[l].listeners.length))return delete w[l],L`unlisten ${L.unsafe('"'+l.replace(/"/g,'""')+'"')}`}}async function oe(l,y){return await g`select pg_notify(${l}, ${""+y})`}async function se(){let l=ne(),y=C.length?C.shift():await new Promise((L,w)=>{let O={reserve:L,reject:w};u.push(O),d.length&&A(d.shift(),O);});S(y,c),y.reserved=()=>l.length?y.execute(l.shift()):S(y,c),y.reserved.release=true;let U=H($);return U.release=()=>{y.reserved=null,Oe(y);},U;function $(L){y.queue===b?l.push(L):y.execute(L)||S(y,b);}}async function ee(l,y){!y&&(y=l,l="");let U=ne(),$=0,L,w=null;try{return await g.unsafe("begin "+l.replace(/[^a-z ]/ig,""),[],{onexecute:k}).execute(),await Promise.race([O(L,y),new Promise((F,G)=>L.onclose=G)])}catch(F){throw F}async function O(F,G,Z){let T=H(V);T.savepoint=he,T.prepare=D=>w=D.replace(/[^a-z0-9$-_. ]/gi);let me,ce;Z&&await T`savepoint ${T(Z)}`;try{if(ce=await new Promise((D,I)=>{let te=G(T);Promise.resolve(Array.isArray(te)?Promise.all(te):te).then(D,I);}),me)throw me}catch(D){throw await(Z?T`rollback to ${T(Z)}`:T`rollback`),D instanceof Ee&&D.code==="25P02"&&me||D}return Z||(w?await T`prepare transaction '${T.unsafe(w)}'`:await T`commit`),ce;function he(D,I){return D&&Array.isArray(D.raw)?he(te=>te.apply(te,arguments)):(arguments.length===1&&(I=D,D=null),O(F,I,"s"+$+++(D?"_"+D:"")))}function V(D){D.catch(I=>me||(me=I)),F.queue===b?U.push(D):F.execute(D)||S(F,b);}}function k(F){L=F,S(F,c),F.reserved=()=>U.length?F.execute(U.shift()):S(F,c);}}function S(l,y){return l.queue.remove(l),y.push(l),l.queue=y,y===C?l.idleTimer.start():l.idleTimer.cancel(),l}function pe(l){return new ie(l,3802)}function le(l,y){return Array.isArray(l)?new ie(l,y||(l.length?Ke(l)||25:0),n.shared.typeArrayMap):le(Array.from(arguments))}function Ae(l){if(i)return l.reject(z.connection("CONNECTION_ENDED",n,n));if(C.length)return be(C.shift(),l);if(d.length)return A(d.shift(),l);P.length?be(P.shift(),l):u.push(l);}function be(l,y){return l.execute(y)?S(l,P):S(l,b)}function v(l){return new Promise((y,U)=>{l.state?l.active?yt(n).cancel(l.state,y,U):l.cancelled={resolve:y,reject:U}:(u.remove(l),l.cancelled=true,l.reject(z.generic("57014","canceling statement due to user request")),y());})}async function m({timeout:l=null}={}){if(i)return i;await 1;let y;return i=Promise.race([new Promise(U=>l!==null&&(y=setTimeout(x,l*1e3,U))),Promise.all(R.map(U=>U.end()).concat(N.sql?N.sql.end({timeout:0}):[],a.sql?a.sql.end({timeout:0}):[]))]).then(()=>clearTimeout(y))}async function ue(){await Promise.all(R.map(l=>l.end()));}async function x(l){for(await Promise.all(R.map(y=>y.terminate()));u.length;)u.shift().reject(z.connection("CONNECTION_DESTROYED",n));l();}function A(l,y){return S(l,o),l.connect(y),l}function J(l){S(l,j);}function Oe(l){if(u.length===0)return S(l,C);let y=Math.ceil(u.length/(o.length+1)),U=true;for(;U&&u.length&&y-- >0;){let $=u.shift();if($.reserve)return $.reserve(l);U=l.execute($);}U?S(l,P):S(l,b);}function fe(l,y){S(l,d),l.reserved=null,l.onclose&&(l.onclose(y),l.onclose=null),n.onclose&&n.onclose(l.id),u.length&&A(l,u.shift());}}function pn(e,r){if(e&&e.shared)return e;let n=process.env,a=(!e||typeof e=="string"?r:e)||{},{url:i,multihost:u}=bn(e),o=[...i.searchParams].reduce((b,[E,R])=>(b[E]=R,b),{}),c=a.hostname||a.host||u||i.hostname||n.PGHOST||"localhost",d=a.port||i.port||n.PGPORT||5432,j=a.user||a.username||i.username||n.PGUSERNAME||n.PGUSER||En();a.no_prepare&&(a.prepare=false),o.sslmode&&(o.ssl=o.sslmode,delete o.sslmode),"timeout"in a&&(console.log("The timeout option is deprecated, use idle_timeout instead"),a.idle_timeout=a.timeout),o.sslrootcert==="system"&&(o.ssl="verify-full");let C=["idle_timeout","connect_timeout","max_lifetime","max_pipeline","backoff","keep_alive"],P={max:globalThis.Cloudflare?3:10,ssl:false,sslnegotiation:null,idle_timeout:null,connect_timeout:30,max_lifetime:yn,max_pipeline:100,backoff:gn,keep_alive:60,prepare:true,debug:false,fetch_types:true,publications:"alltables",target_session_attrs:null};return {host:Array.isArray(c)?c:c.split(",").map(b=>b.split(":")[0]),port:Array.isArray(d)?d:c.split(",").map(b=>parseInt(b.split(":")[1]||d)),path:a.path||c.indexOf("/")>-1&&c+"/.s.PGSQL."+d,database:a.database||a.db||(i.pathname||"").slice(1)||n.PGDATABASE||j,user:j,pass:a.pass||a.password||i.password||n.PGPASSWORD||"",...Object.entries(P).reduce((b,[E,R])=>{let g=E in a?a[E]:E in o?o[E]==="disable"||o[E]==="false"?false:o[E]:n["PG"+E.toUpperCase()]||R;return b[E]=typeof g=="string"&&C.includes(E)?+g:g,b},{}),connection:{application_name:n.PGAPPNAME||"postgres.js",...a.connection,...Object.entries(o).reduce((b,[E,R])=>(E in P||(b[E]=R),b),{})},types:a.types||{},target_session_attrs:hn(a,i,n),onnotice:a.onnotice,onnotify:a.onnotify,onclose:a.onclose,onparameter:a.onparameter,socket:a.socket,transform:wn(a.transform||{undefined:void 0}),parameters:{},shared:{retries:0,typeArrayMap:{}},...Lt(a.types)}}function hn(e,r,n){let a=e.target_session_attrs||r.searchParams.get("target_session_attrs")||n.PGTARGETSESSIONATTRS;if(!a||["read-write","read-only","primary","standby","prefer-standby"].includes(a))return a;throw new Error("target_session_attrs "+a+" is not supported")}function gn(e){return (.5+Math.random()/2)*Math.min(3**e/100,20)}function yn(){return 60*(30+Math.random()*30)}function wn(e){return {undefined:e.undefined,column:{from:typeof e.column=="function"?e.column:e.column&&e.column.from,to:e.column&&e.column.to},value:{from:typeof e.value=="function"?e.value:e.value&&e.value.from,to:e.value&&e.value.to},row:{from:typeof e.row=="function"?e.row:e.row&&e.row.from,to:e.row&&e.row.to}}}function bn(e){if(!e||typeof e!="string")return {url:{searchParams:new Map}};let r=e;r=r.slice(r.indexOf("://")+3).split(/[?/]/)[0],r=decodeURIComponent(r.slice(r.indexOf("@")+1));let n=new URL(e.replace(r,r.split(",")[0]));return {url:{username:decodeURIComponent(n.username),password:decodeURIComponent(n.password),host:n.host,hostname:n.hostname,port:n.port,pathname:n.pathname,searchParams:n.searchParams},multihost:r.indexOf(",")>-1&&r}}function En(){try{return mn__default.default.userInfo().username}catch{return process.env.USERNAME||process.env.USER||process.env.LOGNAME}}
23
- exports.a=cs;
@@ -1 +0,0 @@
1
- 'use strict';var chunkBUNLC3II_cjs=require('./chunk-BUNLC3II.cjs');chunkBUNLC3II_cjs.h();function t(e,r,o){let n=new Error(`[unstorage] [${e}] ${r}`,o);return Error.captureStackTrace&&Error.captureStackTrace(n,t),n}function c(e,r){return Array.isArray(r)?t(e,`Missing some of the required options ${r.map(o=>"`"+o+"`").join(", ")}`):t(e,`Missing required option \`${r}\`.`)}exports.a=t;exports.b=c;
@@ -1 +0,0 @@
1
- 'use strict';var chunk73D2PNHD_cjs=require('./chunk-73D2PNHD.cjs'),chunkBUNLC3II_cjs=require('./chunk-BUNLC3II.cjs');chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();var d=class{channels=new Map;maxListeners;constructor(e=100){this.maxListeners=e;}subscribe(e,s){this.channels.has(e)||this.channels.set(e,new Set);let t=this.channels.get(e);if(t.size>=this.maxListeners)throw new Error(`Max listeners (${this.maxListeners}) reached for channel "${e}"`);return t.add(s),()=>{t.delete(s),t.size===0&&this.channels.delete(e);}}publish(e,s){let t=this.channels.get(e);if(t)for(let r of t)try{let n=r(s);n instanceof Promise&&n.catch(i=>{console.error(`[PubSub] Error in handler for channel "${e}":`,i);});}catch(n){console.error(`[PubSub] Error in handler for channel "${e}":`,n);}}hasSubscribers(e){return this.channels.has(e)&&this.channels.get(e).size>0}getSubscriberCount(e){return this.channels.get(e)?.size||0}getChannels(){return Array.from(this.channels.keys())}clear(){this.channels.clear();}},b=class extends d{registry;constructor(e,s=100){super(s),this.registry=e;}publishCollectionEvent(e,s){this.publish(`collection:${e}`,s),this.publish("events:collection",s),s.tenantId&&(this.publish(`tenant:${s.tenantId}:collection:${e}`,s),this.publish(`tenant:${s.tenantId}:events`,s)),this.publish(`collection:${e}:${s.type}`,s);}subscribeToCollection(e,s){return this.subscribe(`collection:${e}`,s)}subscribeToCollectionEvent(e,s,t){return this.subscribe(`collection:${e}:${s}`,t)}subscribeToTenant(e,s){return this.subscribe(`tenant:${e}:events`,s)}subscribeToTenantCollection(e,s,t){return this.subscribe(`tenant:${e}:collection:${s}`,t)}subscribeToAllCollections(e){return this.subscribe("events:collection",e)}createAfterChangeHook(e){return async s=>{this.publishCollectionEvent(e,{type:s.operation==="create"?"create":"update",collection:e,doc:s.doc,originalDoc:s.originalDoc,id:s.id||s.doc?.id,tenantId:s.tenantId,timestamp:new Date().toISOString(),user:s.user});}}createAfterDeleteHook(e){return async s=>{this.publishCollectionEvent(e,{type:"delete",collection:e,doc:s.doc,originalDoc:s.originalDoc,id:s.id||s.doc?.id,tenantId:s.tenantId,timestamp:new Date().toISOString(),user:s.user});}}autoRegisterHooks(){let e=this.registry.getCollections();for(let s of e){let t=this.registry.getCollection(s.slug);t&&(t.hooks||(t.hooks={}),t.hooks.afterChange||(t.hooks.afterChange=[]),t.hooks.afterDelete||(t.hooks.afterDelete=[]),t.hooks.afterChange.push(this.createAfterChangeHook(s.slug)),t.hooks.afterDelete.push(this.createAfterDeleteHook(s.slug)));}}};chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();var l=class{documents=new Map;defaultLockTtlMs=3e4;getOrCreateDoc(e){let s=this.documents.get(e);return s||(s={docKey:e,users:new Map,cursors:new Map,locks:new Map,comments:[]},this.documents.set(e,s)),s}join(e,s){let t=this.getOrCreateDoc(e),r={...s,color:s.color||this.generateUserColor(s.id),lastSeen:Date.now()};return t.users.set(s.id,r),Array.from(t.users.values())}leave(e,s){let t=this.documents.get(e);if(!t)return {remainingUsers:[],releasedLocks:[]};t.users.delete(s),t.cursors.delete(s);let r=[];for(let[n,i]of t.locks.entries())i.userId===s&&(t.locks.delete(n),r.push(n));return t.users.size===0&&t.locks.size===0&&t.comments.length===0&&this.documents.delete(e),{remainingUsers:Array.from(t.users.values()),releasedLocks:r}}updateCursor(e,s,t){let r=this.getOrCreateDoc(e),n=r.users.get(s);n&&(n.lastSeen=Date.now());let i={userId:s,field:t.field,position:t.position,selection:t.selection,updatedAt:Date.now()};return r.cursors.set(s,i),i}acquireLock(e,s,t,r=this.defaultLockTtlMs){let n=this.getOrCreateDoc(e),i=Date.now(),o=n.locks.get(s);if(o&&o.expiresAt>i&&o.userId!==t.id)return {success:false,currentLock:o};let a={fieldName:s,userId:t.id,userName:t.name,lockedAt:i,expiresAt:i+r};return n.locks.set(s,a),{success:true,lock:a}}releaseLock(e,s,t){let r=this.documents.get(e);if(!r)return false;let n=r.locks.get(s);return n&&(n.userId===t||n.expiresAt<=Date.now())?(r.locks.delete(s),true):false}addComment(e,s){let t=this.getOrCreateDoc(e),r={...s,createdAt:new Date().toISOString(),resolved:false};return t.comments.push(r),r}resolveComment(e,s){let t=this.documents.get(e);if(!t)return false;let r=t.comments.find(n=>n.id===s);return r?(r.resolved=true,true):false}getSnapshot(e){let s=this.documents.get(e);if(!s)return {users:[],cursors:[],locks:[],comments:[]};let t=Date.now();for(let[r,n]of s.locks.entries())n.expiresAt<=t&&s.locks.delete(r);return {users:Array.from(s.users.values()),cursors:Array.from(s.cursors.values()),locks:Array.from(s.locks.values()),comments:s.comments}}generateUserColor(e){let s=["#ef4444","#f97316","#eab308","#10b981","#06b6d4","#3b82f6","#8b5cf6","#ec4899"],t=0;for(let r=0;r<e.length;r++)t=e.charCodeAt(r)+((t<<5)-t);return s[Math.abs(t)%s.length]}};var p=class{wss;clients=new Map;pubsub;options;pingTimer;presence=new l;constructor(e){this.options=e,this.pubsub=e.pubsub,this.wss=new chunk73D2PNHD_cjs.b.default({port:e.port||8080}),this.setupServer(),this.startPingInterval();}setupServer(){this.wss.on("connection",(e,s)=>{let t=this.generateClientId();if(this.options.maxConnections&&this.clients.size>=this.options.maxConnections){e.close(1013,"Server at capacity");return}let r={id:t,ws:e,subscriptions:new Map,authenticated:false,connectedAt:new Date,lastActivity:new Date};this.clients.set(t,r),this.sendToClient(r,{type:"connected",clientId:t,timestamp:new Date().toISOString()}),e.on("message",n=>{this.handleMessage(r,n);}),e.on("error",n=>{console.error(`[WS] Client error ${t}:`,n);}),e.on("close",()=>{this.handleDisconnect(r);}),e.on("pong",()=>{r.lastActivity=new Date;});}),this.wss.on("error",e=>{console.error("[WS] Server error:",e);});}handleMessage(e,s){e.lastActivity=new Date;let t;try{t=JSON.parse(s.toString());}catch{this.sendToClient(e,{type:"error",error:"Invalid JSON"});return}switch(t.type){case "authenticate":this.handleAuthenticate(e,t);break;case "subscribe":this.handleSubscribe(e,t);break;case "unsubscribe":this.handleUnsubscribe(e,t);break;case "unsubscribeAll":this.handleUnsubscribeAll(e);break;case "list":this.handleList(e);break;case "ping":this.sendToClient(e,{type:"pong",timestamp:new Date().toISOString()});break;case "presence:join":this.handlePresenceJoin(e,t);break;case "presence:leave":this.handlePresenceLeave(e,t);break;case "presence:cursor":this.handlePresenceCursor(e,t);break;case "presence:lock":this.handlePresenceLock(e,t);break;case "presence:unlock":this.handlePresenceUnlock(e,t);break;case "presence:comment":this.handlePresenceComment(e,t);break;case "presence:snapshot":this.handlePresenceSnapshot(e,t);break;default:this.sendToClient(e,{type:"error",error:`Unknown message type: ${t.type}`});}}async handleAuthenticate(e,s){if(!this.options.requireAuth){e.authenticated=true,this.sendToClient(e,{type:"authenticated",success:true});return}if(!this.options.verifyToken){e.authenticated=true,this.sendToClient(e,{type:"authenticated",success:true});return}try{let t=await this.options.verifyToken(s.token);e.authenticated=!0,e.user=t,e.tenantId=t.tenantId,this.sendToClient(e,{type:"authenticated",success:!0,user:{id:t.id,email:t.email}});}catch(t){this.sendToClient(e,{type:"authenticated",success:false,error:t.message});}}handleSubscribe(e,s){if(this.options.requireAuth&&!e.authenticated){this.sendToClient(e,{type:"error",error:"Not authenticated"});return}let t=s.channel;if(!t){this.sendToClient(e,{type:"error",error:"Channel is required"});return}if(e.subscriptions.has(t)){this.sendToClient(e,{type:"subscribed",channel:t,success:true,message:"Already subscribed"});return}let r=this.pubsub.subscribe(t,n=>{this.sendToClient(e,{type:"event",channel:t,data:n,timestamp:new Date().toISOString()});});e.subscriptions.set(t,{channel:t,unsubscribe:r}),this.sendToClient(e,{type:"subscribed",channel:t,success:true});}handleUnsubscribe(e,s){let t=s.channel;if(!t){this.sendToClient(e,{type:"error",error:"Channel is required"});return}let r=e.subscriptions.get(t);r?(r.unsubscribe(),e.subscriptions.delete(t),this.sendToClient(e,{type:"unsubscribed",channel:t,success:true})):this.sendToClient(e,{type:"unsubscribed",channel:t,success:false,message:"Not subscribed"});}handleUnsubscribeAll(e){for(let[,s]of e.subscriptions)s.unsubscribe();e.subscriptions.clear(),this.sendToClient(e,{type:"unsubscribedAll",success:true});}handleList(e){let s=this.pubsub.getChannels();this.sendToClient(e,{type:"channels",channels:s,count:s.length});}handlePresenceJoin(e,s){let{docKey:t,user:r}=s;if(!t||!r||!r.id){this.sendToClient(e,{type:"error",error:"docKey and user object with id are required for presence:join"});return}e.activeDocKey=t;let n=this.presence.join(t,r),i=`presence:${t}`;if(!e.subscriptions.has(i)){let o=this.pubsub.subscribe(i,a=>{this.sendToClient(e,{type:"event",channel:i,data:a,timestamp:new Date().toISOString()});});e.subscriptions.set(i,{channel:i,unsubscribe:o});}this.sendToClient(e,{type:"presence:joined",docKey:t,users:n,snapshot:this.presence.getSnapshot(t)}),this.pubsub.publish(i,{type:"presence:users_changed",docKey:t,users:n});}handlePresenceLeave(e,s){let{docKey:t,userId:r}=s;if(!t||!r)return;let{remainingUsers:n,releasedLocks:i}=this.presence.leave(t,r);e.activeDocKey=void 0;let o=`presence:${t}`;this.pubsub.publish(o,{type:"presence:users_changed",docKey:t,users:n,releasedLocks:i}),this.sendToClient(e,{type:"presence:left",docKey:t,success:true});}handlePresenceCursor(e,s){let{docKey:t,userId:r,cursor:n}=s;if(!t||!r||!n)return;let i=this.presence.updateCursor(t,r,n),o=`presence:${t}`;this.pubsub.publish(o,{type:"presence:cursor_moved",docKey:t,cursor:i});}handlePresenceLock(e,s){let{docKey:t,fieldName:r,user:n,ttlMs:i}=s;if(!t||!r||!n||!n.id){this.sendToClient(e,{type:"error",error:"docKey, fieldName, and user are required to acquire lock"});return}let o=this.presence.acquireLock(t,r,n,i),a=`presence:${t}`;o.success?(this.pubsub.publish(a,{type:"presence:field_locked",docKey:t,lock:o.lock}),this.sendToClient(e,{type:"presence:lock_acquired",docKey:t,lock:o.lock})):this.sendToClient(e,{type:"presence:lock_rejected",docKey:t,fieldName:r,currentLock:o.currentLock});}handlePresenceUnlock(e,s){let{docKey:t,fieldName:r,userId:n}=s;if(!t||!r||!n)return;let i=this.presence.releaseLock(t,r,n);if(i){let o=`presence:${t}`;this.pubsub.publish(o,{type:"presence:field_unlocked",docKey:t,fieldName:r,userId:n});}this.sendToClient(e,{type:"presence:unlocked",docKey:t,fieldName:r,success:i});}handlePresenceComment(e,s){let{docKey:t,comment:r}=s;if(!t||!r||!r.id){this.sendToClient(e,{type:"error",error:"docKey and comment payload are required"});return}let n=this.presence.addComment(t,r),i=`presence:${t}`;this.pubsub.publish(i,{type:"presence:comment_added",docKey:t,comment:n}),this.sendToClient(e,{type:"presence:comment_created",docKey:t,comment:n});}handlePresenceSnapshot(e,s){let{docKey:t}=s;if(!t){this.sendToClient(e,{type:"error",error:"docKey is required for snapshot"});return}let r=this.presence.getSnapshot(t);this.sendToClient(e,{type:"presence:snapshot",docKey:t,snapshot:r});}handleDisconnect(e){if(e.activeDocKey&&e.user?.id){let{remainingUsers:s,releasedLocks:t}=this.presence.leave(e.activeDocKey,e.user.id);this.pubsub.publish(`presence:${e.activeDocKey}`,{type:"presence:users_changed",docKey:e.activeDocKey,users:s,releasedLocks:t});}for(let[,s]of e.subscriptions)s.unsubscribe();this.clients.delete(e.id);}sendToClient(e,s){e.ws.readyState===chunk73D2PNHD_cjs.a.default.OPEN&&e.ws.send(JSON.stringify(s));}generateClientId(){return `ws_${Date.now()}_${Math.random().toString(36).slice(2,9)}`}startPingInterval(){this.options.pingInterval&&(this.pingTimer=setInterval(()=>{for(let[e,s]of this.clients)if(s.ws.readyState===chunk73D2PNHD_cjs.a.default.OPEN){if(Date.now()-s.lastActivity.getTime()>this.options.pingInterval*3){s.ws.terminate(),this.handleDisconnect(s);continue}s.ws.ping();}},this.options.pingInterval));}broadcast(e,s){this.pubsub.publish(e,s);}getConnectedClients(){return Array.from(this.clients.values())}getClientCount(){return this.clients.size}getSubscriptionCount(){let e=0;for(let s of this.clients.values())e+=s.subscriptions.size;return e}async close(){this.pingTimer&&clearInterval(this.pingTimer);for(let e of this.clients.values())e.ws.close(1001,"Server shutting down");return new Promise(e=>{this.wss.close(()=>{e();});})}getServer(){return this.wss}};function y(u){return new p(u)}exports.a=d;exports.b=b;exports.c=l;exports.d=p;exports.e=y;
@@ -1,132 +0,0 @@
1
- 'use strict';var chunk7ACHOBWY_cjs=require('./chunk-7ACHOBWY.cjs'),chunkRVBSJ4UQ_cjs=require('./chunk-RVBSJ4UQ.cjs'),chunkBCEE4NBZ_cjs=require('./chunk-BCEE4NBZ.cjs'),chunkVRZC4TTF_cjs=require('./chunk-VRZC4TTF.cjs'),chunkVQ53TFYA_cjs=require('./chunk-VQ53TFYA.cjs'),chunkF4ITQ6XQ_cjs=require('./chunk-F4ITQ6XQ.cjs'),chunkZUBJ6RLQ_cjs=require('./chunk-ZUBJ6RLQ.cjs'),chunkBUNLC3II_cjs=require('./chunk-BUNLC3II.cjs');chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();function b(f,t="postgres"){switch(f.type){case "text":case "email":case "password":case "color":case "icon":return t==="sqlite"?"text":"varchar";case "textarea":case "code":case "markdown":case "secret":return "text";case "number":return f.integer?"integer":"decimal";case "checkbox":return "boolean";case "date":return "timestamp";case "select":case "radio":return t==="sqlite"?"text":"varchar";case "richtext":case "json":case "array":case "group":case "blocks":case "row":case "collapsible":case "tabs":return "jsonb";case "relationship":return t==="sqlite"?"text":"varchar";case "upload":return "jsonb";default:return "jsonb"}}function de(f,t="postgres"){let i=f.slug.replace(/-/g,"_"),e=[];e.push(`export const ${i} = pgTable('${i}', {`),e.push(" id: uuid('id').primaryKey().defaultRandom(),");for(let s of f.fields){if(s.name==="id"||s.type==="password")continue;let n=b(s,t),o=s.required,a=` ${s.name}: pg.${n}('${s.name}')`;s.unique&&(a+=".unique()"),o||(a+=".nullable()"),s.defaultValue!==void 0&&(typeof s.defaultValue=="string"?a+=`.default('${s.defaultValue}')`:typeof s.defaultValue=="boolean"?a+=`.default(${s.defaultValue})`:a+=`.default(sql\`${JSON.stringify(s.defaultValue)}\`)`),a+=",",e.push(a);}return f.timestamps&&(e.push(" createdAt: pg.timestamp('created_at').defaultNow(),"),e.push(" updatedAt: pg.timestamp('updated_at').defaultNow(),")),e.push(` status: ${t==="sqlite"?"sqlite":"pg"}.varchar('status').default('draft'),`),e.push(` hasDraft: ${t==="sqlite"?"sqlite":"pg"}.boolean('hasDraft').default(false),`),e.push("});"),e.join(`
2
- `)}function j(f,t){return Array.isArray(f)?f.map(i=>{if(!i||typeof i!="object")return i;let e=i.data?{...i.data}:void 0;if(!e)return i;let s=t.find(n=>n.slug===i.type||n.slug===i.slug);if(!s||!Array.isArray(s.fields))return i;for(let n of s.fields){if(n.name&&(n.type==="upload"||n.type==="image")&&e[n.name]){let o=e[n.name];Array.isArray(o)?e[n.name]=o.map(a=>typeof a=="string"?{id:a}:a):typeof o=="string"&&(e[n.name]={id:o});}if(n.type==="blocks"&&n.name&&e[n.name]){let o=n.blocks||[];e[n.name]=j(e[n.name],o);}}return {...i,data:e}}):f}function C(f){if(typeof f!="string")return f;let t=f.replace(/-/g,"").toLowerCase();return t.length===32?`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`:f}var O=class extends chunkVQ53TFYA_cjs.a{client;schema;_schemaEnsured=false;dialect;connectionString;versionsTableReady=false;rawClient;constructor(t){if(super(),this.schema=t.schema||{},t.connectionString){this.connectionString=t.connectionString;let i=t.connectionString.toLowerCase();i.startsWith("postgres://")||i.startsWith("postgresql://")?this.dialect="postgres":i.includes(".db")||i.includes("sqlite")||i.includes("file:")?this.dialect="sqlite":this.dialect=t.type||"postgres";}else this.rawClient=t.client,this.client=t.client,this.dialect=t.type||"sqlite";}prepareData(t,i){let e=super.prepareData(t,i);e.createdAt&&typeof e.createdAt=="string"&&(e.createdAt=new Date(e.createdAt)),e.updatedAt&&typeof e.updatedAt=="string"&&(e.updatedAt=new Date(e.updatedAt));for(let s of i.fields)if(s.type==="date"&&s.name){let n=e[s.name];n&&typeof n=="string"&&(e[s.name]=new Date(n));}for(let s of i.fields){let o=b(s,this.dialect)==="jsonb";if(s.type==="tabs"&&"tabs"in s&&s.name){let a=t[s.name];if(a&&typeof a=="object"){let r={};for(let[l,c]of Object.entries(a)){let u=s.tabs.flatMap(g=>g.fields).find(g=>g.name===l);(u?.type==="upload"||u?.type==="image"||u?.type==="list"||u?.type==="relationship-block")&&c?r[l]=Array.isArray(c)||typeof c=="object"?JSON.stringify(c):c:r[l]=c;}e[s.name]=this.dialect==="sqlite"||!o?JSON.stringify(r):r;}}else if(o&&s.name&&t[s.name]!==void 0&&t[s.name]!==null)e[s.name]=this.dialect==="sqlite"?JSON.stringify(t[s.name]):t[s.name];else if((s.type==="upload"||s.type==="image"||s.type==="list"||s.type==="relationship-block")&&s.name){let a=t[s.name];a!=null&&(e[s.name]=this.dialect==="sqlite"||!o?typeof a=="string"?a:JSON.stringify(a):a);}}for(let s of i.fields)if(s.name&&e[s.name]===""){let n=b(s,this.dialect);(n==="timestamp"||n==="jsonb"||n==="decimal"||n==="integer"||n==="numeric"||n==="boolean")&&(e[s.name]=null);}return e}async connect(){if(this.connectionString&&!this.client){if(this.dialect==="postgres"){let t,i;try{t=(await import('./src-6LAUXXDM.cjs')).default,i=(await import('./postgres-js-7YBZKGXG.cjs')).drizzle;}catch{chunkF4ITQ6XQ_cjs.a(["postgres","drizzle-orm"]),t=(await import('./src-6LAUXXDM.cjs')).default,i=(await import('./postgres-js-7YBZKGXG.cjs')).drizzle;}let e=t(this.connectionString,{onnotice:()=>{}});this.client=i(e,{schema:this.schema});}else if(this.dialect==="sqlite"){let t,i;try{t=(await import('better-sqlite3')).default,i=(await import('./better-sqlite3-5IISPX34.cjs')).drizzle;}catch{chunkF4ITQ6XQ_cjs.a(["better-sqlite3","drizzle-orm"]),t=(await import('better-sqlite3')).default,i=(await import('./better-sqlite3-5IISPX34.cjs')).drizzle;}let e=new t(this.connectionString.replace("file:",""));this.client=i(e,{schema:this.schema});}}if(this.rawClient&&typeof this.rawClient.prepare=="function"&&typeof this.client?.select!="function"){let{drizzle:t}=await import('./d1-5ZQJOFDX.cjs');this.client=t(this.rawClient,{schema:this.schema});}this.connected=true;}async init(t,i=[]){if(await super.init(t,i),(this.connectionString&&!this.client||this.rawClient&&typeof this.client?.select!="function")&&await this.connect(),this.client&&!this._schemaEnsured){for(let s of t){let n=this.getTableName(s.slug);this.schema[n]||(this.schema[n]=this.createTableFromConfig(s));}await this.ensureCollectionTables(t);let e=i.map(s=>({slug:`_globals_${s.slug}`,fields:s.fields,label:s.label}));for(let s of e){let n=this.getTableName(s.slug);this.schema[n]||(this.schema[n]=this.createTableFromConfig(s,true)),this.collections.has(s.slug)||this.collections.set(s.slug,s);}await this.ensureCollectionTables(e),this._schemaEnsured=true;}}createTableFromConfig(t,i=false){let e=this.getTableName(t.slug),s={id:i?chunkVRZC4TTF_cjs.ia("id").primaryKey():chunkVRZC4TTF_cjs.oa("id").primaryKey().defaultRandom()};for(let n of t.fields){if(!n.name||n.name==="id"||n.type==="password")continue;let o=b(n,this.dialect),a=n.name.replace(/-/g,"_"),r=a.replace(/([A-Z])/g,"_$1").toLowerCase(),l;if(this.dialect==="sqlite")switch(o){case "varchar":case "text":l=chunk7ACHOBWY_cjs.c(r);break;case "integer":l=chunk7ACHOBWY_cjs.a(r);break;case "decimal":case "numeric":l=chunk7ACHOBWY_cjs.b(r);break;case "boolean":l=chunk7ACHOBWY_cjs.a(r,{mode:"boolean"});break;case "timestamp":l=chunk7ACHOBWY_cjs.c(r);break;case "jsonb":l=chunk7ACHOBWY_cjs.c(r);break;default:l=chunk7ACHOBWY_cjs.c(r);}else switch(o){case "varchar":l=chunkVRZC4TTF_cjs.pa(r,{length:255});break;case "integer":l=chunkVRZC4TTF_cjs.ca(r);break;case "decimal":l=chunkVRZC4TTF_cjs.ha(r);break;case "boolean":l=chunkVRZC4TTF_cjs.$(r);break;case "timestamp":l=chunkVRZC4TTF_cjs.ma(r);break;case "jsonb":l=chunkVRZC4TTF_cjs.fa(r);break;default:l=chunkVRZC4TTF_cjs.ia(r);}n.required||(l=l.default(null)),s[a]=l;}return s.createdAt||(s.createdAt=this.dialect==="sqlite"?chunk7ACHOBWY_cjs.c("created_at").default(new Date().toISOString()):chunkVRZC4TTF_cjs.ma("created_at").defaultNow()),s.updatedAt||(s.updatedAt=this.dialect==="sqlite"?chunk7ACHOBWY_cjs.c("updated_at").default(new Date().toISOString()):chunkVRZC4TTF_cjs.ma("updated_at").defaultNow()),e!=="users"&&e!=="audit_logs"&&(s.status||(s.status=this.dialect==="sqlite"?chunk7ACHOBWY_cjs.c("status").default("draft"):chunkVRZC4TTF_cjs.pa("status",{length:20}).default("draft")),s.hasDraft||(s.hasDraft=this.dialect==="sqlite"?chunk7ACHOBWY_cjs.a("hasDraft",{mode:"boolean"}).default(false):chunkVRZC4TTF_cjs.$("hasDraft").default(false))),this.dialect==="sqlite"?chunk7ACHOBWY_cjs.e(e,s):chunkVRZC4TTF_cjs.ra(e,s)}async ensureCollectionTables(t){let i=[];for(let e of t){let s=e.slug.startsWith("_globals_"),n=this.getTableName(e.slug),o=this.generateCreateColumns(e),a=e.fields.some(u=>u.name==="createdAt"),r=e.fields.some(u=>u.name==="updatedAt"),l=e.fields.some(u=>u.name==="status"),c=e.fields.some(u=>u.name==="hasDraft");if(this.dialect==="postgres"){let u=s?'"id" TEXT PRIMARY KEY':'"id" UUID PRIMARY KEY DEFAULT gen_random_uuid()';i.push(`
3
- CREATE TABLE IF NOT EXISTS "${n}" (
4
- ${u},
5
- ${o}
6
- ${a?"":'"created_at" TIMESTAMP NOT NULL DEFAULT NOW(),'}
7
- ${r?"":'"updated_at" TIMESTAMP NOT NULL DEFAULT NOW(),'}
8
- ${l?"":`"status" VARCHAR(20) DEFAULT 'draft',`}
9
- ${c?"":'"hasDraft" BOOLEAN DEFAULT false'}
10
- )
11
- `);}else i.push(`
12
- CREATE TABLE IF NOT EXISTS "${n}" (
13
- "id" TEXT PRIMARY KEY,
14
- ${o}
15
- ${a?"":`"created_at" TEXT NOT NULL DEFAULT (datetime('now')),`}
16
- ${r?"":`"updated_at" TEXT NOT NULL DEFAULT (datetime('now')),`}
17
- ${l?"":`"status" TEXT DEFAULT 'draft',`}
18
- ${c?"":'"hasDraft" INTEGER DEFAULT 0'}
19
- )
20
- `);}if(i.length>0)if(this.dialect==="postgres")await this.executeRaw(chunkVRZC4TTF_cjs.J.raw(i.join(`;
21
- `)));else for(let e of i)await this.executeRaw(chunkVRZC4TTF_cjs.J.raw(e));for(let e of t){let s=this.getTableName(e.slug);s==="users"||s==="audit_logs"||await this.syncTableColumns(e,s);}}getColumnSqlDefinition(t,i){let e=b(t,i),s=t.name.replace(/-/g,"_").replace(/([A-Z])/g,"_$1").toLowerCase(),n=this.columnSqlType(e,i);return `"${s}" ${n} DEFAULT NULL`}columnSqlType(t,i){if(i==="sqlite")switch(t){case "varchar":return "TEXT";case "text":return "TEXT";case "integer":return "INTEGER";case "decimal":case "numeric":return "NUMERIC";case "boolean":return "INTEGER";case "timestamp":return "TEXT";case "jsonb":return "TEXT";default:return "TEXT"}switch(t){case "varchar":return "VARCHAR(255)";case "text":return "TEXT";case "integer":return "INTEGER";case "decimal":case "numeric":return "DECIMAL";case "boolean":return "BOOLEAN";case "timestamp":return "TIMESTAMP";case "jsonb":return "JSONB";default:return "TEXT"}}getExpectedColumnDefs(t,i){let e={},s=t.slug.startsWith("_globals_"),n=t.fields.some(l=>l.name==="createdAt"),o=t.fields.some(l=>l.name==="updatedAt"),a=t.fields.some(l=>l.name==="status"),r=t.fields.some(l=>l.name==="hasDraft");this.dialect==="postgres"?(e.id=s?'"id" TEXT PRIMARY KEY':'"id" UUID PRIMARY KEY DEFAULT gen_random_uuid()',n||(e.created_at='"created_at" TIMESTAMP DEFAULT NULL'),o||(e.updated_at='"updated_at" TIMESTAMP DEFAULT NULL'),a||(e.status='"status" VARCHAR(20) DEFAULT NULL'),r||(e.hasDraft='"hasDraft" BOOLEAN DEFAULT NULL')):(e.id='"id" TEXT PRIMARY KEY',n||(e.created_at='"created_at" TEXT DEFAULT NULL'),o||(e.updated_at='"updated_at" TEXT DEFAULT NULL'),a||(e.status='"status" TEXT DEFAULT NULL'),r||(e.hasDraft='"hasDraft" INTEGER DEFAULT NULL'));for(let l of t.fields){if(!l.name||l.name==="id")continue;let c=this.getColumnSqlDefinition(l,this.dialect),u=l.name.replace(/-/g,"_").replace(/([A-Z])/g,"_$1").toLowerCase();e[u]=c;}return e}async syncTableColumns(t,i){let e;try{if(this.dialect==="postgres"){let o=await this.executeRaw(chunkVRZC4TTF_cjs.J`SELECT column_name, data_type, character_maximum_length FROM information_schema.columns WHERE table_name = ${i}`);e=new Map(o.map(a=>[a.column_name,{type:a.data_type,maxLen:a.character_maximum_length}]));}else {let o=await this.executeRaw(chunkVRZC4TTF_cjs.J`PRAGMA table_info("${chunkVRZC4TTF_cjs.J.raw(i)}")`);e=new Map(o.map(a=>[a.name,{type:a.type,maxLen:null}]));}}catch{return}let s=this.getExpectedColumnDefs(t,i),n=Object.keys(s).filter(o=>!e.has(o));if(n.length>0){let o=n.map(a=>`ALTER TABLE "${i}" ADD COLUMN ${s[a]}`);await this.executeRaw(chunkVRZC4TTF_cjs.J.raw(o.join(`;
22
- `)));}if(this.dialect==="postgres")for(let o of t.fields){if(!o.name||o.name==="id")continue;let a=b(o,this.dialect),r=o.name.replace(/-/g,"_").replace(/([A-Z])/g,"_$1").toLowerCase(),l=e.get(r);!l||l.type!=="character varying"||(a==="text"?await this.executeRaw(chunkVRZC4TTF_cjs.J.raw(`ALTER TABLE "${i}" ALTER COLUMN "${r}" TYPE TEXT`)):a==="jsonb"&&(await this.executeRaw(chunkVRZC4TTF_cjs.J.raw(`ALTER TABLE "${i}" ALTER COLUMN "${r}" DROP DEFAULT`)),await this.executeRaw(chunkVRZC4TTF_cjs.J.raw(`ALTER TABLE "${i}" ALTER COLUMN "${r}" TYPE JSONB USING (CASE WHEN "${r}" IS NULL THEN NULL WHEN "${r}"::text ~ '^\\s*\\{' THEN "${r}"::jsonb ELSE jsonb_build_object('id', "${r}"::text) END)`))));}}generateCreateColumns(t){let i=[];for(let e of t.fields){if(!e.name||e.name==="id")continue;let s=b(e,this.dialect),n=e.name.replace(/-/g,"_").replace(/([A-Z])/g,"_$1").toLowerCase(),o=e.required?"NOT NULL":"DEFAULT NULL",a;if(this.dialect==="sqlite")switch(s){case "varchar":case "text":a=`TEXT ${o}`;break;case "integer":a=`INTEGER ${o}`;break;case "decimal":case "numeric":a=`NUMERIC ${o}`;break;case "boolean":a=`INTEGER ${o}`;break;case "timestamp":a=`TEXT ${o}`;break;case "jsonb":a=`TEXT ${o}`;break;default:a=`TEXT ${o}`;}else switch(s){case "varchar":a=`VARCHAR(255) ${o}`;break;case "integer":a=`INTEGER ${o}`;break;case "decimal":a=`DECIMAL ${o}`;break;case "boolean":a=`BOOLEAN ${o}`;break;case "timestamp":a=`TIMESTAMP ${o}`;break;case "jsonb":a=`JSONB ${o}`;break;default:a=`TEXT ${o}`;}i.push(`"${n}" ${a}`);}return i.join(`,
23
- `)+(i.length>0?",":"")}async disconnect(){this.connected=false;}async find(t){let{collection:i,where:e={},sort:s,limit:n=10,page:o=1,tenantId:a,select:r,draft:l}=t,c=this.getCollection(i),u=this.getTable(i),m={...e};this.tenantContext&&c.tenantScoped&&(m=chunkVQ53TFYA_cjs.c({where:m},i,this.tenantContext,chunkVQ53TFYA_cjs.b).where||{});let g=this.buildWhereClause(m,c,u,a),y=c.fields.find(h=>h.name==="status"),p=y?.type==="select"&&Array.isArray(y.options)&&y.options.some(h=>h.value==="published");!l&&u.status&&p&&g.push(chunkBCEE4NBZ_cjs.n(u.status,"published"));let E=this.parseSort(s),A=!l&&u.status&&p?{...m,status:"published"}:m,ue=await this.count({collection:i,where:A,tenantId:a}),fe=(o-1)*n,z=[];try{let h=u[E.field]||u.createdAt||u.id,$=E.direction==="asc"?h:chunkBCEE4NBZ_cjs.M(h),D=this.client.select().from(u);g.length>0&&(D=D.where(chunkBCEE4NBZ_cjs.p(...g))),z=await D.orderBy($).limit(n).offset(fe);}catch(h){console.error("[DrizzleAdapter] Query error:",h);}let R=z.map(h=>this.processResult(h,c));return this.tenantContext&&!this.tenantContext.isSuperAdmin&&(R=R.filter(h=>chunkVQ53TFYA_cjs.d(h,i,this.tenantContext,chunkVQ53TFYA_cjs.b))),l&&(R=await Promise.all(R.map(async h=>{let $=await this.executeRaw(chunkVRZC4TTF_cjs.J`
24
- SELECT * FROM kyro_versions
25
- WHERE collection_slug = ${i}
26
- AND document_id = ${h.id}
27
- ORDER BY created_at DESC
28
- LIMIT 1
29
- `);if($.length>0){let D=$[0],w=D.data;for(;typeof w=="string";)try{w=JSON.parse(w);}catch{break}return (!w||typeof w!="object"||Array.isArray(w))&&(w={}),{...h,...w,status:h.status,_hasUnpublishedChanges:D.status==="draft"}}return h}))),{docs:R,...this.calculatePagination(o,n,ue)}}async findByID(t){let{collection:i,id:e,tenantId:s,draft:n}=t,o=this.getCollection(i),a=this.getTable(i),r=this.dialect==="postgres"&&typeof e=="string"?C(e):e;if(this.tenantContext&&o.tenantScoped){let p={id:r,tenantId:this.tenantContext.tenantId};if(!chunkVQ53TFYA_cjs.d(p,i,this.tenantContext,chunkVQ53TFYA_cjs.b))return null}let l=[chunkBCEE4NBZ_cjs.n(a.id,r)];s&&a.tenantId&&l.push(chunkBCEE4NBZ_cjs.n(a.tenantId,s));let c=o.fields.find(p=>p.name==="status"),u=c?.type==="select"&&Array.isArray(c.options)&&c.options.some(p=>p.value==="published");!n&&a.status&&u&&l.push(chunkBCEE4NBZ_cjs.n(a.status,"published"));let m=l.length>1?chunkBCEE4NBZ_cjs.p(...l):l[0],g=await this.client.select().from(a).where(m);if(g.length===0)return null;let y=this.processResult(g[0],o);if(n){let p=await this.executeRaw(chunkVRZC4TTF_cjs.J`
30
- SELECT * FROM kyro_versions
31
- WHERE collection_slug = ${i}
32
- AND document_id = ${y.id}
33
- ORDER BY created_at DESC
34
- LIMIT 1
35
- `);if(p.length>0){let E=p[0],A=E.data;for(;typeof A=="string";)try{A=JSON.parse(A);}catch{break}(!A||typeof A!="object"||Array.isArray(A))&&(A={}),y={...y,...A,status:y.status,_hasUnpublishedChanges:E.status==="draft"};}}return y}async create(t){let{collection:i,data:e,tenantId:s}=t,n=this.getCollection(i),o=this.getTable(i),a=this.prepareData(e,n);s&&n.tenantScoped&&(a.tenantId=s);let r=await this.client.insert(o).values(a).returning();return this.processResult(r[0],n)}async update(t){let{collection:i,id:e,data:s,tenantId:n}=t,o=this.getCollection(i),a=this.getTable(i),r=this.prepareData(s,o),l=this.dialect==="postgres"&&typeof e=="string"?C(e):e,c=[chunkBCEE4NBZ_cjs.n(a.id,l)];n&&a.tenantId&&c.push(chunkBCEE4NBZ_cjs.n(a.tenantId,n));let u=await this.client.update(a).set(r).where(chunkBCEE4NBZ_cjs.p(...c)).returning();if(u.length===0)throw new Error(`Document not found: ${i}/${e}`);return this.processResult(u[0],o)}async delete(t){let{collection:i,id:e,tenantId:s}=t,n=this.getCollection(i),o=this.getTable(i),a=this.dialect==="postgres"&&typeof e=="string"?C(e):e,r=[chunkBCEE4NBZ_cjs.n(o.id,a)];s&&o.tenantId&&r.push(chunkBCEE4NBZ_cjs.n(o.tenantId,s));let l=await this.client.delete(o).where(chunkBCEE4NBZ_cjs.p(...r)).returning();if(l.length===0)throw new Error(`Document not found: ${i}/${e}`);return this.processResult(l[0],n)}async count(t){let{collection:i,where:e={},tenantId:s}=t,n=this.getCollection(i),o=this.getTable(i),a=this.buildWhereClause(e,n,o,s);try{let r=this.client.select({count:chunkVRZC4TTF_cjs.J`count(*)`}).from(o);a.length>0&&(r=r.where(chunkBCEE4NBZ_cjs.p(...a)));let l=await r;return Number(l[0]?.count||0)}catch{return 0}}async findOne(t){let{collection:i,where:e={},tenantId:s,draft:n}=t;if(i.startsWith("_globals_")){let a=i.replace("_globals_",""),r=this.globals.get(a);if(!r)throw new Error(`Global "${a}" not found`);let l=this.getTable(i),c=this.client.select().from(l),u=r.fields.find(p=>p.name==="status"),m=u?.type==="select"&&Array.isArray(u.options)&&u.options.some(p=>p.value==="published");!n&&l.status&&m&&(c=c.where(chunkBCEE4NBZ_cjs.n(l.status,"published")));let g=await c.limit(1);if(g.length===0)return null;let y=this.processResult(g[0],r);if(n){let p=await this.executeRaw(chunkVRZC4TTF_cjs.J`
36
- SELECT * FROM kyro_versions
37
- WHERE collection_slug = ${i}
38
- AND document_id = ${a}
39
- ORDER BY created_at DESC
40
- LIMIT 1
41
- `);if(p.length>0){let E=p[0],A=typeof E.data=="string"?JSON.parse(E.data):E.data;y={...y,...A,status:y.status,_hasUnpublishedChanges:E.status==="draft"};}}return y}return (await this.find({...t,limit:1})).docs[0]||null}async findVersions(t){await this.ensureVersionsTable();let{collection:i,documentId:e,limit:s=10,page:n=1,tenantId:o}=t,a=(n-1)*s,r=this.getCollection(i),l=await this.executeRaw(chunkVRZC4TTF_cjs.J`
42
- SELECT count(*) as count
43
- FROM kyro_versions
44
- WHERE collection_slug = ${i}
45
- AND document_id = ${e}
46
- AND autosave = 0
47
- ${o&&r.tenantScoped?chunkVRZC4TTF_cjs.J`AND tenant_id = ${o}`:chunkVRZC4TTF_cjs.J``}
48
- `),c=parseInt(l[0]?.count||"0");return {docs:(await this.executeRaw(chunkVRZC4TTF_cjs.J`
49
- SELECT *
50
- FROM kyro_versions
51
- WHERE collection_slug = ${i}
52
- AND document_id = ${e}
53
- AND autosave = 0
54
- ${o&&r.tenantScoped?chunkVRZC4TTF_cjs.J`AND tenant_id = ${o}`:chunkVRZC4TTF_cjs.J``}
55
- ORDER BY created_at DESC
56
- LIMIT ${s}
57
- OFFSET ${a}
58
- `)).map(m=>({...m,data:typeof m.data=="string"?JSON.parse(m.data):m.data})),...this.calculatePagination(n,s,c)}}async findVersionByID(t){await this.ensureVersionsTable();let i=this.getCollection(t.collection),e=await this.executeRaw(chunkVRZC4TTF_cjs.J`
59
- SELECT * FROM kyro_versions
60
- WHERE id = ${t.versionId}
61
- AND collection_slug = ${t.collection}
62
- ${t.tenantId&&i.tenantScoped?chunkVRZC4TTF_cjs.J`AND tenant_id = ${t.tenantId}`:chunkVRZC4TTF_cjs.J``}
63
- LIMIT 1
64
- `);if(e.length===0)return null;let s=e[0];return {...s,data:typeof s.data=="string"?JSON.parse(s.data):s.data}}async createVersion(t){await this.ensureVersionsTable();let i=this.getCollection(t.collection),e=new Date().toISOString();if(t.autosave){let o=await this.executeRaw(chunkVRZC4TTF_cjs.J`
65
- SELECT * FROM kyro_versions
66
- WHERE collection_slug = ${t.collection}
67
- AND document_id = ${t.documentId}
68
- AND autosave = 1
69
- ${t.tenantId&&i.tenantScoped?chunkVRZC4TTF_cjs.J`AND tenant_id = ${t.tenantId}`:chunkVRZC4TTF_cjs.J``}
70
- LIMIT 1
71
- `);if(o.length>0)return await this.executeRaw(chunkVRZC4TTF_cjs.J`
72
- UPDATE kyro_versions
73
- SET data = ${JSON.stringify(t.data)},
74
- status = ${t.status},
75
- updated_at = ${e}
76
- WHERE id = ${o[0].id}
77
- `),this.findVersionByID({collection:t.collection,versionId:o[0].id,tenantId:t.tenantId})}let s=Math.random().toString(36).substring(2,15),n=typeof t.data=="string"?t.data:JSON.stringify(t.data);if(await this.executeRaw(chunkVRZC4TTF_cjs.J`
78
- INSERT INTO kyro_versions (
79
- id, collection_slug, document_id, tenant_id, data, status, autosave, created_by, change_description, created_at, updated_at
80
- ) VALUES (
81
- ${s}, ${t.collection}, ${t.documentId}, ${t.tenantId&&i.tenantScoped?t.tenantId:null},
82
- ${n}, ${t.status}, ${t.autosave?1:0}, ${t.createdBy||null},
83
- ${t.changeDescription||null}, ${e}, ${e}
84
- )
85
- `),!t.autosave){let o=this.getCollection(t.collection);o.versions?.maxPerDoc&&await this.deleteVersions({collection:t.collection,documentId:t.documentId,keepLatest:o.versions.maxPerDoc,tenantId:t.tenantId});}return this.findVersionByID({collection:t.collection,versionId:s,tenantId:t.tenantId})}async updateLatestVersion(t){return this.createVersion({...t,autosave:true})}async deleteVersions(t){await this.ensureVersionsTable();let i=this.getCollection(t.collection);if(t.keepLatest){let s=(await this.executeRaw(chunkVRZC4TTF_cjs.J`
86
- SELECT id FROM kyro_versions
87
- WHERE collection_slug = ${t.collection}
88
- AND document_id = ${t.documentId}
89
- AND autosave = 0
90
- ${t.tenantId&&i.tenantScoped?chunkVRZC4TTF_cjs.J`AND tenant_id = ${t.tenantId}`:chunkVRZC4TTF_cjs.J``}
91
- ORDER BY created_at DESC
92
- LIMIT ${t.keepLatest}
93
- `)).map(n=>n.id);s.length>0&&await this.executeRaw(chunkVRZC4TTF_cjs.J`
94
- DELETE FROM kyro_versions
95
- WHERE collection_slug = ${t.collection}
96
- AND document_id = ${t.documentId}
97
- AND autosave = 0
98
- AND id NOT IN (${chunkVRZC4TTF_cjs.J.join(s.map(n=>chunkVRZC4TTF_cjs.J`${n}`),chunkVRZC4TTF_cjs.J`, `)})
99
- `);}else await this.executeRaw(chunkVRZC4TTF_cjs.J`
100
- DELETE FROM kyro_versions
101
- WHERE collection_slug = ${t.collection}
102
- AND document_id = ${t.documentId}
103
- ${t.tenantId&&i.tenantScoped?chunkVRZC4TTF_cjs.J`AND tenant_id = ${t.tenantId}`:chunkVRZC4TTF_cjs.J``}
104
- `);}getTable(t){let i=this.getTableName(t),e=this.schema[i];if(!e)throw new Error(`Table "${i}" not found in schema`);return e}buildWhereClause(t,i,e,s){let n=[];s&&i.tenantScoped&&e.tenantId&&n.push(chunkBCEE4NBZ_cjs.n(e.tenantId,s));for(let[o,a]of Object.entries(t)){let r=o,l=r.toUpperCase();if(r==="id"&&this.dialect==="postgres"&&(typeof a=="string"?a=C(a):a&&typeof a=="object"&&(a.equals!==void 0&&typeof a.equals=="string"&&(a={...a,equals:C(a.equals)}),a.in&&Array.isArray(a.in)&&(a={...a,in:a.in.map(c=>typeof c=="string"?C(c):c)}))),l==="AND"&&Array.isArray(a)){let c=a.map(u=>this.buildWhereClause(u,i,e)).flat().filter(Boolean);c.length>0&&n.push(chunkBCEE4NBZ_cjs.p(...c));}else if(l==="OR"&&Array.isArray(a)){let c=a.map(u=>this.buildWhereClause(u,i,e)).flat().filter(Boolean);c.length>0&&n.push(chunkBCEE4NBZ_cjs.q(...c));}else if(typeof a=="object"&&a!==null&&!Array.isArray(a)){let c=e[r]||e[r.replace(/-/g,"_")]||e[r.replace(/([A-Z])/g,"_$1").toLowerCase()]||(r==="created_at"?e.createdAt:void 0)||(r==="createdAt"?e.created_at:void 0)||(r==="updated_at"?e.updatedAt:void 0)||(r==="updatedAt"?e.updated_at:void 0);if(!c)continue;a.equals!==void 0&&n.push(chunkBCEE4NBZ_cjs.n(c,a.equals)),a.not_equals!==void 0&&n.push(chunkBCEE4NBZ_cjs.o(c,a.not_equals)),a.in&&Array.isArray(a.in)&&(a.in.length===0?n.push(chunkVRZC4TTF_cjs.J`1 = 0`):n.push(chunkBCEE4NBZ_cjs.w(c,a.in))),a.like!==void 0&&(this.dialect==="postgres"?n.push(chunkBCEE4NBZ_cjs.G(c,a.like)):n.push(chunkBCEE4NBZ_cjs.E(c,a.like))),a.contains!==void 0&&(this.dialect==="postgres"?n.push(chunkBCEE4NBZ_cjs.G(c,`%${a.contains}%`)):n.push(chunkBCEE4NBZ_cjs.E(c,`%${a.contains}%`))),a.greater_than!==void 0&&n.push(chunkBCEE4NBZ_cjs.s(c,a.greater_than)),a.greater_than_equal!==void 0&&n.push(chunkBCEE4NBZ_cjs.t(c,a.greater_than_equal)),a.less_than!==void 0&&n.push(chunkBCEE4NBZ_cjs.u(c,a.less_than)),a.less_than_equal!==void 0&&n.push(chunkBCEE4NBZ_cjs.v(c,a.less_than_equal));}else {let c=e[r]||e[r.replace(/-/g,"_")]||e[r.replace(/([A-Z])/g,"_$1").toLowerCase()];c&&n.push(chunkBCEE4NBZ_cjs.n(c,a));}}return n}processResult(t,i){if(!t)return null;let e={...t};for(let s of Object.keys(e))/^\d+$/.test(s)&&delete e[s];t.id&&(e.id=String(t.id));for(let s of i.fields){if(!s.name)continue;let n=s.name.replace(/-/g,"_").replace(/([A-Z])/g,"_$1").toLowerCase();n!==s.name&&e[n]!==void 0&&e[s.name]===void 0&&(e[s.name]=e[n],delete e[n]);}for(let s of i.fields){if(["json","richtext","array","group","blocks","upload","image","list","relationship-block"].includes(s.type)){let n=s;if(e[n.name]&&typeof e[n.name]=="string")try{let o=JSON.parse(e[n.name]);e[n.name]=o;}catch{}if(s.type==="blocks"&&e[n.name]&&Array.isArray(e[n.name])){let o=n.blocks||[];e[n.name]=j(e[n.name],o);}}if(s.type==="tabs"&&"tabs"in s&&s.name){if(typeof e[s.name]=="object"&&e[s.name]!==null&&!Array.isArray(e[s.name])){for(let o of s.tabs)for(let a of o.fields)if((a.type==="upload"||a.type==="image")&&a.name){let r=e[s.name][a.name];if(typeof r=="string")try{let l=JSON.parse(r);e[s.name][a.name]=Array.isArray(l)?l.map(c=>c&&typeof c=="object"&&typeof c.id=="string"?c.id:String(c||"")):typeof l.id=="string"?l.id:String(l.id||"");}catch{}else r&&typeof r=="object"&&(e[s.name][a.name]=Array.isArray(r)?r.map(l=>l&&typeof l=="object"&&typeof l.id=="string"?l.id:String(l||"")):typeof r.id=="string"?r.id:String(r.id||""));}continue}if(typeof e[s.name]=="string")try{let o=JSON.parse(e[s.name]);if(typeof o=="object"&&o!==null){e[s.name]=o;continue}}catch{}let n={};for(let o of s.tabs)for(let a of o.fields)if(a.name&&e[a.name]!==void 0){let r=e[a.name];if(["json","richtext","array","group","blocks","upload","image","list","relationship-block"].includes(a.type)){if(r&&typeof r=="string")try{r=JSON.parse(r);}catch{}(a.type==="upload"||a.type==="image")&&r&&typeof r=="object"&&(r=Array.isArray(r)?r.map(l=>l&&typeof l=="object"&&typeof l.id=="string"?l.id:String(l||"")):typeof r.id=="string"?r.id:String(r.id||""));}n[a.name]=r,delete e[a.name];}e[s.name]=n;}}return e.createdAt&&(e.createdAt=new Date(e.createdAt).toISOString()),e.updatedAt&&(e.updatedAt=new Date(e.updatedAt).toISOString()),chunkZUBJ6RLQ_cjs.a(e)}async ensureVersionsTable(){if(this.versionsTableReady)return;let t;this.dialect==="sqlite"?t=`
105
- CREATE TABLE IF NOT EXISTS kyro_versions (
106
- id text PRIMARY KEY,
107
- collection_slug text NOT NULL,
108
- document_id text NOT NULL,
109
- tenant_id text,
110
- data text NOT NULL,
111
- status text NOT NULL DEFAULT 'draft',
112
- autosave integer NOT NULL DEFAULT 0,
113
- created_by text,
114
- change_description text,
115
- created_at text DEFAULT (datetime('now')),
116
- updated_at text DEFAULT (datetime('now'))
117
- )
118
- `:t=`
119
- CREATE TABLE IF NOT EXISTS kyro_versions (
120
- id text PRIMARY KEY,
121
- collection_slug text NOT NULL,
122
- document_id text NOT NULL,
123
- tenant_id text,
124
- data text NOT NULL,
125
- status text NOT NULL,
126
- autosave integer NOT NULL DEFAULT 0,
127
- created_by text,
128
- change_description text,
129
- created_at text NOT NULL,
130
- updated_at text NOT NULL
131
- )
132
- `,await this.executeRaw(chunkVRZC4TTF_cjs.J.raw(t));try{this.dialect==="postgres"?await this.executeRaw(chunkVRZC4TTF_cjs.J.raw("ALTER TABLE kyro_versions ADD COLUMN IF NOT EXISTS autosave integer NOT NULL DEFAULT 0")):await this.executeRaw(chunkVRZC4TTF_cjs.J.raw("ALTER TABLE kyro_versions ADD COLUMN autosave integer NOT NULL DEFAULT 0"));}catch{}this.versionsTableReady=true;}async execute(t){return this.executeRaw(t)}async executeRaw(t){let i="",e=[];if(typeof t=="string")i=t;else if(t&&(t.queryChunks||t.decoder))if(this.dialect==="postgres"){let n=new chunkRVBSJ4UQ_cjs.a().sqlToQuery(t);i=n.sql,e=n.params;}else {let n=new chunk7ACHOBWY_cjs.h().sqlToQuery(t);i=n.sql,e=n.params;}else if(t&&typeof t.toSQL=="function"){let n=t.toSQL();i=n.sql,e=n.params||[];}else i=String(t);let s=this.rawClient||this.client;if(s?.prepare&&typeof s.prepare=="function"){let n=s.prepare(i);return (e.length>0?await n.bind(...e).all():await n.all()).results||[]}if(typeof this.client?.execute=="function"){let n=await this.client.execute(t);return Array.isArray(n)?n:Array.isArray(n?.rows)?n.rows:Array.isArray(n?.[0])?n[0]:[]}return []}};function pe(f){return new O(f)}exports.a=b;exports.b=de;exports.c=O;exports.d=pe;
@@ -1,2 +0,0 @@
1
- import {a as a$1,b}from'./chunk-HRAY65XH.js';import {a,l,c,i,N,A as A$1,d,t}from'./chunk-3NSZZCOJ.js';import {g}from'./chunk-Y2YAKDEQ.js';if (typeof window === "undefined") { const { createRequire } = await import(/* @vite-ignore */ 'module'); createRequire(import.meta.url); }
2
- g();var m=class{static[a]="Cache"},x=class extends m{strategy(){return "all"}static[a]="NoopCache";async get(e){}async put(e,a,i,t){}async onMutate(e){}};async function z(s,e){let a=`${s}-${JSON.stringify(e)}`,t=new TextEncoder().encode(a),n=await crypto.subtle.digest("SHA-256",t);return [...new Uint8Array(n)].map($=>$.toString(16).padStart(2,"0")).join("")}g();var C=class s{static[a]="SelectionProxyHandler";config;constructor(e){this.config={...e};}get(e,a){if(a==="_")return {...e._,selectedFields:new Proxy(e._.selectedFields,this)};if(a===l)return {...e[l],selectedFields:new Proxy(e[l].selectedFields,this)};if(typeof a=="symbol")return e[a];let t=(c(e,i)?e._.selectedFields:c(e,N)?e[l].selectedFields:e)[a];if(c(t,A$1.Aliased)){if(this.config.sqlAliasedBehavior==="sql"&&!t.isSelectionField)return t.sql;let n=t.clone();return n.isSelectionField=true,n}if(c(t,A$1)){if(this.config.sqlBehavior==="sql")return t;throw new Error(`You tried to reference "${a}" 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 c(t,d)?this.config.alias?new Proxy(t,new a$1(new Proxy(t.table,new b(this.config.alias,this.config.replaceOriginalName??false)))):t:typeof t!="object"||t===null?t:new Proxy(t,new s(this.config))}};g();function F(s){return (s.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map(a=>a.toLowerCase()).join("_")}function T(s){return (s.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).reduce((a,i,t)=>{let n=t===0?i.toLowerCase():`${i[0].toUpperCase()}${i.slice(1)}`;return a+n},"")}function v(s){return s}var A=class{static[a]="CasingCache";cache={};cachedTables={};convert;constructor(e){this.convert=e==="snake_case"?F:e==="camelCase"?T:v;}getColumnCasing(e){if(!e.keyAsName)return e.name;let a=e.table[t.Symbol.Schema]??"public",i=e.table[t.Symbol.OriginalName],t$1=`${a}.${i}.${e.name}`;return this.cache[t$1]||this.cacheTable(e.table),this.cache[t$1]}cacheTable(e){let a=e[t.Symbol.Schema]??"public",i=e[t.Symbol.OriginalName],t$1=`${a}.${i}`;if(!this.cachedTables[t$1]){for(let n of Object.values(e[t.Symbol.Columns])){let y=`${t$1}.${n.name}`;this.cache[y]=this.convert(n.name);}this.cachedTables[t$1]=true;}}clearCache(){this.cache={},this.cachedTables={};}};g();var _=class{static[a]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}};export{C as a,A as b,_ as c,x as d,z as e};
@@ -1 +0,0 @@
1
- 'use strict';var chunkVRZC4TTF_cjs=require('./chunk-VRZC4TTF.cjs'),chunkBUNLC3II_cjs=require('./chunk-BUNLC3II.cjs');chunkBUNLC3II_cjs.h();chunkBUNLC3II_cjs.h();function p(r){return chunkVRZC4TTF_cjs.J`count(${r||chunkVRZC4TTF_cjs.J.raw("*")})`.mapWith(Number)}function a(r){return chunkVRZC4TTF_cjs.J`count(distinct ${r})`.mapWith(Number)}function s(r){return chunkVRZC4TTF_cjs.J`avg(${r})`.mapWith(String)}function x(r){return chunkVRZC4TTF_cjs.J`avg(distinct ${r})`.mapWith(String)}function y(r){return chunkVRZC4TTF_cjs.J`sum(${r})`.mapWith(String)}function g(r){return chunkVRZC4TTF_cjs.J`sum(distinct ${r})`.mapWith(String)}function A(r){return chunkVRZC4TTF_cjs.J`max(${r})`.mapWith(chunkVRZC4TTF_cjs.c(r,chunkVRZC4TTF_cjs.d)?r:String)}function h(r){return chunkVRZC4TTF_cjs.J`min(${r})`.mapWith(chunkVRZC4TTF_cjs.c(r,chunkVRZC4TTF_cjs.d)?r:String)}chunkBUNLC3II_cjs.h();function o(r){return JSON.stringify(r)}function d(r,t){return Array.isArray(t)?chunkVRZC4TTF_cjs.J`${r} <-> ${o(t)}`:chunkVRZC4TTF_cjs.J`${r} <-> ${t}`}function q(r,t){return Array.isArray(t)?chunkVRZC4TTF_cjs.J`${r} <+> ${o(t)}`:chunkVRZC4TTF_cjs.J`${r} <+> ${t}`}function N(r,t){return Array.isArray(t)?chunkVRZC4TTF_cjs.J`${r} <#> ${o(t)}`:chunkVRZC4TTF_cjs.J`${r} <#> ${t}`}function b(r,t){return Array.isArray(t)?chunkVRZC4TTF_cjs.J`${r} <=> ${o(t)}`:chunkVRZC4TTF_cjs.J`${r} <=> ${t}`}function j(r,t){return Array.isArray(t)?chunkVRZC4TTF_cjs.J`${r} <~> ${o(t)}`:chunkVRZC4TTF_cjs.J`${r} <~> ${t}`}function w(r,t){return Array.isArray(t)?chunkVRZC4TTF_cjs.J`${r} <%> ${o(t)}`:chunkVRZC4TTF_cjs.J`${r} <%> ${t}`}exports.a=p;exports.b=a;exports.c=s;exports.d=x;exports.e=y;exports.f=g;exports.g=A;exports.h=h;exports.i=d;exports.j=q;exports.k=N;exports.l=b;exports.m=j;exports.n=w;