orcaq 1.0.30 → 1.0.32

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 (289) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/public/_nuxt/{DzJD_fir.js → -p9JbKy8.js} +3 -3
  3. package/.output/public/_nuxt/019vQzZn.js +1 -0
  4. package/.output/public/_nuxt/0lRW_xjL.js +1 -0
  5. package/.output/public/_nuxt/{BV6TSzbC.js → 3UJtAGbG.js} +3 -2
  6. package/.output/public/_nuxt/ACOLmAuq.js +15 -0
  7. package/.output/public/_nuxt/B1X10hvy.js +261 -0
  8. package/.output/public/_nuxt/B27ECqWz.js +220 -0
  9. package/.output/public/_nuxt/B6EI6PpE.js +1 -0
  10. package/.output/public/_nuxt/B8JnYxjr.js +2 -0
  11. package/.output/public/_nuxt/B9Mt45db.js +1 -0
  12. package/.output/public/_nuxt/B9zSkyFO.js +1 -0
  13. package/.output/public/_nuxt/BCcTASq_.js +139 -0
  14. package/.output/public/_nuxt/BJxYuvXF.js +7 -0
  15. package/.output/public/_nuxt/{FyrDS92w.js → BM4vnZvX.js} +101 -101
  16. package/.output/public/_nuxt/BNYR501z.js +1 -0
  17. package/.output/public/_nuxt/BQOaPJzs.js +145 -0
  18. package/.output/public/_nuxt/BUDtG__q.js +1 -0
  19. package/.output/public/_nuxt/BVLVn__t.js +9 -0
  20. package/.output/public/_nuxt/{KlH93fIm.js → BY1l0S_M.js} +1 -1
  21. package/.output/public/_nuxt/{ClnidwGv.js → B_PBOfFN.js} +2 -2
  22. package/.output/public/_nuxt/{y68LmDX2.js → BcvJQkv0.js} +1 -1
  23. package/.output/public/_nuxt/{llxtZpFD.js → BdN9B2_l.js} +2 -2
  24. package/.output/public/_nuxt/BflvengI.js +1 -0
  25. package/.output/public/_nuxt/BgolbRTO.js +1 -0
  26. package/.output/public/_nuxt/BhUkpIlA.js +1 -0
  27. package/.output/public/_nuxt/BsoQBloB.js +24 -0
  28. package/.output/public/_nuxt/BwISH3M4.js +1 -0
  29. package/.output/public/_nuxt/C-M4q4KX.js +1 -0
  30. package/.output/public/_nuxt/C07rlnlv.js +1 -0
  31. package/.output/public/_nuxt/C27bL9Es.js +1 -0
  32. package/.output/public/_nuxt/C2Ziircr.js +1 -0
  33. package/.output/public/_nuxt/C3NWXcpd.js +39 -0
  34. package/.output/public/_nuxt/C5p44jKD.js +1 -0
  35. package/.output/public/_nuxt/C617vhDd.js +1 -0
  36. package/.output/public/_nuxt/C6Vqzp-9.js +7 -0
  37. package/.output/public/_nuxt/C7C8tPlA.js +65 -0
  38. package/.output/public/_nuxt/C8S0o4Gy.js +1 -0
  39. package/.output/public/_nuxt/CHOD7i6O.js +4 -0
  40. package/.output/public/_nuxt/CNlsVoWh.js +1 -0
  41. package/.output/public/_nuxt/CQb_mUBo.js +1 -0
  42. package/.output/public/_nuxt/{MLO1tLKS.js → CSTzT9hP.js} +1 -1
  43. package/.output/public/_nuxt/CVliJ52o.js +162 -0
  44. package/.output/public/_nuxt/CWGdTiOD.js +1 -0
  45. package/.output/public/_nuxt/{CzF1NEwP.js → CWkPMmwS.js} +2 -2
  46. package/.output/public/_nuxt/CffFK_qY.js +189 -0
  47. package/.output/public/_nuxt/Cgy4ijjN.js +67 -0
  48. package/.output/public/_nuxt/ChkFTcxr.js +43 -0
  49. package/.output/public/_nuxt/Cjgqfl1g.js +10 -0
  50. package/.output/public/_nuxt/ClBBUcFW.js +1 -0
  51. package/.output/public/_nuxt/{DFd73eNR.js → ClYziJpO.js} +1 -1
  52. package/.output/public/_nuxt/CmKTTxBW.js +1 -0
  53. package/.output/public/_nuxt/CuRyxljq.js +1 -0
  54. package/.output/public/_nuxt/CvTHaPAO.js +1 -0
  55. package/.output/public/_nuxt/{HQyqkOpZ.js → CwdIiq6J.js} +1 -1
  56. package/.output/public/_nuxt/Cx4Bnfq1.js +2 -0
  57. package/.output/public/_nuxt/CyJtwmzi.js +331 -0
  58. package/.output/public/_nuxt/{ubO-cWd-.js → D-H6_V16.js} +1 -1
  59. package/.output/public/_nuxt/D-SDqguC.js +1 -0
  60. package/.output/public/_nuxt/{6I72R6kW.js → D-XwprNU.js} +1 -1
  61. package/.output/public/_nuxt/D3G5Xy_-.js +1 -0
  62. package/.output/public/_nuxt/D4jn2f-6.js +255 -0
  63. package/.output/public/_nuxt/D9o5Pdvp.js +1 -0
  64. package/.output/public/_nuxt/DDYV6jDr.js +1 -0
  65. package/.output/public/_nuxt/DFArp87o.js +1 -0
  66. package/.output/public/_nuxt/{C_CjS9Yt.js → DFZIXzfU.js} +1 -1
  67. package/.output/public/_nuxt/DHRNt0p9.js +1 -0
  68. package/.output/public/_nuxt/DLHYqHwF.js +24 -0
  69. package/.output/public/_nuxt/{D8pqASdN.js → DLKku6fV.js} +1 -1
  70. package/.output/public/_nuxt/DNZpxuwM.js +1 -0
  71. package/.output/public/_nuxt/DRKnK1N_.js +132 -0
  72. package/.output/public/_nuxt/DVxTxYP4.js +34 -0
  73. package/.output/public/_nuxt/{DQiMjOqm.js → DWgjNKGq.js} +1 -1
  74. package/.output/public/_nuxt/DX6XiGOO.js +1 -0
  75. package/.output/public/_nuxt/DYm57BZk.js +2 -0
  76. package/.output/public/_nuxt/DaQw8gVp.js +1 -0
  77. package/.output/public/_nuxt/DcfsxCxL.js +36 -0
  78. package/.output/public/_nuxt/DgnsV5Qb.js +1 -0
  79. package/.output/public/_nuxt/DkY69STm.js +292 -0
  80. package/.output/public/_nuxt/DkggUtNN.js +30 -0
  81. package/.output/public/_nuxt/Dnx67EG9.js +68 -0
  82. package/.output/public/_nuxt/{DVe5MHjS.js → DnxDSFih.js} +1 -1
  83. package/.output/public/_nuxt/Do5Fyo7J.js +1 -0
  84. package/.output/public/_nuxt/{h2fvG4Xe.js → Dqirx7MF.js} +1 -1
  85. package/.output/public/_nuxt/{WrapperErdDiagram.DsE2QNGr.css → ErdDiagram.Cnqgwj9d.css} +1 -1
  86. package/.output/public/_nuxt/FIJP2AmN.js +73 -0
  87. package/.output/public/_nuxt/Gi6I4Gst.js +1 -0
  88. package/.output/public/_nuxt/{C26aAkUg.js → GoTwJjoS.js} +1 -1
  89. package/.output/public/_nuxt/Hs25HoUO.js +22 -0
  90. package/.output/public/_nuxt/IitECNfD.js +89 -0
  91. package/.output/public/_nuxt/J2CvNR3L.js +1 -0
  92. package/.output/public/_nuxt/LFK46Fls.js +61 -0
  93. package/.output/public/_nuxt/LK6Q8l0D.js +1 -0
  94. package/.output/public/_nuxt/Oh9SO2qg.js +1 -0
  95. package/.output/public/_nuxt/{CtRc_P0d.js → P_8UoGnr.js} +2 -2
  96. package/.output/public/_nuxt/UqWhjgOc.js +10 -0
  97. package/.output/public/_nuxt/V5yaR3hv.js +2 -0
  98. package/.output/public/_nuxt/XWTuAj6n.js +1 -0
  99. package/.output/public/_nuxt/XqwbcqcW.js +1 -0
  100. package/.output/public/_nuxt/ZdjmUBoX.js +70 -0
  101. package/.output/public/_nuxt/_8UrUcVF.js +1 -0
  102. package/.output/public/_nuxt/builds/latest.json +1 -1
  103. package/.output/public/_nuxt/builds/meta/27a307c3-bfc5-4ccd-94b8-387eb94981bb.json +1 -0
  104. package/.output/public/_nuxt/cKBf5-av.js +1 -0
  105. package/.output/public/_nuxt/c_huf6xz.js +162 -0
  106. package/.output/public/_nuxt/entry.DeK5kcSi.css +1 -0
  107. package/.output/public/_nuxt/gO22NLpn.js +1 -0
  108. package/.output/public/_nuxt/index.xxedlMJo.css +1 -0
  109. package/.output/public/_nuxt/kc-op4gz.js +12 -0
  110. package/.output/public/_nuxt/lSaGvORn.js +10 -0
  111. package/.output/public/_nuxt/lY3EyFEK.js +1 -0
  112. package/.output/public/_nuxt/qsFoMdT2.js +1 -0
  113. package/.output/public/_nuxt/sE-55p4e.js +1 -0
  114. package/.output/public/_nuxt/tMhdAKU2.js +3 -0
  115. package/.output/public/_nuxt/trZyeId5.js +70 -0
  116. package/.output/public/_nuxt/uyCIL8xw.js +1 -0
  117. package/.output/server/chunks/_/db-connection.mjs +17 -3
  118. package/.output/server/chunks/_/db-connection.mjs.map +1 -1
  119. package/.output/server/chunks/_/instance-insights.factory.mjs.map +1 -1
  120. package/.output/server/chunks/_/metadata.factory.mjs +4 -5
  121. package/.output/server/chunks/_/metadata.factory.mjs.map +1 -1
  122. package/.output/server/chunks/_/query.factory.mjs +31 -2
  123. package/.output/server/chunks/_/query.factory.mjs.map +1 -1
  124. package/.output/server/chunks/build/client.manifest.mjs +1302 -546
  125. package/.output/server/chunks/build/client.manifest.mjs.map +1 -1
  126. package/.output/server/chunks/nitro/nitro.mjs +712 -364
  127. package/.output/server/chunks/routes/api/ai/agent.mjs +258 -89
  128. package/.output/server/chunks/routes/api/ai/agent.mjs.map +1 -1
  129. package/.output/server/chunks/routes/api/ai/chat.mjs +1 -2
  130. package/.output/server/chunks/routes/api/ai/chat.mjs.map +1 -1
  131. package/.output/server/chunks/routes/api/database-export/export-database.mjs +1 -2
  132. package/.output/server/chunks/routes/api/database-export/export-database.mjs.map +1 -1
  133. package/.output/server/chunks/routes/api/database-import/import-database.mjs +1 -2
  134. package/.output/server/chunks/routes/api/database-import/import-database.mjs.map +1 -1
  135. package/.output/server/chunks/routes/api/database-roles/create-role.mjs +1 -2
  136. package/.output/server/chunks/routes/api/database-roles/create-role.mjs.map +1 -1
  137. package/.output/server/chunks/routes/api/database-roles/delete-role.mjs +1 -2
  138. package/.output/server/chunks/routes/api/database-roles/delete-role.mjs.map +1 -1
  139. package/.output/server/chunks/routes/api/database-roles/get-databases-with-permissions.mjs +1 -2
  140. package/.output/server/chunks/routes/api/database-roles/get-databases-with-permissions.mjs.map +1 -1
  141. package/.output/server/chunks/routes/api/database-roles/get-databases.mjs +1 -2
  142. package/.output/server/chunks/routes/api/database-roles/get-databases.mjs.map +1 -1
  143. package/.output/server/chunks/routes/api/database-roles/get-permissions.mjs +1 -2
  144. package/.output/server/chunks/routes/api/database-roles/get-permissions.mjs.map +1 -1
  145. package/.output/server/chunks/routes/api/database-roles/get-role-inheritance.mjs +1 -2
  146. package/.output/server/chunks/routes/api/database-roles/get-role-inheritance.mjs.map +1 -1
  147. package/.output/server/chunks/routes/api/database-roles/get-role.mjs +1 -2
  148. package/.output/server/chunks/routes/api/database-roles/get-role.mjs.map +1 -1
  149. package/.output/server/chunks/routes/api/database-roles/get-roles.mjs +1 -2
  150. package/.output/server/chunks/routes/api/database-roles/get-roles.mjs.map +1 -1
  151. package/.output/server/chunks/routes/api/database-roles/get-schema-objects.mjs +1 -2
  152. package/.output/server/chunks/routes/api/database-roles/get-schema-objects.mjs.map +1 -1
  153. package/.output/server/chunks/routes/api/database-roles/get-schemas.mjs +1 -2
  154. package/.output/server/chunks/routes/api/database-roles/get-schemas.mjs.map +1 -1
  155. package/.output/server/chunks/routes/api/database-roles/grant-bulk-permissions.mjs +1 -2
  156. package/.output/server/chunks/routes/api/database-roles/grant-bulk-permissions.mjs.map +1 -1
  157. package/.output/server/chunks/routes/api/database-roles/grant-permission.mjs +1 -2
  158. package/.output/server/chunks/routes/api/database-roles/grant-permission.mjs.map +1 -1
  159. package/.output/server/chunks/routes/api/database-roles/revoke-permission.mjs +1 -2
  160. package/.output/server/chunks/routes/api/database-roles/revoke-permission.mjs.map +1 -1
  161. package/.output/server/chunks/routes/api/functions/definition.post.mjs +5 -3
  162. package/.output/server/chunks/routes/api/functions/definition.post.mjs.map +1 -1
  163. package/.output/server/chunks/routes/api/functions/delete.post.mjs +1 -2
  164. package/.output/server/chunks/routes/api/functions/delete.post.mjs.map +1 -1
  165. package/.output/server/chunks/routes/api/functions/overview.post.mjs +12 -10
  166. package/.output/server/chunks/routes/api/functions/overview.post.mjs.map +1 -1
  167. package/.output/server/chunks/routes/api/functions/rename.post.mjs +1 -2
  168. package/.output/server/chunks/routes/api/functions/rename.post.mjs.map +1 -1
  169. package/.output/server/chunks/routes/api/functions/signature.post.mjs +5 -3
  170. package/.output/server/chunks/routes/api/functions/signature.post.mjs.map +1 -1
  171. package/.output/server/chunks/routes/api/functions/update.post.mjs +1 -2
  172. package/.output/server/chunks/routes/api/functions/update.post.mjs.map +1 -1
  173. package/.output/server/chunks/routes/api/instance-insights/cancel-query.post.mjs +1 -2
  174. package/.output/server/chunks/routes/api/instance-insights/cancel-query.post.mjs.map +1 -1
  175. package/.output/server/chunks/routes/api/instance-insights/configuration.post.mjs +1 -2
  176. package/.output/server/chunks/routes/api/instance-insights/configuration.post.mjs.map +1 -1
  177. package/.output/server/chunks/routes/api/instance-insights/dashboard.post.mjs +1 -2
  178. package/.output/server/chunks/routes/api/instance-insights/dashboard.post.mjs.map +1 -1
  179. package/.output/server/chunks/routes/api/instance-insights/drop-slot.post.mjs +1 -2
  180. package/.output/server/chunks/routes/api/instance-insights/drop-slot.post.mjs.map +1 -1
  181. package/.output/server/chunks/routes/api/instance-insights/replication.post.mjs +1 -2
  182. package/.output/server/chunks/routes/api/instance-insights/replication.post.mjs.map +1 -1
  183. package/.output/server/chunks/routes/api/instance-insights/state.post.mjs +1 -2
  184. package/.output/server/chunks/routes/api/instance-insights/state.post.mjs.map +1 -1
  185. package/.output/server/chunks/routes/api/instance-insights/terminate-connection.post.mjs +1 -2
  186. package/.output/server/chunks/routes/api/instance-insights/terminate-connection.post.mjs.map +1 -1
  187. package/.output/server/chunks/routes/api/instance-insights/toggle-slot-status.post.mjs +1 -2
  188. package/.output/server/chunks/routes/api/instance-insights/toggle-slot-status.post.mjs.map +1 -1
  189. package/.output/server/chunks/routes/api/managment-connection/health-check.mjs +1 -2
  190. package/.output/server/chunks/routes/api/managment-connection/health-check.mjs.map +1 -1
  191. package/.output/server/chunks/routes/api/metadata/erd.post.mjs +12 -10
  192. package/.output/server/chunks/routes/api/metadata/erd.post.mjs.map +1 -1
  193. package/.output/server/chunks/routes/api/metadata/meta-data.post.mjs +14 -12
  194. package/.output/server/chunks/routes/api/metadata/meta-data.post.mjs.map +1 -1
  195. package/.output/server/chunks/routes/api/metadata/reverse-schemas.post.mjs +12 -10
  196. package/.output/server/chunks/routes/api/metadata/reverse-schemas.post.mjs.map +1 -1
  197. package/.output/server/chunks/routes/api/metrics/monitor.post.mjs +12 -10
  198. package/.output/server/chunks/routes/api/metrics/monitor.post.mjs.map +1 -1
  199. package/.output/server/chunks/routes/api/query/execute.post.mjs +14 -12
  200. package/.output/server/chunks/routes/api/query/execute.post.mjs.map +1 -1
  201. package/.output/server/chunks/routes/api/query/raw-execute-stream.post.mjs +14 -12
  202. package/.output/server/chunks/routes/api/query/raw-execute-stream.post.mjs.map +1 -1
  203. package/.output/server/chunks/routes/api/query/raw-execute.post.mjs +14 -12
  204. package/.output/server/chunks/routes/api/query/raw-execute.post.mjs.map +1 -1
  205. package/.output/server/chunks/routes/api/tables/bulk-delete.post.mjs +1 -2
  206. package/.output/server/chunks/routes/api/tables/bulk-delete.post.mjs.map +1 -1
  207. package/.output/server/chunks/routes/api/tables/bulk-update.post.mjs +1 -2
  208. package/.output/server/chunks/routes/api/tables/bulk-update.post.mjs.map +1 -1
  209. package/.output/server/chunks/routes/api/tables/ddl.post.mjs +5 -3
  210. package/.output/server/chunks/routes/api/tables/ddl.post.mjs.map +1 -1
  211. package/.output/server/chunks/routes/api/tables/export.post.mjs +1 -2
  212. package/.output/server/chunks/routes/api/tables/export.post.mjs.map +1 -1
  213. package/.output/server/chunks/routes/api/tables/indexes.post.mjs +5 -3
  214. package/.output/server/chunks/routes/api/tables/indexes.post.mjs.map +1 -1
  215. package/.output/server/chunks/routes/api/tables/meta.post.mjs +12 -10
  216. package/.output/server/chunks/routes/api/tables/meta.post.mjs.map +1 -1
  217. package/.output/server/chunks/routes/api/tables/overview.post.mjs +5 -3
  218. package/.output/server/chunks/routes/api/tables/overview.post.mjs.map +1 -1
  219. package/.output/server/chunks/routes/api/tables/rls.post.mjs +5 -3
  220. package/.output/server/chunks/routes/api/tables/rls.post.mjs.map +1 -1
  221. package/.output/server/chunks/routes/api/tables/rules.post.mjs +5 -3
  222. package/.output/server/chunks/routes/api/tables/rules.post.mjs.map +1 -1
  223. package/.output/server/chunks/routes/api/tables/size.post.mjs +5 -3
  224. package/.output/server/chunks/routes/api/tables/size.post.mjs.map +1 -1
  225. package/.output/server/chunks/routes/api/tables/structure.post.mjs +5 -3
  226. package/.output/server/chunks/routes/api/tables/structure.post.mjs.map +1 -1
  227. package/.output/server/chunks/routes/api/tables/triggers.post.mjs +5 -3
  228. package/.output/server/chunks/routes/api/tables/triggers.post.mjs.map +1 -1
  229. package/.output/server/chunks/routes/api/views/definition.post.mjs +5 -3
  230. package/.output/server/chunks/routes/api/views/definition.post.mjs.map +1 -1
  231. package/.output/server/chunks/routes/api/views/dependencies.post.mjs +5 -3
  232. package/.output/server/chunks/routes/api/views/dependencies.post.mjs.map +1 -1
  233. package/.output/server/chunks/routes/api/views/explain.post.mjs +1 -2
  234. package/.output/server/chunks/routes/api/views/explain.post.mjs.map +1 -1
  235. package/.output/server/chunks/routes/api/views/indexes.post.mjs +5 -3
  236. package/.output/server/chunks/routes/api/views/indexes.post.mjs.map +1 -1
  237. package/.output/server/chunks/routes/api/views/meta.post.mjs +5 -3
  238. package/.output/server/chunks/routes/api/views/meta.post.mjs.map +1 -1
  239. package/.output/server/chunks/routes/api/views/overview.post.mjs +5 -3
  240. package/.output/server/chunks/routes/api/views/overview.post.mjs.map +1 -1
  241. package/.output/server/chunks/routes/renderer.mjs +1 -2
  242. package/.output/server/index.mjs +1 -2
  243. package/.output/server/index.mjs.map +1 -1
  244. package/.output/server/package.json +1 -1
  245. package/README.md +8 -2
  246. package/package.json +1 -1
  247. package/.output/public/_nuxt/8_EuFD3X.js +0 -1
  248. package/.output/public/_nuxt/B6H7odCi.js +0 -1
  249. package/.output/public/_nuxt/B7nSJBpY.js +0 -1
  250. package/.output/public/_nuxt/BBNxNerU.js +0 -1
  251. package/.output/public/_nuxt/BDKd-SA5.js +0 -1
  252. package/.output/public/_nuxt/BDRdbLz0.js +0 -1
  253. package/.output/public/_nuxt/BKWWO5HE.js +0 -1
  254. package/.output/public/_nuxt/BVKG-F8j.js +0 -1
  255. package/.output/public/_nuxt/BoGW82nK.js +0 -1
  256. package/.output/public/_nuxt/Bs_ItSbk.js +0 -1
  257. package/.output/public/_nuxt/Btu7FO8S.js +0 -1
  258. package/.output/public/_nuxt/C04Tz2vC.js +0 -67
  259. package/.output/public/_nuxt/C4JPKbJK.js +0 -1
  260. package/.output/public/_nuxt/C5KSeJUi.js +0 -8
  261. package/.output/public/_nuxt/CDnZBTSk.js +0 -1
  262. package/.output/public/_nuxt/CKq06U7u.js +0 -19
  263. package/.output/public/_nuxt/CQpD-JHn.js +0 -1
  264. package/.output/public/_nuxt/Chcc8yNZ.js +0 -1
  265. package/.output/public/_nuxt/CpzDNDcD.js +0 -1
  266. package/.output/public/_nuxt/Cs1HkKH7.js +0 -1
  267. package/.output/public/_nuxt/CsYOf3m-.js +0 -39
  268. package/.output/public/_nuxt/Ctr2mpV9.js +0 -2
  269. package/.output/public/_nuxt/D2j2esR5.js +0 -3
  270. package/.output/public/_nuxt/D4ZGn1tW.js +0 -1
  271. package/.output/public/_nuxt/D6YseYA6.js +0 -1
  272. package/.output/public/_nuxt/D7EPcL9i.js +0 -1
  273. package/.output/public/_nuxt/DCMJS6Fh.js +0 -1
  274. package/.output/public/_nuxt/D_G1mAJ8.js +0 -3
  275. package/.output/public/_nuxt/De1hkrJC.js +0 -1
  276. package/.output/public/_nuxt/DnCs9xpG.js +0 -1
  277. package/.output/public/_nuxt/DvJ2MjiW.js +0 -2
  278. package/.output/public/_nuxt/Dzr_z_mY.js +0 -9
  279. package/.output/public/_nuxt/OEVyCyyD.js +0 -1
  280. package/.output/public/_nuxt/builds/meta/0ab6db39-d52b-46b9-a687-0df3b4c65db5.json +0 -1
  281. package/.output/public/_nuxt/builds/meta/dev.json +0 -1
  282. package/.output/public/_nuxt/e_Ir8LP9.js +0 -1
  283. package/.output/public/_nuxt/entry.XV7TCKso.css +0 -1
  284. package/.output/public/_nuxt/fRxmPZZB.js +0 -8
  285. package/.output/public/_nuxt/logo.BsJ2Dfin.png +0 -0
  286. package/.output/public/_nuxt/q4KcRwD-.js +0 -1
  287. package/.output/public/_nuxt/qIKg23Pc.js +0 -1
  288. package/.output/public/_nuxt/txD20ixW.js +0 -1
  289. package/.output/public/_nuxt/x2HBvptj.js +0 -1
