orcaq 1.1.2 → 1.1.4
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.
- package/.output/nitro.json +1 -1
- package/.output/public/_nuxt/{CDJKw_ak.js → -sZwfgN3.js} +1 -1
- package/.output/public/_nuxt/1iqadsOZ.js +1 -0
- package/.output/public/_nuxt/2WkPV7Mp.js +22 -0
- package/.output/public/_nuxt/{Bq7OeLM1.js → 2XEGje4L.js} +1 -1
- package/.output/public/_nuxt/{atdCACH-.js → 5cKDQgbQ.js} +1 -1
- package/.output/public/_nuxt/{C3ZBsVV_.js → B8rT4ISg.js} +2 -2
- package/.output/public/_nuxt/{C7BQpy74.js → B9Yq_mZo.js} +1 -1
- package/.output/public/_nuxt/{Ca0KO9Xq.js → BCFLQ_rL.js} +1 -1
- package/.output/public/_nuxt/{BWebIWit.js → BIHJR--x.js} +1 -1
- package/.output/public/_nuxt/{DSaBCmOg.js → BN9sUptU.js} +1 -1
- package/.output/public/_nuxt/{BjqbQLK3.js → BNkZeak0.js} +1 -1
- package/.output/public/_nuxt/{DWqOZJe7.js → BNqd1Zca.js} +1 -1
- package/.output/public/_nuxt/BOZgY48g.js +1 -0
- package/.output/public/_nuxt/{Ci5B19-c.js → BQFJwqXj.js} +1 -1
- package/.output/public/_nuxt/{DAr5YiBT.js → BSBcOKKj.js} +1 -1
- package/.output/public/_nuxt/{dNPwafbq.js → BVl8VKr5.js} +1 -1
- package/.output/public/_nuxt/{B9uki8o2.js → BWphy0Pi.js} +1 -1
- package/.output/public/_nuxt/{DHAL8jJG.js → BXp87mMj.js} +4 -4
- package/.output/public/_nuxt/{8tyEaimf.js → BYY9MB0h.js} +1 -1
- package/.output/public/_nuxt/{BPACuoI0.js → BYav_5oM.js} +1 -1
- package/.output/public/_nuxt/{Bq47tjcm.js → B_J4rjuT.js} +1 -1
- package/.output/public/_nuxt/B_U4hCvn.js +7 -0
- package/.output/public/_nuxt/{B5WGo5x7.js → BdCzQG_z.js} +1 -1
- package/.output/public/_nuxt/{DsmBazLf.js → BdX6JvdH.js} +1 -1
- package/.output/public/_nuxt/{S1qa1a4x.js → BdaSWOzD.js} +1 -1
- package/.output/public/_nuxt/{BcsKoAPU.js → BfSmOVMj.js} +119 -119
- package/.output/public/_nuxt/{xp7rFxcm.js → BiMJOLHR.js} +1 -1
- package/.output/public/_nuxt/{BJCrbji-.js → BlRPNODF.js} +1 -1
- package/.output/public/_nuxt/BmREJclf.js +1 -0
- package/.output/public/_nuxt/{BoMjapT5.js → Bp1mKnR0.js} +1 -1
- package/.output/public/_nuxt/{Cnfx1zWl.js → BqZGP9WI.js} +1 -1
- package/.output/public/_nuxt/{BTYBVtfa.js → BqjMHuu8.js} +1 -1
- package/.output/public/_nuxt/{DuCDilAk.js → Brupmvos.js} +1 -1
- package/.output/public/_nuxt/{B6MkNyZd.js → BsA8eQHh.js} +1 -1
- package/.output/public/_nuxt/Bwe8I9vL.js +1 -0
- package/.output/public/_nuxt/{CrNLwdoE.js → BxdkXfb_.js} +1 -1
- package/.output/public/_nuxt/{BoIj4dtd.js → C20WaARR.js} +1 -1
- package/.output/public/_nuxt/{D4pAW_0T.js → C2kyA9ZS.js} +1 -1
- package/.output/public/_nuxt/C4HRDaS8.js +1 -0
- package/.output/public/_nuxt/{FDw04QOj.js → C5zTeLKh.js} +1 -1
- package/.output/public/_nuxt/{wRAs0MDn.js → C6r_nDJz.js} +1 -1
- package/.output/public/_nuxt/{ioXB9E2w.js → C6yADG7D.js} +1 -1
- package/.output/public/_nuxt/{vhkvHdfO.js → CBfQCVFf.js} +1 -1
- package/.output/public/_nuxt/{BzvSm28k.js → CDPrFhDR.js} +1 -1
- package/.output/public/_nuxt/{D-9vaM6z.js → CFOJLBf2.js} +1 -1
- package/.output/public/_nuxt/{63YtjFEq.js → CJhlBUX_.js} +1 -1
- package/.output/public/_nuxt/{iNy-Nl0_.js → CLXbv9E5.js} +1 -1
- package/.output/public/_nuxt/{DpEV6S2O.js → CMT3TfI0.js} +1 -1
- package/.output/public/_nuxt/{COHOh4Oe.js → CRX1CszZ.js} +1 -1
- package/.output/public/_nuxt/{Bmgr9uz4.js → CYaqLaPZ.js} +1 -1
- package/.output/public/_nuxt/{BEyCol50.js → Cih6uwf6.js} +1 -1
- package/.output/public/_nuxt/{BrNfge84.js → CmzTcheK.js} +1 -1
- package/.output/public/_nuxt/{DDebxXP-.js → CrNrSEll.js} +1 -1
- package/.output/public/_nuxt/{DJH-4SVI.js → CwgI7YXL.js} +1 -1
- package/.output/public/_nuxt/{DEZMnZ2r.js → CxSk31iP.js} +1 -1
- package/.output/public/_nuxt/CyEWn2V2.js +1 -0
- package/.output/public/_nuxt/{xOD4Ev56.js → D-pZQQ02.js} +1 -1
- package/.output/public/_nuxt/{BWZ7atse.js → D0mrO5vS.js} +1 -1
- package/.output/public/_nuxt/{DcCF9IZB.js → D3ujZRkc.js} +1 -1
- package/.output/public/_nuxt/{C2XHqDOf.js → D4PtOV7Y.js} +1 -1
- package/.output/public/_nuxt/{BJVPtt2X.js → D65Keo_g.js} +1 -1
- package/.output/public/_nuxt/{BtyzMl9p.js → D6c_aTbv.js} +1 -1
- package/.output/public/_nuxt/{DNoTlUiY.js → D9SUnmGh.js} +1 -1
- package/.output/public/_nuxt/{BpUSbMUb.js → DDIVwUV6.js} +1 -1
- package/.output/public/_nuxt/{C_7gtl40.js → DDS9xPxH.js} +1 -1
- package/.output/public/_nuxt/{ByiJDSw8.js → DEsdpKnm.js} +1 -1
- package/.output/public/_nuxt/{CMkzSwnO.js → DHnV-0Qj.js} +1 -1
- package/.output/public/_nuxt/{COq7mAG7.js → DIoeBtoF.js} +3 -3
- package/.output/public/_nuxt/{ByibjLZn.js → DKJfWiWm.js} +1 -1
- package/.output/public/_nuxt/{DPIEiNwW.js → DKhuBYhy.js} +1 -1
- package/.output/public/_nuxt/DLTvS7Vr.js +2 -0
- package/.output/public/_nuxt/{dWu56FdP.js → DNgNuAci.js} +1 -1
- package/.output/public/_nuxt/{B8TrrBEb.js → DNpk_jbU.js} +1 -1
- package/.output/public/_nuxt/{C6dIAdHr.js → DQCTvlJf.js} +1 -1
- package/.output/public/_nuxt/DQf3b-ld.js +1 -0
- package/.output/public/_nuxt/{B46blMXm.js → DT4w6IwV.js} +1 -1
- package/.output/public/_nuxt/{CS9hqyP3.js → DUqYnCG7.js} +1 -1
- package/.output/public/_nuxt/{DkD29_YA.js → DYqNroD1.js} +1 -1
- package/.output/public/_nuxt/{Bmx1kTaZ.js → DZ9fd-xA.js} +1 -1
- package/.output/public/_nuxt/{qzrMNYut.js → DaiufW99.js} +1 -1
- package/.output/public/_nuxt/{Sf02B6Pt.js → DdRczQp2.js} +2 -2
- package/.output/public/_nuxt/{L2I3LmpB.js → DdW7QNKl.js} +1 -1
- package/.output/public/_nuxt/{B2IKcIj2.js → Ddtv9Dxp.js} +1 -1
- package/.output/public/_nuxt/Dfzgj0Oq.js +1 -0
- package/.output/public/_nuxt/DgRHzRny.js +1 -0
- package/.output/public/_nuxt/{CAnr3OhD.js → DijSUoYv.js} +1 -1
- package/.output/public/_nuxt/Dm-rJ5VH.js +1 -0
- package/.output/public/_nuxt/{sk7V7xQl.js → DmpCN34M.js} +1 -1
- package/.output/public/_nuxt/{CHEpbbGc.js → DoB1FFC2.js} +1 -1
- package/.output/public/_nuxt/Dp2UQPgO.js +1 -0
- package/.output/public/_nuxt/{CycELG5y.js → DryPPXlb.js} +1 -1
- package/.output/public/_nuxt/{BogEzQi9.js → DyCQWd5B.js} +3 -3
- package/.output/public/_nuxt/{AymhMj9v.js → Ef-1UUMy.js} +1 -1
- package/.output/public/_nuxt/{MW5K_zef.js → HP3PGEjt.js} +1 -1
- package/.output/public/_nuxt/{B73IHAoF.js → KK3goksi.js} +1 -1
- package/.output/public/_nuxt/{kvtnkChG.js → MC96ynYQ.js} +1 -1
- package/.output/public/_nuxt/{BpvGVfME.js → N6_KTIJr.js} +1 -1
- package/.output/public/_nuxt/{Dq1JM9WZ.js → TKeZJpIw.js} +1 -1
- package/.output/public/_nuxt/{DVnDb6ua.js → UHOKyE8O.js} +1 -1
- package/.output/public/_nuxt/{Y1gXUmjt.js → Z42SRPvO.js} +1 -1
- package/.output/public/_nuxt/{DpT8FO1Q.js → _Od8x2z5.js} +1 -1
- package/.output/public/_nuxt/{DMmjWR_K.js → bpGjU0QQ.js} +1 -1
- package/.output/public/_nuxt/builds/latest.json +1 -1
- package/.output/public/_nuxt/builds/meta/9b89410f-7683-420e-9dea-d15741f0e6ce.json +1 -0
- package/.output/public/_nuxt/{CsRSZpa6.js → doR1dsEF.js} +1 -1
- package/.output/public/_nuxt/{DGvAu532.js → e04t7nee.js} +1 -1
- package/.output/public/_nuxt/entry.DEE2Ngsu.css +1 -0
- package/.output/public/_nuxt/{Oe2GG0Lt.js → g4lEPr__.js} +1 -1
- package/.output/public/_nuxt/{Cq-MDPLE.js → l12ZvGEh.js} +1 -1
- package/.output/public/_nuxt/{CSQ0xnqv.js → u7qmw6wa.js} +1 -1
- package/.output/public/_nuxt/{MeLWmO7R.js → xoY3RXI7.js} +1 -1
- package/.output/public/_nuxt/{Bf6Q3Zl5.js → ziSTJBFH.js} +1 -1
- package/.output/server/chunks/build/client.manifest.mjs +651 -650
- package/.output/server/chunks/build/client.manifest.mjs.map +1 -1
- package/.output/server/chunks/nitro/nitro.mjs +650 -650
- package/.output/server/package.json +1 -1
- package/package.json +1 -1
- package/.output/public/_nuxt/BL__uYa3.js +0 -1
- package/.output/public/_nuxt/BRFPdiIh.js +0 -1
- package/.output/public/_nuxt/BS-LtKx4.js +0 -1
- package/.output/public/_nuxt/BTheloyh.js +0 -1
- package/.output/public/_nuxt/Bj7ctTfH.js +0 -1
- package/.output/public/_nuxt/BpLDGvqy.js +0 -1
- package/.output/public/_nuxt/BqU89KuH.js +0 -2
- package/.output/public/_nuxt/CerLmMsC.js +0 -22
- package/.output/public/_nuxt/CtWq1MER.js +0 -7
- package/.output/public/_nuxt/Cww9dXBK.js +0 -1
- package/.output/public/_nuxt/DfNTLojg.js +0 -1
- package/.output/public/_nuxt/JOg_XIAv.js +0 -1
- package/.output/public/_nuxt/M6bBaUHa.js +0 -1
- package/.output/public/_nuxt/_qKPTuua.js +0 -1
- package/.output/public/_nuxt/builds/meta/7c171291-8bbd-4c4c-8904-0afae065b82e.json +0 -1
- package/.output/public/_nuxt/entry.DxCQuGXb.css +0 -1
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as G}from"./C_7gtl40.js";import{d as R,bD as H,e as a,m as d,f as o,bn as U,w as C,g as r,A as j,a0 as K,o as t,z as k,k as V,t as u,l as z,bq as W,r as q,c as M,av as J,F as y,s as T,n as S,j as X,bm as Y,a3 as Z,i as ee,bE as te,bF as se,bG as ne}from"./BcsKoAPU.js";import{_ as oe,a as ae}from"./dNPwafbq.js";import{_ as ie}from"./BWZ7atse.js";import{_ as P}from"./MW5K_zef.js";import{_ as re}from"./Ca0KO9Xq.js";const de={class:"flex flex-col gap-2 rounded-lg border bg-card p-4 sm:flex-row sm:items-end sm:justify-between"},le={class:"flex min-w-0 flex-1 flex-col gap-1.5"},ce={class:"flex h-9 items-center justify-center sm:w-6"},ue={class:"flex min-w-0 flex-1 flex-col gap-1.5"},me=R({__name:"SchemaDiffConnectionSelector",props:{sourceConnection:{},targetConnection:{},connections:{},isLoading:{type:Boolean}},emits:["update:targetConnection","run"],setup(x,{emit:_}){const{workspaceId:p}=H(),l=_;return(n,f)=>{var e,c;const g=U,v=j,w=K;return t(),a("div",de,[d("div",le,[o(g,{class:"text-xs font-medium text-muted-foreground"},{default:C(()=>f[2]||(f[2]=[k("Source")])),_:1}),o(P,{class:"h-9 w-full","workspace-id":r(p)||"","connection-id":((e=n.sourceConnection)==null?void 0:e.id)||"",connection:n.sourceConnection||void 0,connections:n.sourceConnection?[n.sourceConnection]:[],disabled:""},null,8,["workspace-id","connection-id","connection","connections"])]),d("div",ce,[o(v,{name:"hugeicons:arrow-right-02",class:"size-4 text-muted-foreground"})]),d("div",ue,[o(g,{class:"text-xs font-medium text-muted-foreground"},{default:C(()=>f[3]||(f[3]=[k("Target")])),_:1}),o(P,{class:"h-9 w-full","workspace-id":r(p)||"","connection-id":((c=n.targetConnection)==null?void 0:c.id)||"",connection:n.targetConnection||void 0,connections:n.connections,"onUpdate:connectionId":f[0]||(f[0]=$=>l("update:targetConnection",n.connections.find(b=>b.id===$)||null)),"skip-strict-mode-connections":""},null,8,["workspace-id","connection-id","connection","connections"])]),o(w,{disabled:!n.sourceConnection||!n.targetConnection||n.isLoading,size:"sm",onClick:f[1]||(f[1]=$=>l("run"))},{default:C(()=>[n.isLoading?(t(),V(v,{key:0,name:"hugeicons:loading-03",class:"size-4 animate-spin"})):(t(),V(v,{key:1,name:"hugeicons:git-compare",class:"size-4"})),k(" "+u(n.isLoading?"Comparing...":"Run Diff"),1)]),_:1},8,["disabled"])])}}}),fe={class:"flex flex-col gap-3"},pe={class:"flex items-center gap-3"},ge={class:"flex items-center gap-2 text-sm"},xe={class:"text-xs text-muted-foreground"},_e={class:"ml-auto flex items-center gap-2 text-xs"},he={key:0,class:"flex items-center gap-1 rounded-md bg-red-100 px-2 py-1 text-xs text-red-700 dark:bg-red-900/30 dark:text-red-400"},ve={key:0,class:"flex items-start gap-2 rounded-md border border-amber-200 bg-amber-50 p-3 text-xs text-amber-800 dark:border-amber-800 dark:bg-amber-900/20 dark:text-amber-300"},ye={key:2,class:"min-h-32 flex items-center justify-center rounded-md border bg-muted/30 p-4 font-mono text-xs text-muted-foreground"},ke=R({__name:"SchemaDiffSqlPanel",props:{sql:{},safeMode:{type:Boolean},statementCount:{},destructiveCount:{}},emits:["update:safeMode"],setup(x,{emit:_}){const p=_;return(l,n)=>{const f=j,g=U,v=W,w=re;return t(),a("div",fe,[d("div",pe,[d("div",ge,[o(f,{name:"hugeicons:code",class:"size-4 text-muted-foreground"}),n[1]||(n[1]=d("span",{class:"font-medium"},"Generated SQL",-1)),d("span",xe,"("+u(l.statementCount)+" statements)",1)]),d("div",_e,[o(g,{for:"safe-mode-toggle",class:"cursor-pointer text-muted-foreground"},{default:C(()=>n[2]||(n[2]=[k(" Safe mode ")])),_:1}),o(v,{id:"safe-mode-toggle","model-value":l.safeMode,"onUpdate:modelValue":n[0]||(n[0]=e=>p("update:safeMode",e))},null,8,["model-value"])]),l.destructiveCount>0&&!l.safeMode?(t(),a("div",he,[o(f,{name:"hugeicons:alert-circle",class:"size-3.5"}),k(" "+u(l.destructiveCount)+" destructive ",1)])):z("",!0)]),l.safeMode?(t(),a("div",ve,[o(f,{name:"hugeicons:shield-01",class:"mt-0.5 size-3.5 shrink-0"}),n[3]||(n[3]=d("span",null,"Safe mode is on — destructive statements (DROP TABLE, DROP COLUMN) are commented out. Disable to include them.",-1))])):z("",!0),l.sql?(t(),V(w,{key:1,code:l.sql,language:"sql","max-height":"400px"},null,8,["code"])):(t(),a("div",ye," No SQL statements generated. "))])}}}),be={class:"space-y-1 font-mono text-sm"},we={class:"mb-3 flex flex-wrap gap-2"},Ce=["onClick"],$e={key:0,class:"divide-y"},Se=["onClick"],ze={class:"flex-1 truncate"},De={class:"flex-1 truncate text-xs"},qe={class:"shrink-0 text-xxs text-muted-foreground"},Le={class:"flex-1 truncate text-xs"},Te={class:"flex-1 truncate"},Me={class:"flex-1 truncate"},Ve={key:0,class:"flex flex-col items-center gap-2 py-12 text-muted-foreground"},Be=R({__name:"SchemaDiffTree",props:{result:{}},setup(x){const _=q(new Set),p=q(new Set),l={added:{label:"Added",class:"text-emerald-600 dark:text-emerald-400",icon:"hugeicons:plus-sign"},removed:{label:"Removed",class:"text-red-600 dark:text-red-400",icon:"hugeicons:minus-sign"},modified:{label:"Modified",class:"text-amber-600 dark:text-amber-400",icon:"hugeicons:edit-02"},unchanged:{label:"Unchanged",class:"text-muted-foreground",icon:"hugeicons:check-01"}},n={added:"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-400 rounded-sm",removed:"bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-400 rounded-sm",modified:"bg-amber-100 text-amber-700 dark:bg-amber-900/40 dark:text-amber-400 rounded-sm"},f=e=>{_.value.has(e)?_.value.delete(e):_.value.add(e)},g=e=>{p.value.has(e)?p.value.delete(e):p.value.add(e)},v=(e,c)=>`${e}.${c}`,w=M(()=>x.result.schemas.filter(e=>e.tables.some(c=>c.status!=="unchanged")||e.views.some(c=>c.status!=="unchanged")||e.functions.some(c=>c.status!=="unchanged")));return J(()=>{for(const e of w.value)_.value.add(e.name)}),(e,c)=>{const $=Y,b=j;return t(),a("div",be,[d("div",we,[(t(!0),a(y,null,T(e.result.summary,(h,s)=>(t(),a(y,{key:s},[s!=="unchanged"?(t(),V($,{key:0,variant:"outline",class:S(r(X)(n[s],"capitalize border-0"))},{default:C(()=>[k(u(h)+" "+u(s),1)]),_:2},1032,["class"])):z("",!0)],64))),128))]),(t(!0),a(y,null,T(r(w),h=>(t(),a("div",{key:h.name,class:"rounded-md border overflow-hidden"},[d("button",{class:"flex w-full items-center gap-2 bg-muted/50 px-3 py-2 text-left text-xs font-semibold capitalize text-muted-foreground hover:bg-muted",onClick:s=>f(h.name)},[o(b,{name:r(_).has(h.name)?"hugeicons:arrow-down-01":"hugeicons:arrow-right-01",class:"size-3.5 shrink-0"},null,8,["name"]),o(b,{name:"hugeicons:database",class:"size-3.5 shrink-0"}),k(" "+u(h.name),1)],8,Ce),r(_).has(h.name)?(t(),a("div",$e,[(t(!0),a(y,null,T(h.tables.filter(s=>s.status!=="unchanged"),s=>(t(),a(y,{key:s.name},[d("div",{class:S(["flex cursor-pointer items-center gap-2 px-4 py-2 hover:bg-muted/30",l[s.status].class]),onClick:i=>g(v(h.name,s.name))},[o(b,{name:r(p).has(v(h.name,s.name))?"hugeicons:arrow-down-01":"hugeicons:arrow-right-01",class:"size-3 shrink-0 text-muted-foreground"},null,8,["name"]),o(b,{name:"hugeicons:table-01",class:"size-3.5 shrink-0"}),d("span",ze,u(s.name),1),d("span",{class:S(["ml-auto shrink-0 rounded px-1.5 py-0.5 text-xxs font-medium capitalize",n[s.status]])},u(s.status),3)],10,Se),r(p).has(v(h.name,s.name))?(t(),a(y,{key:0},[(t(!0),a(y,null,T(s.columns.filter(i=>i.status!=="unchanged"),i=>{var D,m,B;return t(),a("div",{key:i.name,class:S(["flex items-center gap-2 py-1.5 pl-10 pr-4",l[i.status].class])},[o(b,{name:"hugeicons:columns-02",class:"size-3 shrink-0 opacity-60"}),d("span",De,u(i.name),1),d("span",qe,[i.status==="added"?(t(),a(y,{key:0},[k(u((D=i.source)==null?void 0:D.type),1)],64)):i.status==="removed"?(t(),a(y,{key:1},[k(u((m=i.target)==null?void 0:m.type),1)],64)):(B=i.changes)!=null&&B.type?(t(),a(y,{key:2},[k(u(i.changes.type.from)+" → "+u(i.changes.type.to),1)],64)):z("",!0)]),d("span",{class:S(["shrink-0 rounded px-1 py-0.5 text-[9px] font-medium capitalize",n[i.status]])},u(i.status),3)],2)}),128)),(t(!0),a(y,null,T(s.foreignKeys.filter(i=>i.status!=="unchanged"),i=>(t(),a("div",{key:i.key,class:S(["flex items-center gap-2 py-1.5 pl-10 pr-4",l[i.status].class])},[o(b,{name:"hugeicons:link-01",class:"size-3 shrink-0 opacity-60"}),d("span",Le,u(i.key),1),d("span",{class:S(["shrink-0 rounded px-1 py-0.5 text-[9px] font-medium capitalize",n[i.status]])},u(i.status),3)],2))),128))],64)):z("",!0)],64))),128)),(t(!0),a(y,null,T(h.views.filter(s=>s.status!=="unchanged"),s=>(t(),a("div",{key:s.name,class:S(["flex items-center gap-2 px-4 py-2",l[s.status].class])},[o(b,{name:"hugeicons:eye",class:"size-3.5 shrink-0"}),d("span",Te,u(s.name),1),c[0]||(c[0]=d("span",{class:"ml-2 shrink-0 text-xxs text-muted-foreground"},"view",-1)),d("span",{class:S(["ml-auto shrink-0 rounded px-1.5 py-0.5 text-xxs font-medium capitalize",n[s.status]])},u(s.status),3)],2))),128)),(t(!0),a(y,null,T(h.functions.filter(s=>s.status!=="unchanged"),s=>(t(),a("div",{key:s.signature,class:S(["flex items-center gap-2 px-4 py-2",l[s.status].class])},[o(b,{name:"hugeicons:function-of-x",class:"size-3.5 shrink-0"}),d("span",Me,u(s.name),1),c[1]||(c[1]=d("span",{class:"ml-2 shrink-0 text-xxs text-muted-foreground"},"fn",-1)),d("span",{class:S(["ml-auto shrink-0 rounded px-1.5 py-0.5 text-xxs font-medium capitalize",n[s.status]])},u(s.status),3)],2))),128))])):z("",!0)]))),128)),r(w).length===0?(t(),a("div",Ve,[o(b,{name:"hugeicons:checkmark-circle-02",class:"size-10 text-emerald-500"}),c[2]||(c[2]=d("p",{class:"text-sm font-medium"},"Schemas are identical",-1)),c[3]||(c[3]=d("p",{class:"text-xs"},"No differences detected between source and target.",-1))])):z("",!0)])}}}),Ie={diff:x=>$fetch("/api/schema-diff",{method:"POST",body:x})};function Re(){const x=q(null),_=q(!1),p=q(null),l=q(!0),n=e=>({type:e.type,connectionString:e.connectionString,host:e.host,port:e.port,username:e.username,password:e.password,database:e.database,ssl:e.ssl,ssh:e.ssh}),f=async(e,c)=>{_.value=!0,p.value=null,x.value=null;try{x.value=await Ie.diff({source:n(e),target:n(c),safeMode:l.value})}catch($){p.value=$ instanceof Error?$.message:"Schema diff failed. Check connection details."}finally{_.value=!1}},g=()=>{x.value=null,p.value=null},v=M(()=>x.value?l.value?x.value.sql.safe:x.value.sql.full:""),w=M(()=>{if(!x.value)return!1;const{added:e,removed:c,modified:$}=x.value.summary;return e+c+$>0});return{result:x,isLoading:_,error:p,safeMode:l,currentSql:v,hasDifferences:w,runDiff:f,reset:g}}const je={class:"flex h-full flex-col gap-4 overflow-hidden p-4"},Ne={class:"flex items-center justify-between gap-2"},Pe={key:0,class:"ml-1 rounded-full bg-primary px-1.5 py-0.5 text-xxs text-primary-foreground"},Ue={key:0,class:"ml-1 rounded-full bg-muted px-1.5 py-0.5 text-xxs text-muted-foreground"},Ae={class:"text-xs text-muted-foreground"},Ee={key:0,class:"flex-1 overflow-y-auto"},Fe={key:1,class:"flex-1 overflow-y-auto"},Oe={key:2,class:"flex flex-1 flex-col items-center justify-center gap-3 text-muted-foreground"},Xe=R({__name:"SchemaDiffContainer",props:{sourceConnectionId:{}},setup(x){const _=x,p=Z(),l=M(()=>p.connections.find(D=>D.id===_.sourceConnectionId)??null),n=M(()=>p.connections.filter(D=>D.id!==_.sourceConnectionId)),f=q(null),{result:g,isLoading:v,error:w,safeMode:e,currentSql:c,hasDifferences:$,runDiff:b}=Re(),h=async()=>{!l.value||!f.value||await b(l.value,f.value)},s=M(()=>{var D;return((D=g.value)==null?void 0:D.sql.statements.filter(m=>m.destructive).length)??0}),i=q("diff");return(D,m)=>{const B=G,I=j,A=ie,E=ae,F=oe,N=ne,O=se,Q=te;return t(),a("div",je,[o(B,{icon:"hugeicons:git-compare",title:"Schema Diff",description:"Compare schemas between two database connections and generate sync SQL."}),o(me,{"source-connection":r(l),"target-connection":r(f),connections:r(n),"is-loading":r(v),"onUpdate:targetConnection":m[0]||(m[0]=L=>f.value=L),onRun:h},null,8,["source-connection","target-connection","connections","is-loading"]),r(w)?(t(),V(F,{key:0,class:"border-border bg-muted/30"},{default:C(()=>[o(I,{name:"hugeicons:alert-circle",class:"size-4 text-destructive"}),o(A,{class:"text-destructive"},{default:C(()=>m[5]||(m[5]=[k("Diff Failed")])),_:1}),o(E,{class:"text-muted-foreground"},{default:C(()=>[k(u(r(w)),1)]),_:1})]),_:1})):z("",!0),r(g)?(t(),a(y,{key:1},[d("div",Ne,[o(Q,{modelValue:r(i),"onUpdate:modelValue":m[3]||(m[3]=L=>ee(i)?i.value=L:null),class:"min-w-0 flex-1 gap-0"},{default:C(()=>[o(O,{class:"h-8 max-w-full justify-start! overflow-x-auto"},{default:C(()=>[o(N,{value:"diff",class:"min-w-fit shrink-0 cursor-pointer rounded-sm px-1.5 text-xs",onClick:m[1]||(m[1]=L=>i.value="diff")},{default:C(()=>[o(I,{name:"hugeicons:git-compare",class:"shrink-0 size-3.5"}),m[6]||(m[6]=k(" Diff View ")),r($)?(t(),a("span",Pe,u(r(g).summary.added+r(g).summary.removed+r(g).summary.modified),1)):z("",!0)]),_:1}),o(N,{value:"sql",class:"min-w-fit shrink-0 cursor-pointer rounded-sm px-1.5 text-xs",onClick:m[2]||(m[2]=L=>i.value="sql")},{default:C(()=>[o(I,{name:"hugeicons:code",class:"shrink-0 size-3.5"}),m[7]||(m[7]=k(" SQL ")),r(g).sql.statements.length>0?(t(),a("span",Ue,u(r(g).sql.statements.length),1)):z("",!0)]),_:1})]),_:1})]),_:1},8,["modelValue"]),d("div",Ae,u(r(i)==="diff"?"Visualize structural differences":"Review synchronization script"),1)]),r(i)==="diff"?(t(),a("div",Ee,[o(Be,{result:r(g)},null,8,["result"])])):(t(),a("div",Fe,[o(ke,{sql:r(c),"safe-mode":r(e),"statement-count":r(g).sql.statements.length,"destructive-count":r(s),"onUpdate:safeMode":m[4]||(m[4]=L=>e.value=L)},null,8,["sql","safe-mode","statement-count","destructive-count"])]))],64)):r(v)?z("",!0):(t(),a("div",Oe,[o(I,{name:"hugeicons:git-compare",class:"size-14 opacity-30"}),m[8]||(m[8]=d("p",{class:"text-sm"},"Select a target connection and run the diff",-1))]))])}}});export{Xe as _};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{E as u}from"./BcsKoAPU.js";function _(o){let e=o.toLowerCase();const d=["tbl_","table_"];for(const a of d)e!=null&&e.startsWith(a)&&(e=e.slice(a.length));e=e.replace(/(_v\d+|_\d+)$/,"");let n=e.split(/[_-]/);n.length===1&&(n=e.match(/[A-Z]?[a-z]+|[A-Z]+(?=[A-Z][a-z]|\b)/g)||[e]);let s=n.filter(a=>a.length>0).map(a=>a[0]).join("");return!s&&e&&(s=e[0]),s}function $(o,e,d){var m,c;const n=document.createElement("div");n.className="gap-1 flex flex-col text-sm min-w-[20rem]";const s=((m=e.primary_keys)==null?void 0:m.map(t=>t.column))||[],a=((c=e.foreign_keys)==null?void 0:c.map(t=>t.column))||[],l=document.createElement("div");l.className="font-medium text-sm mb-1",l.textContent=`${o} (${d||"public"})`,n.appendChild(l);const p=document.createElement("div");if(p.className="text-xs text-muted-foreground",p.textContent=`Columns: ${e.columns.length}`,n.appendChild(p),s.length>0){const t=document.createElement("div");t.className="text-xs text-muted-foreground",t.textContent=`Primary Keys: ${s.join(", ")}`,n.appendChild(t)}if(a.length>0){const t=document.createElement("div");t.className="text-xs text-muted-foreground",t.textContent=`Foreign Keys: ${a.join(", ")}`,n.appendChild(t)}const i=document.createElement("div");i.className="mt-1 text-xs max-h-[12rem] overflow-auto";for(const t of e.columns){const r=document.createElement("div");r.className=s.includes(t.name)?"py-0.5 font-semibold":"py-0.5",r.append(document.createTextNode(`${t.name}: `));const f=document.createElement("span");f.className="text-muted-foreground",f.textContent=t.short_type_name,r.appendChild(f),i.appendChild(r)}return n.appendChild(i),n}function b(o,e,d,n,s,a){const l=document.createElement("div");l.className="gap-1 flex flex-col text-sm min-w-[10rem]";const p=document.createElement("div");p.className="font-medium text-sm mb-1",p.textContent=o,l.appendChild(p);const i=document.createElement("div");i.className="text-xs text-muted-foreground",i.textContent=`Type: ${e}`,l.appendChild(i);const m=document.createElement("div");if(m.className="text-xs text-muted-foreground",m.textContent=`Table: ${a?`${a}.${d}`:d}`,l.appendChild(m),n){const c=document.createElement("div");c.className="text-xs text-yellow-500 mt-1 flex items-center gap-1",c.textContent="Primary Key",l.appendChild(c)}if(s){const c=document.createElement("div");c.className="text-xs text-blue-500 mt-1 flex items-center gap-1",c.textContent=`FK -> ${s.referenced_table}.${s.referenced_column}`,l.appendChild(c)}return l}function N(o){const e=o.toLowerCase();return e.includes("int")||e.includes("numeric")||e.includes("decimal")||e.includes("float")||e.includes("double")||e.includes("real")||e.includes("serial")||e.includes("money")?u.Numeric:e.includes("char")||e.includes("text")||e.includes("varchar")||e.includes("string")||e.includes("uuid")||e.includes("citext")?u.String:e.includes("date")||e.includes("time")||e.includes("timestamp")||e.includes("interval")?u.Calendar:e.includes("array")||e.includes("json")||e.includes("jsonb")||e.includes("[]")?u.Brackets:e.includes("vector")?u.Vector:u.Field}function E({typeName:o,isPrimaryKey:e,hasForeignKey:d}){return e?u.Keyword:d?u.ForeignKey:N(o)}function S({column:o,tableName:e,schemaName:d,isPrimaryKey:n,foreignKey:s,info:a}){const l={label:o.name,type:E({typeName:o.short_type_name,isPrimaryKey:n,hasForeignKey:!!s}),detail:o.short_type_name,boost:-o.ordinal_position};return a?l.info=a:l.info=()=>b(o.name,o.short_type_name,e,n,s,d),l}function w({schemas:o,defaultSchemaName:e,fileVariables:d}){var l,p;const n={};if(o&&o.length>0)for(const i of o){if(!i.tableDetails)continue;const m=i.name,c={};for(const t in i.tableDetails){const r=i.tableDetails[t],f={},y=new Set(((l=r.primary_keys)==null?void 0:l.map(x=>x.column))||[]),h=new Map(((p=r.foreign_keys)==null?void 0:p.map(x=>[x.column,x]))||[]);for(const x of r.columns){const g=y.has(x.name),v=h.get(x.name);f[x.name]={self:S({column:x,tableName:t,schemaName:m,isPrimaryKey:g,foreignKey:v}),children:{}}}f["*"]={self:{label:"*",type:u.Function,detail:"All columns",boost:50,info:()=>b("* All columns","Selects all columns",t,!1,void 0,m)},children:{}};const C=_(t);c[t]={self:{label:t,displayLabel:`${t} AS ${C}`,type:u.Table,detail:`${r.columns.length} columns`,apply:`${t} AS ${C}`,boost:100,info:()=>$(t,r,m)},children:f}}n[m]={self:{label:m,type:u.Database,detail:`${Object.keys(c).length} tables`},children:c}}const s=[];if(d)try{const i=JSON.parse(d);for(const m in i)s.push({label:`:${m}`,type:u.Variable,boost:120,detail:"variable",apply(c,t,r,f){const h=c.state.doc.sliceString(r-1,r)===":"?r-1:r;c.dispatch({changes:{from:h,to:f,insert:t.label}})}})}catch(i){console.error("🚀 ~ mappedSchemaSuggestion ~ error:",i)}const a=(e&&n[e]?e:void 0)||Object.keys(n)[0];return{schema:n,variableCompletions:s,defaultSchema:a}}export{S as c,_ as g,w as m};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{U as a,D as n}from"./DHAL8jJG.js";const t=(r,o)=>a.lang.round(n.parse(r)[o]);export{t as c};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as o}from"./Bq7OeLM1.js";import{d as e,k as t,o as r}from"./BcsKoAPU.js";import"./BWebIWit.js";import"./ioXB9E2w.js";const c=e({__name:"index",setup(a){return(n,_)=>(r(),t(o,{"table-id":void 0}))}});export{c as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as a,c as s,a as e,C as t}from"./B8TrrBEb.js";import{_ as i}from"./DHAL8jJG.js";import"./Ci5B19-c.js";import"./Bq47tjcm.js";import"./kvtnkChG.js";import"./DGvAu532.js";import"./BcsKoAPU.js";var n={parser:e,get db(){return new t},renderer:s,styles:a,init:i(r=>{r.class||(r.class={}),r.class.arrowMarkerAbsolute=r.arrowMarkerAbsolute},"init")};export{n as diagram};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as e}from"./CtWq1MER.js";import{d as r,a8 as c,c as n,k as m,g as o,o as p}from"./BcsKoAPU.js";import"./CHEpbbGc.js";import"./C_7gtl40.js";import"./dNPwafbq.js";import"./BWZ7atse.js";import"./Ca0KO9Xq.js";import"./CS5akSNT.js";import"./D4pAW_0T.js";import"./qzrMNYut.js";const C=r({__name:"[name]",setup(s){const t=c(),i=n(()=>t.params.connectionId),a=n(()=>t.params.name);return(_,u)=>(p(),m(o(e),{"connection-id":o(i),"initial-tab":o(a)},null,8,["connection-id","initial-tab"]))}});export{C as default};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./JOg_XIAv.js","./BcsKoAPU.js","./entry.DxCQuGXb.css","./Ca0KO9Xq.js","./CS5akSNT.js","./D4pAW_0T.js","./DDebxXP-.js","./DsmBazLf.js","./COAycMg4.js","./BPACuoI0.js","./AymhMj9v.js","./ioXB9E2w.js","./BtyzMl9p.js","./BVmBXPoG.js","./CS9hqyP3.js","./dWu56FdP.js","./DynamicTable.B3c2woGb.css","./COq7mAG7.js","./DVnDb6ua.js","./Bq7OeLM1.js","./BWebIWit.js","./ErdDiagram.Cnqgwj9d.css","./Y1gXUmjt.js","./Oe2GG0Lt.js","./COHOh4Oe.js","./vhkvHdfO.js","./B73IHAoF.js","./CSQ0xnqv.js","./C7BQpy74.js","./BoIj4dtd.js","./dNPwafbq.js","./-lZvfnzr.js","./QuickQuery.CJ7tNjo4.css","./DpEV6S2O.js","./C2XHqDOf.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{an as s,ao as c,d as T,a8 as V,a2 as h,am as E,a3 as O,c as o,bP as P,a5 as k,a6 as C,aK as D,ap as t,k as f,g as l,ab as L,p as R,q as S,o as b,bQ as z,aq as A}from"./BcsKoAPU.js";const F=s(()=>c(()=>import("./JOg_XIAv.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]),import.meta.url).then(e=>e.default||e.default||e)),N=s(()=>c(()=>import("./BtyzMl9p.js"),__vite__mapDeps([12,1,2,13,11,14,15,4,16]),import.meta.url).then(e=>e.default||e.default||e)),g=s(()=>c(()=>import("./COq7mAG7.js"),__vite__mapDeps([17,1,2,18,11,15,19,20,21,9,22,3,4,5,14,16,23,24,25,26,27,10,28,29,7,13,30,31,32]),import.meta.url).then(e=>e.default||e.default||e)),q=s(()=>c(()=>import("./DpEV6S2O.js"),__vite__mapDeps([33,1,2,13,11,14,15,4,16]),import.meta.url).then(e=>e.default||e.default||e)),Q=s(()=>c(()=>import("./C2XHqDOf.js"),__vite__mapDeps([34,1,2,13,11,14,15,4,16]),import.meta.url).then(e=>e.default||e.default||e)),x=T({__name:"[tabViewId]",setup(e){const i=V(),w=h(),{tabViews:I}=E(w),d=O(),a=o(()=>I.value.find(n=>n.id===i.params.tabViewId)),m=o(()=>d.selectedConnection),p=o(()=>P(m.value??{type:C.POSTGRES,method:k.STRING}));D(()=>{!m.value||p.value||z({name:"workspaceId-connectionId",params:{workspaceId:i.params.workspaceId,connectionId:i.params.connectionId},replace:!0},{replace:!0})});const v=o(()=>{if(!a.value||!p.value)return null;switch(a.value.type){case t.TableDetail:case t.ViewDetail:case t.CodeQuery:return g;case t.TableOverview:return q;case t.FunctionsOverview:return N;case t.ViewOverview:return Q;case t.FunctionsDetail:return F;default:return null}}),y=o(()=>{var n,u,r,_;return a.value?{connectionId:a.value.connectionId,workspaceId:i.params.workspaceId,schemaName:a.value.schemaId||"",tableName:((n=a.value.metadata)==null?void 0:n.tableName)||"",functionName:((u=a.value.metadata)==null?void 0:u.tableName)||"",tabViewType:a.value.type,virtualTableId:(r=a.value.metadata)==null?void 0:r.virtualTableId,connections:d.connections,functionId:(_=a.value.metadata)==null?void 0:_.functionId}:{}});return(n,u)=>{const r=A;return l(v)?(b(),f(S(l(v)),L(R({key:0},l(y))),null,16)):(b(),f(r,{key:1,title:"Tab view not found",desc:"The requested tab could not be found. Please close this tab and try again."}))}}});export{x as default};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ByiJDSw8.js","./BcsKoAPU.js","./entry.DxCQuGXb.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
var ks=Object.defineProperty;var $s=(s,e,t)=>e in s?ks(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var ae=(s,e,t)=>$s(s,typeof e!="symbol"?e+"":e,t);import{a6 as Z,d as X,bV as zs,ae as As,ar as Ls,k as I,o as v,w as h,D as xe,g as l,p as ss,bU as Pt,bT as Ms,a9 as Ns,aa as Is,ab as Os,ac as Ps,es as qs,M as ns,et as rt,eu as Ds,c as P,bN as Fs,j as et,m as f,f as p,bO as Vs,df as wt,e as A,z as O,l as Q,a1 as _t,W as Et,X as Tt,Y as Rt,A as fe,Z as Bs,t as D,$ as os,a0 as Se,bk as kt,F as ee,s as ne,n as pe,a_ as ie,a$ as ue,aY as ce,r as K,i as Ae,ev as js,ew as Us,ex as as,ey as rs,ez as Hs,bl as ls,eA as Qs,eB as Ws,el as Ks,em as Gs,en as Ys,eC as Ue,dm as Js,au as de,av as $t,aQ as zt,aT as $e,q as Zs,aS as Fe,aR as Xs,aZ as Ve,az as en,ay as Ce,ci as is,am as us,eD as tn,ef as sn,aq as Ke,H as nn,bY as qt,bW as on,bm as an,bE as rn,bF as ln,bG as un,eE as cn,aP as Qe,aL as dn,P as cs,aC as mn,aH as pn,eF as Dt,ao as ds,eG as fn,eH as At,eI as hn,eJ as vn,eK as gn,eL as yn,eM as xn,eN as ms,ba as bn,bb as ut,eO as Cn,bd as Sn,bc as wn,eP as _n,be as En,bf as Tn,eQ as Rn,bg as kn,eR as ct,eS as $n,bi as zn,eT as An,bD as Ln,a8 as ps,eU as Mn,a3 as Nn,a as In,aK as On,b9 as Pn,cq as qn}from"./BcsKoAPU.js";import{_ as Dn,u as Fn}from"./xp7rFxcm.js";import{_ as Vn}from"./63YtjFEq.js";import{_ as Bn}from"./xOD4Ev56.js";import{_ as Lt}from"./AymhMj9v.js";import{c as fs,d as hs,e as vs,C as U,f as jn,g as tt,h as Un,i as Hn,j as Qn,k as Wn,_ as dt,a as mt,b as Kn}from"./C7BQpy74.js";import{_ as Gn,a as Yn,b as Jn}from"./DVnDb6ua.js";import{f as yt,a as We,b as Ye}from"./-lZvfnzr.js";import{M as Zn,_ as Ft,j as Vt,k as Bt}from"./B73IHAoF.js";import{p as Xn,D as eo,_ as to,a as pt,b as so}from"./vhkvHdfO.js";import{_ as jt}from"./BpUSbMUb.js";import{_ as no}from"./MW5K_zef.js";import{s as oo}from"./DDebxXP-.js";import{_ as ao}from"./COHOh4Oe.js";import{u as ro}from"./CsRSZpa6.js";import{_ as Mt,c as Ut,a as ft,e as Ht,b as Qt}from"./Ca0KO9Xq.js";import{i as lo}from"./dWu56FdP.js";import{_ as gs}from"./CS9hqyP3.js";import{r as io}from"./DsmBazLf.js";import{c as uo,m as co}from"./BRFPdiIh.js";import"./CSQ0xnqv.js";import"./D4pAW_0T.js";import"./CHEpbbGc.js";import"./DcCF9IZB.js";import"./BoIj4dtd.js";import"./DAr5YiBT.js";import"./CS5akSNT.js";class mo{constructor(e){this.rawError=e}get nomaltliztionErrror(){var t;const e=((t=this.rawError)==null?void 0:t.message)||"Error parsing SQL execution.";if(!this.rawError)return{message:e};switch(this.rawError.dbType){case Z.POSTGRES:return this.normalizePostgresError(e);case Z.MYSQL:return this.normalizeMysqlError(e);case Z.SQLITE3:return this.normalizeSqliteError(e);case Z.MARIADB:return this.normalizeMysqlError(e);case Z.ORACLE:return this.normalizeOracleError(e);default:return{message:e}}}normalizePostgresError(e){let t;return this.rawError.position&&(t=typeof this.rawError.position=="string"?Number(this.rawError.position):this.rawError.position,Number.isNaN(t)&&(t=void 0)),{message:this.rawError.message||e,position:t,hint:this.rawError.hint}}normalizeMysqlError(e){return{message:this.rawError.sqlMessage||this.rawError.message||e,hint:this.rawError.code?`Error Code: ${this.rawError.code}`:void 0}}normalizeSqliteError(e){return{message:this.rawError.message||e,hint:this.rawError.code?`Error Code: ${this.rawError.code}`:void 0}}normalizeOracleError(e){return{message:this.rawError.message||e,hint:this.rawError.errorNum?`ORA-${String(this.rawError.errorNum).padStart(5,"0")}`:void 0}}}var po=X({__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:e}){const t=s,n=e,a=zs(t,["modelValue"]),o=As(a),r=Ls(t,"modelValue",n);return Xn({modelValue:r}),(i,u)=>(v(),I(Zn,ss({role:"menuitemcheckbox"},l(o),{"aria-checked":l(Pt)(l(r))?"mixed":l(r),"data-state":l(Ms)(l(r)),onSelect:u[0]||(u[0]=async c=>{n("select",c),l(Pt)(l(r))?r.value=!0:r.value=!l(r)})}),{default:h(()=>[xe(i.$slots,"default",{modelValue:l(r)})]),_:3},16,["aria-checked","data-state"]))}}),fo=po,ho=X({__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:e}){const t=s,a=Ns(e);return Is(),(o,r)=>(v(),I(l(fo),Os(Ps({...t,...l(a)})),{default:h(()=>[xe(o.$slots,"default")]),_:3},16))}}),vo=ho;function Nt(s,e){s.dispatch(qs(s.state,e))}function go(s){return s===Z.POSTGRES?"postgres-positional":s===Z.ORACLE?"oracle-positional":"question-mark"}function yo(s,e,t,n={}){if(!Object.keys(e).length)return s;const a=n.style??go(t);let o=n.startIndex??1,r="",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++;r+=s.slice(c,i);continue}if(u==='"'){const c=i++;for(;i<s.length&&s[i]!=='"';)i++;i++,r+=s.slice(c,i);continue}if(u===":"&&i+1<s.length&&/[a-zA-Z_]/.test(s[i+1])){const c=i++;let m="";for(;i<s.length&&/[a-zA-Z0-9_]/.test(s[i]);)m+=s[i++];m in e?a==="postgres-positional"?r+=`$${o++}`:a==="oracle-positional"?r+=`:${o++}`:r+="?":r+=s.slice(c,i);continue}r+=u,i++}return r}function xo(s,e,t){if(s===e)return t;let n=0,a=0;for(;a<t&&n<s.length;){const o=s[n],r=e[a],i=/\s/.test(o),u=/\s/.test(r);if(i&&u){n++,a++;continue}if(o===":"&&(r==="$"||r==="?"||r===":")){for(;n<s.length&&/[:a-zA-Z0-9_]/.test(s[n]);)n++;if(r==="$")for(;a<e.length&&/[$0-9]/.test(e[a]);)a++;else if(r===":")for(;a<e.length&&/[:0-9]/.test(e[a]);)a++;else a++;if(a>=t)return n;continue}o===r?(n++,a++):n++}return n}function Wt({editorView:s,originalSql:e,statementFrom:t,fileParameters:n={},errorDetail:a,clientType:o,queryPrefix:r}){if(!s||!a)return;const{message:i,position:u}=a.normalizeError||new mo(a).nomaltliztionErrror;if(!u){Co(s,t,e,i);return}const c=`${r}${e}`,m=yo(c,n,o),d=xo(c,m,u),y=Math.max(d-1,0)-((r==null?void 0:r.length)||0),{from:x,to:S}=bo(e,t,y);Nt(s,[{from:x,to:S,severity:"error",message:i}])}function bo(s,e,t){let n=t;for(;n<s.length&&!/[\s\n\r\t]/.test(s[n]);)n++;return{from:e+t,to:e+n}}function Co(s,e,t,n){const a=[{from:e,to:e+t.length,severity:"error",message:n}];Nt(s,a)}function So(s){Nt(s,[])}const wo=s=>ns.of([{key:"Mod-Enter",mac:"Cmd-Enter",run:e=>{const{currentStatements:t}=rt(e),n=Ds(e);return t.length&&s({currentStatements:t,treeNodes:n||[]}),!0},preventDefault:!0}]),_o={class:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center"},Eo=X({__name:"DropdownMenuCheckboxItem",props:{modelValue:{type:[Boolean,String]},disabled:{type:Boolean},textValue:{},asChild:{type:Boolean},as:{},class:{}},emits:["select","update:modelValue"],setup(s,{emit:e}){const t=s,n=e,a=P(()=>{const{class:r,...i}=t;return i}),o=Fs(a,n);return(r,i)=>(v(),I(l(vo),ss({"data-slot":"dropdown-menu-checkbox-item"},l(o),{class:l(et)("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",t.class)}),{default:h(()=>[f("span",_o,[p(l(eo),null,{default:h(()=>[p(l(Vs),{class:"size-4"})]),_:1})]),xe(r.$slots,"default")]),_:3},16,["class"]))}}),To={},Ro={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"},$o={class:"list-disc text-sm list-inside text-left space-y-2"};function zo(s,e){const t=Bn,n=Vn,a=Lt;return v(),A("div",Ro,[p(n,{class:"rounded-2xl size-20 shadow-md"},{default:h(()=>[p(t,{src:"/logo.png",alt:"@unovue"})]),_:1}),f("div",ko,[e[7]||(e[7]=f("h2",{class:"text-md font-normal text-foreground"},"Getting Started",-1)),f("ol",$o,[e[5]||(e[5]=f("li",null,[f("span",{class:"font-normal text-foreground"},"Write your query"),O(" in the editor. ")],-1)),e[6]||(e[6]=f("li",null,[f("span",{class:"font-normal text-foreground"},"Click inside your query"),O(" to select it. ")],-1)),f("li",null,[e[1]||(e[1]=O(" Click ")),e[2]||(e[2]=f("span",{class:"text-foreground font-normal"},"'Execute current'",-1)),e[3]||(e[3]=O(" or use shortcut ")),p(a,{class:"font-normal border rounded-md p-1 px-1.5 text-foreground"},{default:h(()=>e[0]||(e[0]=[O("⌘↵")])),_:1}),e[4]||(e[4]=O(" to run the query. "))])])])])}const Ao=wt(To,[["render",zo]]),Lo={class:"font-medium text-foreground"},Mo={class:"font-medium text-foreground"},No=X({__name:"RawQueryConnectionConfirmDialog",props:{open:{type:Boolean},targetConnectionName:{},currentConnectionName:{}},emits:["confirm","cancel"],setup(s,{emit:e}){const t=e,n=()=>{t("confirm")},a=()=>{t("cancel")};return(o,r)=>{const i=fe;return o.open?(v(),I(l(_t),{key:0,open:o.open,"onUpdate:open":r[0]||(r[0]=u=>!u&&a())},{default:h(()=>[p(l(Et),{class:"max-w-md"},{default:h(()=>[p(l(Tt),null,{default:h(()=>[p(l(Rt),{class:"flex items-center gap-2"},{default:h(()=>[p(i,{name:"hugeicons:alert-02",class:"size-5 text-amber-500"}),r[1]||(r[1]=O(" Confirm query execution "))]),_:1}),p(l(Bs),null,{default:h(()=>[r[2]||(r[2]=O(" This query will execute on ")),f("span",Lo,D(o.targetConnectionName),1),r[3]||(r[3]=O(" . The current connection is ")),f("span",Mo,D(o.currentConnectionName),1),r[4]||(r[4]=O(" . Make sure before executing. "))]),_:1})]),_:1}),p(l(os),null,{default:h(()=>[p(l(Se),{variant:"outline",onClick:a},{default:h(()=>r[5]||(r[5]=[O("Cancel")])),_:1}),p(l(Se),{class:"gap-1",onClick:n},{default:h(()=>[p(i,{name:"lucide:play",class:"size-4"}),r[6]||(r[6]=O(" Execute "))]),_:1})]),_:1})]),_:1})]),_:1},8,["open"])):Q("",!0)}}}),Io={key:1,class:"text-xs text-muted-foreground ml-2"},Oo=X({__name:"RawQueryEditorContextMenu",props:{contextMenuItems:{}},emits:["update:open"],setup(s,{emit:e}){const t=e,n=o=>typeof o>"u"?!0:!!o,a=o=>{t("update:open",o)};return(o,r)=>{const i=hs,u=jn,c=fe,m=Lt,d=tt,y=Un,x=Qn,S=Wn,b=Hn,g=vs,C=fs;return v(),I(C,{"onUpdate:open":a},{default:h(()=>[p(i,{"as-child":""},{default:h(()=>[xe(o.$slots,"default")]),_:3}),p(g,{class:"min-w-56",onCloseAutoFocus:r[0]||(r[0]=kt(()=>{},["prevent"]))},{default:h(()=>[(v(!0),A(ee,null,ne(o.contextMenuItems,(E,$)=>(v(),A(ee,{key:$},[E.type===l(U).LABEL&&n(E.condition)?(v(),I(u,{key:0,class:"font-medium text-xs text-muted-foreground"},{default:h(()=>[O(D(E.title),1)]),_:2},1024)):E.type===l(U).ACTION&&n(E.condition)?(v(),I(d,{key:1,onSelect:E.select,disabled:E.disabled},{default:h(()=>[E.icon?(v(),I(c,{key:0,name:E.icon,class:"size-4! min-w-4 text-muted-foreground"},null,8,["name"])):Q("",!0),O(" "+D(E.title)+" ",1),E.shortcut?(v(),I(m,{key:1},{default:h(()=>[O(D(E.shortcut),1)]),_:2},1024)):Q("",!0)]),_:2},1032,["onSelect","disabled"])):E.type===l(U).SEPARATOR&&n(E.condition)?(v(),I(y,{key:2})):E.type===l(U).SUBMENU&&n(E.condition)?(v(),I(b,{key:3,disabled:!E.items||E.items.length===0},{default:h(()=>[p(x,null,{default:h(()=>[E.icon?(v(),I(c,{key:0,name:E.icon,class:"size-4! min-w-4 text-muted-foreground mr-2"},null,8,["name"])):Q("",!0),O(" "+D(E.title)+" ",1),E.desc?(v(),A("span",Io,D(E.desc),1)):Q("",!0)]),_:2},1024),p(S,{class:pe("min-w-52")},{default:h(()=>[(v(!0),A(ee,null,ne(E.items,(L,_)=>(v(),A(ee,{key:_},[L.type===l(U).ACTION&&n(L.condition)?(v(),I(d,{key:0,onSelect:L.select},{default:h(()=>[L.icon?(v(),I(c,{key:0,name:L.icon,class:"size-4! min-w-4 text-muted-foreground"},null,8,["name"])):Q("",!0),O(" "+D(L.title)+" ",1),L.shortcut?(v(),I(m,{key:1},{default:h(()=>[O(D(L.shortcut),1)]),_:2},1024)):Q("",!0)]),_:2},1032,["onSelect"])):L.type===l(U).LABEL&&n(L.condition)?(v(),I(u,{key:1,class:"font-medium text-xs text-muted-foreground"},{default:h(()=>[O(D(L.title),1)]),_:2},1024)):L.type===l(U).SEPARATOR&&n(L.condition)?(v(),I(y,{key:2})):Q("",!0)],64))),128))]),_:2},1024)]),_:2},1032,["disabled"])):Q("",!0)],64))),128))]),_:1})]),_:3})}}}),Po={},qo={class:"mb-2 flex items-center gap-1.5 text-sm font-semibold"};function Do(s,e){const t=fe,n=Se,a=Yn,o=ie,r=ue,i=Jn,u=Gn,c=ce;return v(),I(c,null,{default:h(()=>[p(u,null,{default:h(()=>[p(o,{"as-child":""},{default:h(()=>[p(a,{"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(t,{name:"hugeicons:help-circle",class:"size-3.5!"})]),_:1})]),_:1})]),_:1}),p(r,null,{default:h(()=>e[0]||(e[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",qo,[p(t,{name:"hugeicons:help-circle",class:"size-4!"}),e[1]||(e[1]=O(" Passing variables in queries "))]),e[2]||(e[2]=f("p",{class:"mb-3 text-muted-foreground"},[O(" Use "),f("code",{class:"rounded bg-muted px-1"},":variable_name"),O(" syntax to bind parameters. For array operators, cast to the correct type: ")],-1)),e[3]||(e[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)),e[4]||(e[4]=f("p",{class:"mt-3 border-t pt-2 text-muted-foreground"},[O(" Replace "),f("code",{class:"rounded bg-muted px-1"},"alias_type"),O(" with the actual PostgreSQL type, e.g. "),f("code",{class:"rounded bg-muted px-1"},"integer"),O(", "),f("code",{class:"rounded bg-muted px-1"},"uuid"),O(", "),f("code",{class:"rounded bg-muted px-1"},"text"),O(". ")],-1))]),_:1})]),_:1})]),_:1})}const Fo=wt(Po,[["render",Do]]),Vo={class:"h-fit py-1 flex items-center justify-between px-2"},Bo={class:"flex items-center gap-2"},jo={class:"font-normal text-xs text-muted-foreground"},Uo={key:0,class:"font-normal text-xs text-muted-foreground"},Ho={key:0,class:"flex items-center gap-1"},Qo={key:1,class:"flex items-center gap-1"},Wo={key:2},Ko={key:0},Go={key:1},Yo={class:"flex gap-1"},Jo={class:"flex items-center"},Zo={class:"flex items-center"},Xo={key:0},ea={key:1},ta=X({__name:"RawQueryEditorFooter",props:{cursorInfo:{},isHaveOneExecute:{type:Boolean},executeLoading:{type:Boolean},executeErrors:{type:Boolean},isStreaming:{type:Boolean},streamingRowCount:{},queryTime:{},rawQueryResultsLength:{},isRawViewMode:{type:Boolean},explainAnalyzeOptionItems:{},serializeMode:{},isSupportFormat:{type:Boolean},isSupportVariable:{type:Boolean},isExplainSupported:{type:Boolean}},emits:["onFormatCurrentStatement","onFormatAll","onExplainAnalyzeCurrent","toggleExplainOption","update:serializeMode","onExecuteCurrent","update:isRawViewMode","onCancelQuery"],setup(s){const e=K(!1);return(t,n)=>{const a=Fo,o=fe,r=Lt,i=Se;return v(),A("div",Vo,[f("div",Bo,[f("div",jo," Ln "+D(t.cursorInfo.line)+", Col "+D(t.cursorInfo.column),1),t.isSupportVariable?(v(),I(a,{key:0})):Q("",!0)]),t.isHaveOneExecute?(v(),A("div",Uo,[t.isStreaming?(v(),A("span",Ho,[p(o,{name:"hugeicons:loading-03",class:"size-4! animate-spin"}),O(" Streaming... "+D(l(yt)(t.streamingRowCount))+" rows ",1)])):t.executeLoading?(v(),A("span",Qo,[n[9]||(n[9]=O("Processing ")),p(o,{name:"hugeicons:loading-03",class:"size-4! animate-spin"})])):(v(),A("span",Wo,[t.executeErrors?(v(),A("span",Ko," Query: 1 error in "+D(l(We)(t.queryTime)),1)):(v(),A("span",Go," Query success: "+D(l(yt)(t.rawQueryResultsLength))+" rows in "+D(l(We)(t.queryTime)),1))]))])):Q("",!0),f("div",Yo,[t.isSupportFormat?(v(),I(l(ce),{key:0},{default:h(()=>[p(l(ie),null,{default:h(()=>[f("div",Jo,[p(i,{onClick:n[0]||(n[0]=u=>t.$emit("onFormatCurrentStatement")),variant:"outline",size:"xxs",class:"rounded-r-none"},{default:h(()=>[p(o,{name:"hugeicons:magic-wand-01"}),n[11]||(n[11]=O(" Format ")),p(r,null,{default:h(()=>n[10]||(n[10]=[O("⌘S")])),_:1})]),_:1}),p(l(Ft),null,{default:h(()=>[p(l(Vt),{"as-child":""},{default:h(()=>[p(i,{variant:"outline",size:"iconSm",class:"rounded-l-none border-l-0 px-2"},{default:h(()=>[p(o,{name:"hugeicons:arrow-down-01",class:"size-4! min-w-4"})]),_:1})]),_:1}),p(l(Bt),{align:"end",class:"min-w-44"},{default:h(()=>[p(l(dt),{class:"py-0"},{default:h(()=>n[12]||(n[12]=[O("Format Options ")])),_:1}),p(l(mt)),p(l(jt),{onClick:n[1]||(n[1]=u=>t.$emit("onFormatCurrentStatement")),class:"h-6 cursor-pointer"},{default:h(()=>[n[14]||(n[14]=O(" Current Statement ")),p(r,null,{default:h(()=>n[13]||(n[13]=[O("⌘S")])),_:1})]),_:1}),p(l(jt),{onClick:n[2]||(n[2]=u=>t.$emit("onFormatAll")),class:"h-6 cursor-pointer"},{default:h(()=>[n[16]||(n[16]=O(" All Statement ")),p(r,null,{default:h(()=>n[15]||(n[15]=[O("⇧⌥F")])),_:1})]),_:1})]),_:1})]),_:1})])]),_:1}),p(l(ue),null,{default:h(()=>n[17]||(n[17]=[f("p",null,"Format current statement (⌘S)",-1)])),_:1})]),_:1})):Q("",!0),t.isExplainSupported?(v(),I(l(ce),{key:1},{default:h(()=>[p(l(ie),null,{default:h(()=>[f("div",Zo,[p(i,{onClick:n[3]||(n[3]=u=>t.$emit("onExplainAnalyzeCurrent")),variant:"outline",size:"xxs",class:"rounded-r-none"},{default:h(()=>[p(o,{name:"hugeicons:analytics-up"}),n[19]||(n[19]=O(" Explain ")),p(r,null,{default:h(()=>n[18]||(n[18]=[O("⌘E")])),_:1})]),_:1}),p(l(Ft),{open:l(e),"onUpdate:open":n[6]||(n[6]=u=>Ae(e)?e.value=u:null)},{default:h(()=>[p(l(Vt),{"as-child":""},{default:h(()=>[p(i,{variant:"outline",size:"iconSm",class:"rounded-l-none border-l-0 px-2"},{default:h(()=>[p(o,{name:"hugeicons:arrow-down-01",class:"size-4! min-w-4"})]),_:1})]),_:1}),p(l(Bt),{align:"end",class:"min-w-52"},{default:h(()=>[p(l(dt),{class:"py-0"},{default:h(()=>n[20]||(n[20]=[O("Explain Analyze Options")])),_:1}),p(l(mt)),(v(!0),A(ee,null,ne(t.explainAnalyzeOptionItems,u=>(v(),I(l(Eo),{key:u.key,"model-value":u.checked,onSelect:n[4]||(n[4]=kt(()=>{},["prevent"])),"onUpdate:modelValue":c=>t.$emit("toggleExplainOption",u.key),class:"h-6 cursor-pointer"},{default:h(()=>[O(D(u.label),1)]),_:2},1032,["model-value","onUpdate:modelValue"]))),128)),p(l(mt)),p(l(dt),{class:"py-0"},{default:h(()=>n[21]||(n[21]=[O("Serialize")])),_:1}),p(l(to),{"model-value":t.serializeMode,"onUpdate:modelValue":n[5]||(n[5]=u=>t.$emit("update:serializeMode",u))},{default:h(()=>[p(l(pt),{value:"NONE",class:"h-6 cursor-pointer"},{default:h(()=>n[22]||(n[22]=[O("None")])),_:1}),p(l(pt),{value:"TEXT",class:"h-6 cursor-pointer"},{default:h(()=>n[23]||(n[23]=[O("Text")])),_:1}),p(l(pt),{value:"BINARY",class:"h-6 cursor-pointer"},{default:h(()=>n[24]||(n[24]=[O("Binary")])),_:1})]),_:1},8,["model-value"])]),_:1})]),_:1},8,["open"])])]),_:1}),p(l(ue),null,{default:h(()=>n[25]||(n[25]=[f("p",null,"Run Explain Analyze (⌘E) or open options",-1)])),_:1})]),_:1})):Q("",!0),p(l(ce),null,{default:h(()=>[p(l(ie),{"as-child":""},{default:h(()=>[t.isStreaming||t.executeLoading?(v(),I(i,{key:0,onClick:n[7]||(n[7]=u=>t.$emit("onCancelQuery")),variant:"outline",size:"xxs"},{default:h(()=>[p(o,{name:"hugeicons:stop",class:"size-4! text-red-500"}),n[26]||(n[26]=O(" Cancel query "))]),_:1})):(v(),I(i,{key:1,onClick:n[8]||(n[8]=u=>t.$emit("onExecuteCurrent")),variant:"outline",size:"xxs"},{default:h(()=>[p(o,{name:"hugeicons:play"}),n[28]||(n[28]=O(" Execute current ")),p(r,null,{default:h(()=>n[27]||(n[27]=[O("⌘↵")])),_:1})]),_:1}))]),_:1}),p(l(ue),null,{default:h(()=>[t.isStreaming||t.executeLoading?(v(),A("p",Xo,"Cancel query")):(v(),A("p",ea,"Execute Query (⌘↵)"))]),_:1})]),_:1})])])}}}),ys=X({__name:"VariableEditor",props:{fileVariables:{}},emits:["updateVariables"],setup(s,{emit:e}){const t=e,n=K({line:1,column:1}),a=[js(`Please input your json variable
|
|
6
|
-
{
|
|
7
|
-
"key": "value"
|
|
8
|
-
}`),oo(r=>{try{return Hs(r,{type:"space",size:2})}catch{return r}}),Us(),as(),rs(Qs())],o=r=>{t("updateVariables",r)};return(r,i)=>(v(),I(ls,{"onUpdate:modelValue":o,"onUpdate:cursorInfo":i[0]||(i[0]=u=>n.value=u),modelValue:r.fileVariables,extensions:a,disabled:!1,ref:"codeEditorRef"},null,8,["modelValue"]))}}),sa={class:"h-full flex flex-col overflow-y-auto"},na=X({__name:"AddVariableModal",props:{open:{},fileVariables:{}},emits:["update:open","updateVariables"],setup(s,{emit:e}){const t=e,n=async a=>{t("updateVariables",a)};return(a,o)=>(v(),I(l(_t),{class:"",open:!!a.open,"onUpdate:open":o[1]||(o[1]=r=>t("update:open",r))},{default:h(()=>[p(l(Et),{class:"w-[60vw] h-[50vh] flex flex-col justify-between min-w-[60vw]"},{default:h(()=>[p(l(Tt),null,{default:h(()=>[p(l(Rt),null,{default:h(()=>o[2]||(o[2]=[O(" 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",sa,[p(ys,{onUpdateVariables:n,fileVariables:a.fileVariables},null,8,["fileVariables"])]),p(l(os),{class:"mt-2"},{default:h(()=>[p(l(Se),{onClick:o[0]||(o[0]=r=>t("update:open",!1))},{default:h(()=>o[3]||(o[3]=[O(" Save ")])),_:1})]),_:1})]),_:1})]),_:1},8,["open"]))}}),oa=X({__name:"RawQueryConfigModal",props:{open:{}},emits:["update:open"],setup(s,{emit:e}){const t=e;return(n,a)=>(v(),I(l(_t),{class:"",open:!!n.open,"onUpdate:open":a[0]||(a[0]=o=>t("update:open",o))},{default:h(()=>[p(l(Et),{class:"w-[50vw] h-[70vh] flex flex-col justify-between min-w-[50vw]"},{default:h(()=>[p(l(Tt),null,{default:h(()=>[p(l(Rt),null,{default:h(()=>a[1]||(a[1]=[O(" Editor configs ")])),_:1})]),_:1}),p(Ws)]),_:1})]),_:1},8,["open"]))}}),aa={class:"flex items-center justify-between p-1 rounded-md bg-muted"},ra={class:"flex gap-2 items-center"},la={key:0},ia={key:1},ua=X({__name:"RawQueryEditorHeader",props:{currentFileInfo:{},fileVariables:{},workspaceId:{},selectedConnectionId:{},disableConnectionSwitch:{type:Boolean},connections:{},connection:{},isRedisConnection:{type:Boolean},isSupportVariable:{type:Boolean},redisDatabases:{},redisDatabaseIndex:{},codeEditorLayout:{}},emits:["update:connectionId","update:redisDatabaseIndex","update:updateFileVariables"],setup(s){const e=K(!1),t=K(!1),n=K(!1),a=()=>{e.value=!0},o=()=>{t.value=!0};return(r,i)=>{const u=fe,c=so,m=Ys,d=Gs,y=Ks,x=Se;return v(),A(ee,null,[p(na,{onUpdateVariables:i[0]||(i[0]=S=>r.$emit("update:updateFileVariables",S)),"file-variables":r.fileVariables,open:l(e),"onUpdate:open":i[1]||(i[1]=S=>Ae(e)?e.value=S:null)},null,8,["file-variables","open"]),p(oa,{open:l(t),"onUpdate:open":i[2]||(i[2]=S=>Ae(t)?t.value=S:null)},null,8,["open"]),f("div",aa,[f("div",null,[p(y,null,{default:h(()=>[p(d,{class:"gap-0!"},{default:h(()=>[p(m,null,{default:h(()=>[p(c,{class:"flex items-center gap-0.5"},{default:h(()=>{var S,b;return[p(u,{name:(S=r.currentFileInfo)==null?void 0:S.icon},null,8,["name"]),O(" "+D((b=r.currentFileInfo)==null?void 0:b.title),1)]}),_:1})]),_:1})]),_:1})]),_:1})]),f("div",ra,[r.isSupportVariable&&r.codeEditorLayout===l(Ue).horizontal?(v(),I(l(ce),{key:0},{default:h(()=>[p(l(ie),{"as-child":""},{default:h(()=>[p(x,{onClick:a,variant:"outline",size:"xxs",class:"relative"},{default:h(()=>[l(n)?(v(),I(u,{key:0,name:"lucide:triangle-alert",class:"absolute -top-1 -right-1 text-red-400"})):Q("",!0),p(u,{name:"hugeicons:absolute"}),i[5]||(i[5]=O(" Add variables "))]),_:1})]),_:1}),p(l(ue),null,{default:h(()=>i[6]||(i[6]=[f("p",null,"Add variables",-1)])),_:1})]),_:1})):Q("",!0),p(l(ce),null,{default:h(()=>[p(l(ie),{"as-child":""},{default:h(()=>[p(no,{connectionId:r.selectedConnectionId,"onUpdate:connectionId":i[3]||(i[3]=S=>r.$emit("update:connectionId",S)),connections:r.connections,connection:r.connection,disabled:r.disableConnectionSwitch,class:"w-fit h-6! px-1.5",workspaceId:r.workspaceId},null,8,["connectionId","connections","connection","disabled","workspaceId"])]),_:1}),p(l(ue),null,{default:h(()=>[r.disableConnectionSwitch?(v(),A("p",la," Connection switch is locked because the current connection has a strict mode tag ")):(v(),A("p",ia,"Select connection"))]),_:1})]),_:1}),r.isRedisConnection?(v(),I(Dn,{key:1,compact:"","trigger-id":"raw-query-redis-db-index","trigger-class":"bg-background",databases:r.redisDatabases||[],"database-index":r.redisDatabaseIndex??0,"onUpdate:databaseIndex":i[4]||(i[4]=S=>r.$emit("update:redisDatabaseIndex",S))},null,8,["databases","database-index"])):Q("",!0),p(l(ce),null,{default:h(()=>[p(l(ie),{"as-child":""},{default:h(()=>[p(x,{onClick:o,variant:"outline",size:"iconSm"},{default:h(()=>[p(u,{name:"hugeicons:dashboard-square-02"})]),_:1})]),_:1}),p(l(ue),null,{default:h(()=>i[7]||(i[7]=[f("p",null,"Query Settings",-1)])),_:1})]),_:1})])])],64)}}}),Je={__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:e}){const t=e,n=s,a=Js(),o=K([]),r=P(()=>o.value.reduce((w,k)=>(w[~~k.id]=k)&&w,{})),i=P(()=>o.value.length),u=K(null),c=K(!1),m=K({mouseDown:!1,dragging:!1,activeSplitter:null,cursorOffset:0}),d=K({splitter:null,timeoutId:null}),y=P(()=>({[`splitpanes splitpanes--${n.horizontal?"horizontal":"vertical"}`]:!0,"splitpanes--dragging":m.value.dragging})),x=()=>{document.addEventListener("mousemove",g,{passive:!1}),document.addEventListener("mouseup",C),"ontouchstart"in window&&(document.addEventListener("touchmove",g,{passive:!1}),document.addEventListener("touchend",C))},S=()=>{document.removeEventListener("mousemove",g,{passive:!1}),document.removeEventListener("mouseup",C),"ontouchstart"in window&&(document.removeEventListener("touchmove",g,{passive:!1}),document.removeEventListener("touchend",C))},b=(w,k)=>{const M=w.target.closest(".splitpanes__splitter");if(M){const{left:z,top:N}=M.getBoundingClientRect(),{clientX:R,clientY:V}="ontouchstart"in window&&w.touches?w.touches[0]:w;m.value.cursorOffset=n.horizontal?V-N:R-z}x(),m.value.mouseDown=!0,m.value.activeSplitter=k},g=w=>{m.value.mouseDown&&(w.preventDefault(),m.value.dragging=!0,requestAnimationFrame(()=>{q(_(w)),oe("resize",{event:w},!0)}))},C=w=>{m.value.dragging&&(window.getSelection().removeAllRanges(),oe("resized",{event:w},!0)),m.value.mouseDown=!1,m.value.activeSplitter=null,setTimeout(()=>{m.value.dragging=!1,S()},100)},E=(w,k)=>{"ontouchstart"in window&&(w.preventDefault(),d.value.splitter===k?(clearTimeout(d.value.timeoutId),d.value.timeoutId=null,$(w,k),d.value.splitter=null):(d.value.splitter=k,d.value.timeoutId=setTimeout(()=>d.value.splitter=null,500))),m.value.dragging||oe("splitter-click",{event:w,index:k},!0)},$=(w,k)=>{if(oe("splitter-dblclick",{event:w,index:k},!0),n.maximizePanes){let M=0;o.value=o.value.map((z,N)=>(z.size=N===k?z.max:z.min,N!==k&&(M+=z.min),z)),o.value[k].size-=M,oe("pane-maximize",{event:w,index:k,pane:o.value[k]}),oe("resized",{event:w,index:k},!0)}},L=(w,k)=>{oe("pane-click",{event:w,index:r.value[k].index,pane:r.value[k]})},_=w=>{const k=u.value.getBoundingClientRect(),{clientX:M,clientY:z}="ontouchstart"in window&&w.touches?w.touches[0]:w;return{x:M-(n.horizontal?0:m.value.cursorOffset)-k.left,y:z-(n.horizontal?m.value.cursorOffset:0)-k.top}},B=w=>{w=w[n.horizontal?"y":"x"];const k=u.value[n.horizontal?"clientHeight":"clientWidth"];return n.rtl&&!n.horizontal&&(w=k-w),w*100/k},q=w=>{const k=m.value.activeSplitter;let M={prevPanesSize:H(k),nextPanesSize:W(k),prevReachedMinPanes:0,nextReachedMinPanes:0};const z=0+(n.pushOtherPanes?0:M.prevPanesSize),N=100-(n.pushOtherPanes?0:M.nextPanesSize),R=Math.max(Math.min(B(w),N),z);let V=[k,k+1],Y=o.value[V[0]]||null,se=o.value[V[1]]||null;const be=Y.max<100&&R>=Y.max+M.prevPanesSize,qe=se.max<100&&R<=100-(se.max+W(k+1));if(be||qe){be?(Y.size=Y.max,se.size=Math.max(100-Y.max-M.prevPanesSize-M.nextPanesSize,0)):(Y.size=Math.max(100-se.max-M.prevPanesSize-W(k+1),0),se.size=se.max);return}if(n.pushOtherPanes){const je=T(M,R);if(!je)return;({sums:M,panesToResize:V}=je),Y=o.value[V[0]]||null,se=o.value[V[1]]||null}Y!==null&&(Y.size=Math.min(Math.max(R-M.prevPanesSize-M.prevReachedMinPanes,Y.min),Y.max)),se!==null&&(se.size=Math.min(Math.max(100-R-M.nextPanesSize-M.nextReachedMinPanes,se.min),se.max))},T=(w,k)=>{const M=m.value.activeSplitter,z=[M,M+1];return k<w.prevPanesSize+o.value[z[0]].min&&(z[0]=F(M).index,w.prevReachedMinPanes=0,z[0]<M&&o.value.forEach((N,R)=>{R>z[0]&&R<=M&&(N.size=N.min,w.prevReachedMinPanes+=N.min)}),w.prevPanesSize=H(z[0]),z[0]===void 0)?(w.prevReachedMinPanes=0,o.value[0].size=o.value[0].min,o.value.forEach((N,R)=>{R>0&&R<=M&&(N.size=N.min,w.prevReachedMinPanes+=N.min)}),o.value[z[1]].size=100-w.prevReachedMinPanes-o.value[0].min-w.prevPanesSize-w.nextPanesSize,null):k>100-w.nextPanesSize-o.value[z[1]].min&&(z[1]=G(M).index,w.nextReachedMinPanes=0,z[1]>M+1&&o.value.forEach((N,R)=>{R>M&&R<z[1]&&(N.size=N.min,w.nextReachedMinPanes+=N.min)}),w.nextPanesSize=W(z[1]-1),z[1]===void 0)?(w.nextReachedMinPanes=0,o.value.forEach((N,R)=>{R<i.value-1&&R>=M+1&&(N.size=N.min,w.nextReachedMinPanes+=N.min)}),o.value[z[0]].size=100-w.prevPanesSize-W(z[0]-1),null):{sums:w,panesToResize:z}},H=w=>o.value.reduce((k,M,z)=>k+(z<w?M.size:0),0),W=w=>o.value.reduce((k,M,z)=>k+(z>w+1?M.size:0),0),F=w=>[...o.value].reverse().find(k=>k.index<w&&k.size>k.min)||{},G=w=>o.value.find(k=>k.index>w+1&&k.size>k.min)||{},j=()=>{var w;const k=Array.from(((w=u.value)==null?void 0:w.children)||[]);for(const M of k){const z=M.classList.contains("splitpanes__pane"),N=M.classList.contains("splitpanes__splitter");!z&&!N&&(M.remove(),console.warn("Splitpanes: Only <pane> elements are allowed at the root of <splitpanes>. One of your DOM nodes was removed."))}},te=(w,k,M=!1)=>{const z=w-1,N=document.createElement("div");N.classList.add("splitpanes__splitter"),M||(N.onmousedown=R=>b(R,z),typeof window<"u"&&"ontouchstart"in window&&(N.ontouchstart=R=>b(R,z)),N.onclick=R=>E(R,z+1)),N.ondblclick=R=>$(R,z+1),k.parentNode.insertBefore(N,k)},ge=w=>{w.onmousedown=void 0,w.onclick=void 0,w.ondblclick=void 0,w.remove()},he=()=>{var w;const k=Array.from(((w=u.value)==null?void 0:w.children)||[]);for(const z of k)z.className.includes("splitpanes__splitter")&&ge(z);let M=0;for(const z of k)z.className.includes("splitpanes__pane")&&(!M&&n.firstSplitter?te(M,z,!0):M&&te(M,z),M++)},Me=({uid:w,...k})=>{const M=r.value[w];for(const[z,N]of Object.entries(k))M[z]=N},Ne=w=>{var k;let M=-1;Array.from(((k=u.value)==null?void 0:k.children)||[]).some(z=>(z.className.includes("splitpanes__pane")&&M++,z.isSameNode(w.el))),o.value.splice(M,0,{...w,index:M}),o.value.forEach((z,N)=>z.index=N),c.value&&Ce(()=>{he(),_e({addedPane:o.value[M]}),oe("pane-add",{pane:o.value[M]})})},Ie=w=>{const k=o.value.findIndex(z=>z.id===w);o.value[k].el=null;const M=o.value.splice(k,1)[0];o.value.forEach((z,N)=>z.index=N),Ce(()=>{he(),oe("pane-remove",{pane:M}),_e({removedPane:{...M}})})},_e=(w={})=>{!w.addedPane&&!w.removedPane?me():o.value.some(k=>k.givenSize!==null||k.min||k.max<100)?Re(w):Oe(),c.value&&oe("resized")},Oe=()=>{const w=100/i.value;let k=0;const M=[],z=[];for(const N of o.value)N.size=Math.max(Math.min(w,N.max),N.min),k-=N.size,N.size>=N.max&&M.push(N.id),N.size<=N.min&&z.push(N.id);k>.1&&Ee(k,M,z)},me=()=>{let w=100;const k=[],M=[];let z=0;for(const R of o.value)w-=R.size,R.givenSize!==null&&z++,R.size>=R.max&&k.push(R.id),R.size<=R.min&&M.push(R.id);let N=100;if(w>.1){for(const R of o.value)R.givenSize===null&&(R.size=Math.max(Math.min(w/(i.value-z),R.max),R.min)),N-=R.size;N>.1&&Ee(N,k,M)}},Re=({addedPane:w,removedPane:k}={})=>{let M=100/i.value,z=0;const N=[],R=[];((w==null?void 0:w.givenSize)??null)!==null&&(M=(100-w.givenSize)/(i.value-1));for(const V of o.value)z-=V.size,V.size>=V.max&&N.push(V.id),V.size<=V.min&&R.push(V.id);if(!(Math.abs(z)<.1)){for(const V of o.value)(w==null?void 0:w.givenSize)!==null&&(w==null?void 0:w.id)===V.id||(V.size=Math.max(Math.min(M,V.max),V.min)),z-=V.size,V.size>=V.max&&N.push(V.id),V.size<=V.min&&R.push(V.id);z>.1&&Ee(z,N,R)}},Ee=(w,k,M)=>{let z;w>0?z=w/(i.value-k.length):z=w/(i.value-M.length),o.value.forEach((N,R)=>{if(w>0&&!k.includes(N.id)){const V=Math.max(Math.min(N.size+z,N.max),N.min),Y=V-N.size;w-=Y,N.size=V}else if(!M.includes(N.id)){const V=Math.max(Math.min(N.size+z,N.max),N.min),Y=V-N.size;w-=Y,N.size=V}}),Math.abs(w)>.1&&Ce(()=>{c.value&&console.warn("Splitpanes: Could not resize panes correctly due to their constraints.")})},oe=(w,k=void 0,M=!1)=>{const z=(k==null?void 0:k.index)??m.value.activeSplitter??null;t(w,{...k,...z!==null&&{index:z},...M&&z!==null&&{prevPane:o.value[z-(n.firstSplitter?1:0)],nextPane:o.value[z+(n.firstSplitter?0:1)]},panes:o.value.map(N=>({min:N.min,max:N.max,size:N.size}))})};de(()=>n.firstSplitter,()=>he()),$t(()=>{j(),he(),_e(),oe("ready"),c.value=!0}),zt(()=>c.value=!1);const Pe=()=>{var w;return en("div",{ref:u,class:y.value},(w=a.default)==null?void 0:w.call(a))};return $e("panes",o),$e("indexedPanes",r),$e("horizontal",P(()=>n.horizontal)),$e("requestUpdate",Me),$e("onPaneAdd",Ne),$e("onPaneRemove",Ie),$e("onPaneClick",L),(w,k)=>(v(),I(Zs(Pe)))}},ze={__name:"pane",props:{size:{type:[Number,String]},minSize:{type:[Number,String],default:0},maxSize:{type:[Number,String],default:100}},setup(s){var e;const t=s,n=Fe("requestUpdate"),a=Fe("onPaneAdd"),o=Fe("horizontal"),r=Fe("onPaneRemove"),i=Fe("onPaneClick"),u=(e=Xs())==null?void 0:e.uid,c=Fe("indexedPanes"),m=P(()=>c.value[u]),d=K(null),y=P(()=>{const g=isNaN(t.size)||t.size===void 0?0:parseFloat(t.size);return Math.max(Math.min(g,S.value),x.value)}),x=P(()=>{const g=parseFloat(t.minSize);return isNaN(g)?0:g}),S=P(()=>{const g=parseFloat(t.maxSize);return isNaN(g)?100:g}),b=P(()=>{var g;return`${o.value?"height":"width"}: ${(g=m.value)==null?void 0:g.size}%`});return de(()=>y.value,g=>n({uid:u,size:g})),de(()=>x.value,g=>n({uid:u,min:g})),de(()=>S.value,g=>n({uid:u,max:g})),$t(()=>{a({id:u,el:d.value,min:x.value,max:S.value,givenSize:t.size===void 0?null:y.value,size:y.value})}),zt(()=>r(u)),(g,C)=>(v(),A("div",{ref_key:"paneEl",ref:d,class:"splitpanes__pane",onClick:C[0]||(C[0]=E=>l(i)(E,g._.uid)),style:Ve(b.value)},[xe(g.$slots,"default")],4))}},ca={class:"w-full h-full"},da={class:"flex flex-col w-full h-full overflow-y-auto"},ma={class:"flex flex-col flex-1 h-full p-1"},pa={class:"flex flex-col flex-1 h-full p-1 pl-0 relative"},fa=X({__name:"RawQueryLayout",props:{layout:{},customLayout:{},showResultPanel:{type:Boolean}},setup(s){const e=s,t=is(),{editorLayoutSizes:n,editorLayoutInnerVariableSizes:a}=us(t),o=_=>{n.value=[_[0].size,_[1].size]},r=_=>{a.value=[_[0].size,_[1].size]},i=P(()=>n.value[0]),u=P(()=>a.value[0]),c=P(()=>a.value[1]),m=P(()=>n.value[1]),d=P(()=>e.layout===Ue.horizontalWithVariables||e.layout===Ue.vertical),y=P(()=>e.layout===Ue.horizontalWithVariables),x=P(()=>!!e.customLayout),S=P(()=>{var _;return((_=e.customLayout)==null?void 0:_.direction)==="vertical"}),b=P(()=>{var _,B;return((B=(_=e.customLayout)==null?void 0:_.innerSplit)==null?void 0:B.direction)==="vertical"}),g=_=>{var T,H,W,F,G;const B=(T=e.customLayout)==null?void 0:T.id;if(!B)return((W=(H=e.customLayout)==null?void 0:H.panels[_])==null?void 0:W.defaultSize)??50;const q=t.customLayoutSizes[B];return(q==null?void 0:q.panels[_])??((G=(F=e.customLayout)==null?void 0:F.panels[_])==null?void 0:G.defaultSize)??50},C=_=>{var T,H,W,F,G,j,te;const B=(T=e.customLayout)==null?void 0:T.id;if(!B)return((F=(W=(H=e.customLayout)==null?void 0:H.innerSplit)==null?void 0:W.panels[_])==null?void 0:F.defaultSize)??50;const q=t.customLayoutSizes[B];return(q==null?void 0:q.innerPanels[_])??((te=(j=(G=e.customLayout)==null?void 0:G.innerSplit)==null?void 0:j.panels[_])==null?void 0:te.defaultSize)??50},E=_=>{var q;const B=(q=e.customLayout)==null?void 0:q.id;B&&t.updateCustomLayoutSizes(B,_.map(T=>T.size))},$=_=>{var T,H,W;const B=(T=e.customLayout)==null?void 0:T.id;if(!B)return;const q=((H=t.customLayoutSizes[B])==null?void 0:H.panels)??((W=e.customLayout)==null?void 0:W.panels.map(F=>F.defaultSize))??[];t.updateCustomLayoutSizes(B,q,_.map(F=>F.size))},L={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(_,B)=>(v(),A("div",ca,[l(x)&&_.customLayout?(v(),I(l(Je),{key:0,class:"default-theme",horizontal:l(S),onResize:B[1]||(B[1]=q=>E(q.panes))},{default:h(()=>[(v(!0),A(ee,null,ne(_.customLayout.panels,(q,T)=>(v(),A(ee,{key:T},[_.customLayout.innerSplit&&_.customLayout.innerSplit.panelIndex===T?(v(),I(l(ze),{key:0,size:g(T),"min-size":q.minSize,"max-size":q.maxSize},{default:h(()=>[p(l(Je),{horizontal:l(b),class:"default-theme",onResize:B[0]||(B[0]=H=>$(H.panes))},{default:h(()=>[(v(!0),A(ee,null,ne(_.customLayout.innerSplit.panels,(H,W)=>(v(),I(l(ze),{key:`inner-${W}`,size:C(W),"min-size":H.minSize,"max-size":H.maxSize},{default:h(()=>[f("div",{class:pe(L[H.slot])},[xe(_.$slots,H.slot)],2)]),_:2},1032,["size","min-size","max-size"]))),128))]),_:3},8,["horizontal"])]),_:2},1032,["size","min-size","max-size"])):(v(),I(l(ze),{key:1,size:g(T),"min-size":q.minSize,"max-size":q.maxSize},{default:h(()=>[f("div",{class:pe(L[q.slot])},[xe(_.$slots,q.slot)],2)]),_:2},1032,["size","min-size","max-size"]))],64))),128))]),_:3},8,["horizontal"])):(v(),I(l(Je),{key:1,onResize:B[3]||(B[3]=q=>o(q.panes)),class:"default-theme",horizontal:_.layout===l(Ue).vertical},{default:h(()=>[p(l(ze),{size:l(i)},{default:h(()=>[p(l(Je),{horizontal:l(y),onResize:B[2]||(B[2]=q=>l(d)?r(q.panes):null)},{default:h(()=>[p(l(ze),{size:l(d)?l(u):100,"min-size":"30"},{default:h(()=>[f("div",da,[xe(_.$slots,"content")])]),_:3},8,["size"]),l(d)?(v(),I(l(ze),{key:0,size:l(c),"min-size":"0","max-size":"70"},{default:h(()=>[f("div",ma,[xe(_.$slots,"variables")])]),_:3},8,["size"])):Q("",!0)]),_:3},8,["horizontal"])]),_:3},8,["size"]),e.showResultPanel!==!1?(v(),I(l(ze),{key:0,size:l(m),"min-size":"0","max-size":"80"},{default:h(()=>[f("div",pa,[xe(_.$slots,"result")])]),_:3},8,["size"])):Q("",!0)]),_:3},8,["horizontal"]))]))}}),It={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"},ha=Object.keys(It).sort((s,e)=>e.length-s.length),xs=s=>{const e=s.toUpperCase().trim().replace(/;$/,"");for(const t of ha)if(e===t||e.startsWith(`${t} `))return t;return e.split(/\s+/)[0]||e},va=s=>{const e=s.toUpperCase().trim(),t=xs(e);if(["SELECT","VALUES","SHOW","EXPLAIN","TABLE"].includes(t))return!1;const a=It[t];return!!(["INSERT","UPDATE","DELETE","TRUNCATE","COPY","MERGE","CALL","DO"].includes(t)||a==="DDL"||a==="DCL"||["SET","RESET","GRANT","REVOKE","COMMENT","ANALYZE","VACUUM","REINDEX","CLUSTER"].includes(t)||["CREATE","DROP","ALTER"].includes(t))},ga=(s,e)=>{const t=s||"Query",n=e??0;return["INSERT","UPDATE","DELETE"].includes(t.toUpperCase())?`${t} successful. ${n} rows affected.`:`${t} successful.`};class Be{constructor(e,t){ae(this,"cmd");ae(this,"commandKey");ae(this,"rowCount");this.cmd=e.toUpperCase().trim(),this.commandKey=xs(this.cmd),this.rowCount=t}isMutation(){return va(this.cmd)}getMessage(e){return e?ga(this.cmd,this.rowCount):""}getCategory(){return It[this.commandKey]??"UNKNOWN"}build(){const e=this.isMutation();return{isMutation:e,message:this.getMessage(e),category:this.getCategory()}}}class ya extends Be{isMutation(){return["VACUUM","ANALYZE","REINDEX","CLUSTER"].includes(this.commandKey)?!0:super.isMutation()}}class xt extends Be{isMutation(){return this.commandKey==="OPTIMIZE"?!0:super.isMutation()}getMessage(e){return this.commandKey==="TRUNCATE"?"TRUNCATE successful.":super.getMessage(e)}}class xa extends xt{}class bs extends Be{isMutation(){return this.commandKey==="TRUNCATE"?!0:super.isMutation()}getMessage(e){return this.commandKey==="INSERT"?`INSERT successful. ${this.rowCount} row(s) affected.`:super.getMessage(e)}}class ba extends bs{}class Kt extends Be{}class Ca extends Be{getMessage(e){return this.commandKey==="MERGE"?`MERGE successful. ${this.rowCount} rows affected.`:super.getMessage(e)}}class Sa extends Be{getMessage(e){return this.commandKey==="TRUNCATE"?"TRUNCATE successful.":this.commandKey==="MERGE"?`MERGE successful. ${this.rowCount} rows affected.`:super.getMessage(e)}}const wa={[Z.POSTGRES]:ya,[Z.MARIADB]:xt,[Z.MYSQL]:xt,[Z.MYSQL2]:xa,[Z.REDIS]:Kt,[Z.SQLITE3]:bs,[Z.SNOWFLAKE]:Kt,[Z.BETTER_SQLITE3]:ba,[Z.MSSQL]:Ca,[Z.ORACLE]:Sa},_a=(s,e=0,t=Z.POSTGRES)=>{const n=wa[t];if(!n)throw new Error(`Unsupported database client type: "${t}"`);return new n(s,e).build()};function Gt(s,e){return Object.prototype.hasOwnProperty.call(s,e)}function Ea(s,e){if(Array.isArray(s))return Object.fromEntries(e.map((o,r)=>[o.name,s[r]]));const t=s;if(!e.length)return{...t};const n={};let a=!1;return e.forEach((o,r)=>{if(Gt(t,o.name)){n[o.name]=t[o.name],a=!0;return}const i=String(r);Gt(t,i)&&(n[o.name]=t[i],a=!0)}),a?n:{...t}}function Ta(s,e){return s.map(t=>Ea(t,e))}const Ra={class:"h-full flex flex-col p-2"},ka={class:"flex items-center justify-between mb-2"},$a={class:"flex items-center gap-2 text-xs text-muted-foreground"},za={key:0,class:"mb-3 p-2 bg-muted/50 rounded-md border text-xs"},Aa={class:"text-muted-foreground mb-1 flex items-center gap-1"},La={class:"text-[11px] line-clamp-2"},Ma={key:1,class:"mb-3 p-3 bg-red-50 border border-red-200 rounded-md text-sm text-red-600"},Na={class:"flex items-center gap-2"},Ia={key:2,class:"flex-1 flex items-center justify-center text-muted-foreground"},Oa={class:"text-center"},Pa={class:"text-sm mb-1"},qa={class:"flex flex-wrap justify-center gap-2"},Da={key:0,class:"whitespace-pre-wrap"},Fa={key:1,class:"prose prose-sm dark:prose-invert max-w-none prose-pre:bg-muted prose-pre:text-foreground"},Va={key:0,class:"whitespace-pre-wrap"},Ba={key:1,class:"flex gap-3"},ja={class:"bg-muted rounded-lg p-3 text-sm"},Ua={class:"flex items-center gap-2"},Ha={key:4,class:"flex flex-col gap-2"},Qa=X({__name:"ResultTabAgentView",props:{activeTab:{}},setup(s){const e=s,t=P(()=>e.activeTab.metadata.statementQuery),{selectedProvider:n,selectedModel:a,isLoading:o,error:r,messages:i,hasApiKey:u,currentProvider:c,sendMessage:m,clearChat:d}=ro({body:()=>({sqlContext:t.value})}),{openSettings:y}=sn(),x=K(""),S=K(null),b=async E=>{if(E.preventDefault(),!x.value.trim()||o.value)return;const $=x.value;x.value="",await m($),await Ce(),g()},g=()=>{S.value&&(S.value.scrollTop=S.value.scrollHeight)};de(()=>i.value.length,()=>{Ce(()=>g())}),de(()=>{const E=i.value[i.value.length-1];return E!=null&&E.parts?E.parts.filter($=>$.type==="text").map($=>$.text).join(""):""},()=>{Ce(()=>g())});const C=async E=>{await m(E),await Ce(),g()};return(E,$)=>{var T,H,W;const L=fe,_=Se,B=Ke,q=ao;return v(),A("div",Ra,[f("div",ka,[f("div",$a,[p(L,{name:"hugeicons:chat-bot",class:"size-4"}),$[8]||($[8]=f("span",null,"SQL Assistant",-1)),f("div",null,[p(l(ce),null,{default:h(()=>[p(l(ie),{"as-child":""},{default:h(()=>[f("div",null,[p(tn,{provider:l(n),"onUpdate:provider":$[0]||($[0]=F=>Ae(n)?n.value=F:null),model:l(a),"onUpdate:model":$[1]||($[1]=F=>Ae(a)?a.value=F:null),class:"min-w-[160px] h-6!"},null,8,["provider","model"])])]),_:1}),p(l(ue),null,{default:h(()=>$[7]||($[7]=[f("p",null,"Select AI Model",-1)])),_:1})]),_:1})])]),p(l(ce),null,{default:h(()=>[p(l(ie),{"as-child":""},{default:h(()=>[p(_,{variant:"ghost",size:"xs",onClick:l(d),disabled:l(i).length===0},{default:h(()=>[p(L,{name:"lucide:trash-2",class:"size-3.5"})]),_:1},8,["onClick","disabled"])]),_:1}),p(l(ue),null,{default:h(()=>$[9]||($[9]=[f("p",null,"Clear chat history",-1)])),_:1})]),_:1})]),l(t)?(v(),A("div",za,[f("div",Aa,[p(L,{name:"hugeicons:sql",class:"size-3"}),$[10]||($[10]=O(" Current Query Context: "))]),f("code",La,D(l(t)),1)])):Q("",!0),l(r)?(v(),A("div",Ma,[f("div",Na,[p(L,{name:"lucide:alert-circle",class:"size-4"}),O(" "+D(l(r)),1)])])):Q("",!0),l(u)?(v(),A("div",{key:3,ref_key:"messagesContainer",ref:S,class:"flex-1 overflow-y-auto space-y-4 mb-4"},[l(i).length===0?(v(),I(B,{key:0,title:"Agent Chat",desc:"Ask me anything about your SQL query"},{default:h(()=>[f("div",qa,[p(_,{variant:"outline",size:"xs",onClick:$[3]||($[3]=F=>C("Explain this query"))},{default:h(()=>$[14]||($[14]=[O(" Explain this query ")])),_:1}),p(_,{variant:"outline",size:"xs",onClick:$[4]||($[4]=F=>C("How can I optimize this query?"))},{default:h(()=>$[15]||($[15]=[O(" Optimize query ")])),_:1}),p(_,{variant:"outline",size:"xs",onClick:$[5]||($[5]=F=>C("What are potential issues with this query?"))},{default:h(()=>$[16]||($[16]=[O(" Find issues ")])),_:1})])]),_:1})):Q("",!0),(v(!0),A(ee,null,ne(l(i),F=>(v(),A("div",{key:F.id,class:pe(["flex gap-3",F.role==="user"?"justify-end":"justify-start"])},[f("div",{class:pe(["max-w-[80%] rounded-lg p-3 text-sm",F.role==="user"?"bg-primary text-primary-foreground":"bg-muted"])},[F.role==="user"?(v(!0),A(ee,{key:0},ne(F.parts,(G,j)=>(v(),A(ee,{key:j},[G.type==="text"?(v(),A("span",Da,D(G.text),1)):Q("",!0)],64))),128)):(v(),A("div",Fa,[(v(!0),A(ee,null,ne(F.parts,(G,j)=>(v(),A(ee,{key:j},[G.type==="text"?(v(),A("span",Va,D(G.text),1)):Q("",!0)],64))),128))]))],2)],2))),128)),l(o)&&(!((T=l(i)[l(i).length-1])!=null&&T.parts)||((W=(H=l(i)[l(i).length-1])==null?void 0:H.parts)==null?void 0:W.length)===0)?(v(),A("div",Ba,[f("div",ja,[f("div",Ua,[p(L,{name:"hugeicons:loading-03",class:"size-4 animate-spin"}),$[17]||($[17]=f("span",{class:"text-muted-foreground"},"Thinking...",-1))])])])):Q("",!0)],512)):(v(),A("div",Ia,[f("div",Oa,[p(L,{name:"lucide:key",class:"size-12 mb-3 opacity-50 mx-auto"}),f("p",Pa," No API key configured for "+D(l(c).name),1),$[13]||($[13]=f("p",{class:"text-xs text-muted-foreground mb-3"}," Configure your API keys in Settings → Agent ",-1)),p(l(ce),null,{default:h(()=>[p(l(ie),{"as-child":""},{default:h(()=>[p(_,{variant:"outline",size:"sm",class:"text-xs",onClick:$[2]||($[2]=F=>l(y)("Agent"))},{default:h(()=>[p(L,{name:"lucide:settings",class:"size-4 mr-1"}),$[11]||($[11]=O(" Open Settings "))]),_:1})]),_:1}),p(l(ue),null,{default:h(()=>$[12]||($[12]=[f("p",null,"Open functionality settings",-1)])),_:1})]),_:1})])])),l(u)?(v(),A("div",Ha,[f("form",{onSubmit:b,class:"flex gap-2 relative"},[p(q,{modelValue:l(x),"onUpdate:modelValue":$[6]||($[6]=F=>Ae(x)?x.value=F:null),placeholder:"Ask about your SQL query...",disabled:l(o),class:"min-h-4!"},null,8,["modelValue","disabled"]),p(l(ce),null,{default:h(()=>[p(l(ie),{"as-child":""},{default:h(()=>[p(_,{type:"submit",size:"iconSm",class:"absolute right-2 top-1/2 -translate-y-1/2 rounded-full",disabled:!l(x).trim()||l(o)},{default:h(()=>[p(L,{name:l(o)?"hugeicons:loading-03":"lucide:arrow-up",class:pe(["size-4",l(o)?"animate-spin":""])},null,8,["name","class"])]),_:1},8,["disabled"])]),_:1}),p(l(ue),null,{default:h(()=>$[18]||($[18]=[f("p",null,"Send message",-1)])),_:1})]),_:1})],32)])):Q("",!0)])}}}),Wa={class:"h-full p-2 overflow-y-auto"},Ka={key:0,class:"space-y-2"},Ga={class:"flex items-center justify-between gap-2"},Ya={class:"flex items-center gap-1"},Ja={class:"text-sm pl-5 text-muted-foreground decoration-wavy underline decoration-red-600"},Za={key:0,class:"pl-5 mt-1 text-sm text-amber-600/90 font-medium"},Xa={class:"pt-2 border-t"},er={class:"error-query-container"},tr={key:0,class:"pt-2 border-t"},sr=X({__name:"ResultTabErrorView",props:{activeTab:{}},emits:["onChangeView"],setup(s,{emit:e}){const t=s,n=e,a=x=>!!x.metadata.executeErrors,o=P(()=>{var S,b;const x=(S=t.activeTab.metadata.executeErrors)==null?void 0:S.data;return((b=x==null?void 0:x.normalizeError)==null?void 0:b.position)||null}),r=P(()=>{var b;const x=t.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=P(()=>{var S,b;const x=(S=t.activeTab.metadata.executeErrors)==null?void 0:S.data;return((b=x==null?void 0:x.normalizeError)==null?void 0:b.hint)||null}),u=P(()=>{const x=t.activeTab.metadata.statementQuery;if(!x)return[];const S=o.value,b=[];if(S&&S>0){const g=S-1;let C=g;for(;C<x.length&&x[C]!==`
|
|
9
|
-
`&&x[C]!=="\r"&&x[C]!==" "&&x[C]!==" ";)C++;C<=g&&(C=Math.min(g+1,x.length)),b.push({start:g,end:C,properties:{class:"error-highlight"}})}return b}),c=async()=>{if(typeof window>"u")return;await Ce();const x=document.querySelector(".error-query-container .error-highlight");x&&x.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"})};de(()=>u.value,()=>{c()},{flush:"post"});const m=P(()=>{var S;const x={...((S=t.activeTab.metadata.executeErrors)==null?void 0:S.data)||{}};return x==null||delete x.normalizeError,x?typeof x=="string"?x:JSON.stringify(x,null,2):""}),d=P(()=>t.activeTab.metadata.statementQuery||""),y=()=>{n("onChangeView","agent")};return(x,S)=>{var C;const b=fe,g=Mt;return v(),A("div",Wa,[a(x.activeTab)?(v(),A("div",Ka,[f("div",Ga,[f("div",null,[f("div",Ya,[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",Ja,D(r.value),1),i.value?(v(),A("div",Za," Hint: "+D(i.value),1)):Q("",!0)]),p(l(Se),{onClick:y,size:"xs",variant:"outline"},{default:h(()=>[p(b,{name:"hugeicons:ai-brain-04",class:"size-4"}),S[1]||(S[1]=O(" Ask AI to fix this error "))]),_:1})]),f("div",Xa,[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",er,[p(g,{code:d.value,decorations:u.value,"show-copy-button":""},null,8,["code","decorations"])])]),(C=x.activeTab.metadata.executeErrors)!=null&&C.data?(v(),A("div",tr,[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:m.value,language:"json"},null,8,["code"])])):Q("",!0)])):Q("",!0)])}}}),nr=wt(sr,[["__scopeId","data-v-d4daf140"]]),or={class:"h-full p-4 space-y-3 overflow-y-auto"},ar={class:"space-y-2"},rr={class:"flex items-center gap-2 text-sm"},lr={class:"font-medium"},ir={class:"flex items-center gap-2 text-sm"},ur={class:"font-medium"},cr={class:"flex items-center gap-2 text-sm"},dr={class:"font-medium"},mr={class:"flex items-center gap-2 text-sm"},pr={class:"font-medium"},fr={class:"flex items-center gap-2 text-sm"},hr={class:"font-medium"},vr={key:0,class:"flex items-center gap-2 text-sm"},gr={class:"font-medium"},yr={class:"pt-3 border-t"},xr={key:0,class:"pt-3 border-t"},br={class:"flex flex-wrap gap-1"},Cr=X({__name:"ResultTabInfoView",props:{activeTab:{}},setup(s){const e=s,t=typeof TextEncoder<"u"?new TextEncoder:null,n=P(()=>{var o;const a=((o=e.activeTab)==null?void 0:o.result)??[];if(!t)return{bytes:0,formatted:"N/A"};try{const r=JSON.stringify(a),i=r?t.encode(r).length:0;return{bytes:i,formatted:nn(i)}}catch{return{bytes:0,formatted:"N/A"}}});return(a,o)=>{var u,c,m,d;const r=fe,i=Mt;return v(),A("div",or,[f("div",ar,[f("div",rr,[p(r,{name:"hugeicons:clock-01",class:"size-4 text-muted-foreground"}),o[0]||(o[0]=f("span",{class:"text-muted-foreground"},"Query Time:",-1)),f("span",lr,D(l(We)(a.activeTab.metadata.queryTime)),1)]),f("div",ir,[p(r,{name:"hugeicons:summation-01",class:"size-4 text-muted-foreground"}),o[1]||(o[1]=f("span",{class:"text-muted-foreground"},"Rows:",-1)),f("span",ur,D(l(yt)(((u=a.activeTab.result)==null?void 0:u.length)||0)),1)]),f("div",cr,[p(r,{name:"hugeicons:file-02",class:"size-4 text-muted-foreground"}),o[2]||(o[2]=f("span",{class:"text-muted-foreground"},"Result Size:",-1)),f("span",dr,D(n.value.formatted),1)]),f("div",mr,[p(r,{name:"hugeicons:chart-column",class:"size-4 text-muted-foreground"}),o[3]||(o[3]=f("span",{class:"text-muted-foreground"},"Columns:",-1)),f("span",pr,D(((c=a.activeTab.metadata.fieldDefs)==null?void 0:c.length)||0),1)]),f("div",fr,[p(r,{name:"hugeicons:calendar-03",class:"size-4 text-muted-foreground"}),o[4]||(o[4]=f("span",{class:"text-muted-foreground"},"Executed At:",-1)),f("span",hr,D(((m=a.activeTab.metadata.executedAt)==null?void 0:m.toLocaleString())||"N/A"),1)]),a.activeTab.metadata.connection?(v(),A("div",vr,[p(r,{name:"hugeicons:plug-socket",class:"size-4 text-muted-foreground"}),o[5]||(o[5]=f("span",{class:"text-muted-foreground"},"Connection:",-1)),f("span",gr,D(a.activeTab.metadata.connection.name||"Unknown"),1)])):Q("",!0)]),f("div",yr,[o[6]||(o[6]=f("div",{class:"text-sm text-muted-foreground mb-2"},"Query:",-1)),p(i,{code:a.activeTab.metadata.statementQuery||""},null,8,["code"])]),(d=a.activeTab.metadata.fieldDefs)!=null&&d.length?(v(),A("div",xr,[o[7]||(o[7]=f("div",{class:"text-sm text-muted-foreground mb-2"},"Fields:",-1)),f("div",br,[(v(!0),A(ee,null,ne(a.activeTab.metadata.fieldDefs,y=>(v(),A("span",{key:y.name,class:"text-xs bg-muted px-2 py-1 rounded"},D(y.name),1))),128))])])):Q("",!0)])}}}),Sr={class:"h-full flex flex-col flex-1 overflow-hidden"},wr=X({__name:"ResultTabRawView",props:{formattedData:{},executeLoading:{type:Boolean},isStreaming:{type:Boolean}},setup(s){const e=s;return(t,n)=>{const a=Ke;return v(),A("div",Sr,[e.formattedData.length===0&&!t.executeLoading&&!t.isStreaming?(v(),I(a,{key:0,title:"No Raw Data",desc:"The query returned no records to display as JSON."})):(v(),I(l(lo),{key:1,modelValue:e.formattedData,mode:"text",readOnly:!0,navigationBar:!1,class:"h-full"},null,8,["modelValue"]))])}}}),_r=X({__name:"RawQueryContextMenu",props:{cellContextMenu:{},cellHeaderContextMenu:{},data:{},selectedRows:{},tableName:{},schemaName:{}},emits:["onClearContextMenu"],setup(s,{emit:e}){const t=s,n=e,a=P(()=>{var b,g,C,E;return((g=(b=t.cellContextMenu)==null?void 0:b.column)==null?void 0:g.getColId())??((E=(C=t.cellHeaderContextMenu)==null?void 0:C.column)==null?void 0:E.getColId())}),o=P(()=>{var b,g,C;return((b=t.cellContextMenu)==null?void 0:b.column.getColDef().headerName)??((C=(g=t.cellHeaderContextMenu)==null?void 0:g.column)==null?void 0:C.getColDef().headerName)??""}),r=b=>{Ut(t.selectedRows||[],o.value??"",b)},i=b=>{Ut(t.data||[],o.value??"",b)},u=b=>ft(t.selectedRows||[],t.tableName||"table_data",b,t.schemaName),c=b=>ft(t.data||[],t.tableName||"table_data",b,t.schemaName),m=b=>Ht(t.selectedRows||[],t.tableName||"table_data",b,"selected",t.schemaName),d=b=>Ht(t.data||[],t.tableName||"table_data",b,"all",t.schemaName),y=()=>{var g;const b=(g=t.cellContextMenu)==null?void 0:g.value;if(b!==void 0){if(typeof b=="object")return Qt(JSON.stringify(b));Qt(String(b))}},x=()=>{var b;if(t.cellContextMenu){const g=(b=t.cellContextMenu)==null?void 0:b.data;ft([g],t.tableName||"table_data","csv-no-header",t.schemaName)}},S=P(()=>{var q;const b=!!t.cellContextMenu,g=t.selectedRows.length>0,C=t.selectedRows.length,E=((q=t.data)==null?void 0:q.length)||0,$=!!a.value,L=[{type:U.LABEL,title:`${C} selected`,condition:g&&b},{type:U.ACTION,title:"Copy as text",icon:"hugeicons:file-01",select:()=>r("list"),condition:g&&b},{type:U.ACTION,title:"Copy as JSON",icon:"hugeicons:code",select:()=>r("json"),condition:g&&b},{type:U.SEPARATOR,condition:g&&b},{type:U.LABEL,title:"All data in column"},{type:U.ACTION,title:"Copy as text",icon:"hugeicons:file-01",select:()=>i("list")},{type:U.ACTION,title:"Copy as JSON",icon:"hugeicons:code",select:()=>i("json")}],_=[{type:U.LABEL,title:`${C} selected row(s)`,condition:g},{type:U.ACTION,title:"Copy as CSV/TSV",icon:"hugeicons:csv-02",select:()=>u("csv-no-header"),condition:g},{type:U.ACTION,title:"Copy as JSON",icon:"hugeicons:code",select:()=>u("json"),condition:g},{type:U.ACTION,title:"Copy as SQL",icon:"hugeicons:database",select:()=>u("sql"),condition:g},{type:U.SEPARATOR,condition:g},{type:U.LABEL,title:"All rows"},{type:U.ACTION,title:"Copy as CSV/TSV",icon:"hugeicons:csv-02",select:()=>c("csv-no-header")},{type:U.ACTION,title:"Copy as JSON",icon:"hugeicons:code",select:()=>c("json")},{type:U.ACTION,title:"Copy as SQL",icon:"hugeicons:database",select:()=>c("sql")}],B=[{type:U.LABEL,title:`${C} selected row${C>1?"s":""}`,condition:g},{type:U.ACTION,title:"Export as CSV",icon:"hugeicons:csv-01",select:()=>m("csv-no-header"),condition:g},{type:U.ACTION,title:"Export as CSV (have headers)",icon:"hugeicons:csv-01",select:()=>m("csv-with-header"),condition:g},{type:U.ACTION,title:"Export as JSON",icon:"hugeicons:code",select:()=>m("json"),condition:g},{type:U.ACTION,title:"Export as SQL",icon:"hugeicons:database",select:()=>m("sql"),condition:g},{type:U.SEPARATOR,condition:g},{type:U.LABEL,title:`All ${E.toLocaleString()} row${E!==1?"s":""}`},{type:U.ACTION,title:"Export as CSV",icon:"hugeicons:csv-01",select:()=>d("csv-no-header")},{type:U.ACTION,title:"Export as CSV (have headers)",icon:"hugeicons:csv-01",select:()=>d("csv-with-header")},{type:U.ACTION,title:"Export as JSON",icon:"hugeicons:code",select:()=>d("json")},{type:U.ACTION,title:"Export as SQL",icon:"hugeicons:database",select:()=>d("sql")}];return[{type:U.ACTION,title:"Copy current cell",icon:"hugeicons:copy-02",select:y,condition:b},{type:U.ACTION,title:"Copy current row",icon:"hugeicons:copy-02",select:x,condition:g&&b},{type:U.SEPARATOR,condition:b},{type:U.SUBMENU,title:"Copy column",icon:"hugeicons:layout-3-column",items:L,condition:$,desc:o.value||"Select a column"},{type:U.SUBMENU,title:"Copy row(s)",icon:"hugeicons:layout-3-row",items:_},{type:U.SEPARATOR},{type:U.SUBMENU,title:"Export",icon:"hugeicons:file-download",items:B}]});return(b,g)=>(v(),I(l(Kn),{contextMenuItems:l(S),onOnClearContextMenu:g[0]||(g[0]=C=>n("onClearContextMenu"))},{default:h(()=>[xe(b.$slots,"default")]),_:3},8,["contextMenuItems"]))}}),Er={class:"h-full w-full"},Tr=X({__name:"ResultTabResultView",props:{activeTab:{},activeTabColumns:{},formattedData:{},executeLoading:{type:Boolean},isStreaming:{type:Boolean}},setup(s){const e=s,t=K(),n=K([]),a=c=>{n.value=c},o=P(()=>n.value||[]),r=P(()=>{var c;return _a(e.activeTab.metadata.command||"",e.activeTab.metadata.rowCount||0,(c=e.activeTab.metadata.connection)==null?void 0:c.type)}),i=P(()=>r.value.isMutation),u=P(()=>r.value.message);return(c,m)=>{var x,S;const d=Ke,y=gs;return v(),A("div",Er,[c.activeTab.result.length===0&&l(i)&&!c.executeLoading&&!c.isStreaming?(v(),I(d,{key:0,desc:l(u),hiddenIcon:"",class:"h-full"},null,8,["desc"])):c.activeTab.result.length===0&&!c.executeLoading&&!c.isStreaming?(v(),I(d,{key:1,title:"No Results",desc:"The query returned no records.",class:"h-full"})):(v(),I(_r,{key:2,data:c.formattedData||[],selectedRows:l(o)||[],cellContextMenu:(x=l(t))==null?void 0:x.cellContextMenu,cellHeaderContextMenu:(S=l(t))==null?void 0:S.cellHeaderContextMenu,onOnClearContextMenu:m[0]||(m[0]=b=>{var g;return(g=l(t))==null?void 0:g.clearCellContextMenu()})},{default:h(()=>[p(y,{ref_key:"rawQueryTableRef",ref:t,columns:c.activeTabColumns,data:c.formattedData||[],selectedRows:l(n),onOnSelectedRows:a,class:"h-full","skip-re-column-size":"",columnKeyBy:"field"},null,8,["columns","data","selectedRows"])]),_:1},8,["data","selectedRows","cellContextMenu","cellHeaderContextMenu"]))])}}});var st=(s=>(s.GRID="grid",s.TIMELINE="time-line",s.RAW="raw",s))(st||{});const Rr=[{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"}],kr={class:"flex items-center justify-between px-3 py-2 border-b shrink-0"},$r={class:"flex items-center gap-3 min-w-0"},zr={class:"flex items-center gap-2 flex-wrap"},Ar={class:"flex flex-col gap-1 max-w-[250px] sm:max-w-xs"},Lr={class:"text-[11px] text-muted-foreground list-disc pl-3 break-words whitespace-normal"},Mr={class:"flex flex-col gap-1 max-w-[250px] sm:max-w-xs"},Nr={class:"text-[11px] text-muted-foreground list-disc pl-3 break-words whitespace-normal"},Ir={class:"flex flex-col gap-1 max-w-[250px] sm:max-w-xs"},Or={class:"text-[11px] text-muted-foreground list-disc pl-3 break-words whitespace-normal"},Pr={class:"flex items-center gap-2 shrink-0"},qr=X({__name:"ExplainPlanHeader",props:qt({summaryStats:{},isExpanded:{type:Boolean}},{modelValue:{required:!0},modelModifiers:{}}),emits:qt(["toggle-expand"],["update:modelValue"]),setup(s,{emit:e}){const t=e,n=on(s,"modelValue");return(a,o)=>{const r=fe,i=an,u=ie,c=ue,m=ce,d=un,y=ln,x=rn,S=Se;return v(),A("div",kr,[f("div",$r,[p(r,{name:"hugeicons:analytics-up",class:"size-4 text-muted-foreground"}),o[6]||(o[6]=f("span",{class:"text-sm font-medium"},"Execution Plan",-1)),f("div",zr,[a.summaryStats.executionTime!==void 0?(v(),I(i,{key:0,variant:"outline",class:"text-[11px] h-5 gap-1"},{default:h(()=>[p(r,{name:"hugeicons:clock-01",class:"size-3"}),O(" "+D(l(We)(a.summaryStats.executionTime)),1)]),_:1})):Q("",!0),a.summaryStats.planningTime!==void 0?(v(),I(i,{key:1,variant:"outline",class:"text-[11px] h-5 gap-1"},{default:h(()=>[O(" Planning: "+D(l(We)(a.summaryStats.planningTime)),1)]),_:1})):Q("",!0),a.summaryStats.nodeCount>0?(v(),I(m,{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(()=>[O(D(a.summaryStats.nodeCount)+" nodes ",1)]),_:1})]),_:1}),(b=a.summaryStats.allNodes)!=null&&b.length?(v(),I(c,{key:0},{default:h(()=>[f("div",Ar,[o[2]||(o[2]=f("span",{class:"font-medium text-xs"},"Nodes:",-1)),f("ul",Lr,[(v(!0),A(ee,null,ne(a.summaryStats.allNodes,g=>(v(),A("li",{key:g.id},D(g.label),1))),128))])])]),_:1})):Q("",!0)]}),_:1})):(v(),I(i,{key:3,variant:"outline",class:"text-[11px] h-5 gap-1"},{default:h(()=>o[3]||(o[3]=[O(" 0 nodes ")])),_:1})),a.summaryStats.expensiveCount>0?(v(),I(m,{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(()=>[O(D(a.summaryStats.expensiveCount)+" expensive ",1)]),_:1})]),_:1}),(b=a.summaryStats.expensiveNodes)!=null&&b.length?(v(),I(c,{key:0},{default:h(()=>[f("div",Mr,[o[4]||(o[4]=f("span",{class:"font-medium text-xs"},"Expensive Nodes:",-1)),f("ul",Nr,[(v(!0),A(ee,null,ne(a.summaryStats.expensiveNodes,g=>(v(),A("li",{key:g.id},D(g.label),1))),128))])])]),_:1})):Q("",!0)]}),_:1})):Q("",!0),a.summaryStats.slowCount>0?(v(),I(m,{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(()=>[O(D(a.summaryStats.slowCount)+" slowest ",1)]),_:1})]),_:1}),(b=a.summaryStats.slowNodes)!=null&&b.length?(v(),I(c,{key:0},{default:h(()=>[f("div",Ir,[o[5]||(o[5]=f("span",{class:"font-medium text-xs"},"Slowest Node(s):",-1)),f("ul",Or,[(v(!0),A(ee,null,ne(a.summaryStats.slowNodes,g=>(v(),A("li",{key:g.id},D(g.label),1))),128))])])]),_:1})):Q("",!0)]}),_:1})):Q("",!0)])]),f("div",Pr,[p(x,{modelValue:n.value,"onUpdate:modelValue":o[0]||(o[0]=b=>n.value=b),class:"gap-0"},{default:h(()=>[p(y,{class:"h-6"},{default:h(()=>[(v(!0),A(ee,null,ne(l(Rr),b=>(v(),I(d,{key:b.value,value:b.value,class:"text-xs px-1 rounded-sm cursor-pointer"},{default:h(()=>[p(r,{name:b.icon,class:"size-3.5!"},null,8,["name"]),O(" "+D(b.label),1)]),_:2},1032,["value"]))),128))]),_:1})]),_:1},8,["modelValue"]),p(S,{variant:"outline",size:"iconSm",onClick:o[1]||(o[1]=b=>t("toggle-expand"))},{default:h(()=>[p(r,{name:a.isExpanded?"hugeicons:arrow-shrink":"hugeicons:arrow-expand",class:"size-3.5"},null,8,["name"])]),_:1})])])}}}),Dr={class:"flex items-center text-xs h-full w-full overflow-hidden whitespace-nowrap"},Fr={key:0,class:"text-muted-foreground shrink-0 whitespace-pre",style:{"font-family":"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace !important"}},Vr={key:1,class:"font-normal shrink-0"},Br={key:2,class:"text-xxs pl-0.5 text-muted-foreground truncate shrink min-w-0"},jr=X({__name:"ExplainOperationCell",props:{params:{}},setup(s){const e=s,t=P(()=>{var n;return((n=e.params)==null?void 0:n.data)??{}});return(n,a)=>(v(),A("div",Dr,[l(t).treePrefix?(v(),A("span",Fr,D(l(t).treePrefix),1)):Q("",!0),l(t).nodeType?(v(),A("span",Vr,D(l(t).nodeType),1)):Q("",!0),l(t).contextLabel?(v(),A("span",Br,D(l(t).contextLabel),1)):Q("",!0)]))}}),Yt={"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"},le=s=>s?String(s).replace(/^[\[]|[\]]$/g,"").replace(/"/g,"").trim():"",Ur=s=>s==="Seq Scan"?"bad":Yt[s]?Yt[s]:s.includes("Join")?"join":s.includes("Scan")?"scan":s.includes("Aggregate")?"agg":s.includes("Sort")?"sort":"other",Jt=(s,e,t)=>{for(let n=e+1;n<s.length;n++){const a=s[n].depth??0;if(a<t)return!1;if(a===t)return!0}return!1},Hr=(s,e)=>{const n=s[e].depth??0;if(n===0)return"";const a=[];for(let r=1;r<n;r++)a.push(Jt(s,e,r)?"│ ":" ");const o=!Jt(s,e,n);return a.push(o?"└─ ":"├─ "),a.join("")},Qr=s=>{const e=le(s.hashCond),t=le(s.mergeCond),n=le(s.joinFilter),a=le(s.joinType).toLowerCase();if(a||e||t||n){const b=e||t||n,g=a?`${a} `:"";return{label:b?`${g}on ${b}`.trim():`${g}join`.trim(),kind:"join"}}const o=le(s.indexCond),r=le(s.recheckCond),i=le(s.tidCond);if(o)return{label:`on ${o}`,kind:"relation"};if(r)return{label:`recheck: ${r}`,kind:"relation"};if(i)return{label:`tid: ${i}`,kind:"relation"};const u=le(s.sortKey);if(u)return{label:`by ${u}`,kind:"sort"};const c=le(s.groupKey),m=le(s.hashKey);if(c||m)return{label:`by ${c||m}`,kind:"group"};const d=le(s.oneTimeFilter);if(d)return{label:`one-time: ${d}`,kind:"relation"};const y=le(s.filter);if(y)return{label:`filter: ${y}`,kind:"relation"};const x=le(s.cteName);if(x)return{label:`cte: ${x}`,kind:"relation"};const S=le(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:""}},Wr=s=>[...s].map(e=>{var c,m;const t=e["Plan Rows"]||0,n=e["Actual Rows"]||0,a=e.estimateRatio,o=e["Actual Startup Time"]||0,r=e["Plan Width"]||0,i=e.rowEstimateAccuracy||"accurate",u=[`Node: ${e["Node Type"]}`,e["Relation Name"]?`Relation: ${e["Relation Name"]}`:"",`Depth: ${e.depth}`,`Startup time: ${o.toFixed(3)} ms`,`Total time: ${(e["Actual Total Time"]||0).toFixed(3)} ms`,`Actual rows: ${n.toLocaleString()}`,`Plan rows: ${t.toLocaleString()}`,a!==void 0?`Estimate ratio: ${a}x (${i})`:"Estimate ratio: -",`Total cost: ${(e["Total Cost"]||0).toFixed(2)}`,`Plan width: ${r}`,`Loops: ${(e["Actual Loops"]||0).toLocaleString()}`,`Slowest: ${e.isSlowest?"yes":"no"}`,`Expensive: ${e.isExpensive?"yes":"no"}`].filter(Boolean).join(`
|
|
10
|
-
`);return{id:e.id,order:e.index,nodeType:e["Node Type"],relation:e["Relation Name"],alias:e.Alias,sortKey:((c=e["Sort Key"])==null?void 0:c.join(", "))??"",joinType:e["Join Type"]??"",groupKey:((m=e["Group Key"])==null?void 0:m.join(", "))??"",hashKey:"",filter:e.Filter??"",joinFilter:"",oneTimeFilter:"",indexCond:"",hashCond:e["Hash Cond"]??"",mergeCond:e["Merge Cond"]??"",recheckCond:"",tidCond:"",cteName:"",subplanName:"",timeMs:e["Actual Total Time"]||0,rows:n,planRows:t,estimateRatio:a,cost:e["Total Cost"]||0,width:r,loops:e["Actual Loops"]||0,depth:e.depth,indentPx:e.depth*16,hitReadRatio:e.hitReadRatio,isSlowest:e.isSlowest,isExpensive:e.isExpensive,tooltipLines:u}}),Kr=s=>{const e=s.reduce((t,n)=>t+(n.timeMs||0),0)||1;return s.map((t,n)=>{const a=Hr(s,n),{label:o,kind:r}=Qr(t),i=t.isSlowest?"slowest":t.isExpensive?"expensive":"normal";return{order:t.order,timeMs:t.timeMs,rows:t.rows,planRows:t.planRows,estimateRatioValue:t.estimateRatio,cost:t.cost,width:t.width,loops:t.loops,hitReadRatio:t.hitReadRatio,isSlowest:t.isSlowest,isExpensive:t.isExpensive,orderLabel:`${t.order}`,queryPercentLabel:`${(t.timeMs/e*100).toFixed(2)}%`,timeSpentLabel:`${t.timeMs.toFixed(3)} ms`,rowsLabel:t.rows.toLocaleString(),planRowsLabel:t.planRows.toLocaleString(),estimateLabel:t.estimateRatio!==void 0?`${t.estimateRatio}×`:"-",costLabel:t.cost.toFixed(2),widthLabel:t.width,loopsLabel:t.loops.toLocaleString(),hitReadRatioLabel:t.hitReadRatio!==void 0?`${(t.hitReadRatio*100).toFixed(2)}%`:"-",statusLabel:i,treePrefix:a,nodeType:t.nodeType,nodeTypeCategory:Ur(t.nodeType),contextLabel:o,contextKind:r}})},Gr={class:"h-full p-2"},Yr=X({__name:"ExplainGridPane",props:{nodes:{}},setup(s){const e=s,t=P(()=>Wr(e.nodes)),n=P(()=>Kr(t.value)),a=P(()=>[{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:r=>`${r.data.treePrefix}${r.data.nodeType} ${r.data.contextLabel}`},{headerName:"Status",field:"statusLabel",width:96,sortable:!0,resizable:!0,filter:!0,cellClass:r=>{const i=r.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:r=>{var u;const i=Number((u=r.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 "}]),o={ExplainOperationCell:jr};return(r,i)=>(v(),A("div",Gr,[p(l(gs),{class:"h-full",columns:[],data:[],"column-key-by":"index","skip-re-column-size":"","has-hash-index":!1,"override-column-defs":l(a),"override-row-data":l(n),"external-components":o},null,8,["override-column-defs","override-row-data"])]))}}),Jr={class:"h-full p-2"},Zr={class:"rounded-lg border p-2 flex flex-col h-full min-h-0"},Xr={class:"flex justify-between items-center mb-4"},el={class:"text-sm font-bold text-muted-foreground uppercase flex items-center gap-2"},tl={key:0,class:"h-full grid place-items-center text-sm text-muted-foreground"},sl={key:1,class:"flex-1 overflow-auto relative"},nl={class:"min-w-[680px] text-xs"},ol={class:"flex border-b pb-2 mb-2 sticky top-0 bg-background z-10 font-medium text-muted-foreground"},al={class:"flex-1 relative h-4"},rl={class:"absolute right-0"},ll={class:"pb-2"},il=["onMouseenter"],ul={class:"w-[28%] min-w-[190px] max-w-[260px] px-2 flex items-center overflow-hidden"},cl={class:"truncate flex items-center gap-1"},dl={class:"font-mono text-xxs text-right shrink-0 text-muted-foreground"},ml={class:"flex flex-col truncate"},pl=["title"],fl={key:0,class:"text-muted-foreground text-xxs truncate"},hl={key:0},vl={class:"flex-1 relative h-6 mx-2"},gl={class:"space-y-2 text-xs"},yl={class:"font-semibold flex items-center gap-1"},xl={class:"grid grid-cols-2 gap-x-3 gap-y-1 text-[11px]"},bl={class:"font-mono"},Cl={class:"font-mono"},Sl={class:"font-mono"},wl={class:"font-mono"},_l={class:"font-mono"},El={class:"font-mono"},Tl={class:"font-mono"},Rl={class:"font-mono"},kl={key:0,class:"text-[11px] text-muted-foreground"},$l={key:0},Ze=14,zl=X({__name:"ExplainTimelineChartPane",props:{nodes:{},totalTime:{}},setup(s){const e=s,t=K(null),n=P(()=>{const d=[...e.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<d.length;b+=1){const g=d[b].depth;if(g<S)return!1;if(g===S)return!0}return!1};return d.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}})}),a=P(()=>{const d=n.value.length?Math.max(...n.value.map(y=>y.end)):0;return Math.max(e.totalTime||0,d,1)}),o=(d,y)=>{const x=a.value>0?a.value:1,S=d/x*100,b=Math.max(y/x*100,.5);return{left:`${S}%`,width:`${b}%`}},r=d=>{const y=a.value>0?a.value:1;return(d/y*100).toFixed(2)},i=d=>`${Math.max(d,0)*Ze}px`,u=d=>`${(d-1)*Ze+Ze/2}px`,c=`${Ze/2}px`,m=d=>d==="Seq Scan"?"bg-gray-400 dark:bg-gray-600":d.includes("Scan")?"bg-gray-300 dark:bg-gray-700":d.includes("Join")?"bg-gray-500 dark:bg-gray-500":d==="Sort"?"bg-gray-300 dark:bg-gray-600":(d.includes("Aggregate"),"bg-gray-400 dark:bg-gray-600");return(d,y)=>{const x=fe,S=ie,b=ue,g=ce;return v(),A("div",Jr,[f("div",Zr,[f("div",Xr,[f("h3",el,[p(x,{name:"hugeicons:clock-01",class:"size-4"}),y[1]||(y[1]=O(" Execution Plan Timeline "))]),y[2]||(y[2]=f("span",{class:"text-xs text-muted-foreground"},"Hover for details",-1))]),l(n).length===0?(v(),A("div",tl," No timeline data available ")):(v(),A("div",sl,[f("div",nl,[f("div",ol,[y[7]||(y[7]=f("div",{class:"w-[28%] min-w-[190px] max-w-[260px] pl-2"}," Node Hierarchy ",-1)),f("div",al,[y[3]||(y[3]=f("div",{class:"absolute left-0"},"0ms",-1)),f("div",rl,D(l(Ye)(l(a))),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",ll,[(v(!0),A(ee,null,ne(l(n),C=>(v(),A("div",{key:C.id,class:pe(["flex items-center group rounded transition-colors hover:bg-muted",l(t)===C.id?"bg-muted/40":""]),onMouseenter:E=>t.value=C.id,onMouseleave:y[0]||(y[0]=E=>t.value=null)},[f("div",ul,[f("div",{class:"relative shrink-0 h-7",style:Ve({width:i(C.depth)})},[(v(!0),A(ee,null,ne(C.continuationLevels,E=>(v(),A("div",{key:`${C.id}-v-${E}`,class:"absolute top-0 bottom-0 border-l border-dashed border-muted-foreground/35",style:Ve({left:u(E)})},null,4))),128)),C.depth>0?(v(),A(ee,{key:0},[f("div",{class:"absolute top-0 border-l border-dashed border-muted-foreground/45",style:Ve({left:u(C.depth),height:C.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:Ve({left:u(C.depth),width:c})},null,4)],64)):Q("",!0)],4),f("div",cl,[f("span",dl," #"+D(C.id.replace("ep-","")),1),f("div",ml,[f("span",{class:"truncate font-medium text-sm",title:C.nodeType},D(C.nodeType),9,pl),C.relation?(v(),A("span",fl,[O(D(C.relation)+" ",1),C.alias&&C.alias!==C.relation?(v(),A("span",hl,"("+D(C.alias)+")",1)):Q("",!0)])):Q("",!0)])])]),f("div",vl,[y[16]||(y[16]=cn('<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:pe(["absolute top-1 bottom-1 rounded-sm transition-all shadow-sm opacity-90 cursor-default",[m(C.nodeType),l(t)===C.id?"brightness-105 ring-2 ring-border z-10":""]]),style:Ve(o(C.start,C.duration))},null,6)]),_:2},1024),p(b,{side:"top","side-offset":8,class:"max-w-[360px]"},{default:h(()=>{var E,$,L,_;return[f("div",gl,[f("div",yl,[p(x,{name:"hugeicons:flow-square",class:"size-3.5"}),O(" "+D(C.nodeType),1)]),f("div",xl,[y[8]||(y[8]=f("span",{class:"text-muted-foreground"},"Start",-1)),f("span",bl,D(l(Ye)(C.start)),1),y[9]||(y[9]=f("span",{class:"text-muted-foreground"},"End",-1)),f("span",Cl,D(l(Ye)(C.end)),1),y[10]||(y[10]=f("span",{class:"text-muted-foreground"},"Duration",-1)),f("span",Sl,D(l(Ye)(C.duration)),1),y[11]||(y[11]=f("span",{class:"text-muted-foreground"},"Share",-1)),f("span",wl,D(r(C.duration))+"%",1),y[12]||(y[12]=f("span",{class:"text-muted-foreground"},"Rows",-1)),f("span",_l,D(((E=C.actualRows)==null?void 0:E.toLocaleString())??"-"),1),y[13]||(y[13]=f("span",{class:"text-muted-foreground"},"Plan Rows",-1)),f("span",El,D((($=C.planRows)==null?void 0:$.toLocaleString())??"-"),1),y[14]||(y[14]=f("span",{class:"text-muted-foreground"},"Loops",-1)),f("span",Tl,D(((L=C.actualLoops)==null?void 0:L.toLocaleString())??"-"),1),y[15]||(y[15]=f("span",{class:"text-muted-foreground"},"Total Cost",-1)),f("span",Rl,D(((_=C.totalCost)==null?void 0:_.toFixed(2))??"-"),1)]),C.relation?(v(),A("div",kl,[O(" Relation: "+D(C.relation)+" ",1),C.alias&&C.alias!==C.relation?(v(),A("span",$l,"("+D(C.alias)+")",1)):Q("",!0)])):Q("",!0)])]}),_:2},1024)]),_:2},1024)])],42,il))),128))])])]))])])}}}),Al={class:"h-full overflow-auto p-2"},Ll=X({__name:"ExplainRawPane",props:{rawText:{}},setup(s){const e=s,t=P(()=>{const n=e.rawText.trim();return n.startsWith("{")||n.startsWith("[")?"json":"sql"});return(n,a)=>{const o=Mt;return v(),A("div",Al,[p(o,{code:n.rawText,language:t.value,"max-height":"100%"},null,8,["code","language"])])}}});let lt=0;const Ml=()=>(lt+=1,`ep-${lt}`),Zt=s=>s==null?"":typeof s=="string"?s:typeof s=="number"||typeof s=="boolean"?String(s):JSON.stringify(s),Nl=s=>{const e=(s["Shared Hit Blocks"]??0)+(s["Local Hit Blocks"]??0),t=(s["Shared Read Blocks"]??0)+(s["Local Read Blocks"]??0),n=e+t;if(!(n<=0))return Number((e/n).toFixed(4))},Il=(s,e)=>{const t=e["Plan Rows"],n=e["Actual Rows"];if(t!==void 0&&n!==void 0&&t>0&&n>=0){s.estimateRatio=Number((n/t).toFixed(2));const a=n/t;a>10?s.rowEstimateAccuracy="underestimate":a<.1?s.rowEstimateAccuracy="overestimate":s.rowEstimateAccuracy="accurate"}s.hitReadRatio=Nl(e),(e["Total Cost"]!==void 0&&e["Total Cost"]>1e3||e["Actual Total Time"]!==void 0&&e["Actual Total Time"]>100)&&(s.isExpensive=!0)},Ol=s=>{let e=0,t="";for(const a of s){const o=a.children.reduce((i,u)=>i+(u["Actual Total Time"]??0)*(u["Actual Loops"]??1),0)/(a["Actual Loops"]??1),r=Math.max(0,(a["Actual Total Time"]??0)-o);r>e&&(e=r,t=a.id)}const n=s.find(a=>a.id===t);n&&(n.isSlowest=!0)},Cs=(s,e,t)=>{const{Plans:n,...a}=s,o=s["Node Type"]||"Unknown Node",r=s["Relation Name"],i={...a,id:Ml(),index:lt,label:r?`${o} on ${r}`:o,estimateRatio:void 0,hitReadRatio:void 0,isExpensive:!1,isSlowest:!1,rowEstimateAccuracy:void 0,depth:e,children:(n??[]).map(u=>Cs(u,e+1,t))};return t.push(i),Il(i,s),i},Pl=(s,e)=>{lt=0;const t=[],n=Cs(s.Plan,0,t),a={"Planning Time":s["Planning Time"],"Execution Time":s["Execution Time"],totalCost:n["Total Cost"],triggersInfo:(s.Triggers??[]).map(Zt),jitInfo:[],settingsInfo:s.Settings?Object.entries(s.Settings).map(([r,i])=>`${r}: ${Zt(i)}`):[],rawText:e};Ol(t);const o=[...t].sort((r,i)=>r.index-i.index);return{root:n,summary:a,allNodes:o}},ql=s=>{const e={triggersInfo:[],jitInfo:[],settingsInfo:[],rawText:s},t=s.match(/Planning Time:\s*(\d+\.?\d*)\s*ms/i),n=s.match(/Execution Time:\s*(\d+\.?\d*)\s*ms/i);return t&&(e["Planning Time"]=Number.parseFloat(t[1])),n&&(e["Execution Time"]=Number.parseFloat(n[1])),{root:null,summary:e,allNodes:[]}},bt=s=>{if(!s)return null;if(typeof s=="string")try{return bt(JSON.parse(s))}catch{return null}return Array.isArray(s)?s.length?bt(s[0]):null:typeof s=="object"&&s!==null&&"Plan"in s&&typeof s.Plan=="object"?s:null},Ss=(s,e)=>{var t;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],a=Object.keys(n).find(o=>o.toUpperCase()==="QUERY PLAN")||((t=e==null?void 0:e[0])==null?void 0:t.name)||Object.keys(n)[0];return a?n[a]??null:null}return s[0]??null},Dl=(s,e)=>{const t=Ss(s,e);return t==null?"":typeof t=="string"?t:JSON.stringify(t,null,2)},Fl=s=>{const e=typeof s=="string"?s:JSON.stringify(s,null,2),t=bt(s);return t?Pl(t,e):ql(e)},Vl={class:"h-full min-h-0"},Bl={key:0,class:"h-full flex flex-col items-center justify-center gap-2 text-muted-foreground"},jl=X({__name:"ResultTabExplainView",props:{activeTab:{}},setup(s){const e=s,t=K(st.GRID),n=K(!1),a=P(()=>Ss(e.activeTab.result,e.activeTab.metadata.fieldDefs)),o=P(()=>Dl(e.activeTab.result,e.activeTab.metadata.fieldDefs)),r=P(()=>Fl(a.value)),i=P(()=>{const u=r.value.allNodes,c=u.filter(d=>d.isExpensive),m=u.filter(d=>d.isSlowest);return{planningTime:r.value.summary["Planning Time"],executionTime:r.value.summary["Execution Time"],nodeCount:u.length,expensiveCount:c.length,slowCount:m.length,allNodes:u,expensiveNodes:c,slowNodes:m}});return(u,c)=>{const m=qr,d=fe,y=Yr,x=zl,S=Ll;return v(),A("div",Vl,[l(n)?(v(),A("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:pe(["flex flex-col",l(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(m,{modelValue:l(t),"onUpdate:modelValue":c[1]||(c[1]=b=>Ae(t)?t.value=b:null),"summary-stats":l(i),"is-expanded":l(n),onToggleExpand:c[2]||(c[2]=b=>n.value=!l(n))},null,8,["modelValue","summary-stats","is-expanded"]),f("div",{class:pe(["flex-1 min-h-0",l(n)?"overflow-hidden":"overflow-y-auto"])},[l(r).root?l(t)===l(st).GRID?(v(),I(y,{key:1,nodes:l(r).allNodes},null,8,["nodes"])):l(t)===l(st).TIMELINE?(v(),I(x,{key:2,nodes:l(r).allNodes,"total-time":l(i).executionTime},null,8,["nodes","total-time"])):(v(),I(S,{key:3,"raw-text":l(o)},null,8,["raw-text"])):(v(),A("div",Bl,[p(d,{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)])}}}),Ul={class:"h-full flex w-full"},Hl={key:0,class:"flex mt-7 [writing-mode:vertical-rl]"},Ql=["onClick"],Wl={class:"h-full w-full flex flex-col"},Kl={class:"flex items-end overflow-x-auto pt-0.5"},Gl=["onClick","onContextmenu"],Yl={class:"truncate text-xs font-medium"},Jl=["onClick"],Zl={class:"h-full w-full border rounded-md rounded-tl-none overflow-hidden"},Xl=X({__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:e}){const t=s,n=e,a=K(null),o=P(()=>{if(!a.value)return!1;const g=Array.from(t.executedResults.keys()),C=g.indexOf(a.value);return C>=0&&C<g.length-1}),r=[{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=Qe([]);let c=null;const m=P(()=>t.activeTabId&&t.executedResults.get(t.activeTabId)||null),d=P(()=>{var g;return((g=m.value)==null?void 0:g.view)||"result"}),y=P(()=>{var g;return(g=m.value)!=null&&g.metadata.fieldDefs?m.value.metadata.fieldDefs.map((C,E)=>{var $;return{index:E,originalName:C.name,aliasFieldName:C.name,queryFieldName:C.name,isPrimaryKey:!1,isForeignKey:!1,type:(($=C.dataTypeID)==null?void 0:$.toString())||"unknown",tableName:""}}):[]}),x=g=>{var _;const C=((_=g.result)==null?void 0:_.length)||0,E=`${g.id}_${C}`;if(i.has(E))return i.get(E);const $=g.metadata.fieldDefs||[],L=Ta(g.result||[],$);i.set(E,L);for(const B of i.keys())B.startsWith(`${g.id}_`)&&B!==E&&i.delete(B);return L};de(m,g=>{c&&cancelAnimationFrame(c),c=requestAnimationFrame(()=>{u.value=g?x(g):[],c=null})},{immediate:!0}),dn(()=>{c&&cancelAnimationFrame(c)});const S=g=>{t.activeTabId&&n("update:view",t.activeTabId,g)},b=g=>!!g.metadata.executeErrors;return(g,C)=>{const E=fe,$=ie,L=ue,_=ce,B=cs,q=Ke;return v(),A("div",Ul,[l(m)?(v(),A("div",Hl,[(v(),A(ee,null,ne(r,T=>f("div",{key:T.value,onClick:H=>b(l(m))&&(T.value==="result"||T.value==="raw")||T.value==="error"&&!b(l(m))?null:S(T.value),class:pe(l(et)("border px-1 text-xs font-normal transition-colors",l(d)===T.value?"bg-muted border-transparent border-r-border":"border-transparent",T.value==="error"&&b(l(m))?"hover:bg-muted cursor-pointer":T.value==="explain"&&!l(m).metadata.statementQuery.startsWith("EXPLAIN")?null:"",T.value==="error"&&!b(l(m))?"opacity-40 cursor-not-allowed":"",(T.value==="result"||T.value==="raw")&&b(l(m))?"opacity-40 cursor-not-allowed":"",T.value==="explain"&&!l(m).metadata.statementQuery.startsWith("EXPLAIN")?"opacity-40 cursor-not-allowed":"",T.value==="error"&&!b(l(m))||(T.value==="result"||T.value==="raw")&&b(l(m))||T.value==="explain"&&!l(m).metadata.statementQuery.startsWith("EXPLAIN")?"":"hover:bg-muted cursor-pointer"))},D(T.label),11,Ql)),64))])):Q("",!0),f("div",Wl,[f("div",Kl,[p(l(fs),null,{default:h(()=>[p(l(hs),{class:"flex items-end"},{default:h(()=>[(v(!0),A(ee,null,ne(g.executedResults,([T,H])=>(v(),I(_,{key:T},{default:h(()=>[p($,{"as-child":""},{default:h(()=>[f("div",{onClick:W=>g.$emit("update:activeTab",T),onContextmenu:W=>a.value=T,class:pe(l(et)("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",T===g.activeTabId?"border-b-transparent bg-background dark:bg-accent":"border-transparent bg-muted/30"))},[p(E,{name:b(H)?"hugeicons:alert-02":"hugeicons:sql",class:pe(l(et)("min-w-4",b(H)?"text-red-500":""))},null,8,["name","class"]),f("div",Yl," Query "+D(H.seqIndex)+" - "+D(H.metadata.statementQuery),1),f("div",{onClick:kt(W=>g.$emit("close-tab",T),["stop"]),class:"hover:bg-accent h-5 w-5 flex items-center justify-center rounded-full opacity-0"},[p(E,{name:"lucide:x",class:"stroke-[2.5]! size-3!"})],8,Jl)],42,Gl)]),_:2},1024),p(L,{class:"max-w-xl"},{default:h(()=>[f("p",null,D(H.metadata.statementQuery),1)]),_:2},1024)]),_:2},1024))),128))]),_:1}),l(a)?(v(),I(l(vs),{key:0,hideWhenDetached:"",class:"w-56"},{default:h(()=>[p(l(tt),{onSelect:C[0]||(C[0]=T=>g.$emit("close-tab",l(a)))},{default:h(()=>C[4]||(C[4]=[O(" Close ")])),_:1}),p(l(tt),{onSelect:C[1]||(C[1]=T=>g.$emit("close-other-tabs",l(a)))},{default:h(()=>C[5]||(C[5]=[O(" Close Others ")])),_:1}),p(l(tt),{disabled:!l(o),onSelect:C[2]||(C[2]=T=>g.$emit("close-tabs-to-right",l(a)))},{default:h(()=>C[6]||(C[6]=[O(" Close to the Right ")])),_:1},8,["disabled"])]),_:1})):Q("",!0)]),_:1})]),f("div",Zl,[g.executeLoading&&g.activeTabId?(v(),I(B,{key:0,visible:""})):Q("",!0),l(m)?l(m)&&l(d)==="result"?(v(),I(Tr,{"active-tab":l(m),"active-tab-columns":l(y),"formatted-data":l(u),"execute-loading":g.executeLoading,"is-streaming":g.isStreaming,key:l(m).id},null,8,["active-tab","active-tab-columns","formatted-data","execute-loading","is-streaming"])):l(m)&&l(d)==="explain"?(v(),I(jl,{key:3,"active-tab":l(m)},null,8,["active-tab"])):l(m)&&l(d)==="raw"?(v(),I(wr,{key:4,"formatted-data":l(u),"execute-loading":g.executeLoading,"is-streaming":g.isStreaming},null,8,["formatted-data","execute-loading","is-streaming"])):l(m)&&l(d)==="info"?(v(),I(Cr,{key:5,"active-tab":l(m)},null,8,["active-tab"])):l(m)&&l(d)==="error"?(v(),I(nr,{key:6,"active-tab":l(m),onOnChangeView:C[3]||(C[3]=T=>S(T))},null,8,["active-tab"])):l(m)&&l(d)==="agent"?(v(),I(Qa,{key:7,"active-tab":l(m)},null,8,["active-tab"])):Q("",!0):(v(),I(q,{key:1,title:"No results",desc:"Execute a query to see results"}))])])])}}});function ei({query:s,dbConnectionString:e,type:t,providerKind:n,managedSqlite:a,params:o,onMeta:r,onRows:i,onDone:u,onError:c}){const m=new AbortController;let d=0;return(async()=>{var x;try{const S=await fetch("/api/query/raw-execute-stream",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:s,dbConnectionString:e,type:t,providerKind:n,managedSqlite:a,params:o||{}}),signal:m.signal});if(!S.ok){const E=await S.text();c==null||c(E||`HTTP ${S.status}`);return}const b=(x=S.body)==null?void 0:x.getReader();if(!b){c==null||c("No readable stream available");return}const g=new TextDecoder;let C="";for(;;){const{done:E,value:$}=await b.read();if(E)break;C+=g.decode($,{stream:!0});const L=C.split(`
|
|
11
|
-
`);C=L.pop()||"";for(const _ of L){const B=_.trim();if(B)try{const q=JSON.parse(B);switch(q.type){case"meta":r==null||r(q.fields,q.command);break;case"rows":d+=q.data.length,i==null||i(q.data,d);break;case"done":u==null||u(q.rowCount,q.queryTime);break;case"error":c==null||c(q.message,q.error);break}}catch{console.warn("[StreamingQuery] Malformed NDJSON line:",B)}}}if(C.trim())try{const E=JSON.parse(C.trim());E.type==="done"?u==null||u(E.rowCount,E.queryTime):E.type==="error"&&(c==null||c(E.message))}catch{}}catch(S){if(S.name==="AbortError")return;c==null||c(S.message||"Stream connection failed")}})(),{abort:()=>m.abort()}}const Xt=s=>{if(s===null||typeof s!="object")return!1;const e=Object.getPrototypeOf(s);return e===Object.prototype||e===null},Xe=s=>s.map(e=>({name:e})),ti=s=>{if(Array.isArray(s)){if(s.every(e=>Xt(e))){const e=s,t=Array.from(new Set(e.flatMap(n=>Object.keys(n))));return{rows:e,fields:Xe(t)}}return{rows:s.map((e,t)=>({index:t,value:e})),fields:Xe(["index","value"])}}return Xt(s)?{rows:[s],fields:Xe(Object.keys(s))}:{rows:[{value:s}],fields:Xe(["value"])}};function si({getEditorView:s,connection:e,redisDatabaseIndex:t,fileVariables:n,fieldDefs:a,resultTabs:o,buildExplainAnalyzePrefix:r,beforeExecute:i}){const u=Qe([]),c=Qe({}),m=Qe(0),d=mn({isHaveOneExecute:!1,executeLoading:!1,isStreaming:!1,streamingRowCount:0,queryTime:0,executeErrors:void 0,currentStatementQuery:""});let y=null;const x=async({currentStatements:C,queryPrefix:E})=>{var F,G,j,te,ge,he,Me,Ne,Ie,_e,Oe,me,Re,Ee,oe,Pe,w,k,M,z,N;if(!C.length)return;const $=C[0];if(i&&!await i())return;d.isHaveOneExecute=!0,d.currentStatementQuery=$.text;let L=$.text,_={};try{_=JSON.parse(n.value||"{}")}catch(R){console.log("fileParameters error::",R)}let B="result";const q=((F=e.value)==null?void 0:F.type)===Z.REDIS;E&&!q&&(L=`${E} ${L}`,E.startsWith("EXPLAIN")&&(B="explain")),a.value=[],u.value=[],c.value={},d.executeLoading=!0,d.isStreaming=!1,d.streamingRowCount=0,y&&(y(),y=null),m.value++;const T={id:pn(),metadata:{queryTime:0,statementQuery:L,executedAt:new Date,executeErrors:void 0,fieldDefs:void 0,connection:void 0},result:[],view:B,seqIndex:m.value};o.addResultTab(T),So(s());const H=[];if(q){try{const R=Date.now(),V=await $fetch("/api/redis/workbench/execute",{method:"POST",body:{method:(G=e.value)==null?void 0:G.method,stringConnection:(j=e.value)==null?void 0:j.connectionString,host:(te=e.value)==null?void 0:te.host,port:(ge=e.value)==null?void 0:ge.port,username:(he=e.value)==null?void 0:he.username,password:(Me=e.value)==null?void 0:Me.password,database:(Ne=e.value)==null?void 0:Ne.database,databaseIndex:t==null?void 0:t.value,ssl:(Ie=e.value)==null?void 0:Ie.ssl,ssh:(_e=e.value)==null?void 0:_e.ssh,command:L}}),Y=ti(V.result),se=Date.now()-R;a.value=Y.fields,T.metadata.fieldDefs=Y.fields,T.metadata.connection=e.value,T.metadata.command=((Oe=V.command)==null?void 0:Oe[0])||((me=L.trim().split(/\s+/)[0])==null?void 0:me.toUpperCase())||"REDIS",T.metadata.queryTime=se,T.metadata.rowCount=Y.rows.length,T.result=Y.rows,c.value={rows:Y.rows,fields:Y.fields,queryTime:se},u.value=Y.rows,d.executeLoading=!1,d.isStreaming=!1,d.streamingRowCount=Y.rows.length,d.queryTime=se,d.executeErrors=void 0,o.refreshResultTab(T.id,T)}catch(R){const V=((Re=R==null?void 0:R.data)==null?void 0:Re.message)||(R==null?void 0:R.message)||"Failed to execute Redis command.";d.executeLoading=!1,d.isStreaming=!1,d.executeErrors={message:V,data:(R==null?void 0:R.data)||{message:V}},T.metadata.executeErrors=d.executeErrors,T.view="error",o.refreshResultTab(T.id,T)}return}if(E&&B==="explain"){try{const R=await $fetch("/api/query/raw-execute",{method:"POST",body:{dbConnectionString:(Ee=e.value)==null?void 0:Ee.connectionString,type:(oe=e.value)==null?void 0:oe.type,providerKind:(Pe=e.value)==null?void 0:Pe.providerKind,managedSqlite:(w=e.value)==null?void 0:w.managedSqlite,query:L,params:_},onResponseError:({response:V})=>{var be,qe;const Y=(be=V._data)==null?void 0:be.data,se=s();se&&Y&&Wt({editorView:se,originalSql:$.text,statementFrom:Number($.from),fileParameters:_,errorDetail:Y,clientType:((qe=e.value)==null?void 0:qe.type)||Z.POSTGRES,queryPrefix:E})}});a.value=R.fields,T.metadata.fieldDefs=R.fields,T.result=R.rows,T.metadata.queryTime=R.queryTime||0,T.metadata.connection=e.value,c.value=R,u.value=R.rows,d.executeErrors=void 0,d.queryTime=R.queryTime||0}catch(R){d.executeErrors=R.data,T.metadata.executeErrors=R.data,T.view="error"}d.executeLoading=!1,o.refreshResultTab(T.id,T);return}d.isStreaming=!0,d.executeLoading=!1;const{abort:W}=ei({query:L,dbConnectionString:((k=e.value)==null?void 0:k.connectionString)||"",type:(M=e.value)==null?void 0:M.type,providerKind:(z=e.value)==null?void 0:z.providerKind,managedSqlite:(N=e.value)==null?void 0:N.managedSqlite,params:_,onMeta:(R,V)=>{a.value=R,T.metadata.fieldDefs=R,T.metadata.connection=e.value,T.metadata.command=V,o.refreshResultTab(T.id,T)},onRows:(R,V)=>{H.push(...R),d.streamingRowCount=V,T.result=H,T.metadata.rowCount=V,u.value=H,o.refreshResultTab(T.id,T)},onDone:(R,V)=>{d.executeLoading=!1,d.isStreaming=!1,d.queryTime=V,d.executeErrors=void 0,d.streamingRowCount=R,T.metadata.queryTime=V,T.metadata.rowCount=R,c.value={rows:T.result,fields:a.value,queryTime:V},o.refreshResultTab(T.id,T),y=null},onError:(R,V)=>{var be;const Y={message:R,data:V||{message:R}};d.executeLoading=!1,d.isStreaming=!1,d.executeErrors=Y,T.metadata.executeErrors=Y,T.view="error";const se=s();se&&V&&Wt({editorView:se,originalSql:$.text,statementFrom:Number($.from),fileParameters:_,errorDetail:V,clientType:((be=e.value)==null?void 0:be.type)||Z.POSTGRES}),o.refreshResultTab(T.id,T),y=null}});y=W};return{currentRawQueryResult:u,rawResponse:c,queryProcessState:d,executeCurrentStatement:x,onExecuteCurrent:()=>{const C=s();if(!C)return;const{currentStatements:E}=rt(C);x({currentStatements:E})},onExplainAnalyzeCurrent:()=>{const C=s();if(!C)return;const{currentStatements:E}=rt(C);x({currentStatements:E,queryPrefix:r()})},cancelStreamingQuery:()=>{y&&(y(),y=null,d.executeLoading=!1,d.isStreaming=!1)}}}function ni(){const s=K({BUFFERS:!0,COSTS:!0,GENERIC_PLAN:!1,MEMORY:!1,SETTINGS:!0,SUMMARY:!0,TIMING:!0,VERBOSE:!0,WAL:!0}),e=K("NONE"),t=r=>{s.value[r]=!s.value[r]},n=r=>{e.value=r};return{explainAnalyzeOptionItems:P(()=>Dt.filter(r=>r.key!=="SERIALIZE").map(r=>({key:r.key,label:r.label,checked:s.value[r.key]}))),serializeMode:e,toggleExplainOption:t,setSerializeMode:n,buildExplainAnalyzePrefix:()=>{const r=Dt.filter(c=>c.key!=="SERIALIZE"&&s.value[c.key]).map(c=>c.key).flatMap(c=>c==="GENERIC_PLAN"?[]:[c]),i=e.value==="NONE"?[]:[`SERIALIZE ${e.value}`];return`EXPLAIN (${["ANALYZE","FORMAT JSON",...r,...i].join(", ")})`}}}function oi(){const s=Qe(new Map),e=K(null),t=m=>{const d=new Map;d.set(m.id,m),s.value.forEach((y,x)=>{d.set(x,y)}),s.value=d,e.value=m.id},n=(m,d)=>{const y=new Map(s.value);y.set(m,{...d}),s.value=y};return{executedResults:s,activeResultTabId:e,addResultTab:t,refreshResultTab:n,setActiveResultTab:m=>{s.value.has(m)&&(e.value=m)},closeResultTab:m=>{const d=new Map(s.value);if(d.delete(m),s.value=d,e.value===m){const y=Array.from(d.keys());e.value=y.length>0?y[y.length-1]:null}},updateResultTabView:(m,d)=>{const y=s.value.get(m);y&&n(m,{...y,view:d})},closeOtherResultTabs:m=>{const d=s.value.get(m);if(!d)return;const y=new Map;y.set(m,d),s.value=y,e.value=m},closeResultTabsToRight:m=>{const d=Array.from(s.value.keys()),y=d.indexOf(m);if(y<0)return;const x=new Map;for(let S=0;S<=y;S++){const b=d[S],g=s.value.get(b);g&&x.set(b,g)}s.value=x,x.has(e.value||"")||(e.value=m)},updateResultTabResult:(m,d)=>{const x=new Map(s.value).get(m);x&&(x.result=d)}}}function He(s,...e){}const ai=s=>{let e;return async()=>(e||(e=s()),await e)};class Ot{constructor(e={}){ae(this,"opts");ae(this,"parser",null);ae(this,"offsetRecord",{});ae(this,"getParser",ai(async()=>{if(this.parser)return this.parser;const e=await ds(()=>import("./ByiJDSw8.js").then(n=>n.i),__vite__mapDeps([0,1,2]),import.meta.url),{Parser:t}=e.default||e;return this.parser=new t,this.parser}));this.opts=e}async parse(e,t){var o,r;this.offsetRecord={};const n=(r=(o=this.opts).getParserOptions)==null?void 0:r.call(o,t.state),a=await this.sanitizeSql(e,n);try{const i=await this.getParser();if((n==null?void 0:n.database)==="DuckDB")return this.parseWithDuckDBSupport(a,n);const u=i.astify(a,n);return{success:!0,errors:[],ast:u}}catch(i){return{success:!1,errors:[this.extractErrorInfo(i,a)]}}}async sanitizeSql(e,t){if(t!=null&&t.ignoreBrackets){const{sql:n,offsetRecord:a}=ii(e);return this.offsetRecord=a,n}return e}async parseWithDuckDBSupport(e,t){const n=await this.getParser(),a=ri(e).trimStart().toLowerCase();if(a.startsWith("from")||a.includes("macro"))return He(),{success:!0,errors:[]};let o=e;a.includes("create or replace table")&&(this.offsetRecord[e.indexOf("create or replace table")]=-11,o=e.replace(/create or replace table/i,"create table"));try{const r={...t,database:"PostgreSQL"},i=n.astify(o,r);return{success:!0,errors:[],ast:i}}catch(r){return{success:!1,errors:[this.extractErrorInfo(r,e)]}}}extractErrorInfo(e,t){var i,u,c;let n=1,a=1;const o=(e==null?void 0:e.message)||"SQL parsing error",r=e;if(r!=null&&r.location)n=((i=r.location.start)==null?void 0:i.line)||1,a=((u=r.location.start)==null?void 0:u.column)||1;else if(r!=null&&r.hash)n=r.hash.line||1,a=((c=r.hash.loc)==null?void 0:c.first_column)||1;else{const m=o.match(/line (\d+)/i),d=o.match(/column (\d+)/i);m!=null&&m[1]&&(n=parseInt(m[1],10)),d!=null&&d[1]&&(a=parseInt(d[1],10))}for(const[m,d]of Object.entries(this.offsetRecord))a>parseInt(m,10)&&(a-=d);return a>t.length&&(a=t.length),{message:this.cleanErrorMessage(o),line:Math.max(1,n),column:a,severity:"error"}}cleanErrorMessage(e){return e.replace(/^Error: /,"").replace(/Expected .* but .* found\./i,t=>t.replace(/but .* found/,"found unexpected token")).trim()}async validateSql(e,t){return(await this.parse(e,t)).errors}async extractTableReferences(e,t){var a,o;const n=t?(o=(a=this.opts).getParserOptions)==null?void 0:o.call(a,t.state):void 0;try{return(await this.getParser()).tableList(e,n).map(u=>{const c=u.split("::");return c[c.length-1]||u})}catch{return[]}}async extractColumnReferences(e,t){var a,o;const n=t!=null&&t.state?(o=(a=this.opts).getParserOptions)==null?void 0:o.call(a,t.state):void 0;try{return(await this.getParser()).columnList(e,n).map(c=>{const m=c.split("::");return m[m.length-1]||c})}catch{return[]}}}function ri(s,e=["/*","--"]){const t=[];if(e.includes("/*")&&t.push("/\\*[\\s\\S]*?\\*/"),e.includes("--")&&t.push("--[^\\n]*"),t.length===0)return s;const n=new RegExp(`^\\s*(${t.join("|")})\\s*`,"");let a=s,o="";for(;a!==o;)o=a,a=a.replace(n,"");return a}const li=2;function ii(s){const e={};return{sql:s.replace(/("(?:[^"\\]|\\.)*")|('(?:[^'\\]|\\.)*')|(\{[^}]*\})/g,(n,a,o,r,i)=>a||o?n:r?(e[i]=li,`'${r}'`):n),offsetRecord:e}}const ui=750;function ci(s,e){const n=e.line(s.line).from+Math.max(0,s.column-1),a=n+1;return{from:n,to:a,severity:s.severity,message:s.message,source:"sql-parser"}}function di(s={}){const e=s.parser||new Ot;return rs(async t=>{const n=t.state.doc,a=n.toString();return a.trim()?(await e.validateSql(a,{state:t.state})).map(r=>ci(r,n)):[]},{delay:s.delay||ui})}function Le(s){return typeof s=="object"&&!Array.isArray(s)&&!("self"in s)}function we(s){return typeof s=="object"&&!Array.isArray(s)&&"self"in s&&"children"in s}function ye(s){return Array.isArray(s)}function re(s,e,t,n){const a=s.length;if(e==="string"||e==="completion"&&n&&ye(n))return"column";if(e==="namespace"&&t){if(ye(t))return"table";if(Le(t))return Object.values(t).some(r=>ye(r)||we(r)&&ye(r.children))?a<=1?"database":"schema":a===0?"database":"namespace"}if(e==="completion"&&t)return ye(t)?"table":(Le(t)&&Object.values(t).some(r=>ye(r)||we(r)&&ye(r.children)),a<=1?"database":"schema");switch(a){case 0:return"database";case 1:return"schema";default:return"namespace"}}function ws(s,e,t={}){const{maxDepth:n=10}=t;if(e===""&&we(s)){const o=re([],"completion",s.children);return{completion:s.self,path:[],type:"completion",semanticType:o,namespace:s.children}}const a=e.split(".").filter(o=>o.length>0);return a.length===0||a.length>n?null:Ct(s,a,[],t)}function Ct(s,e,t,n,a){if(e.length===0){if(we(s)){const c=re(t,"completion",s.children,a);return{completion:s.self,path:t,type:"completion",semanticType:c,namespace:s.children}}const u=re(t,"namespace",s,a);return{path:t,type:"namespace",semanticType:u,namespace:s}}const[o,...r]=e,{caseSensitive:i=!1}=n;if(!o)return null;if(Le(s)){const u=i?Object.keys(s).find(c=>c===o):Object.keys(s).find(c=>c.toLowerCase()===o.toLowerCase());if(u){const c=s[u];if(c)return Ct(c,r,[...t,u],n,s)}}else{if(we(s))return Ct(s.children,e,t,n,s);if(ye(s)){for(const u of s)if(typeof u=="string"){if((i?u===o:u.toLowerCase()===o.toLowerCase())&&r.length===0){const m=re([...t,u],"string",void 0,s);return{value:u,path:[...t,u],type:"string",semanticType:m}}}else if((i?u.label===o:u.label.toLowerCase()===o.toLowerCase())&&r.length===0){const m=re([...t,u.label],"completion",void 0,s);return{completion:u,path:[...t,u.label],type:"completion",semanticType:m}}}}return null}function mi(s,e,t={}){const n=[];if(e.includes(".")){const a=e.lastIndexOf("."),o=e.substring(0,a),r=e.substring(a+1),i=ws(s,o,t);if(i!=null&&i.namespace)return St(i.namespace,r,i.path,t)}else return St(s,e,[],t);return n}function St(s,e,t,n){const a=[],{caseSensitive:o=!1,allowPartialMatch:r=!0}=n;if(Le(s)){for(const[i,u]of Object.entries(s))if(r?o?i.startsWith(e):i.toLowerCase().startsWith(e.toLowerCase()):o?i===e:i.toLowerCase()===e.toLowerCase())if(we(u)){const m=re([...t,i],"completion",u.children,s);a.push({completion:u.self,path:[...t,i],type:"completion",semanticType:m,namespace:u.children})}else{const m=re([...t,i],"namespace",u,s);a.push({path:[...t,i],type:"namespace",semanticType:m,namespace:u})}}else if(we(s)){if(r?o?s.self.label.startsWith(e):s.self.label.toLowerCase().startsWith(e.toLowerCase()):o?s.self.label===e:s.self.label.toLowerCase()===e.toLowerCase()){const u=re([...t,s.self.label],"completion",s.children);a.push({completion:s.self,path:[...t,s.self.label],type:"completion",semanticType:u,namespace:s.children})}a.push(...St(s.children,e,t,n))}else if(ye(s)){for(const i of s)if(typeof i=="string"){if(r?o?i.startsWith(e):i.toLowerCase().startsWith(e.toLowerCase()):o?i===e:i.toLowerCase()===e.toLowerCase()){const c=re([...t,i],"string",void 0,s);a.push({value:i,path:[...t,i],type:"string",semanticType:c})}}else if(r?o?i.label.startsWith(e):i.label.toLowerCase().startsWith(e.toLowerCase()):o?i.label===e:i.label.toLowerCase()===e.toLowerCase()){const c=re([...t,i.label],"completion",void 0,s);a.push({completion:i,path:[...t,i.label],type:"completion",semanticType:c})}}return a}function pi(s,e,t={}){const n=[],{maxDepth:a=10}=t;nt(s,[],n,a);const{caseSensitive:o=!1}=t;return n.filter(i=>i.path.some(u=>o?u===e:u.toLowerCase()===e.toLowerCase())).sort((i,u)=>{var d,y;const c=o?i.path[i.path.length-1]===e:((d=i.path[i.path.length-1])==null?void 0:d.toLowerCase())===e.toLowerCase(),m=o?u.path[u.path.length-1]===e:((y=u.path[u.path.length-1])==null?void 0:y.toLowerCase())===e.toLowerCase();return c&&!m?-1:!c&&m?1:i.path.length-u.path.length})}function nt(s,e,t,n){if(!(e.length>=n)){if(Le(s))for(const[a,o]of Object.entries(s)){const r=[...e,a];if(we(o)){const i=re(r,"completion",o.children,s);t.push({completion:o.self,path:r,type:"completion",semanticType:i,namespace:o.children}),nt(o.children,r,t,n)}else{const i=re(r,"namespace",o,s);t.push({path:r,type:"namespace",semanticType:i,namespace:o}),nt(o,r,t,n)}}else if(we(s)){const a=re(e,"completion",s.children);t.push({completion:s.self,path:e,type:"completion",semanticType:a,namespace:s.children}),nt(s.children,e,t,n)}else if(ye(s))for(const a of s)if(typeof a=="string"){const o=re([...e,a],"string",void 0,s);t.push({value:a,path:[...e,a],type:"string",semanticType:o})}else{const o=re([...e,a.label],"completion",void 0,s);t.push({completion:a,path:[...e,a.label],type:"completion",semanticType:o})}}}function es(s,e,t={}){const{enableFuzzySearch:n=!1}=t,a=ws(s,e,t);if(a)return a;const o=mi(s,e,t);if(o.length>0)return o[0]||null;if(n){const r=pi(s,e,t);if(r.length>0)return r[0]||null}return null}function _s(s,e){if(e.size===0)return{};if(Le(s)){const t={};for(const[n,a]of Object.entries(s))if(Array.from(e).some(r=>r.toLowerCase()===n.toLowerCase()))t[n]=a;else if(Le(a)){const r=_s(a,e);Object.keys(r).length>0&&(t[n]=r)}return t}return s}function fi(s={}){const{schema:e={},keywords:t={},hoverTime:n=300,enableKeywords:a=!0,enableTables:o=!0,enableColumns:r=!0,enableFuzzySearch:i=!0,parser:u=new Ot,tooltipRender:c,tooltipRenderers:m={}}=s;let d=null;return fn(async(y,x,S)=>{const{from:b,to:g,text:C}=y.state.doc.lineAt(x);let E=x,$=x;d===null&&(d=typeof t=="function"?t(y):Promise.resolve(t));const L=await d;for(;E>b&&/[\w.]/.test(C[E-b-1]??"");)E--;for(;$<g&&/[\w.]/.test(C[$-b]??"");)$++;if(E===x&&S<0||$===x&&S>0)return null;const _=C.slice(E-b,$-b).toLowerCase();if(!_||_.length===0)return null;const B=typeof e=="function"?e(y):e;let q=null;if(He(),!q&&a&&L[_]){He("keywordResult",_,L[_]);const T={keyword:_,info:L[_]};q={word:_,view:y,pos:x,tooltipType:"keyword",keywordData:T}}if(!q&&(o||r)&&B){const T=y.state.doc.toString(),H=await u.extractTableReferences(T),W=new Set(H.map(j=>j.toLowerCase())),F=_s(B,W);let G=es(F,_,{enableFuzzySearch:i});if(!G&&W.size===0&&(G=es(B,_,{enableFuzzySearch:i})),G){He("namespaceResult (query-aware)",_,G,"tableRefs:",Array.from(W));const j={item:G,word:_,resolvedSchema:W.size>0?F:B};q={word:_,view:y,pos:x,tooltipType:"namespace",namespaceData:j}}else He("No namespace item found for:",_)}return q?{pos:E,end:$,above:!0,create(T){if(c){const F=c(_,T,x);if(F)return{dom:F}}let H=null;if(q.tooltipType==="keyword"&&q.keywordData)H=m.keyword?m.keyword(q.keywordData):vi(q.keywordData);else if(q.tooltipType==="namespace"&&q.namespaceData){const F=q.namespaceData,{semanticType:G}=F.item;G==="table"&&m.table?H=m.table(F):G==="column"&&m.column?H=m.column(F):(G==="database"||G==="schema"||G==="namespace")&&m.namespace?H=m.namespace(F):H=hi(F.item)}if(!H)return{dom:document.createElement("div")};const W=document.createElement("div");return W.className="cm-sql-hover-tooltip",W.innerHTML=H,{dom:W}}}:null},{hoverTime:n})}function hi(s){var a,o,r,i,u,c,m;const e=s.path.join("."),t=((a=s.completion)==null?void 0:a.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>${t}</strong> <span class="sql-hover-type">${s.semanticType}</span></div>`,s.semanticType){case"database":if(n+=`<div class="sql-hover-description">Database${(o=s.completion)!=null&&o.detail?`: ${s.completion.detail}`:""}</div>`,s.namespace){const d=ot(s.namespace);d>0&&(n+=`<div class="sql-hover-children">Contains ${d} schema${d!==1?"s":""}</div>`)}break;case"schema":if(n+=`<div class="sql-hover-description">Schema${(r=s.completion)!=null&&r.detail?`: ${s.completion.detail}`:""}</div>`,e&&(n+=`<div class="sql-hover-path"><strong>Path:</strong> <code>${e}</code></div>`),s.namespace){const d=ot(s.namespace);d>0&&(n+=`<div class="sql-hover-children">Contains ${d} table${d!==1?"s":""}</div>`)}break;case"table":if(n+=`<div class="sql-hover-description">Table${(i=s.completion)!=null&&i.detail?`: ${s.completion.detail}`:""}</div>`,e){const d=s.path;d.length>1&&(n+=`<div class="sql-hover-path"><strong>Schema:</strong> <code>${d.slice(0,-1).join(".")}</code></div>`)}if(s.namespace&&ye(s.namespace)){const d=s.namespace;if(d.length>0){n+=`<div class="sql-hover-columns"><strong>Columns (${d.length}):</strong><br>`;const x=d.slice(0,8).map(S=>typeof S=="string"?S:S.label);n+=x.map(S=>`<code>${S}</code>`).join(", "),d.length>8&&(n+=`, <em>and ${d.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>`,e){const d=s.path;d.length>1&&(n+=`<div class="sql-hover-path"><strong>Table:</strong> <code>${d.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>`,e&&(n+=`<div class="sql-hover-path"><strong>Path:</strong> <code>${e}</code></div>`),s.namespace){const d=ot(s.namespace);d>0&&(n+=`<div class="sql-hover-children">Contains ${d} item${d!==1?"s":""}</div>`)}break}return(m=s.completion)!=null&&m.info&&typeof s.completion.info=="string"&&(n+=`<div class="sql-hover-info">${s.completion.info}</div>`),n+="</div>",n}function ot(s){return Array.isArray(s)?s.length:typeof s=="object"&&s!==null?"self"in s&&"children"in s?1+ot(s.children):Object.keys(s).length:0}function vi(s){const{keyword:e,info:t}=s;let n='<div class="sql-hover-keyword">';if(n+=`<div class="sql-hover-header"><strong>${e.toUpperCase()}</strong> <span class="sql-hover-type">keyword</span></div>`,n+=`<div class="sql-hover-description">${t.description}</div>`,t.syntax&&(n+=`<div class="sql-hover-syntax"><strong>Syntax:</strong> <code>${t.syntax}</code></div>`),t.example&&(n+=`<div class="sql-hover-example"><strong>Example:</strong><br><code>${t.example}</code></div>`),t.metadata&&typeof t.metadata=="object"&&Object.keys(t.metadata).length>0){n+='<div class="sql-hover-metadata">';for(const[a,o]of Object.entries(t.metadata))n+=`<span class="sql-hover-tag" title="${a}">${o}</span> `;n+="</div>"}return n+="</div>",n}const gi=(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 At.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 yi{constructor(e){ae(this,"parser");ae(this,"cache",new Map);ae(this,"MAX_CACHE_SIZE",10);this.parser=e}async analyzeDocument(e){const t=e.doc.toString(),n=this.generateCacheKey(t),a=this.cache.get(n);if(a)return a;const o=await this.extractStatements(t,e);if(this.cache.set(n,o),this.cache.size>this.MAX_CACHE_SIZE){const r=this.cache.keys().next().value;r!==void 0&&this.cache.delete(r)}return o}async getStatementAtPosition(e,t){return(await this.analyzeDocument(e)).find(a=>t>=a.from&&t<=a.to)||null}async getStatementsInRange(e,t,n){return(await this.analyzeDocument(e)).filter(o=>o.from<=n&&o.to>=t)}async extractStatements(e,t){const n=[],a=this.splitByStatementSeparators(e);let o=0;for(const r of a){const i=r.trim();if(i.length===0){o+=r.length;continue}const u=o+r.indexOf(i),c=u+i.length,m=t.doc.lineAt(u),d=t.doc.lineAt(c),y=this.stripComments(i);if(y.trim().length===0||y.trim()===";"){o+=r.length;continue}const x=await this.parser.parse(y,{state:t}),S=this.determineStatementType(y),b=y.endsWith(";")?y.slice(0,-1).trim():y.trim();n.push({from:u,to:c,lineFrom:m.number,lineTo:d.number,content:b,type:S,isValid:x.success}),o+=r.length}return n}splitByStatementSeparators(e){const t=[];let n="",a=!1,o="",r=!1,i=!1,u=0;for(;u<e.length;){const c=e[u],m=e[u+1];if(!a&&!i&&c==="-"&&m==="-"){r=!0,n+=c+m,u+=2;continue}if(!a&&!r&&c==="/"&&m==="*"){i=!0,n+=c+m,u+=2;continue}if(i&&c==="*"&&m==="/"){i=!1,n+=c+m,u+=2;continue}if(r&&(c===`
|
|
12
|
-
`||c==="\r")){r=!1,n+=c,u++;continue}if(r||i){n+=c,u++;continue}if(!a&&(c==="'"||c==='"'||c==="`"))a=!0,o=c,n+=c;else if(a&&c===o){if(m===o){n+=c+m,u+=2;continue}a=!1,o="",n+=c}else!a&&c===";"?(n+=c,t.push(n),n=""):n+=c;u++}return n.trim()&&t.push(n),t}determineStatementType(e){const t=e.trim().toLowerCase();return t.startsWith("select")?"select":t.startsWith("insert")?"insert":t.startsWith("update")?"update":t.startsWith("delete")?"delete":t.startsWith("create")?"create":t.startsWith("drop")?"drop":t.startsWith("alter")?"alter":t.startsWith("use")?"use":"other"}stripComments(e){let t="",n=!1,a="",o=!1,r=!1,i=0;for(;i<e.length;){const u=e[i],c=e[i+1];if(!n&&!r&&u==="-"&&c==="-"){o=!0,i+=2;continue}if(!n&&!o&&u==="/"&&c==="*"){r=!0,i+=2;continue}if(r&&u==="*"&&c==="/"){r=!1,i+=2;continue}if(o&&(u===`
|
|
13
|
-
`||u==="\r")){o=!1,t+=u,i++;continue}if(o||r){i++;continue}if(!n&&(u==="'"||u==='"'||u==="`"))n=!0,a=u,t+=u;else if(n&&u===a){if(c===a){t+=u+c,i+=2;continue}n=!1,a="",t+=u}else t+=u;i++}return t}generateCacheKey(e){let t=0;for(let n=0;n<e.length;n++){const a=e.charCodeAt(n);t=(t<<5)-t+a,t=t&t}return t.toString()}clearCache(){this.cache.clear()}}const Es=vn.define(),Ts=hn.define({create(){return{currentStatement:null,allStatements:[],cursorPosition:0,isFocused:!0}},update(s,e){for(const t of e.effects)if(t.is(Es))return t.value;return s}});class xi extends xn{constructor(t,n,a=!0,o=!0){super();ae(this,"config");ae(this,"isCurrent");ae(this,"isValid");ae(this,"isFocused");this.config=t,this.isCurrent=n,this.isValid=a,this.isFocused=o}toDOM(){const t=document.createElement("div");t.className="cm-sql-gutter-marker";let n=this.config.backgroundColor||"#3b82f6";!this.isValid&&this.config.showInvalid!==!1&&(n=this.config.errorBackgroundColor||"#ef4444");let a;return this.isFocused?a=this.isCurrent?"1":(this.config.inactiveOpacity||"0.3").toString():this.config.unfocusedOpacity!==void 0?a=this.config.unfocusedOpacity.toString():this.config.hideWhenNotFocused?a="0":a=this.isCurrent?"1":(this.config.inactiveOpacity||"0.3").toString(),t.style.cssText=`
|
|
14
|
-
background: ${n};
|
|
15
|
-
height: 100%;
|
|
16
|
-
width: 100%;
|
|
17
|
-
opacity: ${a};
|
|
18
|
-
transition: opacity 150ms ease-in-out;
|
|
19
|
-
border-radius: 1px;
|
|
20
|
-
`,t}eq(t){return this.isCurrent===t.isCurrent&&this.isValid===t.isValid&&this.isFocused===t.isFocused&&this.config===t.config}}function bi(s,e){var i;let t=yn.empty;if((i=e.whenHide)!=null&&i.call(e,s))return t;const n=s.state.field(Ts,!1);if(!n)return t;const{currentStatement:a,allStatements:o,isFocused:r}=n;try{for(const u of o){const c=(a==null?void 0:a.from)===u.from&&(a==null?void 0:a.to)===u.to;if(!u.isValid&&e.showInvalid===!1)continue;const m=new xi(e,c,u.isValid,r);for(let d=u.lineFrom;d<=u.lineTo;d++)try{if(d<1||d>s.state.doc.lines)continue;const y=s.state.doc.line(d);t=t.update({add:[m.range(y.from)]})}catch(y){console.warn("SqlGutter: Invalid line number",d,y)}}}catch(u){console.warn("SqlGutter: Error creating markers",u)}return t}function Ci(s){return At.updateListener.of(async e=>{if(!e.docChanged&&!e.selectionSet&&!e.focusChanged)return;const{state:t}=e.view,{main:n}=t.selection,a=n.head,o=await s.analyzeDocument(t),i={currentStatement:await s.getStatementAtPosition(t,a),allStatements:o,cursorPosition:a,isFocused:e.view.hasFocus};e.view.dispatch({effects:Es.of(i)})})}function Si(s){const e=s.width||3;return At.baseTheme({".cm-sql-gutter":{width:`${e}px`,minWidth:`${e}px`},".cm-sql-gutter .cm-gutterElement":{width:`${e}px`,padding:"0",margin:"0"},".cm-sql-gutter-marker":{width:"100%",height:"100%",display:"block"},".cm-lineNumbers .cm-gutterElement":{paddingLeft:"8px",paddingRight:"8px"}})}function wi(s){return gn({class:`cm-sql-gutter ${s.className||""}`,markers:e=>bi(e,s)})}function _i(s={}){const e=s.parser||new Ot,t=new yi(e);return[Ts,Ci(t),Si(s),wi(s)]}function Ei(s={}){const e=[],{enableLinting:t=!0,enableGutterMarkers:n=!0,enableHover:a=!0,linterConfig:o,gutterConfig:r,hoverConfig:i}=s;return t&&e.push(di(o)),n&&e.push(_i(r)),a&&(e.push(fi(i)),i!=null&&i.theme?e.push(i.theme):e.push(gi())),e}const at='(?:"(?:[^"]|"")+"|[A-Za-z_][A-Za-z0-9_$]*)',Ti=new RegExp(`(${at})\\s*\\.\\s*([A-Za-z_][A-Za-z0-9_$]*)?$`),ts=new RegExp(`\\b(?:FROM|JOIN)\\s+(${at}(?:\\s*\\.\\s*${at})*)(?:\\s+(?:AS\\s+)?(${at}))?`,"gi"),Ri=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 Te(s){const e=s.trim();return e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1).replace(/""/g,'"'):e.toLowerCase()}function Rs(s){const e=[];let t="",n=!1;for(let a=0;a<s.length;a++){const o=s[a];if(o==='"'){if(t+=o,n&&s[a+1]==='"'){t+=s[a+1],a++;continue}n=!n;continue}if(!n&&o==="."){t.trim()&&e.push(t.trim()),t="";continue}t+=o}return t.trim()&&e.push(t.trim()),e}function ki(s,e){let n=ms(s).resolveInner(e,-1);for(;n;){if(n.type.name==="Statement")return n;n=n.parent}return null}function $i(s){const e=new Map;let t=ts.exec(s);for(;t!==null;){const n=t[1],a=t[2];if(n){const r=Rs(n).at(-1);if(r&&e.set(Te(r),n),a){const i=Te(a);Ri.has(i)||e.set(i,n)}}t=ts.exec(s)}return e}function zi(s){return/Comment|String/.test(s.type.name)}function ht(s,e){if(!s.tableDetails)return null;for(const[t,n]of Object.entries(s.tableDetails))if(Te(t)===e)return{tableName:t,schemaName:s.name,tableInfo:n};return null}function vt({tableReference:s,tableName:e,schemaName:t,tableInfo:n}){var a,o;return{tableName:e,schemaName:t,tableReference:s,columns:n.columns||[],primaryKeyColumns:new Set(((a=n.primary_keys)==null?void 0:a.map(r=>r.column))||[]),foreignKeysByColumn:new Map(((o=n.foreign_keys)==null?void 0:o.map(r=>[r.column,r]))||[])}}function Ai({tableReference:s,schemas:e,defaultSchemaName:t}){if(!(e!=null&&e.length))return null;const n=Rs(s).map(i=>Te(i));if(!n.length)return null;const a=n[n.length-1],o=n.length>1?n[n.length-2]:void 0;if(o){const i=e.find(u=>Te(u.name)===o);if(i){const u=ht(i,a);if(u)return vt({tableReference:s,tableName:u.tableName,schemaName:u.schemaName,tableInfo:u.tableInfo})}}const r=t?Te(t):void 0;if(r){const i=e.find(u=>Te(u.name)===r);if(i){const u=ht(i,a);if(u)return vt({tableReference:s,tableName:u.tableName,schemaName:u.schemaName,tableInfo:u.tableInfo})}}for(const i of e){const u=ht(i,a);if(u)return vt({tableReference:s,tableName:u.tableName,schemaName:u.schemaName,tableInfo:u.tableInfo})}return null}function Li(s){return[...s.columns].sort((t,n)=>(t.ordinal_position||0)-(n.ordinal_position||0)).map(t=>uo({column:t,tableName:s.tableName,schemaName:s.schemaName,isPrimaryKey:s.primaryKeyColumns.has(t.name),foreignKey:s.foreignKeysByColumn.get(t.name)}))}function Mi(s,e){const t=ms(s.state).resolveInner(s.pos,-1);if(zi(t))return null;const n=ki(s.state,s.pos);if(!n)return null;const a=s.state.doc.sliceString(n.from,s.pos),o=Ti.exec(a);if(!o)return null;const r=o[1],i=o[2]||"",u=Te(r),c=s.state.doc.sliceString(n.from,n.to),d=$i(c).get(u)||r,y=Ai({tableReference:d,schemas:e.schemas,defaultSchemaName:e.defaultSchemaName});return y?{from:s.pos-i.length,options:Li(y),validFor:/^[A-Za-z0-9_$]*$/}:null}function Ni(s){return e=>Mi(e,s)}const Ii=async()=>(await ds(()=>import("./BiOIaWuc.js"),[],import.meta.url)).default.keywords;function Oi({codeEditorRef:s,fileVariables:e,connection:t,onExecuteStatement:n,onExplainAnalyzeCurrent:a}){const o=bn(),{schemasByContext:r,activeSchema:i}=us(o),u=K({line:1,column:1}),c=()=>{var j;return(j=s.value)==null?void 0:j.editorView},m=P(()=>{var j,te,ge;return((j=i.value)==null?void 0:j.name)||((ge=(te=r.value)==null?void 0:te[0])==null?void 0:ge.name)}),d=P(()=>{var j;return((j=t==null?void 0:t.value)==null?void 0:j.type)===Z.REDIS}),y=P(()=>!d.value),x=P(()=>{var j;return((j=t==null?void 0:t.value)==null?void 0:j.type)===Z.POSTGRES}),S=P(()=>co({schemas:r.value,defaultSchemaName:m.value,fileVariables:e.value})),b=new ut,g=new ut,C=new ut,E=()=>{var j,te;return kn({dialect:ct((j=t==null?void 0:t.value)==null?void 0:j.type),upperCaseKeywords:!0,keywordCompletion:!((te=t==null?void 0:t.value)!=null&&te.type)||t.value.type===Z.POSTGRES?zn:void 0,tables:S.value.variableCompletions,schema:S.value.schema,defaultSchema:S.value.defaultSchema})},$=()=>d.value?Rn():E(),L=()=>{var j;return d.value?[]:ct((j=t==null?void 0:t.value)==null?void 0:j.type).language.data.of({autocomplete:B()})},_=()=>d.value?[]:Ei({enableLinting:!1,enableGutterMarkers:!1,enableHover:!0,hoverConfig:{hoverTime:250,enableKeywords:!0,keywords:async()=>await Ii(),enableTables:!1,enableColumns:!1,enableFuzzySearch:!1}}),B=()=>Ni({schemas:r.value,defaultSchemaName:m.value}),{onHandleFormatCurrentStatement:q,onHandleFormatCode:T}=io({getEditorView:()=>c()}),H=()=>{y.value&&q()},W=()=>{y.value&&T()},F=[wo(n),ns.of([{key:"Mod-s",run:()=>(H(),!0),preventDefault:!0},{key:"Shift-Alt-f",run:()=>(W(),!0),preventDefault:!0},{key:"Mod-e",run:()=>(x.value&&a(),!0),preventDefault:!0},{key:"Mod-i",run:En},{key:"Tab",run:Tn}]),b.of($()),g.of(L()),Cn,Sn,...wn(),as(),C.of(_()),_n],G=()=>{var he;const j=c();if(!j)return;const te=ct((he=t==null?void 0:t.value)==null?void 0:he.type),ge=d.value?"line":"sql";j.dispatch({effects:[$n.of({dialect:te,isEnable:!d.value,statementMode:ge}),b.reconfigure($()),g.reconfigure(L()),C.reconfigure(_())]})};return de(()=>{var j;return[(j=i.value)==null?void 0:j.name,r.value]},()=>{var j;(j=i.value)!=null&&j.name&&G()},{deep:!0,immediate:!0}),t&&de(()=>{var j;return(j=t.value)==null?void 0:j.type},()=>{G()}),de(()=>{var j;return(j=s.value)==null?void 0:j.editorView},j=>{j&&G()},{immediate:!0}),{extensions:F,sqlCompartment:b,cursorInfo:u,onHandleFormatCode:W,onHandleFormatCurrentStatement:H,reloadSqlCompartment:G}}function Pi({fileVariables:s,connection:e,redisDatabaseIndex:t,fieldDefs:n,beforeExecute:a}){const o=K(null),{explainAnalyzeOptionItems:r,serializeMode:i,toggleExplainOption:u,setSerializeMode:c,buildExplainAnalyzePrefix:m}=ni(),d=oi(),x=si({getEditorView:()=>{var b;return((b=o.value)==null?void 0:b.editorView)??null},connection:e,redisDatabaseIndex:t,fileVariables:s,fieldDefs:n,resultTabs:d,buildExplainAnalyzePrefix:m,beforeExecute:a}),S=Oi({codeEditorRef:o,fileVariables:s,connection:e,onExecuteStatement:x.executeCurrentStatement,onExplainAnalyzeCurrent:x.onExplainAnalyzeCurrent});return{codeEditorRef:o,currentRawQueryResult:x.currentRawQueryResult,rawResponse:x.rawResponse,queryProcessState:x.queryProcessState,onExecuteCurrent:x.onExecuteCurrent,extensions:S.extensions,sqlCompartment:S.sqlCompartment,cursorInfo:S.cursorInfo,onHandleFormatCode:S.onHandleFormatCode,onHandleFormatCurrentStatement:S.onHandleFormatCurrentStatement,onExplainAnalyzeCurrent:x.onExplainAnalyzeCurrent,explainAnalyzeOptionItems:r,serializeMode:i,toggleExplainOption:u,setSerializeMode:c,reloadSqlCompartment:S.reloadSqlCompartment,cancelStreamingQuery:x.cancelStreamingQuery,executedResults:d.executedResults,activeResultTabId:d.activeResultTabId,setActiveResultTab:d.setActiveResultTab,closeResultTab:d.closeResultTab,closeOtherResultTabs:d.closeOtherResultTabs,closeResultTabsToRight:d.closeResultTabsToRight,updateResultTabView:d.updateResultTabView}}const gt=s=>{const{currentStatements:e}=rt(s);if(!e.length)return null;const t=Math.min(...e.map(o=>o.from)),n=Math.max(...e.map(o=>o.to));return{text:e.map(o=>o.text).join(`
|
|
21
|
-
`),from:t,to:n}};function qi(s){const e=K(!1),t=K(!1),n=()=>{const u=s.getEditorView();if(!u)return;const c=gt(u);c&&navigator.clipboard.writeText(c.text)},a=()=>{const u=s.getEditorView();if(!u)return;const c=u.state.doc.toString();c&&navigator.clipboard.writeText(c)},o=()=>{const u=s.getEditorView();if(!u)return;const c=gt(u);if(!c)return;let m=c.to;const d=u.state.doc.length;for(;m<d;){const y=u.state.sliceDoc(m,m+1);if(y===`
|
|
22
|
-
`||y==="\r"){m++;break}if(y===" "||y===" ")m++;else break}u.dispatch({changes:{from:c.from,to:m,insert:""},annotations:[An.addToHistory.of(!0)]}),u.focus()};return{contextMenuItems:P(()=>{var m,d;const u=!e.value,c=!t.value;return[{type:U.ACTION,title:"Execute",icon:"hugeicons:play",shortcut:"⌘↵",select:s.onExecuteCurrent,disabled:u},...(m=s.isExplainSupported)!=null&&m.value?[{type:U.ACTION,title:"Analyze Query",icon:"hugeicons:analytics-01",shortcut:"⌘E",select:s.onExplainAnalyzeCurrent,disabled:u}]:[],{type:U.SEPARATOR},...(d=s.isSupportFormat)!=null&&d.value?[{type:U.ACTION,title:"Format Current",icon:"hugeicons:magic-wand-01",shortcut:"⌘S",select:s.onHandleFormatCurrentStatement,disabled:u},{type:U.ACTION,title:"Format All",icon:"hugeicons:text-align-left",shortcut:"⇧⌥F",select:s.onHandleFormatCode,disabled:c}]:[],{type:U.SEPARATOR},{type:U.ACTION,title:"Copy Statement",icon:"hugeicons:copy-02",select:n,disabled:u},{type:U.ACTION,title:"Copy All",icon:"hugeicons:copy-01",select:a,disabled:c},{type:U.SEPARATOR},{type:U.ACTION,title:"Delete Statement",icon:"hugeicons:delete-02",select:o,disabled:u}]}),onContextMenuOpen:u=>{if(!u)return;const c=s.getEditorView();if(!c){e.value=!1,t.value=!1;return}t.value=c.state.doc.length>0,e.value=!!gt(c)}}}function Di(){const{workspaceId:s,connectionId:e}=Ln(),t=ps(),n=Mn(),a=Nn(),o=n.getFileContentByIdSync(t.params.fileId),r=K((o==null?void 0:o.contents)??""),i=K(""),u=K(""),c=K([]),m=P(()=>{var L;return(L=n==null?void 0:n.flatNodes)==null?void 0:L.find(_=>_.id===t.params.fileId)});de(()=>{var L;return(L=m.value)==null?void 0:L.variables},L=>{i.value=L||""},{immediate:!0});const d=P(()=>a.getConnectionsByWorkspaceId(s.value)),y=P(()=>d.value.find(L=>L.id===e.value));de([()=>t.params.fileId,e],()=>{u.value=e.value},{immediate:!0});const x=P(()=>d.value.find(L=>L.id===u.value));return{fieldDefs:c,fileContents:r,fileVariables:i,currentFile:m,selectedConnectionId:u,updateSelectedConnection:L=>{u.value=L},updateFileContent:async L=>{var _;(_=m.value)!=null&&_.id&&(r.value=L,n.updateFileContent({contents:L,id:m.value.id}))},updateFileVariables:async L=>{var _;(_=m.value)!=null&&_.id&&(i.value=L,n.updateFile({id:m.value.id,variables:L}))},connection:x,currentOpenedConnection:y,connectionsByWsId:d,updateFileCursorPos:L=>{var _;(_=m.value)!=null&&_.id&&n.updateFile({id:m.value.id,cursorPos:L})},loadFileContent:async()=>{var _;const{contents:L}=await n.getFileContentById(t.params.fileId);r.value=L,i.value=((_=m.value)==null?void 0:_.variables)||""},isFromCache:o!==null}}const Fi={class:"flex flex-col h-full p-1"},Vi={class:"flex flex-col h-full border rounded-md"},Bi={class:"h-full flex flex-col overflow-y-auto"},ji={class:"flex flex-col h-full border rounded-md bg-muted"},Ui={class:"flex items-center gap-1 font-normal text-sm px-2 py-1"},Hi={class:"h-full flex flex-col overflow-y-auto"},Qi=X({__name:"RawQuery",props:{isSupportVariable:{type:Boolean,default:!0}},setup(s){const e=s,t=ps(),n=P(()=>{const J=t.params.workspaceId;return Array.isArray(J)?J[0]??"":J??""}),a=is(),o=In(),r=Di(),{connection:i,currentFile:u,currentOpenedConnection:c,fileContents:m,fileVariables:d,selectedConnectionId:y,updateSelectedConnection:x,updateFileContent:S,updateFileVariables:b,connectionsByWsId:g,fieldDefs:C}=r,E=P(()=>{var J;return((J=i.value)==null?void 0:J.type)===Z.REDIS}),$=P(()=>!E.value),L=P(()=>{var J;return[Z.SQLITE3,Z.BETTER_SQLITE3].includes((J=i.value)==null?void 0:J.type)}),_=P(()=>e.isSupportVariable&&!E.value&&!L.value),B=P(()=>{var J;return((J=i.value)==null?void 0:J.type)===Z.POSTGRES}),q=K("");On(()=>{q.value=_.value?d.value:""});const T=P(()=>E.value?i.value:void 0),H=Fn({connection:T,mode:"meta"}),W=J=>{H.selectedDatabaseIndex.value=J},F=Pi({connection:i,redisDatabaseIndex:H.selectedDatabaseIndex,fieldDefs:C,fileVariables:q,beforeExecute:()=>Y()}),{cursorInfo:G,extensions:j,codeEditorRef:te,onExecuteCurrent:ge,onHandleFormatCode:he,onHandleFormatCurrentStatement:Me,onExplainAnalyzeCurrent:Ne,explainAnalyzeOptionItems:Ie,serializeMode:_e,currentRawQueryResult:Oe,queryProcessState:me,executedResults:Re,activeResultTabId:Ee}=F,{contextMenuItems:oe,onContextMenuOpen:Pe}=qi({onExecuteCurrent:F.onExecuteCurrent,onExplainAnalyzeCurrent:F.onExplainAnalyzeCurrent,onHandleFormatCurrentStatement:F.onHandleFormatCurrentStatement,onHandleFormatCode:F.onHandleFormatCode,isSupportFormat:$,isExplainSupported:B,getEditorView:()=>{var J;return(J=te.value)==null?void 0:J.editorView}}),w=K(0),k=K(!0),M=K(!1),z=K(""),N=K("");let R=null;const V=P(()=>c.value?o.getTagsByIds(c.value.tagIds??[]).some(J=>J.strictMode):!1),Y=()=>{const J=i.value,ve=c.value;return!J||!ve||J.id===ve.id?Promise.resolve(!0):M.value?Promise.resolve(!1):(z.value=J.name,N.value=ve.name,M.value=!0,new Promise(ke=>{R=ke}))},se=()=>{M.value=!1,R==null||R(!0),R=null},be=()=>{M.value=!1,R==null||R(!1),R=null};Pn([{key:"mod+j",callback:()=>{k.value=!k.value}},{key:"ctrl+j",callback:()=>{k.value=!k.value}}]),de(q,()=>{F.reloadSqlCompartment()});const qe=({column:J,from:ve,line:ke,to:De})=>{G.value={column:J,line:ke},r.updateFileCursorPos({from:ve,to:De})},je=(J=!0)=>{var De,Ge;if(!((De=u.value)!=null&&De.cursorPos)||!((Ge=te.value)!=null&&Ge.editorView))return;const ve=u.value.cursorPos.from??0,ke=u.value.cursorPos.to||0;te.value.setCursorPosition({from:ve,to:ke,allowScroll:J})},it=K(!r.isFromCache);return $t(async()=>{it.value&&(await r.loadFileContent(),it.value=!1,await Ce()),je()}),qn(async()=>{var J;await Ce(),je(!1),(J=te.value)!=null&&J.editorView&&(te.value.editorView.scrollDOM.scrollTop=w.value)}),zt(()=>{R&&(R(!1),R=null)}),(J,ve)=>{const ke=fe,De=Ke;return v(),A(ee,null,[p(No,{open:l(M),"target-connection-name":l(z),"current-connection-name":l(N),onConfirm:se,onCancel:be},null,8,["open","target-connection-name","current-connection-name"]),p(fa,{layout:l(a).codeEditorLayout,customLayout:l(a).activeCustomLayout,"show-result-panel":l(k)},{content:h(()=>[f("div",Fi,[f("div",Vi,[p(ua,{"onUpdate:connectionId":l(x),connections:l(g),connection:l(i),"selected-connection-id":l(y),"disable-connection-switch":l(V),"is-redis-connection":l(E),"redis-databases":l(H).databases.value,"redis-database-index":l(H).selectedDatabaseIndex.value,workspaceId:l(n),"file-variables":l(d),"code-editor-layout":l(a).codeEditorLayout,currentFileInfo:l(u),"is-support-variable":l(_),"onUpdate:redisDatabaseIndex":W,"onUpdate:updateFileVariables":l(b)},null,8,["onUpdate:connectionId","connections","connection","selected-connection-id","disable-connection-switch","is-redis-connection","redis-databases","redis-database-index","workspaceId","file-variables","code-editor-layout","currentFileInfo","is-support-variable","onUpdate:updateFileVariables"]),f("div",Bi,[p(Oo,{"context-menu-items":l(oe),"onUpdate:open":l(Pe)},{default:h(()=>[l(it)?(v(),I(l(cs),{key:0,visible:""})):(v(),I(ls,{key:1,"onUpdate:modelValue":l(S),"onUpdate:cursorInfo":qe,"onUpdate:onScrollTop":ve[0]||(ve[0]=Ge=>w.value=Ge),modelValue:l(m),extensions:l(j),ref_key:"codeEditorRef",ref:te},null,8,["onUpdate:modelValue","modelValue","extensions"]))]),_:1},8,["context-menu-items","onUpdate:open"])]),p(ta,{"cursor-info":l(G),"execute-loading":l(me).executeLoading,"execute-errors":!!l(me).executeErrors,"is-have-one-execute":l(me).isHaveOneExecute,"is-streaming":l(me).isStreaming,"streaming-row-count":l(me).streamingRowCount,queryTime:l(me).queryTime,"raw-query-results-length":l(Oe).length,"explain-analyze-option-items":l(Ie),"serialize-mode":l(_e),"is-support-format":l($),"is-support-variable":l(_),"is-explain-supported":l(B),onOnFormatCurrentStatement:l(Me),onOnFormatAll:l(he),onOnExplainAnalyzeCurrent:l(Ne),onToggleExplainOption:l(F).toggleExplainOption,"onUpdate:serializeMode":l(F).setSerializeMode,onOnExecuteCurrent:l(ge),onOnCancelQuery:l(F).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","is-support-format","is-support-variable","is-explain-supported","onOnFormatCurrentStatement","onOnFormatAll","onOnExplainAnalyzeCurrent","onToggleExplainOption","onUpdate:serializeMode","onOnExecuteCurrent","onOnCancelQuery"])])])]),variables:h(()=>[f("div",ji,[f("div",Ui,[p(ke,{name:"hugeicons:absolute"}),ve[1]||(ve[1]=O(" Variables "))]),f("div",Hi,[l(_)?(v(),I(ys,{key:1,variables:l(d),"onUpdate:variables":l(b),onUpdateVariables:l(b),"file-variables":l(d)},null,8,["variables","onUpdate:variables","onUpdateVariables","file-variables"])):(v(),I(De,{key:0,title:"Variables not supported",desc:"Variables are not available for Redis and SQLite connections.",icon:"icons:ghost"}))])])]),result:h(()=>[l(Re).size===0?(v(),I(Ao,{key:0})):(v(),I(Xl,{key:1,"executed-results":l(Re),"active-tab-id":l(Ee),"execute-loading":l(me).executeLoading,"is-streaming":l(me).isStreaming,"onUpdate:activeTab":l(F).setActiveResultTab,onCloseTab:l(F).closeResultTab,onCloseOtherTabs:l(F).closeOtherResultTabs,onCloseTabsToRight:l(F).closeResultTabsToRight,"onUpdate:view":l(F).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"])],64)}}}),Cu=X({__name:"[fileId]",setup(s){return(e,t)=>(v(),I(Qi))}});export{Cu as default};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import{_ as ue}from"./C_7gtl40.js";import{d as J,e as P,m as w,t as F,F as de,s as pe,o as T,k as I,w as g,z as V,bm as yt,f,A as j,l as me,r as x,c as s,au as H,g as b,bn as fe,_ as kt,i as W,a0 as G,n as wt,h as $t,bS as Ct,x as Bt,B as Nt,bk as St,bW as Vt,bq as Tt,a1 as _e,X as ge,Y as ve,Z as he,bo as xe,bL as be,$ as ye,W as ke,aZ as Et,bX as we,by as $e,G as K,a3 as Ce,ba as Be,bE as Ne,bF as Se,bG as Ve}from"./BcsKoAPU.js";import{_ as X,a as Z}from"./dNPwafbq.js";import{_ as Y,g as At,a as Q,b as Te,c as Ee,d as ee,i as De,e as Fe,f as Ie}from"./BWZ7atse.js";import{_ as Re}from"./Ca0KO9Xq.js";import{u as Ae}from"./qzrMNYut.js";const Oe={class:"text-muted-foreground"},ze={class:"space-y-2 text-xs"},Me=`brew install postgresql # macOS
|
|
2
|
-
apt-get install postgresql-client # Linux
|
|
3
|
-
# Windows: Download from https://www.postgresql.org/download/windows/`,qe=`brew install mysql # macOS
|
|
4
|
-
apt-get install mysql-client # Linux
|
|
5
|
-
# Windows: Download from https://dev.mysql.com/downloads/`,Je=`brew install sqlite # macOS
|
|
6
|
-
apt-get install sqlite3 # Linux
|
|
7
|
-
# Windows: Download from https://www.sqlite.org/download.html`,je=J({__name:"BackupRestoreUnsupportedAlert",props:{supportMessage:{},connectionType:{}},setup(n){return(t,u)=>{const d=j,r=Y,a=Re,m=Z,p=X;return T(),I(p,null,{default:g(()=>[f(r,{class:"flex items-center font-medium gap-1"},{default:g(()=>[f(d,{name:"hugeicons:alert-circle",class:"size-4"}),u[0]||(u[0]=V(" Native Tools Required"))]),_:1}),f(m,{class:"space-y-3"},{default:g(()=>[w("p",Oe,F(t.supportMessage),1),w("div",ze,[u[1]||(u[1]=w("p",{class:"font-medium"},"Installation instructions:",-1)),t.connectionType==="postgres"?(T(),I(a,{key:0,code:Me,language:"bash"})):t.connectionType==="mysql"||t.connectionType==="mariadb"?(T(),I(a,{key:1,code:qe,language:"bash"})):t.connectionType==="sqlite3"?(T(),I(a,{key:2,code:Je,language:"bash"})):me("",!0)])]),_:1})]),_:1})}}});const Le={class:"space-y-3 py-1"},q="restore backup",Pe=J({__name:"RestoreConfirmDialog",props:{open:{type:Boolean}},emits:["confirm","cancel"],setup(n,{emit:t}){const u=n,d=t,r=x("");H(()=>u.open,p=>{p&&(r.value="")});const a=s(()=>r.value===q),m=()=>{a.value&&d("confirm")};return(p,o)=>{const v=j,$=ve,y=he,C=ge,E=fe,e=xe,l=G,h=ye,B=ke,k=_e;return T(),I(k,{open:p.open,"onUpdate:open":o[2]||(o[2]=_=>!_&&p.$emit("cancel"))},{default:g(()=>[f(B,{class:"max-w-sm"},{default:g(()=>[f(C,null,{default:g(()=>[f($,{class:"flex items-center gap-2 text-destructive"},{default:g(()=>[f(v,{name:"hugeicons:alert-02",class:"size-5"}),o[3]||(o[3]=V(" Confirm Restore "))]),_:1}),f(y,null,{default:g(()=>o[4]||(o[4]=[V(" This will overwrite existing data in the target database. This action cannot be undone. ")])),_:1})]),_:1}),w("div",Le,[f(E,{for:"restore-confirm-input"},{default:g(()=>[o[5]||(o[5]=V(" Type ")),w("code",{class:"rounded bg-muted px-1 py-0.5 text-xs font-mono"},F(q)),o[6]||(o[6]=V(" to continue: "))]),_:1}),f(e,{id:"restore-confirm-input",modelValue:b(r),"onUpdate:modelValue":o[0]||(o[0]=_=>W(r)?r.value=_:null),placeholder:q,autocomplete:"off",onKeydown:be(m,["enter"])},null,8,["modelValue"])]),f(h,null,{default:g(()=>[f(l,{variant:"outline",onClick:o[1]||(o[1]=_=>p.$emit("cancel"))},{default:g(()=>o[7]||(o[7]=[V("Cancel")])),_:1}),f(l,{variant:"destructive",disabled:!b(a),onClick:m},{default:g(()=>o[8]||(o[8]=[V(" Restore ")])),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1},8,["open"])}}});function U(n){return!!(n&&(n.status==="completed"||n.status==="error"))}const te=()=>{const n=x(null),t=x(null),u=x(null),d=x(!1);let r=null,a=null;const m=e=>{r==null||r(e),r=null,a=null},p=e=>{a==null||a(e),r=null,a=null},o=async()=>{if(!u.value)throw new Error("Backup job status URL is missing.");if(d.value){if(n.value)return n.value;throw new Error("Backup job refresh is already in progress.")}d.value=!0;try{const e=await $fetch(u.value);return n.value=e,e.status==="error"&&(t.value=e.error||e.message),U(e)&&(v(),m(e)),e}catch(e){const l=e instanceof Error?e:new Error("Failed to refresh backup job status.");throw t.value=l.message,v(),p(l),l}finally{d.value=!1}},{pause:v,resume:$,isActive:y}=we(()=>{o()},1e3,{immediate:!1,immediateCallback:!1}),C=async e=>{u.value=e,t.value=null;const l=await o();return U(l)?l:($(),await new Promise((h,B)=>{r=h,a=B}))},E=()=>{v(),u.value=null,n.value=null,t.value=null,d.value=!1,r=null,a=null};return $e(()=>{v()}),{job:n,error:t,isRefreshing:d,isPolling:y,progress:s(()=>{var e;return((e=n.value)==null?void 0:e.progress)??0}),message:s(()=>{var e;return((e=n.value)==null?void 0:e.message)??null}),stage:s(()=>{var e;return((e=n.value)==null?void 0:e.stage)??"queued"}),status:s(()=>{var e;return((e=n.value)==null?void 0:e.status)??"queued"}),isRunning:s(()=>{var e,l;return((e=n.value)==null?void 0:e.status)==="queued"||((l=n.value)==null?void 0:l.status)==="running"}),monitorJob:C,refresh:o,reset:E}},Ue=n=>{const t=x(null),u=x(null),d=te(),{downloadStream:r,isDownloading:a,downloadedBytes:m}=Ae(),p=s(()=>d.isRunning.value||a.value),o=s(()=>a.value?100:d.progress.value),v=s(()=>a.value?`Downloading backup artifact (${m.value} bytes)...`:d.message.value),$=s(()=>d.job.value),y=async(e,l)=>{var h,B;if(!n.value)return t.value="No database connection provided",!1;t.value=null,u.value=null;try{const k=await $fetch("/api/database-export/export-database",{method:"POST",body:{...K(n.value),databaseName:e,options:l}}),_=await d.monitorJob(k.statusUrl);if(_.status==="error")return t.value=_.error||_.message,!1;if(!_.downloadUrl||!_.downloadFileName)return t.value="Export finished but no download artifact was returned.",!1;const i=await r({url:_.downloadUrl,method:"GET",filename:_.downloadFileName||`${e}_backup${C((h=n.value)==null?void 0:h.type,l.format)}`});return i.success?(u.value={fileName:_.downloadFileName,duration:_.duration||0},!0):(t.value=((B=i.error)==null?void 0:B.message)||"Download failed.",!1)}catch(k){return t.value=k instanceof Error?k.message:"Export failed. Check the connection and backup configuration.",console.error("Export error:",k),!1}},C=(e,l)=>Ee(e,l);return{isExporting:p,progress:o,error:t,lastExport:u,currentJob:$,statusMessage:v,exportDatabase:y,reset:()=>{d.reset(),t.value=null,u.value=null}}},He=n=>{const t=te(),u=s(()=>t.isRunning.value),d=s(()=>t.progress.value),r=s(()=>t.message.value),a=s(()=>t.job.value),m=x(null),p=x(null),o=x(null),v=x(null),$=x({clean:!1,dataOnly:!1,schemaOnly:!1,exitOnError:!0}),y=s(()=>{var i;return(i=n.value)==null?void 0:i.type}),C=s(()=>Q(y.value)),E=s(()=>ee(y.value)),e=s(()=>C.value.map(i=>i.extension).join(" / ")),l=()=>{o.value=null,v.value&&(v.value.value="")};return{isImporting:u,progress:d,statusMessage:r,currentJob:a,error:m,success:p,selectedFile:o,fileInputRef:v,options:$,extensionSummary:e,clearSelectedFile:l,openFilePicker:()=>{var i;(i=v.value)==null||i.click()},onFileSelect:i=>{var O;const R=i.target;if(!((O=R.files)!=null&&O.length))return;const A=R.files[0];if(!C.value.some(N=>A.name.toLowerCase().endsWith(N.extension.toLowerCase()))){l(),m.value=`Unsupported file type. Use ${e.value} for ${E.value}.`,p.value=null;return}o.value=A,m.value=null,p.value=null},importDatabase:async()=>{if(!(!o.value||!n.value)){m.value=null,p.value=null;try{const i=new FormData;i.append("file",o.value);const R=K(n.value);Object.entries(R).forEach(([O,N])=>{N!==void 0&&i.append(O,typeof N=="object"?JSON.stringify(N):String(N))}),i.append("options",JSON.stringify($.value));const A=await $fetch("/api/database-import/import-database",{method:"POST",body:i}),D=await t.monitorJob(A.statusUrl);if(D.status==="completed"){p.value=D.message||"Database imported successfully",l();return}m.value=D.error||D.message||"Import failed"}catch(i){m.value=i instanceof Error?i.message:"Import failed. Check the backup file and connection compatibility.",console.error("Import error:",i)}}},reset:()=>{t.reset(),m.value=null,p.value=null,l()}}},We={class:"flex flex-col h-full gap-3 overflow-hidden p-3"},Ge={class:"font-medium text-foreground"},Ke={class:"text-muted-foreground/60"},Xe={class:"flex items-center justify-between gap-2"},Ze={class:"text-xs text-muted-foreground"},Ye={class:"flex-1 overflow-y-auto rounded-lg border bg-background p-4"};const Mt=J({__name:"BackupRestoreContainer",props:{connectionId:{},initialTab:{}},setup(n){const t=n,u=Ce(),d=Be(),r=s(()=>{if(t.connectionId)return u.connections.find(c=>c.id===t.connectionId)}),a=s(()=>{var c;return(c=r.value)==null?void 0:c.type}),m=s(()=>{var c,z;return((c=r.value)==null?void 0:c.database)||((z=r.value)==null?void 0:z.name)||"database"}),p=s(()=>ee(a.value)),o=s(()=>De(a.value)),v=s(()=>Fe(a.value)),$=s(()=>Te(a.value)),y=s(()=>Q(a.value)),C=s(()=>Ie(a.value)),E=s(()=>y.value.map(c=>c.extension).join(" / ")),e=s(()=>t.connectionId?(d.schemas[t.connectionId]||[]).filter(c=>c.connectionId===t.connectionId).map(c=>c.name):[]),l=[{id:"export",tabLabel:"Create Backup",subtitle:"Generate native backup artifacts for the current connection.",icon:"hugeicons:download-01"},{id:"import",tabLabel:"Restore Backup",subtitle:"Apply a native backup artifact back into this connection.",icon:"hugeicons:upload-01"}],h=x(t.initialTab),B=s(()=>l.find(c=>c.id===h.value));H(()=>t.initialTab,c=>{h.value=c});const k=c=>{h.value=c},{isExporting:_,progress:i,error:R,lastExport:A,currentJob:D,statusMessage:O,exportDatabase:N,reset:Qe}=Ue(r),et=async c=>{await N(m.value,c)},{isImporting:tt,progress:ot,statusMessage:st,currentJob:nt,error:at,success:rt,selectedFile:lt,options:it,extensionSummary:ct,onFileSelect:ut,clearSelectedFile:dt,importDatabase:oe,reset:pt}=He(r),M=x(!1),mt=()=>{M.value=!0},se=async()=>{M.value=!1,await oe()},ne=()=>{M.value=!1};return(c,z)=>{var L;const ae=ue,re=j,le=Ve,ie=Se,ce=Ne,ft=Y,_t=Z,gt=G,vt=X;return T(),P("div",We,[f(Pe,{open:b(M),onConfirm:se,onCancel:ne},null,8,["open"]),f(ae,{icon:"hugeicons:database-import",title:"Backup & Restore"},{context:g(()=>[w("span",Ge,F(b(m)),1),w("span",Ke,"· "+F(b(p)),1)]),_:1}),w("div",Xe,[f(ce,{modelValue:b(h),"onUpdate:modelValue":z[0]||(z[0]=S=>W(h)?h.value=S:null),class:"min-w-0 flex-1 gap-0"},{default:g(()=>[f(ie,{class:"h-8 max-w-full justify-start! overflow-x-auto"},{default:g(()=>[(T(),P(de,null,pe(l,S=>f(le,{key:S.id,value:S.id,class:"min-w-fit shrink-0 cursor-pointer rounded-sm px-1.5 text-xs",disabled:!b(o),onClick:ht=>k(S.id)},{default:g(()=>[f(re,{name:S.icon,class:"shrink-0 size-3.5"},null,8,["name"]),V(" "+F(S.tabLabel),1)]),_:2},1032,["value","disabled","onClick"])),64))]),_:1})]),_:1},8,["modelValue"]),w("div",Ze,F((L=b(B))==null?void 0:L.subtitle),1)]),w("div",Ye,[(b(o),T(),I(je,{key:0,"support-message":b(v),"connection-type":b(a)},null,8,["support-message","connection-type"]))])])}}});export{Mt as _};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as e}from"./CtWq1MER.js";import{d as r,a8 as c,c as n,k as m,g as o,o as p}from"./BcsKoAPU.js";import"./CHEpbbGc.js";import"./C_7gtl40.js";import"./dNPwafbq.js";import"./BWZ7atse.js";import"./Ca0KO9Xq.js";import"./CS5akSNT.js";import"./D4pAW_0T.js";import"./qzrMNYut.js";const C=r({__name:"[name]",setup(s){const t=c(),i=n(()=>t.params.connectionId),a=n(()=>t.params.name);return(_,u)=>(p(),m(o(e),{"connection-id":o(i),"initial-tab":o(a)},null,8,["connection-id","initial-tab"]))}});export{C as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as e,b as r,a,S as s}from"./BoMjapT5.js";import{_ as i}from"./DHAL8jJG.js";import"./kvtnkChG.js";import"./DGvAu532.js";import"./BcsKoAPU.js";var p={parser:a,get db(){return new s(2)},renderer:r,styles:e,init:i(t=>{t.state||(t.state={}),t.state.arrowMarkerAbsolute=t.arrowMarkerAbsolute},"init")};export{p as diagram};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{M as j,d as G,e as F,o as c,n as se,m as d,k as b,l as q,f as a,w as o,g as e,a_ as z,a0 as te,z as v,A as S,a$ as D,aY as R,a3 as oe,ba as ie,am as le,r as f,c as _,G as L,bb as ue,bc as re,bd as de,be as ce,bf as me,bg as fe,bh as ve,bi as pe,bj as ge,i as A,O as _e,Q as Ce,R as be,t as he,S as ye,T as Se,U as we,V as $e,bk as xe,N as ke,P as Pe,bl as Te,F as qe,K as ze}from"./BcsKoAPU.js";import{_ as De}from"./Ca0KO9Xq.js";import{s as Re}from"./DDebxXP-.js";import{g as O,a as K}from"./COAycMg4.js";import{_ as Oe}from"./BPACuoI0.js";import{_ as Fe}from"./AymhMj9v.js";import{u as Ne}from"./ioXB9E2w.js";import{f as Me}from"./DsmBazLf.js";import"./CS5akSNT.js";import"./D4pAW_0T.js";const Be=w=>j.of([{key:"Ctrl-s",mac:"Cmd-s",run:p=>{const m=p.state.doc.toString();return w(m),!0},preventDefault:!0}]),Ee={class:se(["flex items-center justify-between p-1 rounded-md bg-muted"])},Ie={class:"flex items-center gap-1"},Qe={key:0,class:"text-xs text-muted-foreground"},Ue=G({__name:"FunctionControlBar",props:{hasChanges:{type:Boolean},isSaving:{type:Boolean}},emits:["onPreview","onSave","onDiscard"],setup(w,{emit:p}){const m=p;return(r,t)=>{const l=te,C=Fe;return c(),F("div",Ee,[d("div",Ie,[r.hasChanges?(c(),b(e(R),{key:0},{default:o(()=>[a(e(z),{"as-child":""},{default:o(()=>[d("div",null,[a(l,{variant:"outline",size:"xxs",disabled:r.isSaving,onClick:t[0]||(t[0]=u=>m("onPreview"))},{default:o(()=>[a(e(S),{name:"lucide:file-search",class:"size-4"}),t[3]||(t[3]=v(" Preview changes "))]),_:1},8,["disabled"])])]),_:1}),a(e(D),null,{default:o(()=>t[4]||(t[4]=[d("p",null,"Preview SQL changes before saving",-1)])),_:1})]),_:1})):q("",!0),a(e(R),null,{default:o(()=>[a(e(z),{"as-child":""},{default:o(()=>[d("div",null,[a(l,{variant:"outline",size:"xxs",disabled:!r.hasChanges||r.isSaving,onClick:t[1]||(t[1]=u=>m("onSave"))},{default:o(()=>[r.isSaving?(c(),b(e(S),{key:0,name:"hugeicons:loading-03",class:"size-4 animate-spin"})):(c(),b(e(S),{key:1,name:"lucide:save",class:"size-4"})),t[6]||(t[6]=v(" Save ")),a(C,null,{default:o(()=>t[5]||(t[5]=[v("⌘S")])),_:1})]),_:1},8,["disabled"])])]),_:1}),a(e(D),null,{default:o(()=>[t[7]||(t[7]=d("p",null,"Save routine changes",-1)),r.hasChanges?q("",!0):(c(),F("p",Qe," No changes to save "))]),_:1})]),_:1}),r.hasChanges?(c(),b(e(R),{key:1},{default:o(()=>[a(e(z),{"as-child":""},{default:o(()=>[d("div",null,[a(l,{variant:"outline",size:"xxs",disabled:r.isSaving,onClick:t[2]||(t[2]=u=>m("onDiscard"))},{default:o(()=>[a(e(S),{name:"lucide:undo-2",class:"size-4"}),t[8]||(t[8]=v(" discard changes "))]),_:1},8,["disabled"])])]),_:1}),a(e(D),null,{default:o(()=>t[9]||(t[9]=[d("p",null,"Discard changes",-1)])),_:1})]),_:1})):q("",!0)])])}}}),Ve={class:"flex flex-col h-full p-1"},Le={class:"flex flex-col h-full border rounded-md"},Ae={class:"h-full flex flex-col overflow-y-auto relative"},an=G({__name:"FunctionDetail",props:{functionId:{},connectionId:{}},setup(w){const p=w,m=oe(),r=ie(),{activeSchema:t}=le(r),l=f(""),C=f(""),u=f(!1),N=f(""),M=f("Query error!"),$=f(!1),h=f(!1),y=f(""),H=_(()=>O(l.value)),Y=_(()=>O(C.value)),B=_(()=>H.value!==Y.value),Z=_(()=>{const n=K(y.value);return n?`${n} update preview`:"Routine update preview"}),J=_(()=>{var i,x;const n=(i=t.value)==null?void 0:i.tableDetails,s={};for(const k in n){const g=(x=n[k])==null?void 0:x.columns;s[k]=g.map(T=>({label:T.name,type:"field",info:T.short_type_name||"",boost:-T.ordinal_position}))}return s}),W=new ue,E=_(()=>p.connectionId?m.connections.find(n=>n.id===p.connectionId):m.selectedConnection),I=_(()=>({functionId:p.functionId,...L(E.value)})),{status:X}=Ne("/api/functions/definition",{method:"POST",body:I,onResponse:n=>{if(typeof n.response._data=="string"){const s=n.response._data||"";l.value=s,C.value=s}},watch:[I]},"$cS7qZacQ7d"),P=(n,s)=>{M.value=n,N.value=s,$.value=!0},Q=()=>{if(!B.value){P("No changes to save","The routine definition already matches the loaded version.");return}const n=O(l.value);if(!K(n)){P("Invalid routine definition","Preview requires a valid CREATE OR REPLACE FUNCTION or PROCEDURE statement.");return}return n},U=()=>{if(u.value)return;const n=Q();n&&(y.value=n,h.value=!0)},V=async(n=y.value)=>{var s;if(!(!n||u.value)){u.value=!0;try{const i=await $fetch("/api/functions/update",{method:"POST",body:{...L(E.value),functionDefinition:n}});C.value=l.value,h.value=!1,ze.success("Routine saved",{description:`Updated successfully in ${(i==null?void 0:i.queryTime)??0}ms`})}catch(i){h.value=!1,P("Save failed",((s=i==null?void 0:i.data)==null?void 0:s.message)||(i==null?void 0:i.message)||"Failed to save routine.")}finally{u.value=!1}}},ee=async()=>{if(u.value)return;const n=Q();n&&(y.value=n,await V(n))},ne=()=>{l.value=C.value},ae=[Be(n=>{l.value=n,U()}),Re(n=>Me(n,{language:"postgresql",keywordCase:"upper"})),j.of([{key:"Mod-i",run:ce},{key:"Tab",run:me}]),W.of(fe({dialect:ve.define({...ge.spec,doubleDollarQuotedStrings:!1}),upperCaseKeywords:!0,keywordCompletion:pe,schema:J.value})),...re(),de];return(n,s)=>{const i=S,x=De,k=Pe;return c(),F(qe,null,[a(Oe,{open:e($),"onUpdate:open":s[0]||(s[0]=g=>A($)?$.value=g:null),title:e(M),message:e(N)},null,8,["open","title","message"]),a(e(ke),{open:e(h),"onUpdate:open":s[1]||(s[1]=g=>h.value=g)},{default:o(()=>[a(e(_e),{class:"border w-[55vw]! max-w-[55vw]!"},{default:o(()=>[a(e(Ce),null,{default:o(()=>[a(e(be),{class:"flex items-center text-base font-medium"},{default:o(()=>[a(i,{name:"lucide:file-search",class:"size-4 mr-2"}),v(" "+he(e(Z)),1)]),_:1}),a(e(ye),null,{default:o(()=>s[3]||(s[3]=[v(" Review the exact SQL that will be submitted. The routine is not updated until you confirm this save. ")])),_:1})]),_:1}),a(x,{code:e(y),"show-copy-button":"","max-height":"24rem"},null,8,["code"]),a(e(Se),null,{default:o(()=>[a(e(we),{disabled:e(u)},{default:o(()=>s[4]||(s[4]=[v("Cancel")])),_:1},8,["disabled"]),a(e($e),{class:"gap-2",onClick:xe(V,["prevent"])},{default:o(()=>[e(u)?(c(),b(i,{key:0,name:"hugeicons:loading-03",class:"size-4 animate-spin"})):(c(),b(i,{key:1,name:"lucide:save",class:"size-4"})),s[5]||(s[5]=v(" Save to database "))]),_:1})]),_:1})]),_:1})]),_:1},8,["open"]),d("div",Ve,[d("div",Le,[a(Ue,{"has-changes":e(B),"is-saving":e(u),onOnPreview:U,onOnSave:ee,onOnDiscard:ne},null,8,["has-changes","is-saving"]),d("div",Ae,[a(k,{visible:e(X)==="pending"||e(u)},null,8,["visible"]),a(Te,{modelValue:e(l),"onUpdate:modelValue":s[2]||(s[2]=g=>A(l)?l.value=g:null),extensions:ae,disabled:!1},null,8,["modelValue"])])])])],64)}}});export{an as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as a,c as s,a as e,C as t}from"./B8TrrBEb.js";import{_ as i}from"./DHAL8jJG.js";import"./Ci5B19-c.js";import"./Bq47tjcm.js";import"./kvtnkChG.js";import"./DGvAu532.js";import"./BcsKoAPU.js";var n={parser:e,get db(){return new t},renderer:s,styles:a,init:i(r=>{r.class||(r.class={}),r.class.arrowMarkerAbsolute=r.arrowMarkerAbsolute},"init")};export{n as diagram};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as o}from"./Bq7OeLM1.js";import{d as r,a8 as s,c as n,k as c,g as u,o as l}from"./BcsKoAPU.js";import"./BWebIWit.js";import"./ioXB9E2w.js";const b=r({__name:"[tableId]",setup(m){const e=s(),t=n(()=>e.params.tableId);return(a,p)=>(l(),c(o,{tableId:u(t)},null,8,["tableId"]))}});export{b as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"id":"7c171291-8bbd-4c4c-8904-0afae065b82e","timestamp":1777784369430,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|