@@ -0,0 +1,22 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ClYziJpO.js","./BM4vnZvX.js","./entry.DeK5kcSi.css"])))=>i.map(i=>d[i]);
2
+ var Os=Object.defineProperty;var Ps=(s,t,e)=>t in s?Os(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var ne=(s,t,e)=>Ps(s,typeof t!="symbol"?t+"":t,e);import{d as H,I as Yt,r as G,b as R,o as v,w as h,h as p,u as r,P as Jt,ei as yt,f as J,ej as dt,M as qs,b$ as xt,bV as Ze,U as Xt,N as we,a5 as ke,bY as ze,S as mt,c as q,bX as Zt,H as Ie,bS as et,cD as ae,C as f,bT as Vs,e as Ce,bW as Ds,aw as es,cp as bt,m as E,i as L,aX as _t,a9 as Z,G as Y,F as Q,t as I,j as ce,n as ue,au as re,A as Me,av as le,at as ie,p as Se,dk as Fs,aO as Bs,aR as js,a6 as pt,cu as zt,aT as Us,dp as Qs,dq as Hs,aV as Ws,ek as Gs,el as Ks,B as ts,q as ss,s as ns,x as os,z as Ys,em as Js,dK as Xs,dL as Zs,dM as en,en as Pe,cR as tn,ad as ge,J as Ct,K as as,ap as Ee,ao as Le,an as sn,L as Ne,ab as nn,a2 as ve,c8 as rs,R as ls,eo as on,dA as an,a7 as tt,dE as Mt,dF as rn,aW as ln,ep as un,am as Ve,$ as cn,_ as is,ai as dn,eq as At,a4 as us,bH as mn,b8 as St,bb as pn,bd as fn,bG as hn,bI as vn,bK as gn,bz as cs,ax as yn,ay as Lt,az as xn,aA as bn,aB as Nt,aD as nt,er as It,by as _n,dr as Cn,E as ds,es as Sn,O as wn,aN as Tn,cs as En}from"./BM4vnZvX.js";import{s as Rn,_ as ms,b as $n,c as kn,a as zn}from"./P_8UoGnr.js";import{_ as Mn}from"./C5p44jKD.js";import{_ as An}from"./BgolbRTO.js";import{_ as wt}from"./J2CvNR3L.js";import{M as Ln,a as Nn,b as ps,c as fs,d as hs,C as F,e as In,f as He,g as On,h as Pn,i as qn,j as Vn,_ as Dn}from"./ClBBUcFW.js";import{_ as Fn,a as Bn,b as jn}from"./CuRyxljq.js";import{f as ft,a as De,b as je}from"./-lZvfnzr.js";import{_ as Ot,a as Pt,b as qt,c as Vt}from"./BY1l0S_M.js";import{b as vs}from"./DgnsV5Qb.js";import{C as Un}from"./D-XwprNU.js";import{_ as Qn}from"./D-H6_V16.js";import{_ as Hn}from"./C8S0o4Gy.js";import{j as Wn,g as Gn,i as Kn,_ as gs}from"./B_PBOfFN.js";import{k as Yn,m as ys,n as xs}from"./CWkPMmwS.js";import{g as Je,b as Jn,s as Xn,r as Zn,u as eo,p as Dt}from"./BdN9B2_l.js";import{_ as to}from"./BhUkpIlA.js";import{u as so}from"./CwdIiq6J.js";import{_ as Tt,c as Ft,a as ot,e as Bt,b as jt}from"./-p9JbKy8.js";import{f as no}from"./BKltSiU0.js";import{_ as oo,b as ao,c as ro}from"./BNYR501z.js";import{u as lo}from"./kehy-5uo.js";import{c as io,m as uo}from"./C617vhDd.js";import"./C2Ziircr.js";import"./0lRW_xjL.js";import"./D3G5Xy_-.js";import"./D9o5Pdvp.js";import"./Bdtn2mn5.js";import"./GoTwJjoS.js";import"./DWgjNKGq.js";const[co,bs]=Yt(["MenuCheckboxItem","MenuRadioItem"],"MenuItemIndicatorContext");var mo=H({__name:"MenuItemIndicator",props:{forceMount:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"span"}},setup(s){const t=co({modelValue:G(!1)});return(e,n)=>(v(),R(r(qs),{present:e.forceMount||r(dt)(r(t).modelValue.value)||r(t).modelValue.value===!0},{default:h(()=>[p(r(Jt),{as:e.as,"as-child":e.asChild,"data-state":r(yt)(r(t).modelValue.value)},{default:h(()=>[J(e.$slots,"default")]),_:3},8,["as","as-child","data-state"])]),_:3},8,["present"]))}}),po=mo,fo=H({__name:"MenuCheckboxItem",props:{modelValue:{type:[Boolean,String],required:!1,default:!1},disabled:{type:Boolean,required:!1},textValue:{type:String,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:["select","update:modelValue"],setup(s,{emit:t}){const e=s,n=t,o=xt(e,["modelValue"]),a=Ze(o),l=Xt(e,"modelValue",n);return bs({modelValue:l}),(i,u)=>(v(),R(vs,we({role:"menuitemcheckbox"},r(a),{"aria-checked":r(dt)(r(l))?"mixed":r(l),"data-state":r(yt)(r(l)),onSelect:u[0]||(u[0]=async c=>{n("select",c),r(dt)(r(l))?l.value=!0:l.value=!r(l)})}),{default:h(()=>[J(i.$slots,"default",{modelValue:r(l)})]),_:3},16,["aria-checked","data-state"]))}}),ho=fo,vo=H({__name:"MenuGroup",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(s){const t=s;return(e,n)=>(v(),R(r(Jt),we({role:"group"},t),{default:h(()=>[J(e.$slots,"default")]),_:3},16))}}),go=vo;const[yo,xo]=Yt("MenuRadioGroup");var bo=H({__name:"MenuRadioGroup",props:{modelValue:{type:null,required:!1,default:""},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:["update:modelValue"],setup(s,{emit:t}){const e=s,n=t,o=xt(e,["modelValue"]),a=Ze(o),l=Xt(e,"modelValue",n);return xo({modelValue:l,onValueChange:i=>{l.value=i}}),(i,u)=>(v(),R(go,ke(ze(r(a))),{default:h(()=>[J(i.$slots,"default",{modelValue:r(l)})]),_:3},16))}}),_o=bo,Co=H({__name:"MenuRadioItem",props:{value:{type:null,required:!0},disabled:{type:Boolean,required:!1},textValue:{type:String,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:["select"],setup(s,{emit:t}){const e=s,n=t,o=xt(e,["value"]),a=Ze(o),{value:l}=mt(e),i=yo(),u=q(()=>i.modelValue.value===(l==null?void 0:l.value));return bs({modelValue:u}),(c,d)=>(v(),R(vs,we({role:"menuitemradio"},r(a),{"aria-checked":u.value,"data-state":r(yt)(u.value),onSelect:d[0]||(d[0]=async m=>{n("select",m),r(i).onValueChange(r(l))})}),{default:h(()=>[J(c.$slots,"default")]),_:3},16,["aria-checked","data-state"]))}}),So=Co,wo=H({__name:"DropdownMenuCheckboxItem",props:{modelValue:{type:[Boolean,String],required:!1},disabled:{type:Boolean,required:!1},textValue:{type:String,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:["select","update:modelValue"],setup(s,{emit:t}){const e=s,o=Zt(t);return Ie(),(a,l)=>(v(),R(r(ho),ke(ze({...e,...r(o)})),{default:h(()=>[J(a.$slots,"default")]),_:3},16))}}),To=wo,Eo=H({__name:"DropdownMenuItemIndicator",props:{forceMount:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(s){const t=s;return Ie(),(e,n)=>(v(),R(r(po),ke(ze(t)),{default:h(()=>[J(e.$slots,"default")]),_:3},16))}}),_s=Eo,Ro=H({__name:"DropdownMenuLabel",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(s){const t=s;return Ie(),(e,n)=>(v(),R(r(Ln),ke(ze(t)),{default:h(()=>[J(e.$slots,"default")]),_:3},16))}}),$o=Ro,ko=H({__name:"DropdownMenuRadioGroup",props:{modelValue:{type:null,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:["update:modelValue"],setup(s,{emit:t}){const e=s,o=Zt(t);return Ie(),(a,l)=>(v(),R(r(_o),ke(ze({...e,...r(o)})),{default:h(()=>[J(a.$slots,"default")]),_:3},16))}}),zo=ko,Mo=H({__name:"DropdownMenuRadioItem",props:{value:{type:null,required:!0},disabled:{type:Boolean,required:!1},textValue:{type:String,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:["select"],setup(s,{emit:t}){const o=et(s,t);return Ie(),(a,l)=>(v(),R(r(So),ke(ze(r(o))),{default:h(()=>[J(a.$slots,"default")]),_:3},16))}}),Ao=Mo,Lo=H({__name:"DropdownMenuSeparator",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(s){const t=s;return Ie(),(e,n)=>(v(),R(r(Nn),ke(ze(t)),{default:h(()=>[J(e.$slots,"default")]),_:3},16))}}),No=Lo;class Io{constructor(t){this.rawError=t}get nomaltliztionErrror(){var e;const t=((e=this.rawError)==null?void 0:e.message)||"Error parsing SQL execution.";if(!this.rawError)return{message:t};switch(this.rawError.dbType){case ae.POSTGRES:return this.normalizePostgresError(t);case ae.MYSQL:return this.normalizeMysqlError(t);case ae.SQLITE3:return this.normalizeSqliteError(t);default:return{message:t}}}normalizePostgresError(t){let e;return this.rawError.position&&(e=typeof this.rawError.position=="string"?Number(this.rawError.position):this.rawError.position,Number.isNaN(e)&&(e=void 0)),{message:this.rawError.message||t,position:e,hint:this.rawError.hint}}normalizeMysqlError(t){return{message:this.rawError.sqlMessage||this.rawError.message||t,hint:this.rawError.code?`Error Code: ${this.rawError.code}`:void 0}}normalizeSqliteError(t){return{message:this.rawError.message||t,hint:this.rawError.code?`Error Code: ${this.rawError.code}`:void 0}}}const Oo={class:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center"},Po=H({__name:"DropdownMenuCheckboxItem",props:{modelValue:{type:[Boolean,String]},disabled:{type:Boolean},textValue:{},asChild:{type:Boolean},as:{},class:{}},emits:["select","update:modelValue"],setup(s,{emit:t}){const e=s,n=t,o=q(()=>{const{class:l,...i}=e;return i}),a=et(o,n);return(l,i)=>(v(),R(r(To),we({"data-slot":"dropdown-menu-checkbox-item"},r(a),{class:r(Ce)("focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e.class)}),{default:h(()=>[f("span",Oo,[p(r(_s),null,{default:h(()=>[p(r(Vs),{class:"size-4"})]),_:1})]),J(l.$slots,"default")]),_:3},16,["class"]))}}),at=H({__name:"DropdownMenuLabel",props:{asChild:{type:Boolean},as:{},class:{},inset:{type:Boolean}},setup(s){const t=s,e=Ds(t,"class","inset"),n=Ze(e);return(o,a)=>(v(),R(r($o),we({"data-slot":"dropdown-menu-label","data-inset":o.inset?"":void 0},r(n),{class:r(Ce)("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",t.class)}),{default:h(()=>[J(o.$slots,"default")]),_:3},16,["data-inset","class"]))}}),qo=H({__name:"DropdownMenuRadioGroup",props:{modelValue:{},asChild:{type:Boolean},as:{}},emits:["update:modelValue"],setup(s,{emit:t}){const o=et(s,t);return(a,l)=>(v(),R(r(zo),we({"data-slot":"dropdown-menu-radio-group"},r(o)),{default:h(()=>[J(a.$slots,"default")]),_:3},16))}}),Vo={class:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center"},rt=H({__name:"DropdownMenuRadioItem",props:{value:{},disabled:{type:Boolean},textValue:{},asChild:{type:Boolean},as:{},class:{}},emits:["select"],setup(s,{emit:t}){const e=s,n=t,o=q(()=>{const{class:l,...i}=e;return i}),a=et(o,n);return(l,i)=>(v(),R(r(Ao),we({"data-slot":"dropdown-menu-radio-item"},r(a),{class:r(Ce)("focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e.class)}),{default:h(()=>[f("span",Vo,[p(r(_s),null,{default:h(()=>[p(r(Un),{class:"size-2 fill-current"})]),_:1})]),J(l.$slots,"default")]),_:3},16,["class"]))}}),lt=H({__name:"DropdownMenuSeparator",props:{asChild:{type:Boolean},as:{},class:{}},setup(s){const t=s,e=q(()=>{const{class:n,...o}=t;return o});return(n,o)=>(v(),R(r(No),we({"data-slot":"dropdown-menu-separator"},e.value,{class:r(Ce)("bg-border -mx-1 my-1 h-px",t.class)}),null,16,["class"]))}});function Et(s,t){s.dispatch(Yn(s.state,t))}function Do(s){return s===ae.POSTGRES?"positional":"question-mark"}function Fo(s,t,e,n={}){if(!Object.keys(t).length)return s;const o=n.style??Do(e);let a=n.startIndex??1,l="",i=0;for(;i<s.length;){const u=s[i];if(u==="'"){const c=i++;for(;i<s.length;)if(s[i]==="'"&&s[i+1]==="'")i+=2;else if(s[i]==="'"){i++;break}else i++;l+=s.slice(c,i);continue}if(u==='"'){const c=i++;for(;i<s.length&&s[i]!=='"';)i++;i++,l+=s.slice(c,i);continue}if(u===":"&&i+1<s.length&&/[a-zA-Z_]/.test(s[i+1])){const c=i++;let d="";for(;i<s.length&&/[a-zA-Z0-9_]/.test(s[i]);)d+=s[i++];d in t?l+=o==="positional"?`$${a++}`:"?":l+=s.slice(c,i);continue}l+=u,i++}return l}function Bo(s,t,e){if(s===t)return e;let n=0,o=0;for(;o<e&&n<s.length;){const a=s[n],l=t[o],i=/\s/.test(a),u=/\s/.test(l);if(i&&u){n++,o++;continue}if(a===":"&&(l==="$"||l==="?")){for(;n<s.length&&/[:a-zA-Z0-9_]/.test(s[n]);)n++;if(l==="$")for(;o<t.length&&/[$0-9]/.test(t[o]);)o++;else o++;if(o>=e)return n;continue}a===l?(n++,o++):n++}return n}function Ut({editorView:s,originalSql:t,statementFrom:e,fileParameters:n={},errorDetail:o,clientType:a,queryPrefix:l}){if(!s||!o)return;const{message:i,position:u}=o.normalizeError||new Io(o).nomaltliztionErrror;if(!u){Uo(s,e,t,i);return}const c=`${l}${t}`,d=Fo(c,n,a),m=Bo(c,d,u),y=Math.max(m-1,0)-((l==null?void 0:l.length)||0),{from:x,to:S}=jo(t,e,y);Et(s,[{from:x,to:S,severity:"error",message:i}])}function jo(s,t,e){let n=e;for(;n<s.length&&!/[\s\n\r\t]/.test(s[n]);)n++;return{from:t+e,to:t+n}}function Uo(s,t,e,n){const o=[{from:t,to:t+e.length,severity:"error",message:n}];Et(s,o)}function Qo(s){Et(s,[])}const Ho=s=>es.of([{key:"Mod-Enter",mac:"Cmd-Enter",run:t=>{const{currentStatements:e}=Je(t),n=Jn(t);return e.length&&s({currentStatements:e,treeNodes:n||[]}),!0},preventDefault:!0}]),Wo={},Go={class:"p-4 flex flex-col items-center justify-center h-full text-center space-y-4"},Ko={class:"text-muted-foreground space-y-3"},Yo={class:"list-disc text-sm list-inside text-left space-y-2"};function Jo(s,t){const e=An,n=Mn,o=wt;return v(),E("div",Go,[p(n,{class:"rounded-2xl size-20 shadow-md"},{default:h(()=>[p(e,{src:"/logo.png",alt:"@unovue"})]),_:1}),f("div",Ko,[t[7]||(t[7]=f("h2",{class:"text-md font-normal text-foreground"},"Getting Started",-1)),f("ol",Yo,[t[5]||(t[5]=f("li",null,[f("span",{class:"font-normal text-foreground"},"Write your query"),L(" in the editor. ")],-1)),t[6]||(t[6]=f("li",null,[f("span",{class:"font-normal text-foreground"},"Click inside your query"),L(" to select it. ")],-1)),f("li",null,[t[1]||(t[1]=L(" Click ")),t[2]||(t[2]=f("span",{class:"text-foreground font-normal"},"'Execute current'",-1)),t[3]||(t[3]=L(" or use shortcut ")),p(o,{class:"font-normal border rounded-md p-1 px-1.5 text-foreground"},{default:h(()=>t[0]||(t[0]=[L("⌘↵")])),_:1}),t[4]||(t[4]=L(" to run the query. "))])])])])}const Xo=bt(Wo,[["render",Jo]]),Zo={key:1,class:"text-xs text-muted-foreground ml-2"},ea=H({__name:"RawQueryEditorContextMenu",props:{contextMenuItems:{}},emits:["update:open"],setup(s,{emit:t}){const e=t,n=a=>typeof a>"u"?!0:!!a,o=a=>{e("update:open",a)};return(a,l)=>{const i=fs,u=In,c=ce,d=wt,m=He,y=On,x=qn,S=Vn,b=Pn,g=hs,_=ps;return v(),R(_,{"onUpdate:open":o},{default:h(()=>[p(i,{"as-child":""},{default:h(()=>[J(a.$slots,"default")]),_:3}),p(g,{class:"min-w-56",onCloseAutoFocus:l[0]||(l[0]=_t(()=>{},["prevent"]))},{default:h(()=>[(v(!0),E(Y,null,Z(a.contextMenuItems,(C,k)=>(v(),E(Y,{key:k},[C.type===r(F).LABEL&&n(C.condition)?(v(),R(u,{key:0,class:"font-medium text-xs text-muted-foreground"},{default:h(()=>[L(I(C.title),1)]),_:2},1024)):C.type===r(F).ACTION&&n(C.condition)?(v(),R(m,{key:1,onSelect:C.select,disabled:C.disabled},{default:h(()=>[C.icon?(v(),R(c,{key:0,name:C.icon,class:"size-4! min-w-4 text-muted-foreground"},null,8,["name"])):Q("",!0),L(" "+I(C.title)+" ",1),C.shortcut?(v(),R(d,{key:1},{default:h(()=>[L(I(C.shortcut),1)]),_:2},1024)):Q("",!0)]),_:2},1032,["onSelect","disabled"])):C.type===r(F).SEPARATOR&&n(C.condition)?(v(),R(y,{key:2})):C.type===r(F).SUBMENU&&n(C.condition)?(v(),R(b,{key:3,disabled:!C.items||C.items.length===0},{default:h(()=>[p(x,null,{default:h(()=>[C.icon?(v(),R(c,{key:0,name:C.icon,class:"size-4! min-w-4 text-muted-foreground mr-2"},null,8,["name"])):Q("",!0),L(" "+I(C.title)+" ",1),C.desc?(v(),E("span",Zo,I(C.desc),1)):Q("",!0)]),_:2},1024),p(S,{class:ue("min-w-52")},{default:h(()=>[(v(!0),E(Y,null,Z(C.items,(V,T)=>(v(),E(Y,{key:T},[V.type===r(F).ACTION&&n(V.condition)?(v(),R(m,{key:0,onSelect:V.select},{default:h(()=>[V.icon?(v(),R(c,{key:0,name:V.icon,class:"size-4! min-w-4 text-muted-foreground"},null,8,["name"])):Q("",!0),L(" "+I(V.title)+" ",1),V.shortcut?(v(),R(d,{key:1},{default:h(()=>[L(I(V.shortcut),1)]),_:2},1024)):Q("",!0)]),_:2},1032,["onSelect"])):V.type===r(F).LABEL&&n(V.condition)?(v(),R(u,{key:1,class:"font-medium text-xs text-muted-foreground"},{default:h(()=>[L(I(V.title),1)]),_:2},1024)):V.type===r(F).SEPARATOR&&n(V.condition)?(v(),R(y,{key:2})):Q("",!0)],64))),128))]),_:2},1024)]),_:2},1032,["disabled"])):Q("",!0)],64))),128))]),_:1})]),_:3})}}}),ta={},sa={class:"mb-2 flex items-center gap-1.5 text-sm font-semibold"};function na(s,t){const e=ce,n=Me,o=Bn,a=re,l=le,i=jn,u=Fn,c=ie;return v(),R(c,null,{default:h(()=>[p(u,null,{default:h(()=>[p(a,{"as-child":""},{default:h(()=>[p(o,{"as-child":""},{default:h(()=>[p(n,{size:"iconSm",variant:"ghost",class:"h-4 w-4 p-0 text-muted-foreground hover:text-foreground",title:"How to use query variables","aria-label":"How to use query variables"},{default:h(()=>[p(e,{name:"hugeicons:help-circle",class:"size-3.5!"})]),_:1})]),_:1})]),_:1}),p(l,null,{default:h(()=>t[0]||(t[0]=[f("p",null,"How to use query variables",-1)])),_:1}),p(i,{side:"top",align:"start",class:"w-[440px] p-4 text-xs"},{default:h(()=>[f("p",sa,[p(e,{name:"hugeicons:help-circle",class:"size-4!"}),t[1]||(t[1]=L(" Passing variables in queries "))]),t[2]||(t[2]=f("p",{class:"mb-3 text-muted-foreground"},[L(" Use "),f("code",{class:"rounded bg-muted px-1"},":variable_name"),L(" syntax to bind parameters. For array operators, cast to the correct type: ")],-1)),t[3]||(t[3]=f("div",{class:"space-y-3"},[f("div",null,[f("p",{class:"mb-1 font-medium text-foreground"},[f("code",{class:"rounded bg-muted px-1"},"= ANY()")]),f("pre",{class:"overflow-x-auto whitespace-pre-wrap break-all rounded bg-muted p-2 text-xs"},`WHERE id = ANY (ARRAY[:your_variable]::integer[])
3
+ WHERE status = ANY (ARRAY[:statuses]::text[])`)]),f("div",null,[f("p",{class:"mb-1 font-medium text-foreground"},[f("code",{class:"rounded bg-muted px-1"},"IN()")]),f("pre",{class:"overflow-x-auto whitespace-pre-wrap break-all rounded bg-muted p-2 text-xs"},`WHERE id IN (:your_variable)
4
+ WHERE name IN (:names)`)]),f("div",null,[f("p",{class:"mb-1 font-medium text-foreground"},"Scalar variable"),f("pre",{class:"overflow-x-auto whitespace-pre-wrap break-all rounded bg-muted p-2 text-xs"},`WHERE created_at > :start_date
5
+ WHERE user_id = :user_id`)])],-1)),t[4]||(t[4]=f("p",{class:"mt-3 border-t pt-2 text-muted-foreground"},[L(" Replace "),f("code",{class:"rounded bg-muted px-1"},"alias_type"),L(" with the actual PostgreSQL type, e.g. "),f("code",{class:"rounded bg-muted px-1"},"integer"),L(", "),f("code",{class:"rounded bg-muted px-1"},"uuid"),L(", "),f("code",{class:"rounded bg-muted px-1"},"text"),L(". ")],-1))]),_:1})]),_:1})]),_:1})}const oa=bt(ta,[["render",na]]),aa={class:"h-fit py-1 flex items-center justify-between px-2"},ra={class:"flex items-center gap-2"},la={class:"font-normal text-xs text-muted-foreground"},ia={key:0,class:"font-normal text-xs text-muted-foreground"},ua={key:0,class:"flex items-center gap-1"},ca={key:1,class:"flex items-center gap-1"},da={key:2},ma={key:0},pa={key:1},fa={class:"flex gap-1"},ha={class:"flex items-center"},va={class:"flex items-center"},ga={key:0},ya={key:1},xa=H({__name:"RawQueryEditorFooter",props:{cursorInfo:{},isHaveOneExecute:{type:Boolean},executeLoading:{type:Boolean},executeErrors:{type:Boolean},isStreaming:{type:Boolean},streamingRowCount:{},queryTime:{},rawQueryResultsLength:{},isRawViewMode:{type:Boolean},explainAnalyzeOptionItems:{},serializeMode:{}},emits:["onFormatCurrentStatement","onFormatAll","onExplainAnalyzeCurrent","toggleExplainOption","update:serializeMode","onExecuteCurrent","update:isRawViewMode","onCancelQuery"],setup(s){const t=G(!1);return(e,n)=>{const o=oa,a=ce,l=wt,i=Me;return v(),E("div",aa,[f("div",ra,[f("div",la," Ln "+I(e.cursorInfo.line)+", Col "+I(e.cursorInfo.column),1),p(o)]),e.isHaveOneExecute?(v(),E("div",ia,[e.isStreaming?(v(),E("span",ua,[p(a,{name:"hugeicons:loading-03",class:"size-4! animate-spin"}),L(" Streaming... "+I(r(ft)(e.streamingRowCount))+" rows ",1)])):e.executeLoading?(v(),E("span",ca,[n[9]||(n[9]=L("Processing ")),p(a,{name:"hugeicons:loading-03",class:"size-4! animate-spin"})])):(v(),E("span",da,[e.executeErrors?(v(),E("span",ma," Query: 1 error in "+I(r(De)(e.queryTime)),1)):(v(),E("span",pa," Query success: "+I(r(ft)(e.rawQueryResultsLength))+" rows in "+I(r(De)(e.queryTime)),1))]))])):Q("",!0),f("div",fa,[p(r(ie),null,{default:h(()=>[p(r(re),null,{default:h(()=>[f("div",ha,[p(i,{onClick:n[0]||(n[0]=u=>e.$emit("onFormatCurrentStatement")),variant:"outline",size:"xxs",class:"rounded-r-none"},{default:h(()=>[p(a,{name:"hugeicons:magic-wand-01"}),n[11]||(n[11]=L(" Format ")),p(l,null,{default:h(()=>n[10]||(n[10]=[L("⌘S")])),_:1})]),_:1}),p(r(Ot),null,{default:h(()=>[p(r(Pt),{"as-child":""},{default:h(()=>[p(i,{variant:"outline",size:"iconSm",class:"rounded-l-none border-l-0 px-2"},{default:h(()=>[p(a,{name:"hugeicons:arrow-down-01",class:"size-4! min-w-4"})]),_:1})]),_:1}),p(r(qt),{align:"end",class:"min-w-44"},{default:h(()=>[p(r(at),{class:"py-0"},{default:h(()=>n[12]||(n[12]=[L("Format Options ")])),_:1}),p(r(lt)),p(r(Vt),{onClick:n[1]||(n[1]=u=>e.$emit("onFormatCurrentStatement")),class:"h-6 cursor-pointer"},{default:h(()=>[n[14]||(n[14]=L(" Current Statement ")),p(l,null,{default:h(()=>n[13]||(n[13]=[L("⌘S")])),_:1})]),_:1}),p(r(Vt),{onClick:n[2]||(n[2]=u=>e.$emit("onFormatAll")),class:"h-6 cursor-pointer"},{default:h(()=>[n[16]||(n[16]=L(" All Statement ")),p(l,null,{default:h(()=>n[15]||(n[15]=[L("⇧⌥F")])),_:1})]),_:1})]),_:1})]),_:1})])]),_:1}),p(r(le),null,{default:h(()=>n[17]||(n[17]=[f("p",null,"Format current statement (⌘S)",-1)])),_:1})]),_:1}),p(r(ie),null,{default:h(()=>[p(r(re),null,{default:h(()=>[f("div",va,[p(i,{onClick:n[3]||(n[3]=u=>e.$emit("onExplainAnalyzeCurrent")),variant:"outline",size:"xxs",class:"rounded-r-none"},{default:h(()=>[p(a,{name:"hugeicons:analytics-up"}),n[19]||(n[19]=L(" Explain ")),p(l,null,{default:h(()=>n[18]||(n[18]=[L("⌘E")])),_:1})]),_:1}),p(r(Ot),{open:r(t),"onUpdate:open":n[6]||(n[6]=u=>Se(t)?t.value=u:null)},{default:h(()=>[p(r(Pt),{"as-child":""},{default:h(()=>[p(i,{variant:"outline",size:"iconSm",class:"rounded-l-none border-l-0 px-2"},{default:h(()=>[p(a,{name:"hugeicons:arrow-down-01",class:"size-4! min-w-4"})]),_:1})]),_:1}),p(r(qt),{align:"end",class:"min-w-52"},{default:h(()=>[p(r(at),{class:"py-0"},{default:h(()=>n[20]||(n[20]=[L("Explain Analyze Options")])),_:1}),p(r(lt)),(v(!0),E(Y,null,Z(e.explainAnalyzeOptionItems,u=>(v(),R(r(Po),{key:u.key,"model-value":u.checked,onSelect:n[4]||(n[4]=_t(()=>{},["prevent"])),"onUpdate:modelValue":c=>e.$emit("toggleExplainOption",u.key),class:"h-6 cursor-pointer"},{default:h(()=>[L(I(u.label),1)]),_:2},1032,["model-value","onUpdate:modelValue"]))),128)),p(r(lt)),p(r(at),{class:"py-0"},{default:h(()=>n[21]||(n[21]=[L("Serialize")])),_:1}),p(r(qo),{"model-value":e.serializeMode,"onUpdate:modelValue":n[5]||(n[5]=u=>e.$emit("update:serializeMode",u))},{default:h(()=>[p(r(rt),{value:"NONE",class:"h-6 cursor-pointer"},{default:h(()=>n[22]||(n[22]=[L("None")])),_:1}),p(r(rt),{value:"TEXT",class:"h-6 cursor-pointer"},{default:h(()=>n[23]||(n[23]=[L("Text")])),_:1}),p(r(rt),{value:"BINARY",class:"h-6 cursor-pointer"},{default:h(()=>n[24]||(n[24]=[L("Binary")])),_:1})]),_:1},8,["model-value"])]),_:1})]),_:1},8,["open"])])]),_:1}),p(r(le),null,{default:h(()=>n[25]||(n[25]=[f("p",null,"Run Explain Analyze (⌘E) or open options",-1)])),_:1})]),_:1}),p(r(ie),null,{default:h(()=>[p(r(re),{"as-child":""},{default:h(()=>[e.isStreaming||e.executeLoading?(v(),R(i,{key:0,onClick:n[7]||(n[7]=u=>e.$emit("onCancelQuery")),variant:"outline",size:"xxs"},{default:h(()=>[p(a,{name:"hugeicons:stop",class:"size-4! text-red-500"}),n[26]||(n[26]=L(" Cancel query "))]),_:1})):(v(),R(i,{key:1,onClick:n[8]||(n[8]=u=>e.$emit("onExecuteCurrent")),variant:"outline",size:"xxs"},{default:h(()=>[p(a,{name:"hugeicons:play"}),n[28]||(n[28]=L(" Execute current ")),p(l,null,{default:h(()=>n[27]||(n[27]=[L("⌘↵")])),_:1})]),_:1}))]),_:1}),p(r(le),null,{default:h(()=>[e.isStreaming||e.executeLoading?(v(),E("p",ga,"Cancel query")):(v(),E("p",ya,"Execute Query (⌘↵)"))]),_:1})]),_:1})])])}}}),ba={key:0,class:"flex items-center gap-2 truncate"},_a={key:1,class:"opacity-50"},Ca={class:"flex items-center gap-2"},Sa=H({__name:"PureConnectionSelector",props:{class:{},workspaceId:{},connectionId:{},connections:{},connection:{}},emits:["update:connectionId"],setup(s){const t=s,e=G(!1),{createConnection:n}=Fs(),o=G(!1),a=i=>{n(i)},l=()=>{o.value=!0,e.value=!1};return(i,u)=>{const c=ce,d=Hs,m=Us;return v(),E(Y,null,[p(r(Hn),{open:r(o),"editing-connection":null,"onUpdate:open":u[0]||(u[0]=y=>o.value=y),onAddNew:a,workspaceId:i.workspaceId},null,8,["open","workspaceId"]),p(r(Bs),{"onUpdate:modelValue":u[1]||(u[1]=y=>i.$emit("update:connectionId",y)),"model-value":i.connectionId,open:r(e),"onUpdate:open":u[2]||(u[2]=y=>Se(e)?e.value=y:null)},{default:h(()=>[p(r(js),{class:ue(r(Ce)(t.class," w-fit max-w-[12rem] cursor-pointer")),size:"sm"},{default:h(()=>{var y,x;return[i.connection?(v(),E("div",ba,[(v(),R(pt((y=r(zt)(i.connection.type))==null?void 0:y.icon),{class:"size-4! min-w-4!"})),L(" "+I((x=i.connection)==null?void 0:x.name),1)])):(v(),E("div",_a,"Select connection"))]}),_:1},8,["class"]),p(m,null,{default:h(()=>[p(r(Qs),null,{default:h(()=>[f("div",{class:"flex px-2 py-0.5 h-8 hover:bg-muted rounded-md font-normal text-sm items-center gap-1 cursor-pointer",onClick:l},[p(c,{name:"lucide:plus"}),u[3]||(u[3]=L(" Add new connection "))]),i.connections.length?(v(),R(d,{key:0})):Q("",!0),(v(!0),E(Y,null,Z(i.connections,y=>(v(),R(r(Ws),{class:"cursor-pointer",value:y.id},{default:h(()=>{var x;return[f("div",Ca,[(v(),R(pt((x=r(zt)(y.type))==null?void 0:x.icon),{class:"size-4!"})),L(" "+I(y.name),1)])]}),_:2},1032,["value"]))),256))]),_:1})]),_:1})]),_:1},8,["model-value","open"])],64)}}}),Cs=H({__name:"VariableEditor",props:{fileVariables:{}},emits:["updateVariables"],setup(s,{emit:t}){const e=t,n=G({line:1,column:1}),o=[Gs(`Please input your json variable
6
+ {
7
+ "key": "value"
8
+ }`),Rn(l=>{try{return Ks(l,{type:"space",size:2})}catch{return l}}),Wn(),ys(),xs(Gn())],a=l=>{e("updateVariables",l)};return(l,i)=>(v(),R(ms,{"onUpdate:modelValue":a,"onUpdate:cursorInfo":i[0]||(i[0]=u=>n.value=u),modelValue:l.fileVariables,extensions:o,disabled:!1,ref:"codeEditorRef"},null,8,["modelValue"]))}}),wa={class:"h-full flex flex-col overflow-y-auto"},Ta=H({__name:"AddVariableModal",props:{open:{},fileVariables:{}},emits:["update:open","updateVariables"],setup(s,{emit:t}){const e=t,n=async o=>{e("updateVariables",o)};return(o,a)=>(v(),R(r(ts),{class:"",open:!!o.open,"onUpdate:open":a[1]||(a[1]=l=>e("update:open",l))},{default:h(()=>[p(r(ss),{class:"w-[60vw] h-[50vh] flex flex-col justify-between min-w-[60vw]"},{default:h(()=>[p(r(ns),null,{default:h(()=>[p(r(os),null,{default:h(()=>a[2]||(a[2]=[L(" Add Variable "),f("a",{class:"underline",href:"https://www.w3schools.com/js/js_json_syntax.asp",target:"_blank"}," (JSON format)",-1)])),_:1})]),_:1}),f("div",wa,[p(Cs,{onUpdateVariables:n,fileVariables:o.fileVariables},null,8,["fileVariables"])]),p(r(Ys),{class:"mt-2"},{default:h(()=>[p(r(Me),{onClick:a[0]||(a[0]=l=>e("update:open",!1))},{default:h(()=>a[3]||(a[3]=[L(" Save ")])),_:1})]),_:1})]),_:1})]),_:1},8,["open"]))}}),Ea=H({__name:"RawQueryConfigModal",props:{open:{}},emits:["update:open"],setup(s,{emit:t}){const e=t;return(n,o)=>(v(),R(r(ts),{class:"",open:!!n.open,"onUpdate:open":o[0]||(o[0]=a=>e("update:open",a))},{default:h(()=>[p(r(ss),{class:"w-[50vw] h-[70vh] flex flex-col justify-between min-w-[50vw]"},{default:h(()=>[p(r(ns),null,{default:h(()=>[p(r(os),null,{default:h(()=>o[1]||(o[1]=[L(" Editor configs ")])),_:1})]),_:1}),p(Js)]),_:1})]),_:1},8,["open"]))}}),Ra={class:"flex items-center justify-between p-1 rounded-md bg-muted"},$a={class:"flex gap-2 items-center"},ka=H({__name:"RawQueryEditorHeader",props:{currentFileInfo:{},fileVariables:{},workspaceId:{},connections:{},connection:{},codeEditorLayout:{}},emits:["update:connectionId","update:updateFileVariables"],setup(s){const t=G(!1),e=G(!1),n=G(!1),o=()=>{t.value=!0},a=()=>{e.value=!0};return(l,i)=>{const u=ce,c=Qn,d=en,m=Zs,y=Xs,x=Me;return v(),E(Y,null,[p(Ta,{onUpdateVariables:i[0]||(i[0]=S=>l.$emit("update:updateFileVariables",S)),"file-variables":l.fileVariables,open:r(t),"onUpdate:open":i[1]||(i[1]=S=>Se(t)?t.value=S:null)},null,8,["file-variables","open"]),p(Ea,{open:r(e),"onUpdate:open":i[2]||(i[2]=S=>Se(e)?e.value=S:null)},null,8,["open"]),f("div",Ra,[f("div",null,[p(y,null,{default:h(()=>[p(m,{class:"gap-0!"},{default:h(()=>[p(d,null,{default:h(()=>[p(c,{class:"flex items-center gap-0.5"},{default:h(()=>{var S,b;return[p(u,{name:(S=l.currentFileInfo)==null?void 0:S.icon},null,8,["name"]),L(" "+I((b=l.currentFileInfo)==null?void 0:b.title),1)]}),_:1})]),_:1})]),_:1})]),_:1})]),f("div",$a,[l.codeEditorLayout===r(Pe).horizontal?(v(),R(r(ie),{key:0},{default:h(()=>[p(r(re),{"as-child":""},{default:h(()=>[p(x,{onClick:o,variant:"outline",size:"xs",class:"relative"},{default:h(()=>[r(n)?(v(),R(u,{key:0,name:"lucide:triangle-alert",class:"absolute -top-1 -right-1 text-red-400"})):Q("",!0),p(u,{name:"hugeicons:absolute"}),i[4]||(i[4]=L(" Add variables "))]),_:1})]),_:1}),p(r(le),null,{default:h(()=>i[5]||(i[5]=[f("p",null,"Add variables",-1)])),_:1})]),_:1})):Q("",!0),p(r(ie),null,{default:h(()=>[p(r(re),{"as-child":""},{default:h(()=>{var S;return[p(Sa,{connectionId:((S=l.currentFileInfo)==null?void 0:S.connectionId)||"","onUpdate:connectionId":i[3]||(i[3]=b=>l.$emit("update:connectionId",b)),connections:l.connections,connection:l.connection,class:"w-16 h-6! px-1.5",workspaceId:l.workspaceId},null,8,["connectionId","connections","connection","workspaceId"])]}),_:1}),p(r(le),null,{default:h(()=>i[6]||(i[6]=[f("p",null,"Select connection",-1)])),_:1})]),_:1}),p(r(ie),null,{default:h(()=>[p(r(re),{"as-child":""},{default:h(()=>[p(x,{onClick:a,variant:"outline",size:"iconSm"},{default:h(()=>[p(u,{name:"hugeicons:dashboard-square-02"})]),_:1})]),_:1}),p(r(le),null,{default:h(()=>i[7]||(i[7]=[f("p",null,"Query Settings",-1)])),_:1})]),_:1})])])],64)}}}),Ue={__name:"splitpanes",props:{horizontal:{type:Boolean,default:!1},pushOtherPanes:{type:Boolean,default:!0},maximizePanes:{type:Boolean,default:!0},rtl:{type:Boolean,default:!1},firstSplitter:{type:Boolean,default:!1}},emits:["ready","resize","resized","pane-click","pane-maximize","pane-add","pane-remove","splitter-click","splitter-dblclick"],setup(s,{emit:t}){const e=t,n=s,o=tn(),a=G([]),l=q(()=>a.value.reduce((w,$)=>(w[~~$.id]=$)&&w,{})),i=q(()=>a.value.length),u=G(null),c=G(!1),d=G({mouseDown:!1,dragging:!1,activeSplitter:null,cursorOffset:0}),m=G({splitter:null,timeoutId:null}),y=q(()=>({[`splitpanes splitpanes--${n.horizontal?"horizontal":"vertical"}`]:!0,"splitpanes--dragging":d.value.dragging})),x=()=>{document.addEventListener("mousemove",g,{passive:!1}),document.addEventListener("mouseup",_),"ontouchstart"in window&&(document.addEventListener("touchmove",g,{passive:!1}),document.addEventListener("touchend",_))},S=()=>{document.removeEventListener("mousemove",g,{passive:!1}),document.removeEventListener("mouseup",_),"ontouchstart"in window&&(document.removeEventListener("touchmove",g,{passive:!1}),document.removeEventListener("touchend",_))},b=(w,$)=>{const A=w.target.closest(".splitpanes__splitter");if(A){const{left:z,top:M}=A.getBoundingClientRect(),{clientX:j,clientY:K}="ontouchstart"in window&&w.touches?w.touches[0]:w;d.value.cursorOffset=n.horizontal?K-M:j-z}x(),d.value.mouseDown=!0,d.value.activeSplitter=$},g=w=>{d.value.mouseDown&&(w.preventDefault(),d.value.dragging=!0,requestAnimationFrame(()=>{D(T(w)),me("resize",{event:w},!0)}))},_=w=>{d.value.dragging&&(window.getSelection().removeAllRanges(),me("resized",{event:w},!0)),d.value.mouseDown=!1,d.value.activeSplitter=null,setTimeout(()=>{d.value.dragging=!1,S()},100)},C=(w,$)=>{"ontouchstart"in window&&(w.preventDefault(),m.value.splitter===$?(clearTimeout(m.value.timeoutId),m.value.timeoutId=null,k(w,$),m.value.splitter=null):(m.value.splitter=$,m.value.timeoutId=setTimeout(()=>m.value.splitter=null,500))),d.value.dragging||me("splitter-click",{event:w,index:$},!0)},k=(w,$)=>{if(me("splitter-dblclick",{event:w,index:$},!0),n.maximizePanes){let A=0;a.value=a.value.map((z,M)=>(z.size=M===$?z.max:z.min,M!==$&&(A+=z.min),z)),a.value[$].size-=A,me("pane-maximize",{event:w,index:$,pane:a.value[$]}),me("resized",{event:w,index:$},!0)}},V=(w,$)=>{me("pane-click",{event:w,index:l.value[$].index,pane:l.value[$]})},T=w=>{const $=u.value.getBoundingClientRect(),{clientX:A,clientY:z}="ontouchstart"in window&&w.touches?w.touches[0]:w;return{x:A-(n.horizontal?0:d.value.cursorOffset)-$.left,y:z-(n.horizontal?d.value.cursorOffset:0)-$.top}},U=w=>{w=w[n.horizontal?"y":"x"];const $=u.value[n.horizontal?"clientHeight":"clientWidth"];return n.rtl&&!n.horizontal&&(w=$-w),w*100/$},D=w=>{const $=d.value.activeSplitter;let A={prevPanesSize:B($),nextPanesSize:O($),prevReachedMinPanes:0,nextReachedMinPanes:0};const z=0+(n.pushOtherPanes?0:A.prevPanesSize),M=100-(n.pushOtherPanes?0:A.nextPanesSize),j=Math.max(Math.min(U(w),M),z);let K=[$,$+1],te=a.value[K[0]]||null,pe=a.value[K[1]]||null;const $t=te.max<100&&j>=te.max+A.prevPanesSize,Is=pe.max<100&&j<=100-(pe.max+O($+1));if($t||Is){$t?(te.size=te.max,pe.size=Math.max(100-te.max-A.prevPanesSize-A.nextPanesSize,0)):(te.size=Math.max(100-pe.max-A.prevPanesSize-O($+1),0),pe.size=pe.max);return}if(n.pushOtherPanes){const kt=N(A,j);if(!kt)return;({sums:A,panesToResize:K}=kt),te=a.value[K[0]]||null,pe=a.value[K[1]]||null}te!==null&&(te.size=Math.min(Math.max(j-A.prevPanesSize-A.prevReachedMinPanes,te.min),te.max)),pe!==null&&(pe.size=Math.min(Math.max(100-j-A.nextPanesSize-A.nextReachedMinPanes,pe.min),pe.max))},N=(w,$)=>{const A=d.value.activeSplitter,z=[A,A+1];return $<w.prevPanesSize+a.value[z[0]].min&&(z[0]=P(A).index,w.prevReachedMinPanes=0,z[0]<A&&a.value.forEach((M,j)=>{j>z[0]&&j<=A&&(M.size=M.min,w.prevReachedMinPanes+=M.min)}),w.prevPanesSize=B(z[0]),z[0]===void 0)?(w.prevReachedMinPanes=0,a.value[0].size=a.value[0].min,a.value.forEach((M,j)=>{j>0&&j<=A&&(M.size=M.min,w.prevReachedMinPanes+=M.min)}),a.value[z[1]].size=100-w.prevReachedMinPanes-a.value[0].min-w.prevPanesSize-w.nextPanesSize,null):$>100-w.nextPanesSize-a.value[z[1]].min&&(z[1]=W(A).index,w.nextReachedMinPanes=0,z[1]>A+1&&a.value.forEach((M,j)=>{j>A&&j<z[1]&&(M.size=M.min,w.nextReachedMinPanes+=M.min)}),w.nextPanesSize=O(z[1]-1),z[1]===void 0)?(w.nextReachedMinPanes=0,a.value.forEach((M,j)=>{j<i.value-1&&j>=A+1&&(M.size=M.min,w.nextReachedMinPanes+=M.min)}),a.value[z[0]].size=100-w.prevPanesSize-O(z[0]-1),null):{sums:w,panesToResize:z}},B=w=>a.value.reduce(($,A,z)=>$+(z<w?A.size:0),0),O=w=>a.value.reduce(($,A,z)=>$+(z>w+1?A.size:0),0),P=w=>[...a.value].reverse().find($=>$.index<w&&$.size>$.min)||{},W=w=>a.value.find($=>$.index>w+1&&$.size>$.min)||{},X=()=>{var w;const $=Array.from(((w=u.value)==null?void 0:w.children)||[]);for(const A of $){const z=A.classList.contains("splitpanes__pane"),M=A.classList.contains("splitpanes__splitter");!z&&!M&&(A.remove(),console.warn("Splitpanes: Only <pane> elements are allowed at the root of <splitpanes>. One of your DOM nodes was removed."))}},ee=(w,$,A=!1)=>{const z=w-1,M=document.createElement("div");M.classList.add("splitpanes__splitter"),A||(M.onmousedown=j=>b(j,z),typeof window<"u"&&"ontouchstart"in window&&(M.ontouchstart=j=>b(j,z)),M.onclick=j=>C(j,z+1)),M.ondblclick=j=>k(j,z+1),$.parentNode.insertBefore(M,$)},Ae=w=>{w.onmousedown=void 0,w.onclick=void 0,w.ondblclick=void 0,w.remove()},Te=()=>{var w;const $=Array.from(((w=u.value)==null?void 0:w.children)||[]);for(const z of $)z.className.includes("splitpanes__splitter")&&Ae(z);let A=0;for(const z of $)z.className.includes("splitpanes__pane")&&(!A&&n.firstSplitter?ee(A,z,!0):A&&ee(A,z),A++)},Oe=({uid:w,...$})=>{const A=l.value[w];for(const[z,M]of Object.entries($))A[z]=M},de=w=>{var $;let A=-1;Array.from((($=u.value)==null?void 0:$.children)||[]).some(z=>(z.className.includes("splitpanes__pane")&&A++,z.isSameNode(w.el))),a.value.splice(A,0,{...w,index:A}),a.value.forEach((z,M)=>z.index=M),c.value&&ve(()=>{Te(),ye({addedPane:a.value[A]}),me("pane-add",{pane:a.value[A]})})},he=w=>{const $=a.value.findIndex(z=>z.id===w);a.value[$].el=null;const A=a.value.splice($,1)[0];a.value.forEach((z,M)=>z.index=M),ve(()=>{Te(),me("pane-remove",{pane:A}),ye({removedPane:{...A}})})},ye=(w={})=>{!w.addedPane&&!w.removedPane?Be():a.value.some($=>$.givenSize!==null||$.min||$.max<100)?Ls(w):be(),c.value&&me("resized")},be=()=>{const w=100/i.value;let $=0;const A=[],z=[];for(const M of a.value)M.size=Math.max(Math.min(w,M.max),M.min),$-=M.size,M.size>=M.max&&A.push(M.id),M.size<=M.min&&z.push(M.id);$>.1&&st($,A,z)},Be=()=>{let w=100;const $=[],A=[];let z=0;for(const j of a.value)w-=j.size,j.givenSize!==null&&z++,j.size>=j.max&&$.push(j.id),j.size<=j.min&&A.push(j.id);let M=100;if(w>.1){for(const j of a.value)j.givenSize===null&&(j.size=Math.max(Math.min(w/(i.value-z),j.max),j.min)),M-=j.size;M>.1&&st(M,$,A)}},Ls=({addedPane:w,removedPane:$}={})=>{let A=100/i.value,z=0;const M=[],j=[];((w==null?void 0:w.givenSize)??null)!==null&&(A=(100-w.givenSize)/(i.value-1));for(const K of a.value)z-=K.size,K.size>=K.max&&M.push(K.id),K.size<=K.min&&j.push(K.id);if(!(Math.abs(z)<.1)){for(const K of a.value)(w==null?void 0:w.givenSize)!==null&&(w==null?void 0:w.id)===K.id||(K.size=Math.max(Math.min(A,K.max),K.min)),z-=K.size,K.size>=K.max&&M.push(K.id),K.size<=K.min&&j.push(K.id);z>.1&&st(z,M,j)}},st=(w,$,A)=>{let z;w>0?z=w/(i.value-$.length):z=w/(i.value-A.length),a.value.forEach((M,j)=>{if(w>0&&!$.includes(M.id)){const K=Math.max(Math.min(M.size+z,M.max),M.min),te=K-M.size;w-=te,M.size=K}else if(!A.includes(M.id)){const K=Math.max(Math.min(M.size+z,M.max),M.min),te=K-M.size;w-=te,M.size=K}}),Math.abs(w)>.1&&ve(()=>{c.value&&console.warn("Splitpanes: Could not resize panes correctly due to their constraints.")})},me=(w,$=void 0,A=!1)=>{const z=($==null?void 0:$.index)??d.value.activeSplitter??null;e(w,{...$,...z!==null&&{index:z},...A&&z!==null&&{prevPane:a.value[z-(n.firstSplitter?1:0)],nextPane:a.value[z+(n.firstSplitter?0:1)]},panes:a.value.map(M=>({min:M.min,max:M.max,size:M.size}))})};ge(()=>n.firstSplitter,()=>Te()),Ct(()=>{X(),Te(),ye(),me("ready"),c.value=!0}),as(()=>c.value=!1);const Ns=()=>{var w;return nn("div",{ref:u,class:y.value},(w=o.default)==null?void 0:w.call(o))};return Ee("panes",a),Ee("indexedPanes",l),Ee("horizontal",q(()=>n.horizontal)),Ee("requestUpdate",Oe),Ee("onPaneAdd",de),Ee("onPaneRemove",he),Ee("onPaneClick",V),(w,$)=>(v(),R(pt(Ns)))}},Re={__name:"pane",props:{size:{type:[Number,String]},minSize:{type:[Number,String],default:0},maxSize:{type:[Number,String],default:100}},setup(s){var t;const e=s,n=Le("requestUpdate"),o=Le("onPaneAdd"),a=Le("horizontal"),l=Le("onPaneRemove"),i=Le("onPaneClick"),u=(t=sn())==null?void 0:t.uid,c=Le("indexedPanes"),d=q(()=>c.value[u]),m=G(null),y=q(()=>{const g=isNaN(e.size)||e.size===void 0?0:parseFloat(e.size);return Math.max(Math.min(g,S.value),x.value)}),x=q(()=>{const g=parseFloat(e.minSize);return isNaN(g)?0:g}),S=q(()=>{const g=parseFloat(e.maxSize);return isNaN(g)?100:g}),b=q(()=>{var g;return`${a.value?"height":"width"}: ${(g=d.value)==null?void 0:g.size}%`});return ge(()=>y.value,g=>n({uid:u,size:g})),ge(()=>x.value,g=>n({uid:u,min:g})),ge(()=>S.value,g=>n({uid:u,max:g})),Ct(()=>{o({id:u,el:m.value,min:x.value,max:S.value,givenSize:e.size===void 0?null:y.value,size:y.value})}),as(()=>l(u)),(g,_)=>(v(),E("div",{ref_key:"paneEl",ref:m,class:"splitpanes__pane",onClick:_[0]||(_[0]=C=>r(i)(C,g._.uid)),style:Ne(b.value)},[J(g.$slots,"default")],4))}},za={class:"w-full h-full"},Ma={class:"flex flex-col w-full h-full overflow-y-auto"},Aa={class:"flex flex-col flex-1 h-full p-1"},La={class:"flex flex-col flex-1 h-full p-1 pl-0 relative"},Na=H({__name:"RawQueryLayout",props:{layout:{},customLayout:{},showResultPanel:{type:Boolean}},setup(s){const t=s,e=rs(),{editorLayoutSizes:n,editorLayoutInnerVariableSizes:o}=ls(e),a=T=>{n.value=[T[0].size,T[1].size]},l=T=>{o.value=[T[0].size,T[1].size]},i=q(()=>n.value[0]),u=q(()=>o.value[0]),c=q(()=>o.value[1]),d=q(()=>n.value[1]),m=q(()=>t.layout===Pe.horizontalWithVariables||t.layout===Pe.vertical),y=q(()=>t.layout===Pe.horizontalWithVariables),x=q(()=>!!t.customLayout),S=q(()=>{var T;return((T=t.customLayout)==null?void 0:T.direction)==="vertical"}),b=q(()=>{var T,U;return((U=(T=t.customLayout)==null?void 0:T.innerSplit)==null?void 0:U.direction)==="vertical"}),g=T=>{var N,B,O,P,W;const U=(N=t.customLayout)==null?void 0:N.id;if(!U)return((O=(B=t.customLayout)==null?void 0:B.panels[T])==null?void 0:O.defaultSize)??50;const D=e.customLayoutSizes[U];return(D==null?void 0:D.panels[T])??((W=(P=t.customLayout)==null?void 0:P.panels[T])==null?void 0:W.defaultSize)??50},_=T=>{var N,B,O,P,W,X,ee;const U=(N=t.customLayout)==null?void 0:N.id;if(!U)return((P=(O=(B=t.customLayout)==null?void 0:B.innerSplit)==null?void 0:O.panels[T])==null?void 0:P.defaultSize)??50;const D=e.customLayoutSizes[U];return(D==null?void 0:D.innerPanels[T])??((ee=(X=(W=t.customLayout)==null?void 0:W.innerSplit)==null?void 0:X.panels[T])==null?void 0:ee.defaultSize)??50},C=T=>{var D;const U=(D=t.customLayout)==null?void 0:D.id;U&&e.updateCustomLayoutSizes(U,T.map(N=>N.size))},k=T=>{var N,B,O;const U=(N=t.customLayout)==null?void 0:N.id;if(!U)return;const D=((B=e.customLayoutSizes[U])==null?void 0:B.panels)??((O=t.customLayout)==null?void 0:O.panels.map(P=>P.defaultSize))??[];e.updateCustomLayoutSizes(U,D,T.map(P=>P.size))},V={content:"flex flex-col w-full h-full overflow-y-auto",variables:"flex flex-col flex-1 h-full p-1",result:"flex flex-col flex-1 h-full p-1 pl-0 relative"};return(T,U)=>(v(),E("div",za,[r(x)&&T.customLayout?(v(),R(r(Ue),{key:0,class:"default-theme",horizontal:r(S),onResize:U[1]||(U[1]=D=>C(D.panes))},{default:h(()=>[(v(!0),E(Y,null,Z(T.customLayout.panels,(D,N)=>(v(),E(Y,{key:N},[T.customLayout.innerSplit&&T.customLayout.innerSplit.panelIndex===N?(v(),R(r(Re),{key:0,size:g(N),"min-size":D.minSize,"max-size":D.maxSize},{default:h(()=>[p(r(Ue),{horizontal:r(b),class:"default-theme",onResize:U[0]||(U[0]=B=>k(B.panes))},{default:h(()=>[(v(!0),E(Y,null,Z(T.customLayout.innerSplit.panels,(B,O)=>(v(),R(r(Re),{key:`inner-${O}`,size:_(O),"min-size":B.minSize,"max-size":B.maxSize},{default:h(()=>[f("div",{class:ue(V[B.slot])},[J(T.$slots,B.slot)],2)]),_:2},1032,["size","min-size","max-size"]))),128))]),_:3},8,["horizontal"])]),_:2},1032,["size","min-size","max-size"])):(v(),R(r(Re),{key:1,size:g(N),"min-size":D.minSize,"max-size":D.maxSize},{default:h(()=>[f("div",{class:ue(V[D.slot])},[J(T.$slots,D.slot)],2)]),_:2},1032,["size","min-size","max-size"]))],64))),128))]),_:3},8,["horizontal"])):(v(),R(r(Ue),{key:1,onResize:U[3]||(U[3]=D=>a(D.panes)),class:"default-theme",horizontal:T.layout===r(Pe).vertical},{default:h(()=>[p(r(Re),{size:r(i)},{default:h(()=>[p(r(Ue),{horizontal:r(y),onResize:U[2]||(U[2]=D=>r(m)?l(D.panes):null)},{default:h(()=>[p(r(Re),{size:r(m)?r(u):100,"min-size":"30"},{default:h(()=>[f("div",Ma,[J(T.$slots,"content")])]),_:3},8,["size"]),r(m)?(v(),R(r(Re),{key:0,size:r(c),"min-size":"0","max-size":"70"},{default:h(()=>[f("div",Aa,[J(T.$slots,"variables")])]),_:3},8,["size"])):Q("",!0)]),_:3},8,["horizontal"])]),_:3},8,["size"]),t.showResultPanel!==!1?(v(),R(r(Re),{key:0,size:r(d),"min-size":"0","max-size":"80"},{default:h(()=>[f("div",La,[J(T.$slots,"result")])]),_:3},8,["size"])):Q("",!0)]),_:3},8,["horizontal"]))]))}}),Ia={class:"h-full flex flex-col p-2"},Oa={class:"flex items-center justify-between mb-2"},Pa={class:"flex items-center gap-2 text-xs text-muted-foreground"},qa={key:0,class:"mb-3 p-2 bg-muted/50 rounded-md border text-xs"},Va={class:"text-muted-foreground mb-1 flex items-center gap-1"},Da={class:"text-[11px] line-clamp-2"},Fa={key:1,class:"mb-3 p-3 bg-red-50 border border-red-200 rounded-md text-sm text-red-600"},Ba={class:"flex items-center gap-2"},ja={key:2,class:"flex-1 flex items-center justify-center text-muted-foreground"},Ua={class:"text-center"},Qa={class:"text-sm mb-1"},Ha={class:"flex flex-wrap justify-center gap-2"},Wa={key:0,class:"whitespace-pre-wrap"},Ga={key:1,class:"prose prose-sm dark:prose-invert max-w-none prose-pre:bg-muted prose-pre:text-foreground"},Ka={key:0,class:"whitespace-pre-wrap"},Ya={key:1,class:"flex gap-3"},Ja={class:"bg-muted rounded-lg p-3 text-sm"},Xa={class:"flex items-center gap-2"},Za={key:4,class:"flex flex-col gap-2"},er=H({__name:"ResultTabAgentView",props:{activeTab:{}},setup(s){const t=s,e=q(()=>t.activeTab.metadata.statementQuery),{selectedProvider:n,selectedModel:o,isLoading:a,error:l,messages:i,hasApiKey:u,currentProvider:c,sendMessage:d,clearChat:m}=so({body:()=>({sqlContext:e.value})}),{openSettings:y}=an(),x=G(""),S=G(null),b=async C=>{if(C.preventDefault(),!x.value.trim()||a.value)return;const k=x.value;x.value="",await d(k),await ve(),g()},g=()=>{S.value&&(S.value.scrollTop=S.value.scrollHeight)};ge(()=>i.value.length,()=>{ve(()=>g())}),ge(()=>{const C=i.value[i.value.length-1];return C!=null&&C.parts?C.parts.filter(k=>k.type==="text").map(k=>k.text).join(""):""},()=>{ve(()=>g())});const _=async C=>{await d(C),await ve(),g()};return(C,k)=>{var N,B,O;const V=ce,T=Me,U=tt,D=to;return v(),E("div",Ia,[f("div",Oa,[f("div",Pa,[p(V,{name:"hugeicons:chat-bot",class:"size-4"}),k[8]||(k[8]=f("span",null,"SQL Assistant",-1)),f("div",null,[p(r(ie),null,{default:h(()=>[p(r(re),{"as-child":""},{default:h(()=>[f("div",null,[p(on,{provider:r(n),"onUpdate:provider":k[0]||(k[0]=P=>Se(n)?n.value=P:null),model:r(o),"onUpdate:model":k[1]||(k[1]=P=>Se(o)?o.value=P:null),class:"min-w-[160px] h-6!"},null,8,["provider","model"])])]),_:1}),p(r(le),null,{default:h(()=>k[7]||(k[7]=[f("p",null,"Select AI Model",-1)])),_:1})]),_:1})])]),p(r(ie),null,{default:h(()=>[p(r(re),{"as-child":""},{default:h(()=>[p(T,{variant:"ghost",size:"xs",onClick:r(m),disabled:r(i).length===0},{default:h(()=>[p(V,{name:"lucide:trash-2",class:"size-3.5"})]),_:1},8,["onClick","disabled"])]),_:1}),p(r(le),null,{default:h(()=>k[9]||(k[9]=[f("p",null,"Clear chat history",-1)])),_:1})]),_:1})]),r(e)?(v(),E("div",qa,[f("div",Va,[p(V,{name:"hugeicons:sql",class:"size-3"}),k[10]||(k[10]=L(" Current Query Context: "))]),f("code",Da,I(r(e)),1)])):Q("",!0),r(l)?(v(),E("div",Fa,[f("div",Ba,[p(V,{name:"lucide:alert-circle",class:"size-4"}),L(" "+I(r(l)),1)])])):Q("",!0),r(u)?(v(),E("div",{key:3,ref_key:"messagesContainer",ref:S,class:"flex-1 overflow-y-auto space-y-4 mb-4"},[r(i).length===0?(v(),R(U,{key:0,title:"Agent Chat",desc:"Ask me anything about your SQL query"},{default:h(()=>[f("div",Ha,[p(T,{variant:"outline",size:"xs",onClick:k[3]||(k[3]=P=>_("Explain this query"))},{default:h(()=>k[14]||(k[14]=[L(" Explain this query ")])),_:1}),p(T,{variant:"outline",size:"xs",onClick:k[4]||(k[4]=P=>_("How can I optimize this query?"))},{default:h(()=>k[15]||(k[15]=[L(" Optimize query ")])),_:1}),p(T,{variant:"outline",size:"xs",onClick:k[5]||(k[5]=P=>_("What are potential issues with this query?"))},{default:h(()=>k[16]||(k[16]=[L(" Find issues ")])),_:1})])]),_:1})):Q("",!0),(v(!0),E(Y,null,Z(r(i),P=>(v(),E("div",{key:P.id,class:ue(["flex gap-3",P.role==="user"?"justify-end":"justify-start"])},[f("div",{class:ue(["max-w-[80%] rounded-lg p-3 text-sm",P.role==="user"?"bg-primary text-primary-foreground":"bg-muted"])},[P.role==="user"?(v(!0),E(Y,{key:0},Z(P.parts,(W,X)=>(v(),E(Y,{key:X},[W.type==="text"?(v(),E("span",Wa,I(W.text),1)):Q("",!0)],64))),128)):(v(),E("div",Ga,[(v(!0),E(Y,null,Z(P.parts,(W,X)=>(v(),E(Y,{key:X},[W.type==="text"?(v(),E("span",Ka,I(W.text),1)):Q("",!0)],64))),128))]))],2)],2))),128)),r(a)&&(!((N=r(i)[r(i).length-1])!=null&&N.parts)||((O=(B=r(i)[r(i).length-1])==null?void 0:B.parts)==null?void 0:O.length)===0)?(v(),E("div",Ya,[f("div",Ja,[f("div",Xa,[p(V,{name:"hugeicons:loading-03",class:"size-4 animate-spin"}),k[17]||(k[17]=f("span",{class:"text-muted-foreground"},"Thinking...",-1))])])])):Q("",!0)],512)):(v(),E("div",ja,[f("div",Ua,[p(V,{name:"lucide:key",class:"size-12 mb-3 opacity-50 mx-auto"}),f("p",Qa," No API key configured for "+I(r(c).name),1),k[13]||(k[13]=f("p",{class:"text-xs text-muted-foreground mb-3"}," Configure your API keys in Settings → Agent ",-1)),p(r(ie),null,{default:h(()=>[p(r(re),{"as-child":""},{default:h(()=>[p(T,{variant:"outline",size:"sm",class:"text-xs",onClick:k[2]||(k[2]=P=>r(y)("Agent"))},{default:h(()=>[p(V,{name:"lucide:settings",class:"size-4 mr-1"}),k[11]||(k[11]=L(" Open Settings "))]),_:1})]),_:1}),p(r(le),null,{default:h(()=>k[12]||(k[12]=[f("p",null,"Open functionality settings",-1)])),_:1})]),_:1})])])),r(u)?(v(),E("div",Za,[f("form",{onSubmit:b,class:"flex gap-2 relative"},[p(D,{modelValue:r(x),"onUpdate:modelValue":k[6]||(k[6]=P=>Se(x)?x.value=P:null),placeholder:"Ask about your SQL query...",disabled:r(a),class:"min-h-4!"},null,8,["modelValue","disabled"]),p(r(ie),null,{default:h(()=>[p(r(re),{"as-child":""},{default:h(()=>[p(T,{type:"submit",size:"iconSm",class:"absolute right-2 top-1/2 -translate-y-1/2 rounded-full",disabled:!r(x).trim()||r(a)},{default:h(()=>[p(V,{name:r(a)?"hugeicons:loading-03":"lucide:arrow-up",class:ue(["size-4",r(a)?"animate-spin":""])},null,8,["name","class"])]),_:1},8,["disabled"])]),_:1}),p(r(le),null,{default:h(()=>k[18]||(k[18]=[f("p",null,"Send message",-1)])),_:1})]),_:1})],32)])):Q("",!0)])}}}),tr={class:"h-full p-2 overflow-y-auto"},sr={key:0,class:"space-y-2"},nr={class:"flex items-center justify-between gap-2"},or={class:"flex items-center gap-1"},ar={class:"text-sm pl-5 text-muted-foreground decoration-wavy underline decoration-red-600"},rr={key:0,class:"pl-5 mt-1 text-sm text-amber-600/90 font-medium"},lr={class:"pt-2 border-t"},ir={class:"error-query-container"},ur={key:0,class:"pt-2 border-t"},cr=H({__name:"ResultTabErrorView",props:{activeTab:{}},emits:["onChangeView"],setup(s,{emit:t}){const e=s,n=t,o=x=>!!x.metadata.executeErrors,a=q(()=>{var S,b;const x=(S=e.activeTab.metadata.executeErrors)==null?void 0:S.data;return((b=x==null?void 0:x.normalizeError)==null?void 0:b.position)||null}),l=q(()=>{var b;const x=e.activeTab.metadata.executeErrors,S=x==null?void 0:x.data;return((b=S==null?void 0:S.normalizeError)==null?void 0:b.message)||(x==null?void 0:x.message)||""}),i=q(()=>{var S,b;const x=(S=e.activeTab.metadata.executeErrors)==null?void 0:S.data;return((b=x==null?void 0:x.normalizeError)==null?void 0:b.hint)||null}),u=q(()=>{const x=e.activeTab.metadata.statementQuery;if(!x)return[];const S=a.value,b=[];if(S&&S>0){const g=S-1;let _=g;for(;_<x.length&&x[_]!==`
9
+ `&&x[_]!=="\r"&&x[_]!==" "&&x[_]!==" ";)_++;_<=g&&(_=Math.min(g+1,x.length)),b.push({start:g,end:_,properties:{class:"error-highlight"}})}return b}),c=async()=>{if(typeof window>"u")return;await ve();const x=document.querySelector(".error-query-container .error-highlight");x&&x.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"})};ge(()=>u.value,()=>{c()},{flush:"post"});const d=q(()=>{var S;const x={...((S=e.activeTab.metadata.executeErrors)==null?void 0:S.data)||{}};return x==null||delete x.normalizeError,x?typeof x=="string"?x:JSON.stringify(x,null,2):""}),m=q(()=>e.activeTab.metadata.statementQuery||""),y=()=>{n("onChangeView","agent")};return(x,S)=>{var _;const b=ce,g=Tt;return v(),E("div",tr,[o(x.activeTab)?(v(),E("div",sr,[f("div",nr,[f("div",null,[f("div",or,[p(b,{name:"hugeicons:alert-02",class:"size-4 text-red-500 mt-0.5"}),S[0]||(S[0]=f("div",{class:"font-medium text-red-600"},"Error Message",-1))]),f("span",ar,I(l.value),1),i.value?(v(),E("div",rr," Hint: "+I(i.value),1)):Q("",!0)]),p(r(Me),{onClick:y,size:"xs",variant:"outline"},{default:h(()=>[p(b,{name:"hugeicons:ai-brain-04",class:"size-4"}),S[1]||(S[1]=L(" Ask AI to fix this error "))]),_:1})]),f("div",lr,[S[2]||(S[2]=f("div",{class:"mb-2"},[f("span",{class:"font-normal text-sm text-muted-foreground flex items-center gap-1"}," View executed query : ")],-1)),f("div",ir,[p(g,{code:m.value,decorations:u.value,"show-copy-button":""},null,8,["code","decorations"])])]),(_=x.activeTab.metadata.executeErrors)!=null&&_.data?(v(),E("div",ur,[S[3]||(S[3]=f("div",{class:"flex items-center justify-between mb-2"},[f("div",{class:"text-sm text-muted-foreground"},"Error Details:")],-1)),p(g,{code:d.value,language:"json"},null,8,["code"])])):Q("",!0)])):Q("",!0)])}}}),dr=bt(cr,[["__scopeId","data-v-d4daf140"]]),mr={class:"h-full p-4 space-y-3 overflow-y-auto"},pr={class:"space-y-2"},fr={class:"flex items-center gap-2 text-sm"},hr={class:"font-medium"},vr={class:"flex items-center gap-2 text-sm"},gr={class:"font-medium"},yr={class:"flex items-center gap-2 text-sm"},xr={class:"font-medium"},br={class:"flex items-center gap-2 text-sm"},_r={class:"font-medium"},Cr={class:"flex items-center gap-2 text-sm"},Sr={class:"font-medium"},wr={key:0,class:"flex items-center gap-2 text-sm"},Tr={class:"font-medium"},Er={class:"pt-3 border-t"},Rr={key:0,class:"pt-3 border-t"},$r={class:"flex flex-wrap gap-1"},kr=H({__name:"ResultTabInfoView",props:{activeTab:{}},setup(s){const t=s,e=typeof TextEncoder<"u"?new TextEncoder:null,n=q(()=>{var a;const o=((a=t.activeTab)==null?void 0:a.result)??[];if(!e)return{bytes:0,formatted:"N/A"};try{const l=JSON.stringify(o),i=l?e.encode(l).length:0;return{bytes:i,formatted:no(i)}}catch{return{bytes:0,formatted:"N/A"}}});return(o,a)=>{var u,c,d,m;const l=ce,i=Tt;return v(),E("div",mr,[f("div",pr,[f("div",fr,[p(l,{name:"hugeicons:clock-01",class:"size-4 text-muted-foreground"}),a[0]||(a[0]=f("span",{class:"text-muted-foreground"},"Query Time:",-1)),f("span",hr,I(r(De)(o.activeTab.metadata.queryTime)),1)]),f("div",vr,[p(l,{name:"hugeicons:summation-01",class:"size-4 text-muted-foreground"}),a[1]||(a[1]=f("span",{class:"text-muted-foreground"},"Rows:",-1)),f("span",gr,I(r(ft)(((u=o.activeTab.result)==null?void 0:u.length)||0)),1)]),f("div",yr,[p(l,{name:"hugeicons:file-02",class:"size-4 text-muted-foreground"}),a[2]||(a[2]=f("span",{class:"text-muted-foreground"},"Result Size:",-1)),f("span",xr,I(n.value.formatted),1)]),f("div",br,[p(l,{name:"hugeicons:chart-column",class:"size-4 text-muted-foreground"}),a[3]||(a[3]=f("span",{class:"text-muted-foreground"},"Columns:",-1)),f("span",_r,I(((c=o.activeTab.metadata.fieldDefs)==null?void 0:c.length)||0),1)]),f("div",Cr,[p(l,{name:"hugeicons:calendar-03",class:"size-4 text-muted-foreground"}),a[4]||(a[4]=f("span",{class:"text-muted-foreground"},"Executed At:",-1)),f("span",Sr,I(((d=o.activeTab.metadata.executedAt)==null?void 0:d.toLocaleString())||"N/A"),1)]),o.activeTab.metadata.connection?(v(),E("div",wr,[p(l,{name:"hugeicons:plug-socket",class:"size-4 text-muted-foreground"}),a[5]||(a[5]=f("span",{class:"text-muted-foreground"},"Connection:",-1)),f("span",Tr,I(o.activeTab.metadata.connection.name||"Unknown"),1)])):Q("",!0)]),f("div",Er,[a[6]||(a[6]=f("div",{class:"text-sm text-muted-foreground mb-2"},"Query:",-1)),p(i,{code:o.activeTab.metadata.statementQuery||""},null,8,["code"])]),(m=o.activeTab.metadata.fieldDefs)!=null&&m.length?(v(),E("div",Rr,[a[7]||(a[7]=f("div",{class:"text-sm text-muted-foreground mb-2"},"Fields:",-1)),f("div",$r,[(v(!0),E(Y,null,Z(o.activeTab.metadata.fieldDefs,y=>(v(),E("span",{key:y.name,class:"text-xs bg-muted px-2 py-1 rounded"},I(y.name),1))),128))])])):Q("",!0)])}}}),zr={class:"h-full flex flex-col flex-1 overflow-hidden"},Mr=H({__name:"ResultTabRawView",props:{formattedData:{},executeLoading:{type:Boolean},isStreaming:{type:Boolean}},setup(s){const t=s;return(e,n)=>{const o=tt;return v(),E("div",zr,[t.formattedData.length===0&&!e.executeLoading&&!e.isStreaming?(v(),R(o,{key:0,title:"No Raw Data",desc:"The query returned no records to display as JSON."})):(v(),R(r(Kn),{key:1,modelValue:t.formattedData,mode:"text",readOnly:!0,navigationBar:!1,class:"h-full"},null,8,["modelValue"]))])}}}),Ss={SELECT:"DML",INSERT:"DML",UPDATE:"DML",DELETE:"DML",MERGE:"DML",VALUES:"DML",TRUNCATE:"DML",COPY:"DML",CREATE:"DDL",ALTER:"DDL",DROP:"DDL",COMMENT:"DDL",ANALYZE:"DDL",VACUUM:"DDL",REINDEX:"DDL",CLUSTER:"DDL","REFRESH MATERIALIZED VIEW":"DDL","IMPORT FOREIGN SCHEMA":"DDL","SECURITY LABEL":"DDL",GRANT:"DCL",REVOKE:"DCL",BEGIN:"TCL",COMMIT:"TCL",ROLLBACK:"TCL",SAVEPOINT:"TCL","RELEASE SAVEPOINT":"TCL","ROLLBACK TO SAVEPOINT":"TCL","PREPARE TRANSACTION":"TCL","COMMIT PREPARED":"TCL","ROLLBACK PREPARED":"TCL","SET TRANSACTION":"TCL",SET:"SYSTEM",SHOW:"SYSTEM",RESET:"SYSTEM",DISCARD:"SYSTEM",EXPLAIN:"SYSTEM",LOAD:"SYSTEM",LOCK:"SYSTEM",MOVE:"SYSTEM",FETCH:"SYSTEM",CLOSE:"SYSTEM",DECLARE:"SYSTEM",DEALLOCATE:"SYSTEM",PREPARE:"SYSTEM",EXECUTE:"SYSTEM",LISTEN:"SYSTEM",UNLISTEN:"SYSTEM",NOTIFY:"SYSTEM",DO:"SYSTEM",ABORT:"SYSTEM",CHECKPOINT:"SYSTEM"},Ar=s=>{const t=s.toUpperCase().trim();if(["SELECT","VALUES","SHOW","EXPLAIN","TABLE"].some(o=>t===o||t.startsWith(o+" ")))return!1;const n=Ss[t];return!!(["INSERT","UPDATE","DELETE","TRUNCATE","COPY","MERGE","CALL","DO"].includes(t)||n==="DDL"||n==="DCL"||["SET","RESET","GRANT","REVOKE","COMMENT","ANALYZE","VACUUM","REINDEX","CLUSTER"].includes(t)||t.startsWith("CREATE")||t.startsWith("DROP")||t.startsWith("ALTER"))},Lr=(s,t)=>{const e=s||"Query",n=t??0;return["INSERT","UPDATE","DELETE"].includes(e.toUpperCase())?`${e} successful. ${n} rows affected.`:`${e} successful.`};class Fe{constructor(t,e){ne(this,"cmd");ne(this,"rowCount");this.cmd=t.toUpperCase().trim(),this.rowCount=e}isMutation(){return Ar(this.cmd)}getMessage(t){return t?Lr(this.cmd,this.rowCount):""}getCategory(){return Ss[this.cmd]??"UNKNOWN"}build(){const t=this.isMutation();return{isMutation:t,message:this.getMessage(t),category:this.getCategory()}}}class Nr extends Fe{isMutation(){return["VACUUM","ANALYZE","REINDEX","CLUSTER"].includes(this.cmd)?!0:super.isMutation()}}class ws extends Fe{isMutation(){return this.cmd.startsWith("OPTIMIZE")?!0:super.isMutation()}getMessage(t){return this.cmd==="TRUNCATE"||this.cmd.startsWith("TRUNCATE ")?"TRUNCATE successful.":super.getMessage(t)}}class Ir extends ws{}class Ts extends Fe{isMutation(){return this.cmd.startsWith("TRUNCATE")?!0:super.isMutation()}getMessage(t){return this.cmd==="INSERT"?`INSERT successful. Last insert row id: ${this.rowCount}.`:super.getMessage(t)}}class Or extends Ts{}class Pr extends Fe{getMessage(t){return this.cmd==="MERGE"?`MERGE successful. ${this.rowCount} rows affected.`:super.getMessage(t)}}class qr extends Fe{getMessage(t){return this.cmd==="TRUNCATE"||this.cmd.startsWith("TRUNCATE ")?"TRUNCATE successful.":this.cmd==="MERGE"?`MERGE successful. ${this.rowCount} rows affected.`:super.getMessage(t)}}const Vr={[ae.POSTGRES]:Nr,[ae.MYSQL]:ws,[ae.MYSQL2]:Ir,[ae.SQLITE3]:Ts,[ae.BETTER_SQLITE3]:Or,[ae.MSSQL]:Pr,[ae.ORACLE]:qr},Dr=(s,t=0,e=ae.POSTGRES)=>{const n=Vr[e];if(!n)throw new Error(`Unsupported database client type: "${e}"`);return new n(s,t).build()},Fr=H({__name:"RawQueryContextMenu",props:{cellContextMenu:{},cellHeaderContextMenu:{},data:{},selectedRows:{},tableName:{},schemaName:{}},emits:["onClearContextMenu"],setup(s,{emit:t}){const e=s,n=t,o=q(()=>{var b,g,_,C;return((g=(b=e.cellContextMenu)==null?void 0:b.column)==null?void 0:g.getColId())??((C=(_=e.cellHeaderContextMenu)==null?void 0:_.column)==null?void 0:C.getColId())}),a=q(()=>{var b,g,_;return((b=e.cellContextMenu)==null?void 0:b.column.getColDef().headerName)??((_=(g=e.cellHeaderContextMenu)==null?void 0:g.column)==null?void 0:_.getColDef().headerName)??""}),l=b=>{Ft(e.selectedRows||[],a.value??"",b)},i=b=>{Ft(e.data||[],a.value??"",b)},u=b=>ot(e.selectedRows||[],e.tableName||"table_data",b,e.schemaName),c=b=>ot(e.data||[],e.tableName||"table_data",b,e.schemaName),d=b=>Bt(e.selectedRows||[],e.tableName||"table_data",b,"selected",e.schemaName),m=b=>Bt(e.data||[],e.tableName||"table_data",b,"all",e.schemaName),y=()=>{var g;const b=(g=e.cellContextMenu)==null?void 0:g.value;if(b!==void 0){if(typeof b=="object")return jt(JSON.stringify(b));jt(String(b))}},x=()=>{var b;if(e.cellContextMenu){const g=(b=e.cellContextMenu)==null?void 0:b.data;ot([g],e.tableName||"table_data","csv-no-header",e.schemaName)}},S=q(()=>{var D;const b=!!e.cellContextMenu,g=e.selectedRows.length>0,_=e.selectedRows.length,C=((D=e.data)==null?void 0:D.length)||0,k=!!o.value,V=[{type:F.LABEL,title:`${_} selected`,condition:g&&b},{type:F.ACTION,title:"Copy as text",icon:"hugeicons:file-01",select:()=>l("list"),condition:g&&b},{type:F.ACTION,title:"Copy as JSON",icon:"hugeicons:code",select:()=>l("json"),condition:g&&b},{type:F.SEPARATOR,condition:g&&b},{type:F.LABEL,title:"All data in column"},{type:F.ACTION,title:"Copy as text",icon:"hugeicons:file-01",select:()=>i("list")},{type:F.ACTION,title:"Copy as JSON",icon:"hugeicons:code",select:()=>i("json")}],T=[{type:F.LABEL,title:`${_} selected row(s)`,condition:g},{type:F.ACTION,title:"Copy as CSV/TSV",icon:"hugeicons:csv-02",select:()=>u("csv-no-header"),condition:g},{type:F.ACTION,title:"Copy as JSON",icon:"hugeicons:code",select:()=>u("json"),condition:g},{type:F.ACTION,title:"Copy as SQL",icon:"hugeicons:database",select:()=>u("sql"),condition:g},{type:F.SEPARATOR,condition:g},{type:F.LABEL,title:"All rows"},{type:F.ACTION,title:"Copy as CSV/TSV",icon:"hugeicons:csv-02",select:()=>c("csv-no-header")},{type:F.ACTION,title:"Copy as JSON",icon:"hugeicons:code",select:()=>c("json")},{type:F.ACTION,title:"Copy as SQL",icon:"hugeicons:database",select:()=>c("sql")}],U=[{type:F.LABEL,title:`${_} selected row${_>1?"s":""}`,condition:g},{type:F.ACTION,title:"Export as CSV",icon:"hugeicons:csv-01",select:()=>d("csv-no-header"),condition:g},{type:F.ACTION,title:"Export as CSV (have headers)",icon:"hugeicons:csv-01",select:()=>d("csv-with-header"),condition:g},{type:F.ACTION,title:"Export as JSON",icon:"hugeicons:code",select:()=>d("json"),condition:g},{type:F.ACTION,title:"Export as SQL",icon:"hugeicons:database",select:()=>d("sql"),condition:g},{type:F.SEPARATOR,condition:g},{type:F.LABEL,title:`All ${C.toLocaleString()} row${C!==1?"s":""}`},{type:F.ACTION,title:"Export as CSV",icon:"hugeicons:csv-01",select:()=>m("csv-no-header")},{type:F.ACTION,title:"Export as CSV (have headers)",icon:"hugeicons:csv-01",select:()=>m("csv-with-header")},{type:F.ACTION,title:"Export as JSON",icon:"hugeicons:code",select:()=>m("json")},{type:F.ACTION,title:"Export as SQL",icon:"hugeicons:database",select:()=>m("sql")}];return[{type:F.ACTION,title:"Copy current cell",icon:"hugeicons:copy-02",select:y,condition:b},{type:F.ACTION,title:"Copy current row",icon:"hugeicons:copy-02",select:x,condition:g&&b},{type:F.SEPARATOR,condition:b},{type:F.SUBMENU,title:"Copy column",icon:"hugeicons:layout-3-column",items:V,condition:k,desc:a.value||"Select a column"},{type:F.SUBMENU,title:"Copy row(s)",icon:"hugeicons:layout-3-row",items:T},{type:F.SEPARATOR},{type:F.SUBMENU,title:"Export",icon:"hugeicons:file-download",items:U}]});return(b,g)=>(v(),R(r(Dn),{contextMenuItems:r(S),onOnClearContextMenu:g[0]||(g[0]=_=>n("onClearContextMenu"))},{default:h(()=>[J(b.$slots,"default")]),_:3},8,["contextMenuItems"]))}}),Br={class:"h-full w-full"},jr=H({__name:"ResultTabResultView",props:{activeTab:{},activeTabColumns:{},formattedData:{},executeLoading:{type:Boolean},isStreaming:{type:Boolean}},setup(s){const t=s,e=G(),n=G([]),o=c=>{n.value=c},a=q(()=>{var d,m,y;const c=((d=t.activeTab)==null?void 0:d.metadata.fieldDefs)||[];return((y=(m=n.value)==null?void 0:m.map)==null?void 0:y.call(m,x=>{const S={};for(const[b,g]of Object.entries(x)){const _=c[Number(b)],C=(_==null?void 0:_.name)||"";C&&(S[C]=g)}return S}))||[]}),l=q(()=>{var c;return Dr(t.activeTab.metadata.command||"",t.activeTab.metadata.rowCount||0,(c=t.activeTab.metadata.connection)==null?void 0:c.type)}),i=q(()=>l.value.isMutation),u=q(()=>l.value.message);return(c,d)=>{var x,S;const m=tt,y=gs;return v(),E("div",Br,[c.activeTab.result.length===0&&r(i)&&!c.executeLoading&&!c.isStreaming?(v(),R(m,{key:0,desc:r(u),hiddenIcon:"",class:"h-full"},null,8,["desc"])):c.activeTab.result.length===0&&!c.executeLoading&&!c.isStreaming?(v(),R(m,{key:1,title:"No Results",desc:"The query returned no records.",class:"h-full"})):(v(),R(Fr,{key:2,data:c.formattedData||[],selectedRows:r(a)||[],cellContextMenu:(x=r(e))==null?void 0:x.cellContextMenu,cellHeaderContextMenu:(S=r(e))==null?void 0:S.cellHeaderContextMenu,onOnClearContextMenu:d[0]||(d[0]=b=>{var g;return(g=r(e))==null?void 0:g.clearCellContextMenu()})},{default:h(()=>[p(y,{ref_key:"rawQueryTableRef",ref:e,columns:c.activeTabColumns,data:c.activeTab.result||[],selectedRows:r(n),onOnSelectedRows:o,class:"h-full","skip-re-column-size":"",columnKeyBy:"index"},null,8,["columns","data","selectedRows"])]),_:1},8,["data","selectedRows","cellContextMenu","cellHeaderContextMenu"]))])}}});var We=(s=>(s.GRID="grid",s.TIMELINE="time-line",s.RAW="raw",s))(We||{});const Ur=[{value:"time-line",label:"Timeline",icon:"hugeicons:chart-line-data-01"},{value:"grid",label:"Grid",icon:"hugeicons:grid-table"},{value:"raw",label:"Raw",icon:"hugeicons:3rd-bracket"}],Qr={class:"flex items-center justify-between px-3 py-2 border-b shrink-0"},Hr={class:"flex items-center gap-3 min-w-0"},Wr={class:"flex items-center gap-2 flex-wrap"},Gr={class:"flex flex-col gap-1 max-w-[250px] sm:max-w-xs"},Kr={class:"text-[11px] text-muted-foreground list-disc pl-3 break-words whitespace-normal"},Yr={class:"flex flex-col gap-1 max-w-[250px] sm:max-w-xs"},Jr={class:"text-[11px] text-muted-foreground list-disc pl-3 break-words whitespace-normal"},Xr={class:"flex flex-col gap-1 max-w-[250px] sm:max-w-xs"},Zr={class:"text-[11px] text-muted-foreground list-disc pl-3 break-words whitespace-normal"},el={class:"flex items-center gap-2 shrink-0"},tl=H({__name:"ExplainPlanHeader",props:Mt({summaryStats:{},isExpanded:{type:Boolean}},{modelValue:{required:!0},modelModifiers:{}}),emits:Mt(["toggle-expand"],["update:modelValue"]),setup(s,{emit:t}){const e=t,n=rn(s,"modelValue");return(o,a)=>{const l=ce,i=ln,u=re,c=le,d=ie,m=ro,y=ao,x=oo,S=Me;return v(),E("div",Qr,[f("div",Hr,[p(l,{name:"hugeicons:analytics-up",class:"size-4 text-muted-foreground"}),a[6]||(a[6]=f("span",{class:"text-sm font-medium"},"Execution Plan",-1)),f("div",Wr,[o.summaryStats.executionTime!==void 0?(v(),R(i,{key:0,variant:"outline",class:"text-[11px] h-5 gap-1"},{default:h(()=>[p(l,{name:"hugeicons:clock-01",class:"size-3"}),L(" "+I(r(De)(o.summaryStats.executionTime)),1)]),_:1})):Q("",!0),o.summaryStats.planningTime!==void 0?(v(),R(i,{key:1,variant:"outline",class:"text-[11px] h-5 gap-1"},{default:h(()=>[L(" Planning: "+I(r(De)(o.summaryStats.planningTime)),1)]),_:1})):Q("",!0),o.summaryStats.nodeCount>0?(v(),R(d,{key:2},{default:h(()=>{var b;return[p(u,{"as-child":""},{default:h(()=>[p(i,{variant:"outline",class:"text-[11px] h-5 gap-1 cursor-help"},{default:h(()=>[L(I(o.summaryStats.nodeCount)+" nodes ",1)]),_:1})]),_:1}),(b=o.summaryStats.allNodes)!=null&&b.length?(v(),R(c,{key:0},{default:h(()=>[f("div",Gr,[a[2]||(a[2]=f("span",{class:"font-medium text-xs"},"Nodes:",-1)),f("ul",Kr,[(v(!0),E(Y,null,Z(o.summaryStats.allNodes,g=>(v(),E("li",{key:g.id},I(g.label),1))),128))])])]),_:1})):Q("",!0)]}),_:1})):(v(),R(i,{key:3,variant:"outline",class:"text-[11px] h-5 gap-1"},{default:h(()=>a[3]||(a[3]=[L(" 0 nodes ")])),_:1})),o.summaryStats.expensiveCount>0?(v(),R(d,{key:4},{default:h(()=>{var b;return[p(u,{"as-child":""},{default:h(()=>[p(i,{variant:"outline",class:"text-[11px] h-5 gap-1 border-amber-300 text-amber-700 dark:text-amber-400 cursor-help"},{default:h(()=>[L(I(o.summaryStats.expensiveCount)+" expensive ",1)]),_:1})]),_:1}),(b=o.summaryStats.expensiveNodes)!=null&&b.length?(v(),R(c,{key:0},{default:h(()=>[f("div",Yr,[a[4]||(a[4]=f("span",{class:"font-medium text-xs"},"Expensive Nodes:",-1)),f("ul",Jr,[(v(!0),E(Y,null,Z(o.summaryStats.expensiveNodes,g=>(v(),E("li",{key:g.id},I(g.label),1))),128))])])]),_:1})):Q("",!0)]}),_:1})):Q("",!0),o.summaryStats.slowCount>0?(v(),R(d,{key:5},{default:h(()=>{var b;return[p(u,{"as-child":""},{default:h(()=>[p(i,{variant:"outline",class:"text-[11px] h-5 gap-1 border-red-300 text-red-700 dark:text-red-400 cursor-help"},{default:h(()=>[L(I(o.summaryStats.slowCount)+" slowest ",1)]),_:1})]),_:1}),(b=o.summaryStats.slowNodes)!=null&&b.length?(v(),R(c,{key:0},{default:h(()=>[f("div",Xr,[a[5]||(a[5]=f("span",{class:"font-medium text-xs"},"Slowest Node(s):",-1)),f("ul",Zr,[(v(!0),E(Y,null,Z(o.summaryStats.slowNodes,g=>(v(),E("li",{key:g.id},I(g.label),1))),128))])])]),_:1})):Q("",!0)]}),_:1})):Q("",!0)])]),f("div",el,[p(x,{modelValue:n.value,"onUpdate:modelValue":a[0]||(a[0]=b=>n.value=b),class:"gap-0"},{default:h(()=>[p(y,{class:"h-6"},{default:h(()=>[(v(!0),E(Y,null,Z(r(Ur),b=>(v(),R(m,{key:b.value,value:b.value,class:"text-xs px-1 rounded-sm cursor-pointer"},{default:h(()=>[p(l,{name:b.icon,class:"size-3.5!"},null,8,["name"]),L(" "+I(b.label),1)]),_:2},1032,["value"]))),128))]),_:1})]),_:1},8,["modelValue"]),p(S,{variant:"outline",size:"iconSm",onClick:a[1]||(a[1]=b=>e("toggle-expand"))},{default:h(()=>[p(l,{name:o.isExpanded?"hugeicons:arrow-shrink":"hugeicons:arrow-expand",class:"size-3.5"},null,8,["name"])]),_:1})])])}}}),sl={class:"flex items-center text-xs h-full w-full overflow-hidden whitespace-nowrap"},nl={key:0,class:"text-muted-foreground shrink-0 whitespace-pre",style:{"font-family":"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace !important"}},ol={key:1,class:"font-normal shrink-0"},al={key:2,class:"text-[10px] pl-0.5 text-muted-foreground truncate shrink min-w-0"},rl=H({__name:"ExplainOperationCell",props:{params:{}},setup(s){const t=s,e=q(()=>{var n;return((n=t.params)==null?void 0:n.data)??{}});return(n,o)=>(v(),E("div",sl,[r(e).treePrefix?(v(),E("span",nl,I(r(e).treePrefix),1)):Q("",!0),r(e).nodeType?(v(),E("span",ol,I(r(e).nodeType),1)):Q("",!0),r(e).contextLabel?(v(),E("span",al,I(r(e).contextLabel),1)):Q("",!0)]))}}),Qt={"Seq Scan":"scan","Index Scan":"scan","Index Only Scan":"scan","Bitmap Index Scan":"scan","Bitmap Heap Scan":"scan","CTE Scan":"scan","Function Scan":"scan","Values Scan":"scan","Subquery Scan":"scan",Aggregate:"agg",HashAggregate:"agg",GroupAggregate:"agg",Sort:"sort","Incremental Sort":"sort",Hash:"hash","Hash Join":"join","Merge Join":"join","Nested Loop":"join"},oe=s=>s?String(s).replace(/^[\[]|[\]]$/g,"").replace(/"/g,"").trim():"",ll=s=>s==="Seq Scan"?"bad":Qt[s]?Qt[s]:s.includes("Join")?"join":s.includes("Scan")?"scan":s.includes("Aggregate")?"agg":s.includes("Sort")?"sort":"other",Ht=(s,t,e)=>{for(let n=t+1;n<s.length;n++){const o=s[n].depth??0;if(o<e)return!1;if(o===e)return!0}return!1},il=(s,t)=>{const n=s[t].depth??0;if(n===0)return"";const o=[];for(let l=1;l<n;l++)o.push(Ht(s,t,l)?"│ ":" ");const a=!Ht(s,t,n);return o.push(a?"└─ ":"├─ "),o.join("")},ul=s=>{const t=oe(s.hashCond),e=oe(s.mergeCond),n=oe(s.joinFilter),o=oe(s.joinType).toLowerCase();if(o||t||e||n){const b=t||e||n,g=o?`${o} `:"";return{label:b?`${g}on ${b}`.trim():`${g}join`.trim(),kind:"join"}}const a=oe(s.indexCond),l=oe(s.recheckCond),i=oe(s.tidCond);if(a)return{label:`on ${a}`,kind:"relation"};if(l)return{label:`recheck: ${l}`,kind:"relation"};if(i)return{label:`tid: ${i}`,kind:"relation"};const u=oe(s.sortKey);if(u)return{label:`by ${u}`,kind:"sort"};const c=oe(s.groupKey),d=oe(s.hashKey);if(c||d)return{label:`by ${c||d}`,kind:"group"};const m=oe(s.oneTimeFilter);if(m)return{label:`one-time: ${m}`,kind:"relation"};const y=oe(s.filter);if(y)return{label:`filter: ${y}`,kind:"relation"};const x=oe(s.cteName);if(x)return{label:`cte: ${x}`,kind:"relation"};const S=oe(s.subplanName);if(S)return{label:`subplan: ${S}`,kind:"relation"};if(s.relation){const b=s.alias&&s.alias!==s.relation?` (${s.alias})`:"";return{label:`on ${s.relation}${b}`,kind:"relation"}}return{label:"",kind:""}},cl=s=>[...s].map(t=>{var c,d;const e=t["Plan Rows"]||0,n=t["Actual Rows"]||0,o=t.estimateRatio,a=t["Actual Startup Time"]||0,l=t["Plan Width"]||0,i=t.rowEstimateAccuracy||"accurate",u=[`Node: ${t["Node Type"]}`,t["Relation Name"]?`Relation: ${t["Relation Name"]}`:"",`Depth: ${t.depth}`,`Startup time: ${a.toFixed(3)} ms`,`Total time: ${(t["Actual Total Time"]||0).toFixed(3)} ms`,`Actual rows: ${n.toLocaleString()}`,`Plan rows: ${e.toLocaleString()}`,o!==void 0?`Estimate ratio: ${o}x (${i})`:"Estimate ratio: -",`Total cost: ${(t["Total Cost"]||0).toFixed(2)}`,`Plan width: ${l}`,`Loops: ${(t["Actual Loops"]||0).toLocaleString()}`,`Slowest: ${t.isSlowest?"yes":"no"}`,`Expensive: ${t.isExpensive?"yes":"no"}`].filter(Boolean).join(`
10
+ `);return{id:t.id,order:t.index,nodeType:t["Node Type"],relation:t["Relation Name"],alias:t.Alias,sortKey:((c=t["Sort Key"])==null?void 0:c.join(", "))??"",joinType:t["Join Type"]??"",groupKey:((d=t["Group Key"])==null?void 0:d.join(", "))??"",hashKey:"",filter:t.Filter??"",joinFilter:"",oneTimeFilter:"",indexCond:"",hashCond:t["Hash Cond"]??"",mergeCond:t["Merge Cond"]??"",recheckCond:"",tidCond:"",cteName:"",subplanName:"",timeMs:t["Actual Total Time"]||0,rows:n,planRows:e,estimateRatio:o,cost:t["Total Cost"]||0,width:l,loops:t["Actual Loops"]||0,depth:t.depth,indentPx:t.depth*16,hitReadRatio:t.hitReadRatio,isSlowest:t.isSlowest,isExpensive:t.isExpensive,tooltipLines:u}}),dl=s=>{const t=s.reduce((e,n)=>e+(n.timeMs||0),0)||1;return s.map((e,n)=>{const o=il(s,n),{label:a,kind:l}=ul(e),i=e.isSlowest?"slowest":e.isExpensive?"expensive":"normal";return{order:e.order,timeMs:e.timeMs,rows:e.rows,planRows:e.planRows,estimateRatioValue:e.estimateRatio,cost:e.cost,width:e.width,loops:e.loops,hitReadRatio:e.hitReadRatio,isSlowest:e.isSlowest,isExpensive:e.isExpensive,orderLabel:`${e.order}`,queryPercentLabel:`${(e.timeMs/t*100).toFixed(2)}%`,timeSpentLabel:`${e.timeMs.toFixed(3)} ms`,rowsLabel:e.rows.toLocaleString(),planRowsLabel:e.planRows.toLocaleString(),estimateLabel:e.estimateRatio!==void 0?`${e.estimateRatio}×`:"-",costLabel:e.cost.toFixed(2),widthLabel:e.width,loopsLabel:e.loops.toLocaleString(),hitReadRatioLabel:e.hitReadRatio!==void 0?`${(e.hitReadRatio*100).toFixed(2)}%`:"-",statusLabel:i,treePrefix:o,nodeType:e.nodeType,nodeTypeCategory:ll(e.nodeType),contextLabel:a,contextKind:l}})},ml={class:"h-full p-2"},pl=H({__name:"ExplainGridPane",props:{nodes:{}},setup(s){const t=s,e=q(()=>cl(t.nodes)),n=q(()=>dl(e.value)),o=q(()=>[{headerName:"#",field:"orderLabel",width:30,sortable:!0,resizable:!0,filter:!1,cellClass:"cellCenter"},{headerName:"Operation",field:"operationLabel",width:350,sortable:!1,resizable:!0,filter:!0,cellRenderer:"ExplainOperationCell",cellClass:"operation-cell",valueGetter:l=>`${l.data.treePrefix}${l.data.nodeType} ${l.data.contextLabel}`},{headerName:"Status",field:"statusLabel",width:96,sortable:!0,resizable:!0,filter:!0,cellClass:l=>{const i=l.value;return i==="slowest"?"cellCenter bg-red-300! dark:bg-red-900":i==="expensive"?"cellCenter bg-orange-100! dark:bg-orange-900":"cellCenter"}},{headerName:"Time Spent",field:"timeSpentLabel",width:110,sortable:!0,resizable:!0,filter:!0,cellClass:"cellCenter "},{headerName:"% of Query",field:"queryPercentLabel",width:96,sortable:!0,resizable:!0,filter:!0,cellClass:"cellCenter "},{headerName:"Actual Rows",field:"rowsLabel",width:96,sortable:!0,resizable:!0,filter:!0,cellClass:"cellCenter "},{headerName:"Plan Rows",field:"planRowsLabel",width:88,sortable:!0,resizable:!0,filter:!0,cellClass:"cellCenter "},{headerName:"Estim",field:"estimateLabel",width:76,sortable:!0,resizable:!0,filter:!0,cellClass:l=>{var u;const i=Number((u=l.data)==null?void 0:u.estimateRatioValue);return Number.isFinite(i)?i<.1||i>10?"cellCenter bg-red-200 dark:bg-red-900":i>=.1&&i<.5||i>2&&i<=10?"cellCenter bg-orange-100 dark:bg-orange-900":"cellCenter ":"cellCenter "}},{headerName:"Cost",field:"costLabel",width:88,sortable:!0,resizable:!0,filter:!0,cellClass:"cellCenter "},{headerName:"Hit Read Ratio",field:"hitReadRatioLabel",width:110,sortable:!0,resizable:!0,filter:!0,cellClass:"cellCenter "},{headerName:"Width",field:"widthLabel",width:72,sortable:!0,resizable:!0,filter:!0,cellClass:"cellCenter "},{headerName:"Loops",field:"loopsLabel",width:72,sortable:!0,resizable:!0,filter:!0,cellClass:"cellCenter "}]),a={ExplainOperationCell:rl};return(l,i)=>(v(),E("div",ml,[p(r(gs),{class:"h-full",columns:[],data:[],"column-key-by":"index","skip-re-column-size":"","has-hash-index":!1,"override-column-defs":r(o),"override-row-data":r(n),"external-components":a},null,8,["override-column-defs","override-row-data"])]))}}),fl={class:"h-full p-2"},hl={class:"rounded-lg border p-2 flex flex-col h-full min-h-0"},vl={class:"flex justify-between items-center mb-4"},gl={class:"text-sm font-bold text-muted-foreground uppercase flex items-center gap-2"},yl={key:0,class:"h-full grid place-items-center text-sm text-muted-foreground"},xl={key:1,class:"flex-1 overflow-auto relative"},bl={class:"min-w-[680px] text-xs"},_l={class:"flex border-b pb-2 mb-2 sticky top-0 bg-background z-10 font-medium text-muted-foreground"},Cl={class:"flex-1 relative h-4"},Sl={class:"absolute right-0"},wl={class:"pb-2"},Tl=["onMouseenter"],El={class:"w-[28%] min-w-[190px] max-w-[260px] px-2 flex items-center overflow-hidden"},Rl={class:"truncate flex items-center gap-1"},$l={class:"font-mono text-[10px] text-right shrink-0 text-muted-foreground"},kl={class:"flex flex-col truncate"},zl=["title"],Ml={key:0,class:"text-muted-foreground text-[10px] truncate"},Al={key:0},Ll={class:"flex-1 relative h-6 mx-2"},Nl={class:"space-y-2 text-xs"},Il={class:"font-semibold flex items-center gap-1"},Ol={class:"grid grid-cols-2 gap-x-3 gap-y-1 text-[11px]"},Pl={class:"font-mono"},ql={class:"font-mono"},Vl={class:"font-mono"},Dl={class:"font-mono"},Fl={class:"font-mono"},Bl={class:"font-mono"},jl={class:"font-mono"},Ul={class:"font-mono"},Ql={key:0,class:"text-[11px] text-muted-foreground"},Hl={key:0},Qe=14,Wl=H({__name:"ExplainTimelineChartPane",props:{nodes:{},totalTime:{}},setup(s){const t=s,e=G(null),n=q(()=>{const m=[...t.nodes].filter(x=>typeof x["Actual Startup Time"]=="number"&&typeof x["Actual Total Time"]=="number").map(x=>{const S=x["Actual Startup Time"]||0,b=x["Actual Total Time"]||0,g=Math.max(0,b-S);return{id:x.id,nodeType:x["Node Type"],relation:x["Relation Name"],alias:x.Alias,depth:x.depth,actualRows:x["Actual Rows"],actualLoops:x["Actual Loops"],planRows:x["Plan Rows"],totalCost:x["Total Cost"],start:S,end:b,duration:g}}),y=(x,S)=>{for(let b=x+1;b<m.length;b+=1){const g=m[b].depth;if(g<S)return!1;if(g===S)return!0}return!1};return m.map((x,S)=>{const b=[];for(let g=1;g<x.depth;g+=1)y(S,g)&&b.push(g);return{...x,continuationLevels:b,hasNextSibling:x.depth>0?y(S,x.depth):!1}})}),o=q(()=>{const m=n.value.length?Math.max(...n.value.map(y=>y.end)):0;return Math.max(t.totalTime||0,m,1)}),a=(m,y)=>{const x=o.value>0?o.value:1,S=m/x*100,b=Math.max(y/x*100,.5);return{left:`${S}%`,width:`${b}%`}},l=m=>{const y=o.value>0?o.value:1;return(m/y*100).toFixed(2)},i=m=>`${Math.max(m,0)*Qe}px`,u=m=>`${(m-1)*Qe+Qe/2}px`,c=`${Qe/2}px`,d=m=>m==="Seq Scan"?"bg-gray-400 dark:bg-gray-600":m.includes("Scan")?"bg-gray-300 dark:bg-gray-700":m.includes("Join")?"bg-gray-500 dark:bg-gray-500":m==="Sort"?"bg-gray-300 dark:bg-gray-600":(m.includes("Aggregate"),"bg-gray-400 dark:bg-gray-600");return(m,y)=>{const x=ce,S=re,b=le,g=ie;return v(),E("div",fl,[f("div",hl,[f("div",vl,[f("h3",gl,[p(x,{name:"hugeicons:clock-01",class:"size-4"}),y[1]||(y[1]=L(" Execution Plan Timeline "))]),y[2]||(y[2]=f("span",{class:"text-xs text-muted-foreground"},"Hover for details",-1))]),r(n).length===0?(v(),E("div",yl," No timeline data available ")):(v(),E("div",xl,[f("div",bl,[f("div",_l,[y[7]||(y[7]=f("div",{class:"w-[28%] min-w-[190px] max-w-[260px] pl-2"}," Node Hierarchy ",-1)),f("div",Cl,[y[3]||(y[3]=f("div",{class:"absolute left-0"},"0ms",-1)),f("div",Sl,I(r(je)(r(o))),1),y[4]||(y[4]=f("div",{class:"absolute left-1/4 border-l h-full"},null,-1)),y[5]||(y[5]=f("div",{class:"absolute left-1/2 border-l h-full"},null,-1)),y[6]||(y[6]=f("div",{class:"absolute left-3/4 border-l h-full"},null,-1))])]),f("div",wl,[(v(!0),E(Y,null,Z(r(n),_=>(v(),E("div",{key:_.id,class:ue(["flex items-center group rounded transition-colors hover:bg-muted",r(e)===_.id?"bg-muted/40":""]),onMouseenter:C=>e.value=_.id,onMouseleave:y[0]||(y[0]=C=>e.value=null)},[f("div",El,[f("div",{class:"relative shrink-0 h-7",style:Ne({width:i(_.depth)})},[(v(!0),E(Y,null,Z(_.continuationLevels,C=>(v(),E("div",{key:`${_.id}-v-${C}`,class:"absolute top-0 bottom-0 border-l border-dashed border-muted-foreground/35",style:Ne({left:u(C)})},null,4))),128)),_.depth>0?(v(),E(Y,{key:0},[f("div",{class:"absolute top-0 border-l border-dashed border-muted-foreground/45",style:Ne({left:u(_.depth),height:_.hasNextSibling?"100%":"50%"})},null,4),f("div",{class:"absolute top-1/2 -translate-y-1/2 border-t border-dashed border-muted-foreground/45",style:Ne({left:u(_.depth),width:c})},null,4)],64)):Q("",!0)],4),f("div",Rl,[f("span",$l," #"+I(_.id.replace("ep-","")),1),f("div",kl,[f("span",{class:"truncate font-medium text-sm",title:_.nodeType},I(_.nodeType),9,zl),_.relation?(v(),E("span",Ml,[L(I(_.relation)+" ",1),_.alias&&_.alias!==_.relation?(v(),E("span",Al,"("+I(_.alias)+")",1)):Q("",!0)])):Q("",!0)])])]),f("div",Ll,[y[16]||(y[16]=un('<div class="absolute top-0 bottom-0 left-0 w-px bg-muted"></div><div class="absolute top-0 bottom-0 right-0 w-px bg-muted"></div><div class="absolute top-0 bottom-0 left-1/4 w-px bg-muted"></div><div class="absolute top-0 bottom-0 left-1/2 w-px bg-muted"></div><div class="absolute top-0 bottom-0 left-3/4 w-px bg-muted"></div>',5)),p(g,null,{default:h(()=>[p(S,{"as-child":""},{default:h(()=>[f("div",{class:ue(["absolute top-1 bottom-1 rounded-sm transition-all shadow-sm opacity-90 cursor-default",[d(_.nodeType),r(e)===_.id?"brightness-105 ring-2 ring-border z-10":""]]),style:Ne(a(_.start,_.duration))},null,6)]),_:2},1024),p(b,{side:"top","side-offset":8,class:"max-w-[360px]"},{default:h(()=>{var C,k,V,T;return[f("div",Nl,[f("div",Il,[p(x,{name:"hugeicons:flow-square",class:"size-3.5"}),L(" "+I(_.nodeType),1)]),f("div",Ol,[y[8]||(y[8]=f("span",{class:"text-muted-foreground"},"Start",-1)),f("span",Pl,I(r(je)(_.start)),1),y[9]||(y[9]=f("span",{class:"text-muted-foreground"},"End",-1)),f("span",ql,I(r(je)(_.end)),1),y[10]||(y[10]=f("span",{class:"text-muted-foreground"},"Duration",-1)),f("span",Vl,I(r(je)(_.duration)),1),y[11]||(y[11]=f("span",{class:"text-muted-foreground"},"Share",-1)),f("span",Dl,I(l(_.duration))+"%",1),y[12]||(y[12]=f("span",{class:"text-muted-foreground"},"Rows",-1)),f("span",Fl,I(((C=_.actualRows)==null?void 0:C.toLocaleString())??"-"),1),y[13]||(y[13]=f("span",{class:"text-muted-foreground"},"Plan Rows",-1)),f("span",Bl,I(((k=_.planRows)==null?void 0:k.toLocaleString())??"-"),1),y[14]||(y[14]=f("span",{class:"text-muted-foreground"},"Loops",-1)),f("span",jl,I(((V=_.actualLoops)==null?void 0:V.toLocaleString())??"-"),1),y[15]||(y[15]=f("span",{class:"text-muted-foreground"},"Total Cost",-1)),f("span",Ul,I(((T=_.totalCost)==null?void 0:T.toFixed(2))??"-"),1)]),_.relation?(v(),E("div",Ql,[L(" Relation: "+I(_.relation)+" ",1),_.alias&&_.alias!==_.relation?(v(),E("span",Hl,"("+I(_.alias)+")",1)):Q("",!0)])):Q("",!0)])]}),_:2},1024)]),_:2},1024)])],42,Tl))),128))])])]))])])}}}),Gl={class:"h-full overflow-auto p-2"},Kl=H({__name:"ExplainRawPane",props:{rawText:{}},setup(s){const t=s,e=q(()=>{const n=t.rawText.trim();return n.startsWith("{")||n.startsWith("[")?"json":"sql"});return(n,o)=>{const a=Tt;return v(),E("div",Gl,[p(a,{code:n.rawText,language:e.value,"max-height":"100%"},null,8,["code","language"])])}}});let Xe=0;const Yl=()=>(Xe+=1,`ep-${Xe}`),Wt=s=>s==null?"":typeof s=="string"?s:typeof s=="number"||typeof s=="boolean"?String(s):JSON.stringify(s),Jl=s=>{const t=(s["Shared Hit Blocks"]??0)+(s["Local Hit Blocks"]??0),e=(s["Shared Read Blocks"]??0)+(s["Local Read Blocks"]??0),n=t+e;if(!(n<=0))return Number((t/n).toFixed(4))},Xl=(s,t)=>{const e=t["Plan Rows"],n=t["Actual Rows"];if(e!==void 0&&n!==void 0&&e>0&&n>=0){s.estimateRatio=Number((n/e).toFixed(2));const o=n/e;o>10?s.rowEstimateAccuracy="underestimate":o<.1?s.rowEstimateAccuracy="overestimate":s.rowEstimateAccuracy="accurate"}s.hitReadRatio=Jl(t),(t["Total Cost"]!==void 0&&t["Total Cost"]>1e3||t["Actual Total Time"]!==void 0&&t["Actual Total Time"]>100)&&(s.isExpensive=!0)},Zl=s=>{let t=0,e="";for(const o of s){const a=o.children.reduce((i,u)=>i+(u["Actual Total Time"]??0)*(u["Actual Loops"]??1),0)/(o["Actual Loops"]??1),l=Math.max(0,(o["Actual Total Time"]??0)-a);l>t&&(t=l,e=o.id)}const n=s.find(o=>o.id===e);n&&(n.isSlowest=!0)},Es=(s,t,e)=>{const{Plans:n,...o}=s,a=s["Node Type"]||"Unknown Node",l=s["Relation Name"],i={...o,id:Yl(),index:Xe,label:l?`${a} on ${l}`:a,estimateRatio:void 0,hitReadRatio:void 0,isExpensive:!1,isSlowest:!1,rowEstimateAccuracy:void 0,depth:t,children:(n??[]).map(u=>Es(u,t+1,e))};return e.push(i),Xl(i,s),i},ei=(s,t)=>{Xe=0;const e=[],n=Es(s.Plan,0,e),o={"Planning Time":s["Planning Time"],"Execution Time":s["Execution Time"],totalCost:n["Total Cost"],triggersInfo:(s.Triggers??[]).map(Wt),jitInfo:[],settingsInfo:s.Settings?Object.entries(s.Settings).map(([l,i])=>`${l}: ${Wt(i)}`):[],rawText:t};Zl(e);const a=[...e].sort((l,i)=>l.index-i.index);return{root:n,summary:o,allNodes:a}},ti=s=>{const t={triggersInfo:[],jitInfo:[],settingsInfo:[],rawText:s},e=s.match(/Planning Time:\s*(\d+\.?\d*)\s*ms/i),n=s.match(/Execution Time:\s*(\d+\.?\d*)\s*ms/i);return e&&(t["Planning Time"]=Number.parseFloat(e[1])),n&&(t["Execution Time"]=Number.parseFloat(n[1])),{root:null,summary:t,allNodes:[]}},ht=s=>{if(!s)return null;if(typeof s=="string")try{return ht(JSON.parse(s))}catch{return null}return Array.isArray(s)?s.length?ht(s[0]):null:typeof s=="object"&&s!==null&&"Plan"in s&&typeof s.Plan=="object"?s:null},Rs=(s,t)=>{var e;if(!(s!=null&&s.length))return null;if(Array.isArray(s[0]))return s[0][0]??null;if(typeof s[0]=="object"&&s[0]!==null){const n=s[0],o=Object.keys(n).find(a=>a.toUpperCase()==="QUERY PLAN")||((e=t==null?void 0:t[0])==null?void 0:e.name)||Object.keys(n)[0];return o?n[o]??null:null}return s[0]??null},si=(s,t)=>{const e=Rs(s,t);return e==null?"":typeof e=="string"?e:JSON.stringify(e,null,2)},ni=s=>{const t=typeof s=="string"?s:JSON.stringify(s,null,2),e=ht(s);return e?ei(e,t):ti(t)},oi={class:"h-full min-h-0"},ai={key:0,class:"h-full flex flex-col items-center justify-center gap-2 text-muted-foreground"},ri=H({__name:"ResultTabExplainView",props:{activeTab:{}},setup(s){const t=s,e=G(We.GRID),n=G(!1),o=q(()=>Rs(t.activeTab.result,t.activeTab.metadata.fieldDefs)),a=q(()=>si(t.activeTab.result,t.activeTab.metadata.fieldDefs)),l=q(()=>ni(o.value)),i=q(()=>{const u=l.value.allNodes,c=u.filter(m=>m.isExpensive),d=u.filter(m=>m.isSlowest);return{planningTime:l.value.summary["Planning Time"],executionTime:l.value.summary["Execution Time"],nodeCount:u.length,expensiveCount:c.length,slowCount:d.length,allNodes:u,expensiveNodes:c,slowNodes:d}});return(u,c)=>{const d=tl,m=ce,y=pl,x=Wl,S=Kl;return v(),E("div",oi,[r(n)?(v(),E("div",{key:0,class:"fixed inset-0 z-40 bg-background/70 backdrop-blur-[1px]",onClick:c[0]||(c[0]=b=>n.value=!1)})):Q("",!0),f("div",{class:ue(["flex flex-col",r(n)?"fixed z-50 left-1/2 top-1/2 h-[90vh] w-[95vw] -translate-x-1/2 -translate-y-1/2 rounded-xl border bg-background shadow-2xl":"h-full min-h-0 overflow-hidden"])},[p(d,{modelValue:r(e),"onUpdate:modelValue":c[1]||(c[1]=b=>Se(e)?e.value=b:null),"summary-stats":r(i),"is-expanded":r(n),onToggleExpand:c[2]||(c[2]=b=>n.value=!r(n))},null,8,["modelValue","summary-stats","is-expanded"]),f("div",{class:ue(["flex-1 min-h-0",r(n)?"overflow-hidden":"overflow-y-auto"])},[r(l).root?r(e)===r(We).GRID?(v(),R(y,{key:1,nodes:r(l).allNodes},null,8,["nodes"])):r(e)===r(We).TIMELINE?(v(),R(x,{key:2,nodes:r(l).allNodes,"total-time":r(i).executionTime},null,8,["nodes","total-time"])):(v(),R(S,{key:3,"raw-text":r(a)},null,8,["raw-text"])):(v(),E("div",ai,[p(m,{name:"hugeicons:alert-02",class:"size-8 opacity-50"}),c[3]||(c[3]=f("p",{class:"text-sm"},"Could not parse execution plan",-1))]))],2)],2)])}}}),li={class:"h-full flex w-full"},ii={key:0,class:"flex mt-7 [writing-mode:vertical-rl]"},ui=["onClick"],ci={class:"h-full w-full flex flex-col"},di={class:"flex items-end overflow-x-auto pt-0.5"},mi=["onClick","onContextmenu"],pi={class:"truncate text-xs font-medium"},fi=["onClick"],hi={class:"h-full w-full border rounded-md rounded-tl-none overflow-hidden"},vi=H({__name:"RawQueryResultTabs",props:{executedResults:{},activeTabId:{},executeLoading:{type:Boolean},isStreaming:{type:Boolean}},emits:["update:activeTab","close-tab","close-other-tabs","close-tabs-to-right","update:view"],setup(s,{emit:t}){const e=s,n=t,o=G(null),a=q(()=>{if(!o.value)return!1;const g=Array.from(e.executedResults.keys()),_=g.indexOf(o.value);return _>=0&&_<g.length-1}),l=[{value:"result",label:"Result"},{value:"explain",label:"Explain"},{value:"raw",label:"Raw"},{value:"info",label:"Info"},{value:"error",label:"Errors"},{value:"agent",label:"Agent"}],i=new Map,u=Ve([]);let c=null;const d=q(()=>e.activeTabId&&e.executedResults.get(e.activeTabId)||null),m=q(()=>{var g;return((g=d.value)==null?void 0:g.view)||"result"}),y=q(()=>{var g;return(g=d.value)!=null&&g.metadata.fieldDefs?d.value.metadata.fieldDefs.map((_,C)=>{var k;return{index:C,originalName:_.name,aliasFieldName:_.name,queryFieldName:_.name,isPrimaryKey:!1,isForeignKey:!1,type:((k=_.dataTypeID)==null?void 0:k.toString())||"unknown",tableName:""}}):[]}),x=g=>{var T,U;const _=((T=g.result)==null?void 0:T.length)||0,C=`${g.id}_${_}`;if(i.has(C))return i.get(C);const k=g.metadata.fieldDefs||[],V=((U=g.result)==null?void 0:U.map(D=>{var B;const N={};for(const[O,P]of Object.entries(D)){const W=((B=k[Number(O)])==null?void 0:B.name)||"";W&&(N[W]=P)}return N}))??[];i.set(C,V);for(const D of i.keys())D.startsWith(`${g.id}_`)&&D!==C&&i.delete(D);return V};ge(d,g=>{c&&cancelAnimationFrame(c),c=requestAnimationFrame(()=>{u.value=g?x(g):[],c=null})},{immediate:!0}),cn(()=>{c&&cancelAnimationFrame(c)});const S=g=>{e.activeTabId&&n("update:view",e.activeTabId,g)},b=g=>!!g.metadata.executeErrors;return(g,_)=>{const C=ce,k=re,V=le,T=ie,U=is,D=tt;return v(),E("div",li,[r(d)?(v(),E("div",ii,[(v(),E(Y,null,Z(l,N=>f("div",{key:N.value,onClick:B=>b(r(d))&&(N.value==="result"||N.value==="raw")||N.value==="error"&&!b(r(d))?null:S(N.value),class:ue(r(Ce)("border px-1 text-xs font-normal transition-colors",r(m)===N.value?"bg-muted border-transparent border-r-border":"border-transparent",N.value==="error"&&b(r(d))?"hover:bg-muted cursor-pointer":N.value==="explain"&&!r(d).metadata.statementQuery.startsWith("EXPLAIN")?null:"",N.value==="error"&&!b(r(d))?"opacity-40 cursor-not-allowed":"",(N.value==="result"||N.value==="raw")&&b(r(d))?"opacity-40 cursor-not-allowed":"",N.value==="explain"&&!r(d).metadata.statementQuery.startsWith("EXPLAIN")?"opacity-40 cursor-not-allowed":"",N.value==="error"&&!b(r(d))||(N.value==="result"||N.value==="raw")&&b(r(d))||N.value==="explain"&&!r(d).metadata.statementQuery.startsWith("EXPLAIN")?"":"hover:bg-muted cursor-pointer"))},I(N.label),11,ui)),64))])):Q("",!0),f("div",ci,[f("div",di,[p(r(ps),null,{default:h(()=>[p(r(fs),{class:"flex items-end"},{default:h(()=>[(v(!0),E(Y,null,Z(g.executedResults,([N,B])=>(v(),R(T,{key:N},{default:h(()=>[p(k,{"as-child":""},{default:h(()=>[f("div",{onClick:O=>g.$emit("update:activeTab",N),onContextmenu:O=>o.value=N,class:ue(r(Ce)("h-6! flex gap-0.5 rounded-t-md max-w-44 justify-start! items-center font-normal p-1! hover:[&>div]:opacity-100 transition-all duration-200 border rounded-b-none cursor-pointer relative",N===g.activeTabId?"border-b-transparent bg-background dark:bg-accent":"border-transparent bg-muted/30"))},[p(C,{name:b(B)?"hugeicons:alert-02":"hugeicons:sql",class:ue(r(Ce)("min-w-4",b(B)?"text-red-500":""))},null,8,["name","class"]),f("div",pi," Query "+I(B.seqIndex)+" - "+I(B.metadata.statementQuery),1),f("div",{onClick:_t(O=>g.$emit("close-tab",N),["stop"]),class:"hover:bg-accent h-5 w-5 flex items-center justify-center rounded-full opacity-0"},[p(C,{name:"lucide:x",class:"stroke-[2.5]! size-3!"})],8,fi)],42,mi)]),_:2},1024),p(V,{class:"max-w-xl"},{default:h(()=>[f("p",null,I(B.metadata.statementQuery),1)]),_:2},1024)]),_:2},1024))),128))]),_:1}),r(o)?(v(),R(r(hs),{key:0,hideWhenDetached:"",class:"w-56"},{default:h(()=>[p(r(He),{onSelect:_[0]||(_[0]=N=>g.$emit("close-tab",r(o)))},{default:h(()=>_[4]||(_[4]=[L(" Close ")])),_:1}),p(r(He),{onSelect:_[1]||(_[1]=N=>g.$emit("close-other-tabs",r(o)))},{default:h(()=>_[5]||(_[5]=[L(" Close Others ")])),_:1}),p(r(He),{disabled:!r(a),onSelect:_[2]||(_[2]=N=>g.$emit("close-tabs-to-right",r(o)))},{default:h(()=>_[6]||(_[6]=[L(" Close to the Right ")])),_:1},8,["disabled"])]),_:1})):Q("",!0)]),_:1})]),f("div",hi,[g.executeLoading&&g.activeTabId?(v(),R(U,{key:0,visible:""})):Q("",!0),r(d)?r(d)&&r(m)==="result"?(v(),R(jr,{"active-tab":r(d),"active-tab-columns":r(y),"formatted-data":r(u),"execute-loading":g.executeLoading,"is-streaming":g.isStreaming,key:r(d).id},null,8,["active-tab","active-tab-columns","formatted-data","execute-loading","is-streaming"])):r(d)&&r(m)==="explain"?(v(),R(ri,{key:3,"active-tab":r(d)},null,8,["active-tab"])):r(d)&&r(m)==="raw"?(v(),R(Mr,{key:4,"formatted-data":r(u),"execute-loading":g.executeLoading,"is-streaming":g.isStreaming},null,8,["formatted-data","execute-loading","is-streaming"])):r(d)&&r(m)==="info"?(v(),R(kr,{key:5,"active-tab":r(d)},null,8,["active-tab"])):r(d)&&r(m)==="error"?(v(),R(dr,{key:6,"active-tab":r(d),onOnChangeView:_[3]||(_[3]=N=>S(N))},null,8,["active-tab"])):r(d)&&r(m)==="agent"?(v(),R(er,{key:7,"active-tab":r(d)},null,8,["active-tab"])):Q("",!0):(v(),R(D,{key:1,title:"No results",desc:"Execute a query to see results"}))])])])}}});function gi({query:s,dbConnectionString:t,params:e,onMeta:n,onRows:o,onDone:a,onError:l}){const i=new AbortController;let u=0;return(async()=>{var d;try{const m=await fetch("/api/query/raw-execute-stream",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:s,dbConnectionString:t,params:e||{}}),signal:i.signal});if(!m.ok){const b=await m.text();l==null||l(b||`HTTP ${m.status}`);return}const y=(d=m.body)==null?void 0:d.getReader();if(!y){l==null||l("No readable stream available");return}const x=new TextDecoder;let S="";for(;;){const{done:b,value:g}=await y.read();if(b)break;S+=x.decode(g,{stream:!0});const _=S.split(`
11
+ `);S=_.pop()||"";for(const C of _){const k=C.trim();if(k)try{const V=JSON.parse(k);switch(V.type){case"meta":n==null||n(V.fields,V.command);break;case"rows":u+=V.data.length,o==null||o(V.data,u);break;case"done":a==null||a(V.rowCount,V.queryTime);break;case"error":l==null||l(V.message,V.error);break}}catch{console.warn("[StreamingQuery] Malformed NDJSON line:",k)}}}if(S.trim())try{const b=JSON.parse(S.trim());b.type==="done"?a==null||a(b.rowCount,b.queryTime):b.type==="error"&&(l==null||l(b.message))}catch{}}catch(m){if(m.name==="AbortError")return;l==null||l(m.message||"Stream connection failed")}})(),{abort:()=>i.abort()}}function yi({getEditorView:s,connection:t,fileVariables:e,fieldDefs:n,resultTabs:o,buildExplainAnalyzePrefix:a}){const l=Ve([]),i=Ve({}),u=Ve(0),c=dn({isHaveOneExecute:!1,executeLoading:!1,isStreaming:!1,streamingRowCount:0,queryTime:0,executeErrors:void 0,currentStatementQuery:""});let d=null;const m=async({currentStatements:b,queryPrefix:g})=>{var N,B;if(!b.length)return;const _=b[0];c.isHaveOneExecute=!0,c.currentStatementQuery=_.text;let C=_.text,k={};try{k=JSON.parse(e.value||"{}")}catch(O){console.log("fileParameters error::",O)}let V="result";g&&(C=`${g} ${C}`,g.startsWith("EXPLAIN")&&(V="explain")),n.value=[],l.value=[],i.value={},c.executeLoading=!0,c.isStreaming=!1,c.streamingRowCount=0,d&&(d(),d=null),u.value++;const T={id:lo(),metadata:{queryTime:0,statementQuery:C,executedAt:new Date,executeErrors:void 0,fieldDefs:void 0,connection:void 0},result:[],view:V,seqIndex:u.value};o.addResultTab(T),Qo(s());const U=[];if(g&&V==="explain"){try{const O=await $fetch("/api/query/raw-execute",{method:"POST",body:{dbConnectionString:(N=t.value)==null?void 0:N.connectionString,query:C,params:k},onResponseError:({response:P})=>{var ee,Ae;const W=(ee=P._data)==null?void 0:ee.data,X=s();X&&W&&Ut({editorView:X,originalSql:_.text,statementFrom:Number(_.from),fileParameters:k,errorDetail:W,clientType:((Ae=t.value)==null?void 0:Ae.type)||ae.POSTGRES,queryPrefix:g})}});n.value=O.fields,T.metadata.fieldDefs=O.fields,T.result=O.rows,T.metadata.queryTime=O.queryTime||0,T.metadata.connection=t.value,i.value=O,l.value=O.rows,c.executeErrors=void 0,c.queryTime=O.queryTime||0}catch(O){c.executeErrors=O.data,T.metadata.executeErrors=O.data,T.view="error"}c.executeLoading=!1,o.refreshResultTab(T.id,T);return}c.isStreaming=!0,c.executeLoading=!1;const{abort:D}=gi({query:C,dbConnectionString:((B=t.value)==null?void 0:B.connectionString)||"",params:k,onMeta:(O,P)=>{n.value=O,T.metadata.fieldDefs=O,T.metadata.connection=t.value,T.metadata.command=P,o.refreshResultTab(T.id,T)},onRows:(O,P)=>{U.push(...O),c.streamingRowCount=P,T.result=U,T.metadata.rowCount=P,l.value=U,o.refreshResultTab(T.id,T)},onDone:(O,P)=>{c.executeLoading=!1,c.isStreaming=!1,c.queryTime=P,c.executeErrors=void 0,c.streamingRowCount=O,T.metadata.queryTime=P,T.metadata.rowCount=O,i.value={rows:T.result,fields:n.value,queryTime:P},o.refreshResultTab(T.id,T),d=null},onError:(O,P)=>{var ee;const W={message:O,data:P||{message:O}};c.executeLoading=!1,c.isStreaming=!1,c.executeErrors=W,T.metadata.executeErrors=W,T.view="error";const X=s();X&&P&&Ut({editorView:X,originalSql:_.text,statementFrom:Number(_.from),fileParameters:k,errorDetail:P,clientType:((ee=t.value)==null?void 0:ee.type)||ae.POSTGRES}),o.refreshResultTab(T.id,T),d=null}});d=D};return{currentRawQueryResult:l,rawResponse:i,queryProcessState:c,executeCurrentStatement:m,onExecuteCurrent:()=>{const b=s();if(!b)return;const{currentStatements:g}=Je(b);m({currentStatements:g})},onExplainAnalyzeCurrent:()=>{const b=s();if(!b)return;const{currentStatements:g}=Je(b);m({currentStatements:g,queryPrefix:a()})},cancelStreamingQuery:()=>{d&&(d(),d=null,c.executeLoading=!1,c.isStreaming=!1)}}}function xi(){const s=G({BUFFERS:!0,COSTS:!0,GENERIC_PLAN:!1,MEMORY:!1,SETTINGS:!0,SUMMARY:!0,TIMING:!0,VERBOSE:!0,WAL:!0}),t=G("NONE"),e=l=>{s.value[l]=!s.value[l]},n=l=>{t.value=l};return{explainAnalyzeOptionItems:q(()=>At.filter(l=>l.key!=="SERIALIZE").map(l=>({key:l.key,label:l.label,checked:s.value[l.key]}))),serializeMode:t,toggleExplainOption:e,setSerializeMode:n,buildExplainAnalyzePrefix:()=>{const l=At.filter(c=>c.key!=="SERIALIZE"&&s.value[c.key]).map(c=>c.key).flatMap(c=>c==="GENERIC_PLAN"?[]:[c]),i=t.value==="NONE"?[]:[`SERIALIZE ${t.value}`];return`EXPLAIN (${["ANALYZE","FORMAT JSON",...l,...i].join(", ")})`}}}function bi(){const s=Ve(new Map),t=G(null),e=d=>{const m=new Map;m.set(d.id,d),s.value.forEach((y,x)=>{m.set(x,y)}),s.value=m,t.value=d.id},n=(d,m)=>{const y=new Map(s.value);y.set(d,{...m}),s.value=y};return{executedResults:s,activeResultTabId:t,addResultTab:e,refreshResultTab:n,setActiveResultTab:d=>{s.value.has(d)&&(t.value=d)},closeResultTab:d=>{const m=new Map(s.value);if(m.delete(d),s.value=m,t.value===d){const y=Array.from(m.keys());t.value=y.length>0?y[y.length-1]:null}},updateResultTabView:(d,m)=>{const y=s.value.get(d);y&&n(d,{...y,view:m})},closeOtherResultTabs:d=>{const m=s.value.get(d);if(!m)return;const y=new Map;y.set(d,m),s.value=y,t.value=d},closeResultTabsToRight:d=>{const m=Array.from(s.value.keys()),y=m.indexOf(d);if(y<0)return;const x=new Map;for(let S=0;S<=y;S++){const b=m[S],g=s.value.get(b);g&&x.set(b,g)}s.value=x,x.has(t.value||"")||(t.value=d)},updateResultTabResult:(d,m)=>{const x=new Map(s.value).get(d);x&&(x.result=m)}}}function qe(s,...t){}const _i=s=>{let t;return async()=>(t||(t=s()),await t)};class Rt{constructor(t={}){ne(this,"opts");ne(this,"parser",null);ne(this,"offsetRecord",{});ne(this,"getParser",_i(async()=>{if(this.parser)return this.parser;const t=await us(()=>import("./ClYziJpO.js").then(n=>n.i),__vite__mapDeps([0,1,2]),import.meta.url),{Parser:e}=t.default||t;return this.parser=new e,this.parser}));this.opts=t}async parse(t,e){var a,l;this.offsetRecord={};const n=(l=(a=this.opts).getParserOptions)==null?void 0:l.call(a,e.state),o=await this.sanitizeSql(t,n);try{const i=await this.getParser();if((n==null?void 0:n.database)==="DuckDB")return this.parseWithDuckDBSupport(o,n);const u=i.astify(o,n);return{success:!0,errors:[],ast:u}}catch(i){return{success:!1,errors:[this.extractErrorInfo(i,o)]}}}async sanitizeSql(t,e){if(e!=null&&e.ignoreBrackets){const{sql:n,offsetRecord:o}=wi(t);return this.offsetRecord=o,n}return t}async parseWithDuckDBSupport(t,e){const n=await this.getParser(),o=Ci(t).trimStart().toLowerCase();if(o.startsWith("from")||o.includes("macro"))return qe(),{success:!0,errors:[]};let a=t;o.includes("create or replace table")&&(this.offsetRecord[t.indexOf("create or replace table")]=-11,a=t.replace(/create or replace table/i,"create table"));try{const l={...e,database:"PostgreSQL"},i=n.astify(a,l);return{success:!0,errors:[],ast:i}}catch(l){return{success:!1,errors:[this.extractErrorInfo(l,t)]}}}extractErrorInfo(t,e){var i,u,c;let n=1,o=1;const a=(t==null?void 0:t.message)||"SQL parsing error",l=t;if(l!=null&&l.location)n=((i=l.location.start)==null?void 0:i.line)||1,o=((u=l.location.start)==null?void 0:u.column)||1;else if(l!=null&&l.hash)n=l.hash.line||1,o=((c=l.hash.loc)==null?void 0:c.first_column)||1;else{const d=a.match(/line (\d+)/i),m=a.match(/column (\d+)/i);d!=null&&d[1]&&(n=parseInt(d[1],10)),m!=null&&m[1]&&(o=parseInt(m[1],10))}for(const[d,m]of Object.entries(this.offsetRecord))o>parseInt(d,10)&&(o-=m);return o>e.length&&(o=e.length),{message:this.cleanErrorMessage(a),line:Math.max(1,n),column:o,severity:"error"}}cleanErrorMessage(t){return t.replace(/^Error: /,"").replace(/Expected .* but .* found\./i,e=>e.replace(/but .* found/,"found unexpected token")).trim()}async validateSql(t,e){return(await this.parse(t,e)).errors}async extractTableReferences(t,e){var o,a;const n=e?(a=(o=this.opts).getParserOptions)==null?void 0:a.call(o,e.state):void 0;try{return(await this.getParser()).tableList(t,n).map(u=>{const c=u.split("::");return c[c.length-1]||u})}catch{return[]}}async extractColumnReferences(t,e){var o,a;const n=e!=null&&e.state?(a=(o=this.opts).getParserOptions)==null?void 0:a.call(o,e.state):void 0;try{return(await this.getParser()).columnList(t,n).map(c=>{const d=c.split("::");return d[d.length-1]||c})}catch{return[]}}}function Ci(s,t=["/*","--"]){const e=[];if(t.includes("/*")&&e.push("/\\*[\\s\\S]*?\\*/"),t.includes("--")&&e.push("--[^\\n]*"),e.length===0)return s;const n=new RegExp(`^\\s*(${e.join("|")})\\s*`,"");let o=s,a="";for(;o!==a;)a=o,o=o.replace(n,"");return o}const Si=2;function wi(s){const t={};return{sql:s.replace(/("(?:[^"\\]|\\.)*")|('(?:[^'\\]|\\.)*')|(\{[^}]*\})/g,(n,o,a,l,i)=>o||a?n:l?(t[i]=Si,`'${l}'`):n),offsetRecord:t}}const Ti=750;function Ei(s,t){const n=t.line(s.line).from+Math.max(0,s.column-1),o=n+1;return{from:n,to:o,severity:s.severity,message:s.message,source:"sql-parser"}}function Ri(s={}){const t=s.parser||new Rt;return xs(async e=>{const n=e.state.doc,o=n.toString();return o.trim()?(await t.validateSql(o,{state:e.state})).map(l=>Ei(l,n)):[]},{delay:s.delay||Ti})}function $e(s){return typeof s=="object"&&!Array.isArray(s)&&!("self"in s)}function xe(s){return typeof s=="object"&&!Array.isArray(s)&&"self"in s&&"children"in s}function fe(s){return Array.isArray(s)}function se(s,t,e,n){const o=s.length;if(t==="string"||t==="completion"&&n&&fe(n))return"column";if(t==="namespace"&&e){if(fe(e))return"table";if($e(e))return Object.values(e).some(l=>fe(l)||xe(l)&&fe(l.children))?o<=1?"database":"schema":o===0?"database":"namespace"}if(t==="completion"&&e)return fe(e)?"table":($e(e)&&Object.values(e).some(l=>fe(l)||xe(l)&&fe(l.children)),o<=1?"database":"schema");switch(o){case 0:return"database";case 1:return"schema";default:return"namespace"}}function $s(s,t,e={}){const{maxDepth:n=10}=e;if(t===""&&xe(s)){const a=se([],"completion",s.children);return{completion:s.self,path:[],type:"completion",semanticType:a,namespace:s.children}}const o=t.split(".").filter(a=>a.length>0);return o.length===0||o.length>n?null:vt(s,o,[],e)}function vt(s,t,e,n,o){if(t.length===0){if(xe(s)){const c=se(e,"completion",s.children,o);return{completion:s.self,path:e,type:"completion",semanticType:c,namespace:s.children}}const u=se(e,"namespace",s,o);return{path:e,type:"namespace",semanticType:u,namespace:s}}const[a,...l]=t,{caseSensitive:i=!1}=n;if(!a)return null;if($e(s)){const u=i?Object.keys(s).find(c=>c===a):Object.keys(s).find(c=>c.toLowerCase()===a.toLowerCase());if(u){const c=s[u];if(c)return vt(c,l,[...e,u],n,s)}}else{if(xe(s))return vt(s.children,t,e,n,s);if(fe(s)){for(const u of s)if(typeof u=="string"){if((i?u===a:u.toLowerCase()===a.toLowerCase())&&l.length===0){const d=se([...e,u],"string",void 0,s);return{value:u,path:[...e,u],type:"string",semanticType:d}}}else if((i?u.label===a:u.label.toLowerCase()===a.toLowerCase())&&l.length===0){const d=se([...e,u.label],"completion",void 0,s);return{completion:u,path:[...e,u.label],type:"completion",semanticType:d}}}}return null}function $i(s,t,e={}){const n=[];if(t.includes(".")){const o=t.lastIndexOf("."),a=t.substring(0,o),l=t.substring(o+1),i=$s(s,a,e);if(i!=null&&i.namespace)return gt(i.namespace,l,i.path,e)}else return gt(s,t,[],e);return n}function gt(s,t,e,n){const o=[],{caseSensitive:a=!1,allowPartialMatch:l=!0}=n;if($e(s)){for(const[i,u]of Object.entries(s))if(l?a?i.startsWith(t):i.toLowerCase().startsWith(t.toLowerCase()):a?i===t:i.toLowerCase()===t.toLowerCase())if(xe(u)){const d=se([...e,i],"completion",u.children,s);o.push({completion:u.self,path:[...e,i],type:"completion",semanticType:d,namespace:u.children})}else{const d=se([...e,i],"namespace",u,s);o.push({path:[...e,i],type:"namespace",semanticType:d,namespace:u})}}else if(xe(s)){if(l?a?s.self.label.startsWith(t):s.self.label.toLowerCase().startsWith(t.toLowerCase()):a?s.self.label===t:s.self.label.toLowerCase()===t.toLowerCase()){const u=se([...e,s.self.label],"completion",s.children);o.push({completion:s.self,path:[...e,s.self.label],type:"completion",semanticType:u,namespace:s.children})}o.push(...gt(s.children,t,e,n))}else if(fe(s)){for(const i of s)if(typeof i=="string"){if(l?a?i.startsWith(t):i.toLowerCase().startsWith(t.toLowerCase()):a?i===t:i.toLowerCase()===t.toLowerCase()){const c=se([...e,i],"string",void 0,s);o.push({value:i,path:[...e,i],type:"string",semanticType:c})}}else if(l?a?i.label.startsWith(t):i.label.toLowerCase().startsWith(t.toLowerCase()):a?i.label===t:i.label.toLowerCase()===t.toLowerCase()){const c=se([...e,i.label],"completion",void 0,s);o.push({completion:i,path:[...e,i.label],type:"completion",semanticType:c})}}return o}function ki(s,t,e={}){const n=[],{maxDepth:o=10}=e;Ge(s,[],n,o);const{caseSensitive:a=!1}=e;return n.filter(i=>i.path.some(u=>a?u===t:u.toLowerCase()===t.toLowerCase())).sort((i,u)=>{var m,y;const c=a?i.path[i.path.length-1]===t:((m=i.path[i.path.length-1])==null?void 0:m.toLowerCase())===t.toLowerCase(),d=a?u.path[u.path.length-1]===t:((y=u.path[u.path.length-1])==null?void 0:y.toLowerCase())===t.toLowerCase();return c&&!d?-1:!c&&d?1:i.path.length-u.path.length})}function Ge(s,t,e,n){if(!(t.length>=n)){if($e(s))for(const[o,a]of Object.entries(s)){const l=[...t,o];if(xe(a)){const i=se(l,"completion",a.children,s);e.push({completion:a.self,path:l,type:"completion",semanticType:i,namespace:a.children}),Ge(a.children,l,e,n)}else{const i=se(l,"namespace",a,s);e.push({path:l,type:"namespace",semanticType:i,namespace:a}),Ge(a,l,e,n)}}else if(xe(s)){const o=se(t,"completion",s.children);e.push({completion:s.self,path:t,type:"completion",semanticType:o,namespace:s.children}),Ge(s.children,t,e,n)}else if(fe(s))for(const o of s)if(typeof o=="string"){const a=se([...t,o],"string",void 0,s);e.push({value:o,path:[...t,o],type:"string",semanticType:a})}else{const a=se([...t,o.label],"completion",void 0,s);e.push({completion:o,path:[...t,o.label],type:"completion",semanticType:a})}}}function Gt(s,t,e={}){const{enableFuzzySearch:n=!1}=e,o=$s(s,t,e);if(o)return o;const a=$i(s,t,e);if(a.length>0)return a[0]||null;if(n){const l=ki(s,t,e);if(l.length>0)return l[0]||null}return null}function ks(s,t){if(t.size===0)return{};if($e(s)){const e={};for(const[n,o]of Object.entries(s))if(Array.from(t).some(l=>l.toLowerCase()===n.toLowerCase()))e[n]=o;else if($e(o)){const l=ks(o,t);Object.keys(l).length>0&&(e[n]=l)}return e}return s}function zi(s={}){const{schema:t={},keywords:e={},hoverTime:n=300,enableKeywords:o=!0,enableTables:a=!0,enableColumns:l=!0,enableFuzzySearch:i=!0,parser:u=new Rt,tooltipRender:c,tooltipRenderers:d={}}=s;let m=null;return mn(async(y,x,S)=>{const{from:b,to:g,text:_}=y.state.doc.lineAt(x);let C=x,k=x;m===null&&(m=typeof e=="function"?e(y):Promise.resolve(e));const V=await m;for(;C>b&&/[\w.]/.test(_[C-b-1]??"");)C--;for(;k<g&&/[\w.]/.test(_[k-b]??"");)k++;if(C===x&&S<0||k===x&&S>0)return null;const T=_.slice(C-b,k-b).toLowerCase();if(!T||T.length===0)return null;const U=typeof t=="function"?t(y):t;let D=null;if(qe(),!D&&o&&V[T]){qe("keywordResult",T,V[T]);const N={keyword:T,info:V[T]};D={word:T,view:y,pos:x,tooltipType:"keyword",keywordData:N}}if(!D&&(a||l)&&U){const N=y.state.doc.toString(),B=await u.extractTableReferences(N),O=new Set(B.map(X=>X.toLowerCase())),P=ks(U,O);let W=Gt(P,T,{enableFuzzySearch:i});if(!W&&O.size===0&&(W=Gt(U,T,{enableFuzzySearch:i})),W){qe("namespaceResult (query-aware)",T,W,"tableRefs:",Array.from(O));const X={item:W,word:T,resolvedSchema:O.size>0?P:U};D={word:T,view:y,pos:x,tooltipType:"namespace",namespaceData:X}}else qe("No namespace item found for:",T)}return D?{pos:C,end:k,above:!0,create(N){if(c){const P=c(T,N,x);if(P)return{dom:P}}let B=null;if(D.tooltipType==="keyword"&&D.keywordData)B=d.keyword?d.keyword(D.keywordData):Ai(D.keywordData);else if(D.tooltipType==="namespace"&&D.namespaceData){const P=D.namespaceData,{semanticType:W}=P.item;W==="table"&&d.table?B=d.table(P):W==="column"&&d.column?B=d.column(P):(W==="database"||W==="schema"||W==="namespace")&&d.namespace?B=d.namespace(P):B=Mi(P.item)}if(!B)return{dom:document.createElement("div")};const O=document.createElement("div");return O.className="cm-sql-hover-tooltip",O.innerHTML=B,{dom:O}}}:null},{hoverTime:n})}function Mi(s){var o,a,l,i,u,c,d;const t=s.path.join("."),e=((o=s.completion)==null?void 0:o.label)||s.value||s.path[s.path.length-1]||"unknown";let n=`<div class="sql-hover-${s.semanticType}">`;switch(n+=`<div class="sql-hover-header"><strong>${e}</strong> <span class="sql-hover-type">${s.semanticType}</span></div>`,s.semanticType){case"database":if(n+=`<div class="sql-hover-description">Database${(a=s.completion)!=null&&a.detail?`: ${s.completion.detail}`:""}</div>`,s.namespace){const m=Ke(s.namespace);m>0&&(n+=`<div class="sql-hover-children">Contains ${m} schema${m!==1?"s":""}</div>`)}break;case"schema":if(n+=`<div class="sql-hover-description">Schema${(l=s.completion)!=null&&l.detail?`: ${s.completion.detail}`:""}</div>`,t&&(n+=`<div class="sql-hover-path"><strong>Path:</strong> <code>${t}</code></div>`),s.namespace){const m=Ke(s.namespace);m>0&&(n+=`<div class="sql-hover-children">Contains ${m} table${m!==1?"s":""}</div>`)}break;case"table":if(n+=`<div class="sql-hover-description">Table${(i=s.completion)!=null&&i.detail?`: ${s.completion.detail}`:""}</div>`,t){const m=s.path;m.length>1&&(n+=`<div class="sql-hover-path"><strong>Schema:</strong> <code>${m.slice(0,-1).join(".")}</code></div>`)}if(s.namespace&&fe(s.namespace)){const m=s.namespace;if(m.length>0){n+=`<div class="sql-hover-columns"><strong>Columns (${m.length}):</strong><br>`;const x=m.slice(0,8).map(S=>typeof S=="string"?S:S.label);n+=x.map(S=>`<code>${S}</code>`).join(", "),m.length>8&&(n+=`, <em>and ${m.length-8} more...</em>`),n+="</div>"}}break;case"column":if(n+=`<div class="sql-hover-description">Column${(u=s.completion)!=null&&u.detail?`: ${s.completion.detail}`:""}</div>`,t){const m=s.path;m.length>1&&(n+=`<div class="sql-hover-path"><strong>Table:</strong> <code>${m.slice(0,-1).join(".")}</code></div>`)}break;default:if(n+=`<div class="sql-hover-description">Namespace${(c=s.completion)!=null&&c.detail?`: ${s.completion.detail}`:""}</div>`,t&&(n+=`<div class="sql-hover-path"><strong>Path:</strong> <code>${t}</code></div>`),s.namespace){const m=Ke(s.namespace);m>0&&(n+=`<div class="sql-hover-children">Contains ${m} item${m!==1?"s":""}</div>`)}break}return(d=s.completion)!=null&&d.info&&typeof s.completion.info=="string"&&(n+=`<div class="sql-hover-info">${s.completion.info}</div>`),n+="</div>",n}function Ke(s){return Array.isArray(s)?s.length:typeof s=="object"&&s!==null?"self"in s&&"children"in s?1+Ke(s.children):Object.keys(s).length:0}function Ai(s){const{keyword:t,info:e}=s;let n='<div class="sql-hover-keyword">';if(n+=`<div class="sql-hover-header"><strong>${t.toUpperCase()}</strong> <span class="sql-hover-type">keyword</span></div>`,n+=`<div class="sql-hover-description">${e.description}</div>`,e.syntax&&(n+=`<div class="sql-hover-syntax"><strong>Syntax:</strong> <code>${e.syntax}</code></div>`),e.example&&(n+=`<div class="sql-hover-example"><strong>Example:</strong><br><code>${e.example}</code></div>`),e.metadata&&typeof e.metadata=="object"&&Object.keys(e.metadata).length>0){n+='<div class="sql-hover-metadata">';for(const[o,a]of Object.entries(e.metadata))n+=`<span class="sql-hover-tag" title="${o}">${a}</span> `;n+="</div>"}return n+="</div>",n}const Li=(s="light")=>{const n=s==="dark"?{tooltipBg:"#1f2937",tooltipBorder:"#374151",tooltipText:"#f9fafb",tooltipTypeBg:"#374151",tooltipTypeText:"#9ca3af",tooltipChildren:"#9ca3af",codeBg:"#374151",codeText:"#f3f4f6",strong:"#ffffff",em:"#9ca3af",header:"#ffffff",info:"#d1d5db",related:"#d1d5db",path:"#d1d5db",example:"#d1d5db",columns:"#d1d5db",syntax:"#d1d5db"}:{tooltipBg:"#ffffff",tooltipBorder:"#e5e7eb",tooltipText:"#374151",tooltipTypeBg:"#f3f4f6",tooltipTypeText:"#6b7280",tooltipChildren:"#6b7280",codeBg:"#f9fafb",codeText:"#1f2937",strong:"#111827",em:"#6b7280",header:"#111827",info:"#374151",related:"#374151",path:"#374151",example:"#374151",columns:"#374151",syntax:"#374151"};return St.theme({".cm-sql-hover-tooltip":{padding:"8px 12px",backgroundColor:n.tooltipBg,border:`1px solid ${n.tooltipBorder}`,borderRadius:"6px",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",fontSize:"13px",lineHeight:"1.4",maxWidth:"320px",fontFamily:"system-ui, -apple-system, sans-serif",color:n.tooltipText},".cm-sql-hover-tooltip .sql-hover-header":{marginBottom:"6px",display:"flex",alignItems:"center",gap:"6px",color:n.header},".cm-sql-hover-tooltip .sql-hover-type":{fontSize:"11px",padding:"2px 6px",backgroundColor:n.tooltipTypeBg,color:n.tooltipTypeText,borderRadius:"4px",fontWeight:"500"},".cm-sql-hover-tooltip .sql-hover-description":{color:n.info,marginBottom:"8px"},".cm-sql-hover-tooltip .sql-hover-syntax":{marginBottom:"8px",color:n.syntax},".cm-sql-hover-tooltip .sql-hover-example":{marginBottom:"4px",color:n.example},".cm-sql-hover-tooltip .sql-hover-columns":{marginBottom:"4px",color:n.columns},".cm-sql-hover-tooltip .sql-hover-related":{marginBottom:"4px",color:n.related},".cm-sql-hover-tooltip .sql-hover-path":{marginBottom:"4px",color:n.path},".cm-sql-hover-tooltip .sql-hover-info":{marginBottom:"4px",color:n.info},".cm-sql-hover-tooltip .sql-hover-children":{marginBottom:"4px",color:n.tooltipChildren,fontSize:"12px"},".cm-sql-hover-tooltip code":{backgroundColor:n.codeBg,padding:"1px 4px",borderRadius:"3px",fontSize:"12px",fontFamily:"ui-monospace, 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', monospace",color:n.codeText},".cm-sql-hover-tooltip strong":{fontWeight:"600",color:n.strong},".cm-sql-hover-tooltip em":{fontStyle:"italic",color:n.em}})};class Ni{constructor(t){ne(this,"parser");ne(this,"cache",new Map);ne(this,"MAX_CACHE_SIZE",10);this.parser=t}async analyzeDocument(t){const e=t.doc.toString(),n=this.generateCacheKey(e),o=this.cache.get(n);if(o)return o;const a=await this.extractStatements(e,t);if(this.cache.set(n,a),this.cache.size>this.MAX_CACHE_SIZE){const l=this.cache.keys().next().value;l!==void 0&&this.cache.delete(l)}return a}async getStatementAtPosition(t,e){return(await this.analyzeDocument(t)).find(o=>e>=o.from&&e<=o.to)||null}async getStatementsInRange(t,e,n){return(await this.analyzeDocument(t)).filter(a=>a.from<=n&&a.to>=e)}async extractStatements(t,e){const n=[],o=this.splitByStatementSeparators(t);let a=0;for(const l of o){const i=l.trim();if(i.length===0){a+=l.length;continue}const u=a+l.indexOf(i),c=u+i.length,d=e.doc.lineAt(u),m=e.doc.lineAt(c),y=this.stripComments(i);if(y.trim().length===0||y.trim()===";"){a+=l.length;continue}const x=await this.parser.parse(y,{state:e}),S=this.determineStatementType(y),b=y.endsWith(";")?y.slice(0,-1).trim():y.trim();n.push({from:u,to:c,lineFrom:d.number,lineTo:m.number,content:b,type:S,isValid:x.success}),a+=l.length}return n}splitByStatementSeparators(t){const e=[];let n="",o=!1,a="",l=!1,i=!1,u=0;for(;u<t.length;){const c=t[u],d=t[u+1];if(!o&&!i&&c==="-"&&d==="-"){l=!0,n+=c+d,u+=2;continue}if(!o&&!l&&c==="/"&&d==="*"){i=!0,n+=c+d,u+=2;continue}if(i&&c==="*"&&d==="/"){i=!1,n+=c+d,u+=2;continue}if(l&&(c===`
12
+ `||c==="\r")){l=!1,n+=c,u++;continue}if(l||i){n+=c,u++;continue}if(!o&&(c==="'"||c==='"'||c==="`"))o=!0,a=c,n+=c;else if(o&&c===a){if(d===a){n+=c+d,u+=2;continue}o=!1,a="",n+=c}else!o&&c===";"?(n+=c,e.push(n),n=""):n+=c;u++}return n.trim()&&e.push(n),e}determineStatementType(t){const e=t.trim().toLowerCase();return e.startsWith("select")?"select":e.startsWith("insert")?"insert":e.startsWith("update")?"update":e.startsWith("delete")?"delete":e.startsWith("create")?"create":e.startsWith("drop")?"drop":e.startsWith("alter")?"alter":e.startsWith("use")?"use":"other"}stripComments(t){let e="",n=!1,o="",a=!1,l=!1,i=0;for(;i<t.length;){const u=t[i],c=t[i+1];if(!n&&!l&&u==="-"&&c==="-"){a=!0,i+=2;continue}if(!n&&!a&&u==="/"&&c==="*"){l=!0,i+=2;continue}if(l&&u==="*"&&c==="/"){l=!1,i+=2;continue}if(a&&(u===`
13
+ `||u==="\r")){a=!1,e+=u,i++;continue}if(a||l){i++;continue}if(!n&&(u==="'"||u==='"'||u==="`"))n=!0,o=u,e+=u;else if(n&&u===o){if(c===o){e+=u+c,i+=2;continue}n=!1,o="",e+=u}else e+=u;i++}return e}generateCacheKey(t){let e=0;for(let n=0;n<t.length;n++){const o=t.charCodeAt(n);e=(e<<5)-e+o,e=e&e}return e.toString()}clearCache(){this.cache.clear()}}const zs=fn.define(),Ms=pn.define({create(){return{currentStatement:null,allStatements:[],cursorPosition:0,isFocused:!0}},update(s,t){for(const e of t.effects)if(e.is(zs))return e.value;return s}});class Ii extends gn{constructor(e,n,o=!0,a=!0){super();ne(this,"config");ne(this,"isCurrent");ne(this,"isValid");ne(this,"isFocused");this.config=e,this.isCurrent=n,this.isValid=o,this.isFocused=a}toDOM(){const e=document.createElement("div");e.className="cm-sql-gutter-marker";let n=this.config.backgroundColor||"#3b82f6";!this.isValid&&this.config.showInvalid!==!1&&(n=this.config.errorBackgroundColor||"#ef4444");let o;return this.isFocused?o=this.isCurrent?"1":(this.config.inactiveOpacity||"0.3").toString():this.config.unfocusedOpacity!==void 0?o=this.config.unfocusedOpacity.toString():this.config.hideWhenNotFocused?o="0":o=this.isCurrent?"1":(this.config.inactiveOpacity||"0.3").toString(),e.style.cssText=`
14
+ background: ${n};
15
+ height: 100%;
16
+ width: 100%;
17
+ opacity: ${o};
18
+ transition: opacity 150ms ease-in-out;
19
+ border-radius: 1px;
20
+ `,e}eq(e){return this.isCurrent===e.isCurrent&&this.isValid===e.isValid&&this.isFocused===e.isFocused&&this.config===e.config}}function Oi(s,t){var i;let e=vn.empty;if((i=t.whenHide)!=null&&i.call(t,s))return e;const n=s.state.field(Ms,!1);if(!n)return e;const{currentStatement:o,allStatements:a,isFocused:l}=n;try{for(const u of a){const c=(o==null?void 0:o.from)===u.from&&(o==null?void 0:o.to)===u.to;if(!u.isValid&&t.showInvalid===!1)continue;const d=new Ii(t,c,u.isValid,l);for(let m=u.lineFrom;m<=u.lineTo;m++)try{if(m<1||m>s.state.doc.lines)continue;const y=s.state.doc.line(m);e=e.update({add:[d.range(y.from)]})}catch(y){console.warn("SqlGutter: Invalid line number",m,y)}}}catch(u){console.warn("SqlGutter: Error creating markers",u)}return e}function Pi(s){return St.updateListener.of(async t=>{if(!t.docChanged&&!t.selectionSet&&!t.focusChanged)return;const{state:e}=t.view,{main:n}=e.selection,o=n.head,a=await s.analyzeDocument(e),i={currentStatement:await s.getStatementAtPosition(e,o),allStatements:a,cursorPosition:o,isFocused:t.view.hasFocus};t.view.dispatch({effects:zs.of(i)})})}function qi(s){const t=s.width||3;return St.baseTheme({".cm-sql-gutter":{width:`${t}px`,minWidth:`${t}px`},".cm-sql-gutter .cm-gutterElement":{width:`${t}px`,padding:"0",margin:"0"},".cm-sql-gutter-marker":{width:"100%",height:"100%",display:"block"},".cm-lineNumbers .cm-gutterElement":{paddingLeft:"8px",paddingRight:"8px"}})}function Vi(s){return hn({class:`cm-sql-gutter ${s.className||""}`,markers:t=>Oi(t,s)})}function Di(s={}){const t=s.parser||new Rt,e=new Ni(t);return[Ms,Pi(e),qi(s),Vi(s)]}function Fi(s={}){const t=[],{enableLinting:e=!0,enableGutterMarkers:n=!0,enableHover:o=!0,linterConfig:a,gutterConfig:l,hoverConfig:i}=s;return e&&t.push(Ri(a)),n&&t.push(Di(l)),o&&(t.push(zi(i)),i!=null&&i.theme?t.push(i.theme):t.push(Li())),t}const Ye='(?:"(?:[^"]|"")+"|[A-Za-z_][A-Za-z0-9_$]*)',Bi=new RegExp(`(${Ye})\\s*\\.\\s*([A-Za-z_][A-Za-z0-9_$]*)?$`),Kt=new RegExp(`\\b(?:FROM|JOIN)\\s+(${Ye}(?:\\s*\\.\\s*${Ye})*)(?:\\s+(?:AS\\s+)?(${Ye}))?`,"gi"),ji=new Set(["all","cross","except","fetch","for","from","full","group","having","inner","intersect","join","left","limit","offset","on","order","outer","right","select","union","where"]);function _e(s){const t=s.trim();return t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1).replace(/""/g,'"'):t.toLowerCase()}function As(s){const t=[];let e="",n=!1;for(let o=0;o<s.length;o++){const a=s[o];if(a==='"'){if(e+=a,n&&s[o+1]==='"'){e+=s[o+1],o++;continue}n=!n;continue}if(!n&&a==="."){e.trim()&&t.push(e.trim()),e="";continue}e+=a}return e.trim()&&t.push(e.trim()),t}function Ui(s,t){let n=cs(s).resolveInner(t,-1);for(;n;){if(n.type.name==="Statement")return n;n=n.parent}return null}function Qi(s){const t=new Map;let e=Kt.exec(s);for(;e!==null;){const n=e[1],o=e[2];if(n){const l=As(n).at(-1);if(l&&t.set(_e(l),n),o){const i=_e(o);ji.has(i)||t.set(i,n)}}e=Kt.exec(s)}return t}function Hi(s){return/Comment|String/.test(s.type.name)}function it(s,t){if(!s.tableDetails)return null;for(const[e,n]of Object.entries(s.tableDetails))if(_e(e)===t)return{tableName:e,schemaName:s.name,tableInfo:n};return null}function ut({tableReference:s,tableName:t,schemaName:e,tableInfo:n}){var o,a;return{tableName:t,schemaName:e,tableReference:s,columns:n.columns||[],primaryKeyColumns:new Set(((o=n.primary_keys)==null?void 0:o.map(l=>l.column))||[]),foreignKeysByColumn:new Map(((a=n.foreign_keys)==null?void 0:a.map(l=>[l.column,l]))||[])}}function Wi({tableReference:s,schemas:t,defaultSchemaName:e}){if(!(t!=null&&t.length))return null;const n=As(s).map(i=>_e(i));if(!n.length)return null;const o=n[n.length-1],a=n.length>1?n[n.length-2]:void 0;if(a){const i=t.find(u=>_e(u.name)===a);if(i){const u=it(i,o);if(u)return ut({tableReference:s,tableName:u.tableName,schemaName:u.schemaName,tableInfo:u.tableInfo})}}const l=_e(e);if(l){const i=t.find(u=>_e(u.name)===l);if(i){const u=it(i,o);if(u)return ut({tableReference:s,tableName:u.tableName,schemaName:u.schemaName,tableInfo:u.tableInfo})}}for(const i of t){const u=it(i,o);if(u)return ut({tableReference:s,tableName:u.tableName,schemaName:u.schemaName,tableInfo:u.tableInfo})}return null}function Gi(s){return[...s.columns].sort((e,n)=>(e.ordinal_position||0)-(n.ordinal_position||0)).map(e=>io({column:e,tableName:s.tableName,schemaName:s.schemaName,isPrimaryKey:s.primaryKeyColumns.has(e.name),foreignKey:s.foreignKeysByColumn.get(e.name)}))}function Ki(s,t){const e=cs(s.state).resolveInner(s.pos,-1);if(Hi(e))return null;const n=Ui(s.state,s.pos);if(!n)return null;const o=s.state.doc.sliceString(n.from,s.pos),a=Bi.exec(o);if(!a)return null;const l=a[1],i=a[2]||"",u=_e(l),c=s.state.doc.sliceString(n.from,n.to),m=Qi(c).get(u)||l,y=Wi({tableReference:m,schemas:t.schemas,defaultSchemaName:t.defaultSchemaName});return y?{from:s.pos-i.length,options:Gi(y),validFor:/^[A-Za-z0-9_$]*$/}:null}function Yi(s){return t=>Ki(t,s)}const Ji=async()=>(await us(()=>import("./BiOIaWuc.js"),[],import.meta.url)).default.keywords;function Xi({codeEditorRef:s,fileVariables:t,onExecuteStatement:e,onExplainAnalyzeCurrent:n}){const o=yn(),{schemasByContext:a,activeSchema:l}=ls(o),i=G({line:1,column:1}),u=()=>{var C;return(C=s.value)==null?void 0:C.editorView},c=q(()=>{var C;return((C=l.value)==null?void 0:C.name)||"public"}),d=q(()=>uo({schemas:a.value,defaultSchemaName:c.value,fileVariables:t.value})),m=new Lt,y=new Lt,x=()=>Yi({schemas:a.value,defaultSchemaName:c.value}),{onHandleFormatCurrentStatement:S,onHandleFormatCode:b}=Zn({getEditorView:()=>u()}),g=[Ho(e),es.of([{key:"Mod-s",run:()=>(S(),!0),preventDefault:!0},{key:"Shift-Alt-f",run:()=>(b(),!0),preventDefault:!0},{key:"Mod-e",run:()=>(n(),!0),preventDefault:!0},{key:"Mod-i",run:xn},{key:"Tab",run:bn}]),m.of(Nt({dialect:It.PostgreSQL,upperCaseKeywords:!0,keywordCompletion:Dt,tables:d.value.variableCompletions,schema:d.value.schema,defaultSchema:d.value.defaultSchema})),y.of(nt.language.data.of({autocomplete:x()})),$n,kn,...zn(),ys(),Fi({enableLinting:!1,enableGutterMarkers:!1,enableHover:!0,hoverConfig:{hoverTime:250,enableKeywords:!0,keywords:async()=>await Ji(),enableTables:!1,enableColumns:!1,enableFuzzySearch:!1}}),Xn],_=()=>{const C=u();C&&C.dispatch({effects:[eo.of({dialect:nt,isEnable:!0}),m.reconfigure(Nt({dialect:It.PostgreSQL,upperCaseKeywords:!0,keywordCompletion:Dt,tables:d.value.variableCompletions,schema:d.value.schema,defaultSchema:d.value.defaultSchema})),y.reconfigure(nt.language.data.of({autocomplete:x()}))]})};return ge(()=>{var C;return[(C=l.value)==null?void 0:C.name,a.value]},()=>{var C;(C=l.value)!=null&&C.name&&_()},{deep:!0,immediate:!0}),{extensions:g,sqlCompartment:m,cursorInfo:i,onHandleFormatCode:b,onHandleFormatCurrentStatement:S,reloadSqlCompartment:_}}function Zi({fileVariables:s,connection:t,fieldDefs:e}){const n=G(null),{explainAnalyzeOptionItems:o,serializeMode:a,toggleExplainOption:l,setSerializeMode:i,buildExplainAnalyzePrefix:u}=xi(),c=bi(),m=yi({getEditorView:()=>{var x;return((x=n.value)==null?void 0:x.editorView)??null},connection:t,fileVariables:s,fieldDefs:e,resultTabs:c,buildExplainAnalyzePrefix:u}),y=Xi({codeEditorRef:n,fileVariables:s,onExecuteStatement:m.executeCurrentStatement,onExplainAnalyzeCurrent:m.onExplainAnalyzeCurrent});return{codeEditorRef:n,currentRawQueryResult:m.currentRawQueryResult,rawResponse:m.rawResponse,queryProcessState:m.queryProcessState,onExecuteCurrent:m.onExecuteCurrent,extensions:y.extensions,sqlCompartment:y.sqlCompartment,cursorInfo:y.cursorInfo,onHandleFormatCode:y.onHandleFormatCode,onHandleFormatCurrentStatement:y.onHandleFormatCurrentStatement,onExplainAnalyzeCurrent:m.onExplainAnalyzeCurrent,explainAnalyzeOptionItems:o,serializeMode:a,toggleExplainOption:l,setSerializeMode:i,reloadSqlCompartment:y.reloadSqlCompartment,cancelStreamingQuery:m.cancelStreamingQuery,executedResults:c.executedResults,activeResultTabId:c.activeResultTabId,setActiveResultTab:c.setActiveResultTab,closeResultTab:c.closeResultTab,closeOtherResultTabs:c.closeOtherResultTabs,closeResultTabsToRight:c.closeResultTabsToRight,updateResultTabView:c.updateResultTabView}}const ct=s=>{const{currentStatements:t}=Je(s);if(!t.length)return null;const e=Math.min(...t.map(a=>a.from)),n=Math.max(...t.map(a=>a.to));return{text:t.map(a=>a.text).join(`
21
+ `),from:e,to:n}};function eu(s){const t=G(!1),e=G(!1),n=()=>{const u=s.getEditorView();if(!u)return;const c=ct(u);c&&navigator.clipboard.writeText(c.text)},o=()=>{const u=s.getEditorView();if(!u)return;const c=u.state.doc.toString();c&&navigator.clipboard.writeText(c)},a=()=>{const u=s.getEditorView();if(!u)return;const c=ct(u);if(!c)return;let d=c.to;const m=u.state.doc.length;for(;d<m;){const y=u.state.sliceDoc(d,d+1);if(y===`
22
+ `||y==="\r"){d++;break}if(y===" "||y===" ")d++;else break}u.dispatch({changes:{from:c.from,to:d,insert:""},annotations:[_n.addToHistory.of(!0)]}),u.focus()};return{contextMenuItems:q(()=>{const u=!t.value,c=!e.value;return[{type:F.ACTION,title:"Execute",icon:"hugeicons:play",shortcut:"⌘↵",select:s.onExecuteCurrent,disabled:u},{type:F.ACTION,title:"Analyze Query",icon:"hugeicons:analytics-01",shortcut:"⌘E",select:s.onExplainAnalyzeCurrent,disabled:u},{type:F.SEPARATOR},{type:F.ACTION,title:"Format Current",icon:"hugeicons:magic-wand-01",shortcut:"⌘S",select:s.onHandleFormatCurrentStatement,disabled:u},{type:F.ACTION,title:"Format All",icon:"hugeicons:text-align-left",shortcut:"⇧⌥F",select:s.onHandleFormatCode,disabled:c},{type:F.SEPARATOR},{type:F.ACTION,title:"Copy Statement",icon:"hugeicons:copy-02",select:n,disabled:u},{type:F.ACTION,title:"Copy All",icon:"hugeicons:copy-01",select:o,disabled:c},{type:F.SEPARATOR},{type:F.ACTION,title:"Delete Statement",icon:"hugeicons:delete-02",select:a,disabled:u}]}),onContextMenuOpen:u=>{if(!u)return;const c=s.getEditorView();if(!c){t.value=!1,e.value=!1;return}e.value=c.state.doc.length>0,t.value=!!ct(c)}}}function tu(){const{workspaceId:s}=Cn(),t=ds(),e=Sn(),n=wn(),o=e.getFileContentByIdSync(t.params.fileId),a=G((o==null?void 0:o.contents)??""),l=G((o==null?void 0:o.variables)??""),i=G([]),u=q(()=>{var _;return(_=e==null?void 0:e.flatNodes)==null?void 0:_.find(C=>C.id===t.params.fileId)}),c=q(()=>n.getConnectionsByWorkspaceId(s.value)),d=q(()=>c.value.find(_=>{var C;return _.id===((C=u.value)==null?void 0:C.connectionId)}));return{fieldDefs:i,fileContents:a,fileVariables:l,currentFile:u,updateFileConnection:async _=>{var C;(C=u.value)!=null&&C.id&&await e.updateFile({id:u.value.id,connectionId:_})},updateFileContent:async _=>{var C;(C=u.value)!=null&&C.id&&(a.value=_,e.updateFileContent({contents:_,id:u.value.id,variables:l.value||""}))},updateFileVariables:async _=>{var C;(C=u.value)!=null&&C.id&&(l.value=_,e.updateFileContent({contents:a.value,id:u.value.id,variables:_}))},connection:d,connectionsByWsId:c,updateFileCursorPos:_=>{var C;(C=u.value)!=null&&C.id&&e.updateFile({id:u.value.id,cursorPos:_})},loadFileContent:async()=>{const{contents:_,variables:C}=await e.getFileContentById(t.params.fileId);a.value=_,l.value=C},isFromCache:o!==null}}const su={class:"flex flex-col h-full p-1"},nu={class:"flex flex-col h-full border rounded-md"},ou={class:"h-full flex flex-col overflow-y-auto"},au={class:"flex flex-col h-full border rounded-md bg-muted"},ru={class:"flex items-center gap-1 font-normal text-sm px-2 py-1"},lu={class:"h-full flex flex-col overflow-y-auto"},iu=H({__name:"RawQuery",setup(s){const t=ds(),e=rs(),n=tu(),{connection:o,currentFile:a,fileContents:l,fileVariables:i,updateFileConnection:u,updateFileContent:c,updateFileVariables:d,connectionsByWsId:m,fieldDefs:y}=mt(n),x=Zi({connection:o,fieldDefs:y,fileVariables:i}),{cursorInfo:S,extensions:b,codeEditorRef:g,onExecuteCurrent:_,onHandleFormatCode:C,onHandleFormatCurrentStatement:k,onExplainAnalyzeCurrent:V,explainAnalyzeOptionItems:T,serializeMode:U,currentRawQueryResult:D,queryProcessState:N,executedResults:B,activeResultTabId:O}=mt(x),{contextMenuItems:P,onContextMenuOpen:W}=eu({onExecuteCurrent:x.onExecuteCurrent,onExplainAnalyzeCurrent:x.onExplainAnalyzeCurrent,onHandleFormatCurrentStatement:x.onHandleFormatCurrentStatement,onHandleFormatCode:x.onHandleFormatCode,getEditorView:()=>{var de;return(de=g.value)==null?void 0:de.editorView}}),X=G(0),ee=G(!0);Tn([{key:"mod+j",callback:()=>{ee.value=!ee.value}},{key:"ctrl+j",callback:()=>{ee.value=!ee.value}}]),ge(i,()=>{x.reloadSqlCompartment()});const Ae=({column:de,from:he,line:ye,to:be})=>{S.value={column:de,line:ye},n.updateFileCursorPos({from:he,to:be})},Te=(de=!0)=>{var be,Be;if(!((be=a.value)!=null&&be.cursorPos)||!((Be=g.value)!=null&&Be.editorView))return;const he=a.value.cursorPos.from??0,ye=a.value.cursorPos.to||0;g.value.setCursorPosition({from:he,to:ye,allowScroll:de})},Oe=G(!n.isFromCache);return Ct(async()=>{Oe.value&&(await n.loadFileContent(),Oe.value=!1,await ve()),Te()}),En(async()=>{var de;await ve(),Te(!1),(de=g.value)!=null&&de.editorView&&(g.value.editorView.scrollDOM.scrollTop=X.value)}),(de,he)=>{const ye=ce;return v(),R(Na,{layout:r(e).codeEditorLayout,customLayout:r(e).activeCustomLayout,"show-result-panel":r(ee)},{content:h(()=>[f("div",su,[f("div",nu,[p(ka,{"onUpdate:connectionId":r(u),connections:r(m),connection:r(o),workspaceId:r(t).params.workspaceId,"file-variables":r(i),"code-editor-layout":r(e).codeEditorLayout,currentFileInfo:r(a),"onUpdate:updateFileVariables":r(d)},null,8,["onUpdate:connectionId","connections","connection","workspaceId","file-variables","code-editor-layout","currentFileInfo","onUpdate:updateFileVariables"]),f("div",ou,[p(ea,{"context-menu-items":r(P),"onUpdate:open":r(W)},{default:h(()=>[r(Oe)?(v(),R(r(is),{key:0,visible:""})):(v(),R(ms,{key:1,"onUpdate:modelValue":r(c),"onUpdate:cursorInfo":Ae,"onUpdate:onScrollTop":he[0]||(he[0]=be=>X.value=be),modelValue:r(l),extensions:r(b),ref_key:"codeEditorRef",ref:g},null,8,["onUpdate:modelValue","modelValue","extensions"]))]),_:1},8,["context-menu-items","onUpdate:open"])]),p(xa,{"cursor-info":r(S),"execute-loading":r(N).executeLoading,"execute-errors":!!r(N).executeErrors,"is-have-one-execute":r(N).isHaveOneExecute,"is-streaming":r(N).isStreaming,"streaming-row-count":r(N).streamingRowCount,queryTime:r(N).queryTime,"raw-query-results-length":r(D).length,"explain-analyze-option-items":r(T),"serialize-mode":r(U),onOnFormatCurrentStatement:r(k),onOnFormatAll:r(C),onOnExplainAnalyzeCurrent:r(V),onToggleExplainOption:r(x).toggleExplainOption,"onUpdate:serializeMode":r(x).setSerializeMode,onOnExecuteCurrent:r(_),onOnCancelQuery:r(x).cancelStreamingQuery},null,8,["cursor-info","execute-loading","execute-errors","is-have-one-execute","is-streaming","streaming-row-count","queryTime","raw-query-results-length","explain-analyze-option-items","serialize-mode","onOnFormatCurrentStatement","onOnFormatAll","onOnExplainAnalyzeCurrent","onToggleExplainOption","onUpdate:serializeMode","onOnExecuteCurrent","onOnCancelQuery"])])])]),variables:h(()=>[f("div",au,[f("div",ru,[p(ye,{name:"hugeicons:absolute"}),he[1]||(he[1]=L(" Variables "))]),f("div",lu,[p(Cs,{onUpdateVariables:r(d),"file-variables":r(i)},null,8,["onUpdateVariables","file-variables"])])])]),result:h(()=>[r(B).size===0?(v(),R(Xo,{key:0})):(v(),R(vi,{key:1,"executed-results":r(B),"active-tab-id":r(O),"execute-loading":r(N).executeLoading,"is-streaming":r(N).isStreaming,"onUpdate:activeTab":r(x).setActiveResultTab,onCloseTab:r(x).closeResultTab,onCloseOtherTabs:r(x).closeOtherResultTabs,onCloseTabsToRight:r(x).closeResultTabsToRight,"onUpdate:view":r(x).updateResultTabView},null,8,["executed-results","active-tab-id","execute-loading","is-streaming","onUpdate:activeTab","onCloseTab","onCloseOtherTabs","onCloseTabsToRight","onUpdate:view"]))]),_:1},8,["layout","customLayout","show-result-panel"])}}}),Du=H({__name:"[fileId]",setup(s){return(t,e)=>(v(),R(iu))}});export{Du as default};
@@ -0,0 +1,89 @@
1
+ import{_ as c,l as te,c as W,L as fe,ah as ye,ai as be,aj as me,ac as _e,I as Y,i as G,v as ke,J as Ee,ad as Se,ae as le,af as ce}from"./D4jn2f-6.js";import{g as Ne}from"./ACOLmAuq.js";import"./BM4vnZvX.js";var $=function(){var t=c(function(_,s,n,a){for(n=n||{},a=_.length;a--;n[_[a]]=s);return n},"o"),g=[1,4],d=[1,13],r=[1,12],p=[1,15],k=[1,16],f=[1,20],h=[1,19],L=[6,7,8],C=[1,26],w=[1,24],N=[1,25],i=[6,7,11],j=[1,31],x=[6,7,11,24],P=[1,6,13,16,17,20,23],M=[1,35],U=[1,36],A=[1,6,7,11,13,16,17,20,23],H=[1,38],V={trace:c(function(){},"trace"),yy:{},symbols_:{error:2,start:3,mindMap:4,spaceLines:5,SPACELINE:6,NL:7,KANBAN:8,document:9,stop:10,EOF:11,statement:12,SPACELIST:13,node:14,shapeData:15,ICON:16,CLASS:17,nodeWithId:18,nodeWithoutId:19,NODE_DSTART:20,NODE_DESCR:21,NODE_DEND:22,NODE_ID:23,SHAPE_DATA:24,$accept:0,$end:1},terminals_:{2:"error",6:"SPACELINE",7:"NL",8:"KANBAN",11:"EOF",13:"SPACELIST",16:"ICON",17:"CLASS",20:"NODE_DSTART",21:"NODE_DESCR",22:"NODE_DEND",23:"NODE_ID",24:"SHAPE_DATA"},productions_:[0,[3,1],[3,2],[5,1],[5,2],[5,2],[4,2],[4,3],[10,1],[10,1],[10,1],[10,2],[10,2],[9,3],[9,2],[12,3],[12,2],[12,2],[12,2],[12,1],[12,2],[12,1],[12,1],[12,1],[12,1],[14,1],[14,1],[19,3],[18,1],[18,4],[15,2],[15,1]],performAction:c(function(s,n,a,o,u,e,B){var l=e.length-1;switch(u){case 6:case 7:return o;case 8:o.getLogger().trace("Stop NL ");break;case 9:o.getLogger().trace("Stop EOF ");break;case 11:o.getLogger().trace("Stop NL2 ");break;case 12:o.getLogger().trace("Stop EOF2 ");break;case 15:o.getLogger().info("Node: ",e[l-1].id),o.addNode(e[l-2].length,e[l-1].id,e[l-1].descr,e[l-1].type,e[l]);break;case 16:o.getLogger().info("Node: ",e[l].id),o.addNode(e[l-1].length,e[l].id,e[l].descr,e[l].type);break;case 17:o.getLogger().trace("Icon: ",e[l]),o.decorateNode({icon:e[l]});break;case 18:case 23:o.decorateNode({class:e[l]});break;case 19:o.getLogger().trace("SPACELIST");break;case 20:o.getLogger().trace("Node: ",e[l-1].id),o.addNode(0,e[l-1].id,e[l-1].descr,e[l-1].type,e[l]);break;case 21:o.getLogger().trace("Node: ",e[l].id),o.addNode(0,e[l].id,e[l].descr,e[l].type);break;case 22:o.decorateNode({icon:e[l]});break;case 27:o.getLogger().trace("node found ..",e[l-2]),this.$={id:e[l-1],descr:e[l-1],type:o.getType(e[l-2],e[l])};break;case 28:this.$={id:e[l],descr:e[l],type:0};break;case 29:o.getLogger().trace("node found ..",e[l-3]),this.$={id:e[l-3],descr:e[l-1],type:o.getType(e[l-2],e[l])};break;case 30:this.$=e[l-1]+e[l];break;case 31:this.$=e[l];break}},"anonymous"),table:[{3:1,4:2,5:3,6:[1,5],8:g},{1:[3]},{1:[2,1]},{4:6,6:[1,7],7:[1,8],8:g},{6:d,7:[1,10],9:9,12:11,13:r,14:14,16:p,17:k,18:17,19:18,20:f,23:h},t(L,[2,3]),{1:[2,2]},t(L,[2,4]),t(L,[2,5]),{1:[2,6],6:d,12:21,13:r,14:14,16:p,17:k,18:17,19:18,20:f,23:h},{6:d,9:22,12:11,13:r,14:14,16:p,17:k,18:17,19:18,20:f,23:h},{6:C,7:w,10:23,11:N},t(i,[2,24],{18:17,19:18,14:27,16:[1,28],17:[1,29],20:f,23:h}),t(i,[2,19]),t(i,[2,21],{15:30,24:j}),t(i,[2,22]),t(i,[2,23]),t(x,[2,25]),t(x,[2,26]),t(x,[2,28],{20:[1,32]}),{21:[1,33]},{6:C,7:w,10:34,11:N},{1:[2,7],6:d,12:21,13:r,14:14,16:p,17:k,18:17,19:18,20:f,23:h},t(P,[2,14],{7:M,11:U}),t(A,[2,8]),t(A,[2,9]),t(A,[2,10]),t(i,[2,16],{15:37,24:j}),t(i,[2,17]),t(i,[2,18]),t(i,[2,20],{24:H}),t(x,[2,31]),{21:[1,39]},{22:[1,40]},t(P,[2,13],{7:M,11:U}),t(A,[2,11]),t(A,[2,12]),t(i,[2,15],{24:H}),t(x,[2,30]),{22:[1,41]},t(x,[2,27]),t(x,[2,29])],defaultActions:{2:[2,1],6:[2,2]},parseError:c(function(s,n){if(n.recoverable)this.trace(s);else{var a=new Error(s);throw a.hash=n,a}},"parseError"),parse:c(function(s){var n=this,a=[0],o=[],u=[null],e=[],B=this.table,l="",z=0,ie=0,ue=2,re=1,ge=e.slice.call(arguments,1),b=Object.create(this.lexer),T={yy:{}};for(var J in this.yy)Object.prototype.hasOwnProperty.call(this.yy,J)&&(T.yy[J]=this.yy[J]);b.setInput(s,T.yy),T.yy.lexer=b,T.yy.parser=this,typeof b.yylloc>"u"&&(b.yylloc={});var q=b.yylloc;e.push(q);var de=b.options&&b.options.ranges;typeof T.yy.parseError=="function"?this.parseError=T.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function pe(S){a.length=a.length-2*S,u.length=u.length-S,e.length=e.length-S}c(pe,"popStack");function ae(){var S;return S=o.pop()||b.lex()||re,typeof S!="number"&&(S instanceof Array&&(o=S,S=o.pop()),S=n.symbols_[S]||S),S}c(ae,"lex");for(var E,R,v,Q,F={},X,I,oe,K;;){if(R=a[a.length-1],this.defaultActions[R]?v=this.defaultActions[R]:((E===null||typeof E>"u")&&(E=ae()),v=B[R]&&B[R][E]),typeof v>"u"||!v.length||!v[0]){var Z="";K=[];for(X in B[R])this.terminals_[X]&&X>ue&&K.push("'"+this.terminals_[X]+"'");b.showPosition?Z="Parse error on line "+(z+1)+`:
2
+ `+b.showPosition()+`
3
+ Expecting `+K.join(", ")+", got '"+(this.terminals_[E]||E)+"'":Z="Parse error on line "+(z+1)+": Unexpected "+(E==re?"end of input":"'"+(this.terminals_[E]||E)+"'"),this.parseError(Z,{text:b.match,token:this.terminals_[E]||E,line:b.yylineno,loc:q,expected:K})}if(v[0]instanceof Array&&v.length>1)throw new Error("Parse Error: multiple actions possible at state: "+R+", token: "+E);switch(v[0]){case 1:a.push(E),u.push(b.yytext),e.push(b.yylloc),a.push(v[1]),E=null,ie=b.yyleng,l=b.yytext,z=b.yylineno,q=b.yylloc;break;case 2:if(I=this.productions_[v[1]][1],F.$=u[u.length-I],F._$={first_line:e[e.length-(I||1)].first_line,last_line:e[e.length-1].last_line,first_column:e[e.length-(I||1)].first_column,last_column:e[e.length-1].last_column},de&&(F._$.range=[e[e.length-(I||1)].range[0],e[e.length-1].range[1]]),Q=this.performAction.apply(F,[l,ie,z,T.yy,v[1],u,e].concat(ge)),typeof Q<"u")return Q;I&&(a=a.slice(0,-1*I*2),u=u.slice(0,-1*I),e=e.slice(0,-1*I)),a.push(this.productions_[v[1]][0]),u.push(F.$),e.push(F._$),oe=B[a[a.length-2]][a[a.length-1]],a.push(oe);break;case 3:return!0}}return!0},"parse")},m=function(){var _={EOF:1,parseError:c(function(n,a){if(this.yy.parser)this.yy.parser.parseError(n,a);else throw new Error(n)},"parseError"),setInput:c(function(s,n){return this.yy=n||this.yy||{},this._input=s,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:c(function(){var s=this._input[0];this.yytext+=s,this.yyleng++,this.offset++,this.match+=s,this.matched+=s;var n=s.match(/(?:\r\n?|\n).*/g);return n?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),s},"input"),unput:c(function(s){var n=s.length,a=s.split(/(?:\r\n?|\n)/g);this._input=s+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-n),this.offset-=n;var o=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),a.length-1&&(this.yylineno-=a.length-1);var u=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:a?(a.length===o.length?this.yylloc.first_column:0)+o[o.length-a.length].length-a[0].length:this.yylloc.first_column-n},this.options.ranges&&(this.yylloc.range=[u[0],u[0]+this.yyleng-n]),this.yyleng=this.yytext.length,this},"unput"),more:c(function(){return this._more=!0,this},"more"),reject:c(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
4
+ `+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:c(function(s){this.unput(this.match.slice(s))},"less"),pastInput:c(function(){var s=this.matched.substr(0,this.matched.length-this.match.length);return(s.length>20?"...":"")+s.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:c(function(){var s=this.match;return s.length<20&&(s+=this._input.substr(0,20-s.length)),(s.substr(0,20)+(s.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:c(function(){var s=this.pastInput(),n=new Array(s.length+1).join("-");return s+this.upcomingInput()+`
5
+ `+n+"^"},"showPosition"),test_match:c(function(s,n){var a,o,u;if(this.options.backtrack_lexer&&(u={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(u.yylloc.range=this.yylloc.range.slice(0))),o=s[0].match(/(?:\r\n?|\n).*/g),o&&(this.yylineno+=o.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:o?o[o.length-1].length-o[o.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+s[0].length},this.yytext+=s[0],this.match+=s[0],this.matches=s,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(s[0].length),this.matched+=s[0],a=this.performAction.call(this,this.yy,this,n,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),a)return a;if(this._backtrack){for(var e in u)this[e]=u[e];return!1}return!1},"test_match"),next:c(function(){if(this.done)return this.EOF;this._input||(this.done=!0);var s,n,a,o;this._more||(this.yytext="",this.match="");for(var u=this._currentRules(),e=0;e<u.length;e++)if(a=this._input.match(this.rules[u[e]]),a&&(!n||a[0].length>n[0].length)){if(n=a,o=e,this.options.backtrack_lexer){if(s=this.test_match(a,u[e]),s!==!1)return s;if(this._backtrack){n=!1;continue}else return!1}else if(!this.options.flex)break}return n?(s=this.test_match(n,u[o]),s!==!1?s:!1):this._input===""?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+`. Unrecognized text.
6
+ `+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:c(function(){var n=this.next();return n||this.lex()},"lex"),begin:c(function(n){this.conditionStack.push(n)},"begin"),popState:c(function(){var n=this.conditionStack.length-1;return n>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:c(function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},"_currentRules"),topState:c(function(n){return n=this.conditionStack.length-1-Math.abs(n||0),n>=0?this.conditionStack[n]:"INITIAL"},"topState"),pushState:c(function(n){this.begin(n)},"pushState"),stateStackSize:c(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:c(function(n,a,o,u){switch(o){case 0:return this.pushState("shapeData"),a.yytext="",24;case 1:return this.pushState("shapeDataStr"),24;case 2:return this.popState(),24;case 3:const e=/\n\s*/g;return a.yytext=a.yytext.replace(e,"<br/>"),24;case 4:return 24;case 5:this.popState();break;case 6:return n.getLogger().trace("Found comment",a.yytext),6;case 7:return 8;case 8:this.begin("CLASS");break;case 9:return this.popState(),17;case 10:this.popState();break;case 11:n.getLogger().trace("Begin icon"),this.begin("ICON");break;case 12:return n.getLogger().trace("SPACELINE"),6;case 13:return 7;case 14:return 16;case 15:n.getLogger().trace("end icon"),this.popState();break;case 16:return n.getLogger().trace("Exploding node"),this.begin("NODE"),20;case 17:return n.getLogger().trace("Cloud"),this.begin("NODE"),20;case 18:return n.getLogger().trace("Explosion Bang"),this.begin("NODE"),20;case 19:return n.getLogger().trace("Cloud Bang"),this.begin("NODE"),20;case 20:return this.begin("NODE"),20;case 21:return this.begin("NODE"),20;case 22:return this.begin("NODE"),20;case 23:return this.begin("NODE"),20;case 24:return 13;case 25:return 23;case 26:return 11;case 27:this.begin("NSTR2");break;case 28:return"NODE_DESCR";case 29:this.popState();break;case 30:n.getLogger().trace("Starting NSTR"),this.begin("NSTR");break;case 31:return n.getLogger().trace("description:",a.yytext),"NODE_DESCR";case 32:this.popState();break;case 33:return this.popState(),n.getLogger().trace("node end ))"),"NODE_DEND";case 34:return this.popState(),n.getLogger().trace("node end )"),"NODE_DEND";case 35:return this.popState(),n.getLogger().trace("node end ...",a.yytext),"NODE_DEND";case 36:return this.popState(),n.getLogger().trace("node end (("),"NODE_DEND";case 37:return this.popState(),n.getLogger().trace("node end (-"),"NODE_DEND";case 38:return this.popState(),n.getLogger().trace("node end (-"),"NODE_DEND";case 39:return this.popState(),n.getLogger().trace("node end (("),"NODE_DEND";case 40:return this.popState(),n.getLogger().trace("node end (("),"NODE_DEND";case 41:return n.getLogger().trace("Long description:",a.yytext),21;case 42:return n.getLogger().trace("Long description:",a.yytext),21}},"anonymous"),rules:[/^(?:@\{)/i,/^(?:["])/i,/^(?:["])/i,/^(?:[^\"]+)/i,/^(?:[^}^"]+)/i,/^(?:\})/i,/^(?:\s*%%.*)/i,/^(?:kanban\b)/i,/^(?::::)/i,/^(?:.+)/i,/^(?:\n)/i,/^(?:::icon\()/i,/^(?:[\s]+[\n])/i,/^(?:[\n]+)/i,/^(?:[^\)]+)/i,/^(?:\))/i,/^(?:-\))/i,/^(?:\(-)/i,/^(?:\)\))/i,/^(?:\))/i,/^(?:\(\()/i,/^(?:\{\{)/i,/^(?:\()/i,/^(?:\[)/i,/^(?:[\s]+)/i,/^(?:[^\(\[\n\)\{\}@]+)/i,/^(?:$)/i,/^(?:["][`])/i,/^(?:[^`"]+)/i,/^(?:[`]["])/i,/^(?:["])/i,/^(?:[^"]+)/i,/^(?:["])/i,/^(?:[\)]\))/i,/^(?:[\)])/i,/^(?:[\]])/i,/^(?:\}\})/i,/^(?:\(-)/i,/^(?:-\))/i,/^(?:\(\()/i,/^(?:\()/i,/^(?:[^\)\]\(\}]+)/i,/^(?:.+(?!\(\())/i],conditions:{shapeDataEndBracket:{rules:[],inclusive:!1},shapeDataStr:{rules:[2,3],inclusive:!1},shapeData:{rules:[1,4,5],inclusive:!1},CLASS:{rules:[9,10],inclusive:!1},ICON:{rules:[14,15],inclusive:!1},NSTR2:{rules:[28,29],inclusive:!1},NSTR:{rules:[31,32],inclusive:!1},NODE:{rules:[27,30,33,34,35,36,37,38,39,40,41,42],inclusive:!1},INITIAL:{rules:[0,6,7,8,11,12,13,16,17,18,19,20,21,22,23,24,25,26],inclusive:!0}}};return _}();V.lexer=m;function O(){this.yy={}}return c(O,"Parser"),O.prototype=V,V.Parser=O,new O}();$.parser=$;var xe=$,D=[],ne=[],ee=0,se={},ve=c(()=>{D=[],ne=[],ee=0,se={}},"clear"),De=c(t=>{if(D.length===0)return null;const g=D[0].level;let d=null;for(let r=D.length-1;r>=0;r--)if(D[r].level===g&&!d&&(d=D[r]),D[r].level<g)throw new Error('Items without section detected, found section ("'+D[r].label+'")');return t===(d==null?void 0:d.level)?null:d},"getSection"),he=c(function(){return ne},"getSections"),Le=c(function(){const t=[],g=[],d=he(),r=W();for(const p of d){const k={id:p.id,label:G(p.label??"",r),labelType:"markdown",isGroup:!0,ticket:p.ticket,shape:"kanbanSection",level:p.level,look:r.look};g.push(k);const f=D.filter(h=>h.parentId===p.id);for(const h of f){const L={id:h.id,parentId:p.id,label:G(h.label??"",r),labelType:"markdown",isGroup:!1,ticket:h==null?void 0:h.ticket,priority:h==null?void 0:h.priority,assigned:h==null?void 0:h.assigned,icon:h==null?void 0:h.icon,shape:"kanbanItem",level:h.level,rx:5,ry:5,cssStyles:["text-align: left"]};g.push(L)}}return{nodes:g,edges:t,other:{},config:W()}},"getData"),Oe=c((t,g,d,r,p)=>{var C,w;const k=W();let f=((C=k.mindmap)==null?void 0:C.padding)??Y.mindmap.padding;switch(r){case y.ROUNDED_RECT:case y.RECT:case y.HEXAGON:f*=2}const h={id:G(g,k)||"kbn"+ee++,level:t,label:G(d,k),width:((w=k.mindmap)==null?void 0:w.maxNodeWidth)??Y.mindmap.maxNodeWidth,padding:f,isGroup:!1};if(p!==void 0){let N;p.includes(`
7
+ `)?N=p+`
8
+ `:N=`{
9
+ `+p+`
10
+ }`;const i=ke(N,{schema:Ee});if(i.shape&&(i.shape!==i.shape.toLowerCase()||i.shape.includes("_")))throw new Error(`No such shape: ${i.shape}. Shape names should be lowercase.`);i!=null&&i.shape&&i.shape==="kanbanItem"&&(h.shape=i==null?void 0:i.shape),i!=null&&i.label&&(h.label=i==null?void 0:i.label),i!=null&&i.icon&&(h.icon=i==null?void 0:i.icon.toString()),i!=null&&i.assigned&&(h.assigned=i==null?void 0:i.assigned.toString()),i!=null&&i.ticket&&(h.ticket=i==null?void 0:i.ticket.toString()),i!=null&&i.priority&&(h.priority=i==null?void 0:i.priority)}const L=De(t);L?h.parentId=L.id||"kbn"+ee++:ne.push(h),D.push(h)},"addNode"),y={DEFAULT:0,NO_BORDER:0,ROUNDED_RECT:1,RECT:2,CIRCLE:3,CLOUD:4,BANG:5,HEXAGON:6},Ie=c((t,g)=>{switch(te.debug("In get type",t,g),t){case"[":return y.RECT;case"(":return g===")"?y.ROUNDED_RECT:y.CLOUD;case"((":return y.CIRCLE;case")":return y.CLOUD;case"))":return y.BANG;case"{{":return y.HEXAGON;default:return y.DEFAULT}},"getType"),Ce=c((t,g)=>{se[t]=g},"setElementForId"),we=c(t=>{if(!t)return;const g=W(),d=D[D.length-1];t.icon&&(d.icon=G(t.icon,g)),t.class&&(d.cssClasses=G(t.class,g))},"decorateNode"),Ae=c(t=>{switch(t){case y.DEFAULT:return"no-border";case y.RECT:return"rect";case y.ROUNDED_RECT:return"rounded-rect";case y.CIRCLE:return"circle";case y.CLOUD:return"cloud";case y.BANG:return"bang";case y.HEXAGON:return"hexgon";default:return"no-border"}},"type2Str"),Te=c(()=>te,"getLogger"),Re=c(t=>se[t],"getElementById"),Pe={clear:ve,addNode:Oe,getSections:he,getData:Le,nodeType:y,getType:Ie,setElementForId:Ce,decorateNode:we,type2Str:Ae,getLogger:Te,getElementById:Re},Ve=Pe,Be=c(async(t,g,d,r)=>{var M,U,A,H,V;te.debug(`Rendering kanban diagram
11
+ `+t);const k=r.db.getData(),f=W();f.htmlLabels=!1;const h=fe(g),L=h.append("g");L.attr("class","sections");const C=h.append("g");C.attr("class","items");const w=k.nodes.filter(m=>m.isGroup);let N=0;const i=10,j=[];let x=25;for(const m of w){const O=((M=f==null?void 0:f.kanban)==null?void 0:M.sectionWidth)||200;N=N+1,m.x=O*N+(N-1)*i/2,m.width=O,m.y=0,m.height=O*3,m.rx=5,m.ry=5,m.cssClasses=m.cssClasses+" section-"+N;const _=await ye(L,m);x=Math.max(x,(U=_==null?void 0:_.labelBBox)==null?void 0:U.height),j.push(_)}let P=0;for(const m of w){const O=j[P];P=P+1;const _=((A=f==null?void 0:f.kanban)==null?void 0:A.sectionWidth)||200,s=-_*3/2+x;let n=s;const a=k.nodes.filter(e=>e.parentId===m.id);for(const e of a){if(e.isGroup)throw new Error("Groups within groups are not allowed in Kanban diagrams");e.x=m.x,e.width=_-1.5*i;const l=(await be(C,e,{config:f})).node().getBBox();e.y=n+l.height/2,await me(e),n=e.y+l.height/2+i/2}const o=O.cluster.select("rect"),u=Math.max(n-s+3*i,50)+(x-25);o.attr("height",u)}_e(void 0,h,((H=f.mindmap)==null?void 0:H.padding)??Y.kanban.padding,((V=f.mindmap)==null?void 0:V.useMaxWidth)??Y.kanban.useMaxWidth)},"draw"),Fe={draw:Be},Ge=c(t=>{let g="";for(let r=0;r<t.THEME_COLOR_LIMIT;r++)t["lineColor"+r]=t["lineColor"+r]||t["cScaleInv"+r],Se(t["lineColor"+r])?t["lineColor"+r]=le(t["lineColor"+r],20):t["lineColor"+r]=ce(t["lineColor"+r],20);const d=c((r,p)=>t.darkMode?ce(r,p):le(r,p),"adjuster");for(let r=0;r<t.THEME_COLOR_LIMIT;r++){const p=""+(17-3*r);g+=`
12
+ .section-${r-1} rect, .section-${r-1} path, .section-${r-1} circle, .section-${r-1} polygon, .section-${r-1} path {
13
+ fill: ${d(t["cScale"+r],10)};
14
+ stroke: ${d(t["cScale"+r],10)};
15
+
16
+ }
17
+ .section-${r-1} text {
18
+ fill: ${t["cScaleLabel"+r]};
19
+ }
20
+ .node-icon-${r-1} {
21
+ font-size: 40px;
22
+ color: ${t["cScaleLabel"+r]};
23
+ }
24
+ .section-edge-${r-1}{
25
+ stroke: ${t["cScale"+r]};
26
+ }
27
+ .edge-depth-${r-1}{
28
+ stroke-width: ${p};
29
+ }
30
+ .section-${r-1} line {
31
+ stroke: ${t["cScaleInv"+r]} ;
32
+ stroke-width: 3;
33
+ }
34
+
35
+ .disabled, .disabled circle, .disabled text {
36
+ fill: lightgray;
37
+ }
38
+ .disabled text {
39
+ fill: #efefef;
40
+ }
41
+
42
+ .node rect,
43
+ .node circle,
44
+ .node ellipse,
45
+ .node polygon,
46
+ .node path {
47
+ fill: ${t.background};
48
+ stroke: ${t.nodeBorder};
49
+ stroke-width: 1px;
50
+ }
51
+
52
+ .kanban-ticket-link {
53
+ fill: ${t.background};
54
+ stroke: ${t.nodeBorder};
55
+ text-decoration: underline;
56
+ }
57
+ `}return g},"genSections"),je=c(t=>`
58
+ .edge {
59
+ stroke-width: 3;
60
+ }
61
+ ${Ge(t)}
62
+ .section-root rect, .section-root path, .section-root circle, .section-root polygon {
63
+ fill: ${t.git0};
64
+ }
65
+ .section-root text {
66
+ fill: ${t.gitBranchLabel0};
67
+ }
68
+ .icon-container {
69
+ height:100%;
70
+ display: flex;
71
+ justify-content: center;
72
+ align-items: center;
73
+ }
74
+ .edge {
75
+ fill: none;
76
+ }
77
+ .cluster-label, .label {
78
+ color: ${t.textColor};
79
+ fill: ${t.textColor};
80
+ }
81
+ .kanban-label {
82
+ dy: 1em;
83
+ alignment-baseline: middle;
84
+ text-anchor: middle;
85
+ dominant-baseline: middle;
86
+ text-align: center;
87
+ }
88
+ ${Ne()}
89
+ `,"getStyles"),Me=je,ze={db:Ve,renderer:Fe,parser:xe,styles:Me};export{ze as diagram};
@@ -0,0 +1 @@
1
+ import{d as o,m as a,n,u as r,e as c,f as l,o as u}from"./BM4vnZvX.js";const d=o({__name:"ContextMenuShortcut",props:{class:{}},setup(t){const e=t;return(s,m)=>(u(),a("span",{"data-slot":"context-menu-shortcut",class:n(r(c)("text-muted-foreground ml-auto text-xs tracking-widest",e.class))},[l(s.$slots,"default")],2))}});export{d as _};