orcaq 1.1.9 → 1.1.10
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/{ljX6O69y.js → -WSV_TU1.js} +1 -1
- package/.output/public/_nuxt/{DDNFAZ6A.js → 0U50G6dt.js} +1 -1
- package/.output/public/_nuxt/{Cgc3lXst.js → 0yW2dL-K.js} +1 -1
- package/.output/public/_nuxt/{DZJEpoYA.js → 1V1SIDI5.js} +1 -1
- package/.output/public/_nuxt/{CiGbpFVs.js → 24W1ftax.js} +1 -1
- package/.output/public/_nuxt/{Dcf3u1x9.js → 339BCoyy.js} +1 -1
- package/.output/public/_nuxt/{B6aTbrvX.js → 9PqzQzi0.js} +1 -1
- package/.output/public/_nuxt/{Cilp0euQ.js → 9Skr9Ccw.js} +1 -1
- package/.output/public/_nuxt/{BP23Jaxf.js → 9eKRx5AF.js} +1 -1
- package/.output/public/_nuxt/{CX2dGf8T.js → 9vfu7pKH.js} +1 -1
- package/.output/public/_nuxt/B79M7zD1.js +1 -0
- package/.output/public/_nuxt/{CAnZNTn6.js → BDw-ivE-.js} +1 -1
- package/.output/public/_nuxt/{Btu3pVWi.js → BFOjhnLA.js} +1 -1
- package/.output/public/_nuxt/{B-E4SrDA.js → BFYNB1ok.js} +1 -1
- package/.output/public/_nuxt/{DrfFcngk.js → BIBdWmGh.js} +1 -1
- package/.output/public/_nuxt/{CfglFxLQ.js → BIDVPCgr.js} +1 -1
- package/.output/public/_nuxt/{CT4V-SdE.js → BJMwGHo7.js} +1 -1
- package/.output/public/_nuxt/{B-OC4Wzf.js → BKh6DDUh.js} +1 -1
- package/.output/public/_nuxt/{CGlRJg9T.js → BLDVl9Iw.js} +1 -1
- package/.output/public/_nuxt/{DMhhDVL0.js → BNgGNFV2.js} +1 -1
- package/.output/public/_nuxt/{CjE9xodL.js → BP-G5cXp.js} +1 -1
- package/.output/public/_nuxt/{ImQ5Dcjp.js → BS966b0P.js} +1 -1
- package/.output/public/_nuxt/{BIYjBgOJ.js → B_Oy26qU.js} +1 -1
- package/.output/public/_nuxt/Bdou58NY.js +1 -0
- package/.output/public/_nuxt/{CHFYZcjC.js → BjfaOtB-.js} +1 -1
- package/.output/public/_nuxt/{Dpdssse1.js → BlngscFe.js} +1 -1
- package/.output/public/_nuxt/{DB45HoaN.js → BsXv3P9A.js} +1 -1
- package/.output/public/_nuxt/{DNL5Q-iy.js → Buh85F8i.js} +1 -1
- package/.output/public/_nuxt/{DYFx7Tau.js → Bvi2huT8.js} +1 -1
- package/.output/public/_nuxt/{W2el5otm.js → BxlUlYz1.js} +1 -1
- package/.output/public/_nuxt/{BqQfmS94.js → ByJGqBjE.js} +1 -1
- package/.output/public/_nuxt/{D8dLCNO1.js → C-M7J4rh.js} +1 -1
- package/.output/public/_nuxt/{DDgsZmht.js → C04-ICJx.js} +1 -1
- package/.output/public/_nuxt/{Ce00XEKL.js → C2Czrs1u.js} +1 -1
- package/.output/public/_nuxt/{C4zVAAUp.js → C5Feel6b.js} +1 -1
- package/.output/public/_nuxt/{jgZoykhT.js → CAVSZeVY.js} +1 -1
- package/.output/public/_nuxt/{BblWMS7J.js → CAcViJl9.js} +3 -3
- package/.output/public/_nuxt/{B2Wngdut.js → CBge6eLY.js} +1 -1
- package/.output/public/_nuxt/{lFU3Ma5J.js → CC8wYgAN.js} +1 -1
- package/.output/public/_nuxt/{yPPOBtqs.js → CEIpXOz0.js} +1 -1
- package/.output/public/_nuxt/CI85gLx4.js +1 -0
- package/.output/public/_nuxt/{CH3m0zKs.js → CJeCcjmd.js} +1 -1
- package/.output/public/_nuxt/{V_GiMERb.js → CJuYfiL1.js} +1 -1
- package/.output/public/_nuxt/{BWpduGRB.js → CNErkSjF.js} +1 -1
- package/.output/public/_nuxt/COII6plA.js +31 -0
- package/.output/public/_nuxt/{EzQMUIRl.js → CRCn6mdA.js} +1 -1
- package/.output/public/_nuxt/{w8sha2t6.js → CUtdecax.js} +1 -1
- package/.output/public/_nuxt/{CQi4GvAy.js → CYm7TuhP.js} +1 -1
- package/.output/public/_nuxt/{CM7fDldV.js → CbkolJXg.js} +1 -1
- package/.output/public/_nuxt/{DngnCd9Q.js → CeA2-eDW.js} +1 -1
- package/.output/public/_nuxt/CgY96xS_.js +1 -0
- package/.output/public/_nuxt/{BX-NC3FD.js → Ch9kUYU-.js} +1 -1
- package/.output/public/_nuxt/{DeGwWuWf.js → Ch_iEFHi.js} +1 -1
- package/.output/public/_nuxt/{D_dxq6Av.js → Co6sZiuo.js} +1 -1
- package/.output/public/_nuxt/{BlVXGJOG.js → Cu7zvuYQ.js} +1 -1
- package/.output/public/_nuxt/CwcaMelw.js +1 -0
- package/.output/public/_nuxt/{s10hyhzI.js → CxFAImHj.js} +1 -1
- package/.output/public/_nuxt/{DcIKg-oA.js → D-yya4MN.js} +29 -29
- package/.output/public/_nuxt/{CCwJzmTT.js → D0NZRXnm.js} +1 -1
- package/.output/public/_nuxt/{CB2XoHaK.js → D6XDbGbI.js} +1 -1
- package/.output/public/_nuxt/{DEBj_roB.js → D8JEzGOU.js} +1 -1
- package/.output/public/_nuxt/{DsHltPpv.js → D8wbEppA.js} +1 -1
- package/.output/public/_nuxt/{Dgh1FhxQ.js → D9h-2lVu.js} +1 -1
- package/.output/public/_nuxt/{B1ydsdXg.js → DANeHzIE.js} +1 -1
- package/.output/public/_nuxt/{C9JT2-RE.js → DBku6oAz.js} +1 -1
- package/.output/public/_nuxt/{BeMg7yb6.js → DDXEeq1n.js} +2 -2
- package/.output/public/_nuxt/DESxUB7o.js +1 -0
- package/.output/public/_nuxt/{CBy17iCN.js → DHG-KJyJ.js} +1 -1
- package/.output/public/_nuxt/DHXbNYui.js +1 -0
- package/.output/public/_nuxt/{bJGrilFb.js → DI0LPDTd.js} +1 -1
- package/.output/public/_nuxt/{RpDfSk0l.js → DKSZP8GP.js} +1 -1
- package/.output/public/_nuxt/{C1GKs4YV.js → DL1qmlP8.js} +1 -1
- package/.output/public/_nuxt/{mtBjWkj4.js → DN4-koTG.js} +1 -1
- package/.output/public/_nuxt/{Bc7Kpanq.js → DO1jmufl.js} +1 -1
- package/.output/public/_nuxt/{B9vFZSzU.js → DOuNj3Jn.js} +1 -1
- package/.output/public/_nuxt/{UowwUtRH.js → DPUO8R7l.js} +1 -1
- package/.output/public/_nuxt/{CSIDbD5d.js → DahDvheq.js} +1 -1
- package/.output/public/_nuxt/{D33qa5aT.js → DbHH7dzg.js} +1 -1
- package/.output/public/_nuxt/{DD6NieRw.js → DbehhcO7.js} +23 -23
- package/.output/public/_nuxt/{B-cBPXHS.js → DeTqfKUd.js} +1 -1
- package/.output/public/_nuxt/{C6ajLfO0.js → Df85byjM.js} +1 -1
- package/.output/public/_nuxt/{BY0VC_fp.js → DizXDCtS.js} +1 -1
- package/.output/public/_nuxt/{lPZuSUw2.js → DjKlFOO8.js} +1 -1
- package/.output/public/_nuxt/{CV3uHXW4.js → DjLd7E2v.js} +1 -1
- package/.output/public/_nuxt/{D0TQTmc_.js → DnBjpGBx.js} +1 -1
- package/.output/public/_nuxt/{BZOLz5Xw.js → DnQ4Mwo_.js} +1 -1
- package/.output/public/_nuxt/{RCyqQNC4.js → DqYakCiF.js} +1 -1
- package/.output/public/_nuxt/{BkHJ3kuB.js → DqunUhPG.js} +1 -1
- package/.output/public/_nuxt/{DdjYB9eX.js → Dr1ZFb1n.js} +1 -1
- package/.output/public/_nuxt/Dsis422h.js +1 -0
- package/.output/public/_nuxt/{BorA7uj6.js → Du_4PNZI.js} +1 -1
- package/.output/public/_nuxt/{BgFbw5aK.js → DvTZ16yM.js} +1 -1
- package/.output/public/_nuxt/{QZbgg6bx.js → Dvt9REJL.js} +1 -1
- package/.output/public/_nuxt/{DghZRCwT.js → DxMpy-ot.js} +1 -1
- package/.output/public/_nuxt/{CqwK0iC2.js → DyLnyCs4.js} +1 -1
- package/.output/public/_nuxt/{BcbezgEJ.js → FakvzamF.js} +1 -1
- package/.output/public/_nuxt/LcPL138_.js +1 -0
- package/.output/public/_nuxt/{C0kVUAwR.js → P7T0pdFZ.js} +1 -1
- package/.output/public/_nuxt/{CM4UzWO5.js → Rhi-lAfN.js} +1 -1
- package/.output/public/_nuxt/{CwEAH09c.js → S7ftI9sn.js} +1 -1
- package/.output/public/_nuxt/{C4fd0pgB.js → T01BrTsW.js} +1 -1
- package/.output/public/_nuxt/{CmROOZW3.js → WqpfmT0s.js} +1 -1
- package/.output/public/_nuxt/XhSVj1eQ.js +16 -0
- package/.output/public/_nuxt/{D6FGhPpz.js → _fXjN5Pd.js} +1 -1
- package/.output/public/_nuxt/{CvFBHqKj.js → agpUpIJe.js} +1 -1
- package/.output/public/_nuxt/builds/latest.json +1 -1
- package/.output/public/_nuxt/builds/meta/39c2c89f-bb28-470e-b95a-b7776149dc9f.json +1 -0
- package/.output/public/_nuxt/{CsRqTS8p.js → dDyWVWO8.js} +1 -1
- package/.output/public/_nuxt/entry.BeX6Jkel.css +1 -0
- package/.output/public/_nuxt/{Ck7gJ0Ru.js → f6qCSD-K.js} +1 -1
- package/.output/public/_nuxt/{CRtMS55w.js → goG5gpyv.js} +1 -1
- package/.output/public/_nuxt/{B3ZoiMh5.js → hbGkF-4Z.js} +1 -1
- package/.output/public/_nuxt/{CkVRbNxk.js → jDSo3fNb.js} +1 -1
- package/.output/public/_nuxt/{CvrjITPr.js → k4d17TZz.js} +1 -1
- package/.output/public/_nuxt/{FrxNy5Hb.js → m4Dxzyfa.js} +2 -2
- package/.output/public/_nuxt/{Dzy2Amcc.js → ndyknmtb.js} +4 -4
- package/.output/public/_nuxt/{DuvFgQqu.js → vIV0z0PD.js} +1 -1
- package/.output/public/_nuxt/{DI-I25kb.js → wTs8ybMd.js} +1 -1
- package/.output/public/_nuxt/{Ds4LpS8e.js → ymlmmOzU.js} +1 -1
- package/.output/server/chunks/_/tables.factory.mjs +133 -43
- package/.output/server/chunks/_/tables.factory.mjs.map +1 -1
- package/.output/server/chunks/build/client.manifest.mjs +817 -806
- package/.output/server/chunks/build/client.manifest.mjs.map +1 -1
- package/.output/server/chunks/nitro/nitro.mjs +701 -694
- package/.output/server/package.json +1 -1
- package/package.json +1 -1
- package/.output/public/_nuxt/B3jyHGmo.js +0 -1
- package/.output/public/_nuxt/BFxd7ZWZ.js +0 -1
- package/.output/public/_nuxt/BI0OYmAG.js +0 -1
- package/.output/public/_nuxt/BMwuBt1W.js +0 -1
- package/.output/public/_nuxt/Cv8aMucD.js +0 -31
- package/.output/public/_nuxt/DA2L1Ivx.js +0 -1
- package/.output/public/_nuxt/DBIf1geQ.js +0 -1
- package/.output/public/_nuxt/DX42Brjy.js +0 -1
- package/.output/public/_nuxt/DYBPW385.js +0 -1
- package/.output/public/_nuxt/builds/meta/657bdee4-fa56-4862-bc13-309345429302.json +0 -1
- package/.output/public/_nuxt/entry.CQwtqNMg.css +0 -1
- package/.output/public/_nuxt/ngeX9iiO.js +0 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./9PqzQzi0.js","./DbehhcO7.js","./entry.BeX6Jkel.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
var fo=Object.defineProperty;var vo=(n,t,e)=>t in n?fo(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var we=(n,t,e)=>vo(n,typeof t!="symbol"?t+"":t,e);import{D as re,d as se,bX as ho,a4 as go,aj as yo,q as F,o as C,w as y,E as Ke,u as d,s as gs,dK as bn,dJ as bo,$ as xo,a0 as So,a1 as Co,a2 as wo,es as _o,S as ys,e8 as ra,et as Ro,i as O,bJ as To,a5 as pt,p as _t,e as S,n as ye,a as h,bK as Eo,ck as Ja,c as z,f as k,b as K,bO as en,bU as tn,bP as an,bQ as nn,_ as be,bR as No,t as U,bT as bs,N as Le,bf as sn,F as ae,x as ue,J as Oe,L as Ve,O as Pe,r as j,l as _e,eu as Ao,ev as Mo,ew as xs,ex as Ss,ey as Io,bh as Cs,ez as Lo,eA as ko,e2 as zo,e3 as $o,e4 as Oo,eB as zt,da as Vo,am as ce,an as ha,aI as on,aK as dt,v as Po,aJ as Do,M as Ct,ar as Fo,aq as Rt,cB as ws,ad as ga,cE as Me,k as We,m as je,bS as Qe,z as Ye,A as Bo,eC as Ho,B as fe,cF as ia,bk as xn,bm as Sn,ai as Bt,aH as nt,d4 as qo,at as _a,bi as Uo,bA as Ko,bB as Go,bC as Wo,eD as jo,H as Qo,au as Yo,az as Xo,eE as Cn,ag as _s,eF as Zo,e7 as rn,eG as Jo,eH as er,eI as tr,eJ as ar,eK as nr,T as sr,eL as Rs,a$ as ln,b0 as Ra,eM as or,b2 as rr,b1 as ir,eN as lr,b3 as ur,b4 as cr,eO as dr,b5 as mr,eP as wn,eQ as pr,eR as fr,b7 as vr,eS as hr,bz as gr,Z as Ts,ed as yr,V as br,K as lt,G as xr,bg as Sr,b8 as Cr,ae as ya,b9 as wr,ba as _r,bb as Rr,bc as Tr,bd as Er,be as Nr,a_ as Es,aD as Ar,h as Mr,aC as Ir,co as Lr}from"./DbehhcO7.js";import{_ as kr,u as zr}from"./0U50G6dt.js";import{_ as $r}from"./BS966b0P.js";import{_ as Or}from"./CBge6eLY.js";import{_ as vt}from"./339BCoyy.js";import{b as Ns,c as As,d as Ms,C as ge,f as Vr,e as Jt,g as Pr,h as Dr,i as Fr,j as Br}from"./vIV0z0PD.js";import{_ as Hr,a as qr,b as Ur}from"./CeA2-eDW.js";import{D as Kr,g as Gr,h as Wr,j as jr,_ as Ba,e as Ha,f as qa}from"./DN4-koTG.js";import{M as Qr}from"./CEIpXOz0.js";import{p as Yr,D as Xr,o as Zr,q as Ta,r as Jr,a as ei,s as Is,t as ti,v as ai,w as ni,x as si,_ as oi}from"./goG5gpyv.js";import{_ as Vt}from"./CC8wYgAN.js";import{b as Ea,c as Na}from"./-WSV_TU1.js";import{_ as ri}from"./Co6sZiuo.js";import{s as ii}from"./CYm7TuhP.js";import{e as X,ao as li,i as ke,_ as De,ap as un,a as Ls,q as _n,M as Tt,t as Rn,u as Tn,d as Et,v as En,aq as cn,j as ks,ar as He,x as zs,y as Ua,w as $s,C as Os,a0 as qe,as as ui,at as ci,Q as la,E as Ie,au as di,av as Nn,J as Vs,aw as ua,a5 as ba,ax as Ps,ay as mi,az as pi,aA as fi,aB as vi,af as Ds,aC as hi,aD as gi,aE as yi,aF as An,ag as Fs,aG as bi,p as Ut,aH as Mn,aI as xi,f as Si,V as ca,a1 as Ci,Y as gt,aJ as Aa,aK as Ma,aL as wi,aM as _i,l as yt,aN as Ri,aO as Ti,aP as Ia,aQ as In,aR as Ei,aS as Ni,aT as da,L as Ai,aU as Mi,aV as Ii,aW as Li,a8 as ki,aX as Bs,aY as Hs,aZ as zi,a_ as $i,g as Oi,Z as Pt,a$ as ea,b0 as Ln,b1 as Ka,b2 as Vi,b3 as Pi,b4 as La,b5 as ka,b6 as Di,b7 as Fi,R as Bi,b8 as Hi,b9 as qi,ba as kn,bb as Ui,bc as Ki,ai as Gi,ak as Wi,aj as ji,al as Qi,am as Yi,an as Xi,ah as Zi}from"./_fXjN5Pd.js";import{_ as za,a as $a}from"./DxMpy-ot.js";import{_ as Oa}from"./agpUpIJe.js";import{L as Ji,c as el,d as tl,i as al,a as nl}from"./Rhi-lAfN.js";import{_ as qs,n as sl,i as ol,j as rl,k as il,l as ll,s as ul,m as cl,a as dl}from"./DahDvheq.js";import{f as Dt,b as Kt,a as Ga}from"./D9Ycznwo.js";import{_ as xa}from"./DL1qmlP8.js";import{i as ml}from"./Ch_iEFHi.js";import{f as pl,H as zn}from"./BKh6DDUh.js";import{r as fl}from"./DOuNj3Jn.js";import{c as vl,a as hl,m as gl}from"./ymlmmOzU.js";import"./B5rxJs06.js";import"./dDyWVWO8.js";import"./CJeCcjmd.js";import"./hbGkF-4Z.js";import"./Dr1ZFb1n.js";import"./wTs8ybMd.js";import"./BJMwGHo7.js";import"./DbHH7dzg.js";import"./BVmBXPoG.js";import"./9Skr9Ccw.js";import"./DvTZ16yM.js";import"./C04-ICJx.js";import"./DnQ4Mwo_.js";import"./jDSo3fNb.js";var ta=(n=>(n.CSV_WITH_HEADER="csv-with-header",n.CSV_NO_HEADER="csv-no-header",n.JSON="json",n.SQL="sql",n.TSV="tsv",n))(ta||{});class yl{constructor(t){this.rawError=t}get nomaltliztionErrror(){var e;const t=((e=this.rawError)==null?void 0:e.message)||"Error parsing SQL execution.";if(!this.rawError)return{message:t};switch(this.rawError.dbType){case re.POSTGRES:return this.normalizePostgresError(t);case re.MYSQL:return this.normalizeMysqlError(t);case re.SQLITE3:return this.normalizeSqliteError(t);case re.MARIADB:return this.normalizeMysqlError(t);case re.ORACLE:return this.normalizeOracleError(t);default:return{message:t}}}normalizePostgresError(t){let e;return this.rawError.position&&(e=typeof this.rawError.position=="string"?Number(this.rawError.position):this.rawError.position,Number.isNaN(e)&&(e=void 0)),{message:this.rawError.message||t,position:e,hint:this.rawError.hint}}normalizeMysqlError(t){return{message:this.rawError.sqlMessage||this.rawError.message||t,hint:this.rawError.code?`Error Code: ${this.rawError.code}`:void 0}}normalizeSqliteError(t){return{message:this.rawError.message||t,hint:this.rawError.code?`Error Code: ${this.rawError.code}`:void 0}}normalizeOracleError(t){return{message:this.rawError.message||t,hint:this.rawError.errorNum?`ORA-${String(this.rawError.errorNum).padStart(5,"0")}`:void 0}}}var bl=se({__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(n,{emit:t}){const e=n,a=t,s=ho(e,["modelValue"]),o=go(s),r=yo(e,"modelValue",a);return Yr({modelValue:r}),(i,l)=>(C(),F(Qr,gs({role:"menuitemcheckbox"},d(o),{"aria-checked":d(bn)(d(r))?"mixed":d(r),"data-state":d(bo)(d(r)),onSelect:l[0]||(l[0]=async c=>{a("select",c),d(bn)(d(r))?r.value=!0:r.value=!d(r)})}),{default:y(()=>[Ke(i.$slots,"default",{modelValue:d(r)})]),_:3},16,["aria-checked","data-state"]))}}),xl=bl,Sl=se({__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(n,{emit:t}){const e=n,s=xo(t);return So(),(o,r)=>(C(),F(d(xl),Co(wo({...e,...d(s)})),{default:y(()=>[Ke(o.$slots,"default")]),_:3},16))}}),Cl=Sl;function dn(n,t){n.dispatch(_o(n.state,t))}function wl(n){return n===re.POSTGRES?"postgres-positional":n===re.ORACLE?"oracle-positional":"question-mark"}function _l(n,t,e,a={}){if(!Object.keys(t).length)return n;const s=a.style??wl(e);let o=a.startIndex??1,r="",i=0;for(;i<n.length;){const l=n[i];if(l==="'"){const c=i++;for(;i<n.length;)if(n[i]==="'"&&n[i+1]==="'")i+=2;else if(n[i]==="'"){i++;break}else i++;r+=n.slice(c,i);continue}if(l==='"'){const c=i++;for(;i<n.length&&n[i]!=='"';)i++;i++,r+=n.slice(c,i);continue}if(l==="$"&&e===re.POSTGRES){const c=i;let m="$",u=i+1;for(;u<n.length&&n[u]!=="$"&&/[a-zA-Z0-9_]/.test(n[u]);)m+=n[u++];if(u<n.length&&n[u]==="$"){m+="$",u++;const p=n.indexOf(m,u);if(p!==-1){i=p+m.length,r+=n.slice(c,i);continue}}}if(l===":"&&i+1<n.length&&/[a-zA-Z_]/.test(n[i+1])){const c=i++;let m="";for(;i<n.length&&/[a-zA-Z0-9_]/.test(n[i]);)m+=n[i++];m in t?s==="postgres-positional"?r+=`$${o++}`:s==="oracle-positional"?r+=`:${o++}`:r+="?":r+=n.slice(c,i);continue}r+=l,i++}return r}function Rl(n,t,e){if(n===t)return e;let a=0,s=0;for(;s<e&&a<n.length;){const o=n[a],r=t[s],i=/\s/.test(o),l=/\s/.test(r);if(i&&l){a++,s++;continue}if(o===":"&&(r==="$"||r==="?"||r===":")){for(;a<n.length&&/[:a-zA-Z0-9_]/.test(n[a]);)a++;if(r==="$")for(;s<t.length&&/[$0-9]/.test(t[s]);)s++;else if(r===":")for(;s<t.length&&/[:0-9]/.test(t[s]);)s++;else s++;if(s>=e)return a;continue}o===r?(a++,s++):a++}return a}function $n({editorView:n,originalSql:t,statementFrom:e,fileParameters:a={},errorDetail:s,clientType:o,queryPrefix:r}){if(!n||!s)return;const{message:i,position:l}=s.normalizeError||new yl(s).nomaltliztionErrror;if(!l){El(n,e,t,i);return}const c=`${r}${t}`,m=_l(c,a,o),u=Rl(c,m,l),p=Math.max(u-1,0)-((r==null?void 0:r.length)||0),{from:f,to:g}=Tl(t,e,p);dn(n,[{from:f,to:g,severity:"error",message:i}])}function Tl(n,t,e){let a=e;for(;a<n.length&&!/[\s\n\r\t]/.test(n[a]);)a++;return{from:t+e,to:t+a}}function El(n,t,e,a){const s=[{from:t,to:t+e.length,severity:"error",message:a}];dn(n,s)}function Nl(n){dn(n,[])}const Al=n=>ys.of([{key:"Mod-Enter",mac:"Cmd-Enter",run:t=>{const{currentStatements:e}=ra(t),a=Ro(t);return e.length&&n({currentStatements:e,treeNodes:a||[]}),!0},preventDefault:!0}]),Ml=se({__name:"DropdownMenuCheckboxItem",props:{modelValue:{type:[Boolean,String]},disabled:{type:Boolean},textValue:{},asChild:{type:Boolean},as:{},class:{}},emits:["select","update:modelValue"],setup(n,{emit:t}){const e=n,a=t,s=O(()=>{const{class:i,...l}=e;return l}),o=To(s,a),r=pt(Kr,O(()=>"default"));return(i,l)=>(C(),F(d(Cl),gs({"data-slot":"dropdown-menu-checkbox-item","data-size":d(r)},d(o),{class:d(_t)("focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-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",d(Gr)[d(r)],e.class)}),{default:y(()=>[S("span",{class:ye(d(_t)("pointer-events-none absolute flex items-center justify-center",d(Wr)[d(r)]))},[h(d(Xr),null,{default:y(()=>[h(d(Eo),{class:ye(d(jr)[d(r)])},null,8,["class"])]),_:1})],2),Ke(i.$slots,"default")]),_:3},16,["data-size","class"]))}}),Il={},Ll={class:"p-4 flex flex-col items-center justify-center h-full text-center space-y-4"},kl={class:"text-muted-foreground space-y-3"},zl={class:"list-disc text-sm list-inside text-left space-y-2"};function $l(n,t){const e=Or,a=$r,s=vt;return C(),z("div",Ll,[h(a,{class:"rounded-2xl size-20 shadow-md"},{default:y(()=>[h(e,{src:"/logo.png",alt:"@unovue"})]),_:1}),S("div",kl,[t[7]||(t[7]=S("h2",{class:"text-md font-normal text-foreground"},"Getting Started",-1)),S("ol",zl,[t[5]||(t[5]=S("li",null,[S("span",{class:"font-normal text-foreground"},"Write your query"),k(" in the editor. ")],-1)),t[6]||(t[6]=S("li",null,[S("span",{class:"font-normal text-foreground"},"Click inside your query"),k(" to select it. ")],-1)),S("li",null,[t[1]||(t[1]=k(" Click ")),t[2]||(t[2]=S("span",{class:"text-foreground font-normal"},"'Execute current'",-1)),t[3]||(t[3]=k(" or use shortcut ")),h(s,{class:"font-normal border rounded-md p-1 px-1.5 text-foreground"},{default:y(()=>t[0]||(t[0]=[k("⌘↵")])),_:1}),t[4]||(t[4]=k(" to run the query. "))])])])])}const Ol=Ja(Il,[["render",$l]]),Vl={class:"font-medium text-foreground"},Pl={class:"font-medium text-foreground"},Dl=se({__name:"RawQueryConnectionConfirmDialog",props:{open:{type:Boolean},targetConnectionName:{},currentConnectionName:{}},emits:["confirm","cancel"],setup(n,{emit:t}){const e=t,a=()=>{e("confirm")},s=()=>{e("cancel")};return(o,r)=>{const i=be;return o.open?(C(),F(d(en),{key:0,open:o.open,"onUpdate:open":r[0]||(r[0]=l=>!l&&s())},{default:y(()=>[h(d(tn),{class:"max-w-md"},{default:y(()=>[h(d(an),null,{default:y(()=>[h(d(nn),{class:"flex items-center gap-2"},{default:y(()=>[h(i,{name:"hugeicons:alert-02",class:"size-5 text-amber-500"}),r[1]||(r[1]=k(" Confirm query execution "))]),_:1}),h(d(No),null,{default:y(()=>[r[2]||(r[2]=k(" This query will execute on ")),S("span",Vl,U(o.targetConnectionName),1),r[3]||(r[3]=k(" . The current connection is ")),S("span",Pl,U(o.currentConnectionName),1),r[4]||(r[4]=k(" . Make sure before executing. "))]),_:1})]),_:1}),h(d(bs),null,{default:y(()=>[h(d(Le),{variant:"outline",onClick:s},{default:y(()=>r[5]||(r[5]=[k("Cancel")])),_:1}),h(d(Le),{class:"gap-1",onClick:a},{default:y(()=>[h(i,{name:"lucide:play",class:"size-4"}),r[6]||(r[6]=k(" Execute "))]),_:1})]),_:1})]),_:1})]),_:1},8,["open"])):K("",!0)}}}),Fl={key:1,class:"text-xs text-muted-foreground ml-2"},Bl=se({__name:"RawQueryEditorContextMenu",props:{contextMenuItems:{}},emits:["update:open"],setup(n,{emit:t}){const e=t,a=o=>typeof o>"u"?!0:!!o,s=o=>{e("update:open",o)};return(o,r)=>{const i=As,l=Vr,c=be,m=vt,u=Jt,p=Pr,f=Fr,g=Br,b=Dr,v=Ms,w=Ns;return C(),F(w,{"onUpdate:open":s},{default:y(()=>[h(i,{"as-child":""},{default:y(()=>[Ke(o.$slots,"default")]),_:3}),h(v,{class:"min-w-56",onCloseAutoFocus:r[0]||(r[0]=sn(()=>{},["prevent"]))},{default:y(()=>[(C(!0),z(ae,null,ue(o.contextMenuItems,(x,N)=>(C(),z(ae,{key:N},[x.type===d(ge).LABEL&&a(x.condition)?(C(),F(l,{key:0,class:"font-medium text-xs text-muted-foreground"},{default:y(()=>[k(U(x.title),1)]),_:2},1024)):x.type===d(ge).ACTION&&a(x.condition)?(C(),F(u,{key:1,onSelect:x.select,disabled:x.disabled},{default:y(()=>[x.icon?(C(),F(c,{key:0,name:x.icon,class:"size-4! min-w-4 text-muted-foreground"},null,8,["name"])):K("",!0),k(" "+U(x.title)+" ",1),x.shortcut?(C(),F(m,{key:1},{default:y(()=>[k(U(x.shortcut),1)]),_:2},1024)):K("",!0)]),_:2},1032,["onSelect","disabled"])):x.type===d(ge).SEPARATOR&&a(x.condition)?(C(),F(p,{key:2})):x.type===d(ge).SUBMENU&&a(x.condition)?(C(),F(b,{key:3,disabled:!x.items||x.items.length===0},{default:y(()=>[h(f,null,{default:y(()=>[x.icon?(C(),F(c,{key:0,name:x.icon,class:"size-4! min-w-4 text-muted-foreground mr-2"},null,8,["name"])):K("",!0),k(" "+U(x.title)+" ",1),x.desc?(C(),z("span",Fl,U(x.desc),1)):K("",!0)]),_:2},1024),h(g,{class:ye("min-w-52")},{default:y(()=>[(C(!0),z(ae,null,ue(x.items,(R,_)=>(C(),z(ae,{key:_},[R.type===d(ge).ACTION&&a(R.condition)?(C(),F(u,{key:0,onSelect:R.select},{default:y(()=>[R.icon?(C(),F(c,{key:0,name:R.icon,class:"size-4! min-w-4 text-muted-foreground"},null,8,["name"])):K("",!0),k(" "+U(R.title)+" ",1),R.shortcut?(C(),F(m,{key:1},{default:y(()=>[k(U(R.shortcut),1)]),_:2},1024)):K("",!0)]),_:2},1032,["onSelect"])):R.type===d(ge).LABEL&&a(R.condition)?(C(),F(l,{key:1,class:"font-medium text-xs text-muted-foreground"},{default:y(()=>[k(U(R.title),1)]),_:2},1024)):R.type===d(ge).SEPARATOR&&a(R.condition)?(C(),F(p,{key:2})):K("",!0)],64))),128))]),_:2},1024)]),_:2},1032,["disabled"])):K("",!0)],64))),128))]),_:1})]),_:3})}}}),Hl={},ql={class:"mb-2 flex items-center gap-1.5 text-sm font-semibold"};function Ul(n,t){const e=be,a=Le,s=qr,o=Oe,r=Ve,i=Ur,l=Hr,c=Pe;return C(),F(c,null,{default:y(()=>[h(l,null,{default:y(()=>[h(o,{"as-child":""},{default:y(()=>[h(s,{"as-child":""},{default:y(()=>[h(a,{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:y(()=>[h(e,{name:"hugeicons:help-circle",class:"size-3.5!"})]),_:1})]),_:1})]),_:1}),h(r,null,{default:y(()=>t[0]||(t[0]=[S("p",null,"How to use query variables",-1)])),_:1}),h(i,{side:"top",align:"start",class:"w-[440px] p-4 text-xs"},{default:y(()=>[S("p",ql,[h(e,{name:"hugeicons:help-circle",class:"size-4!"}),t[1]||(t[1]=k(" Passing variables in queries "))]),t[2]||(t[2]=S("p",{class:"mb-3 text-muted-foreground"},[k(" Use "),S("code",{class:"rounded bg-muted px-1"},":variable_name"),k(" syntax to bind parameters. For array operators, cast to the correct type: ")],-1)),t[3]||(t[3]=S("div",{class:"space-y-3"},[S("div",null,[S("p",{class:"mb-1 font-medium text-foreground"},[S("code",{class:"rounded bg-muted px-1"},"= ANY()")]),S("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[])`)]),S("div",null,[S("p",{class:"mb-1 font-medium text-foreground"},[S("code",{class:"rounded bg-muted px-1"},"IN()")]),S("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)`)]),S("div",null,[S("p",{class:"mb-1 font-medium text-foreground"},"Scalar variable"),S("pre",{class:"overflow-x-auto whitespace-pre-wrap break-all rounded bg-muted p-2 text-xs"},`WHERE created_at > :start_date
|
|
5
|
+
WHERE user_id = :user_id`)])],-1)),t[4]||(t[4]=S("p",{class:"mt-3 border-t pt-2 text-muted-foreground"},[k(" Replace "),S("code",{class:"rounded bg-muted px-1"},"alias_type"),k(" with the actual PostgreSQL type, e.g. "),S("code",{class:"rounded bg-muted px-1"},"integer"),k(", "),S("code",{class:"rounded bg-muted px-1"},"uuid"),k(", "),S("code",{class:"rounded bg-muted px-1"},"text"),k(". ")],-1))]),_:1})]),_:1})]),_:1})}const Kl=Ja(Hl,[["render",Ul]]),Gl={class:"h-fit py-1 flex items-center justify-between px-2"},Wl={class:"flex items-center gap-2"},jl={class:"font-normal text-xs text-muted-foreground"},Ql={class:"flex gap-1"},Yl={class:"flex items-center"},Xl={class:"flex items-center"},Zl={key:0},Jl={key:1},eu=se({__name:"RawQueryEditorFooter",props:{cursorInfo:{},executeLoading:{type:Boolean},isStreaming:{type:Boolean},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(n){const t=j(!1);return(e,a)=>{const s=Kl,o=be,r=vt,i=Le;return C(),z("div",Gl,[S("div",Wl,[S("div",jl," Ln "+U(e.cursorInfo.line)+", Col "+U(e.cursorInfo.column),1),e.isSupportVariable?(C(),F(s,{key:0})):K("",!0)]),S("div",Ql,[e.isSupportFormat?(C(),F(d(Pe),{key:0},{default:y(()=>[h(d(Oe),null,{default:y(()=>[S("div",Yl,[h(i,{onClick:a[0]||(a[0]=l=>e.$emit("onFormatCurrentStatement")),variant:"outline",size:"xxs",class:"rounded-r-none"},{default:y(()=>[h(o,{name:"hugeicons:magic-wand-01"}),a[10]||(a[10]=k(" Format ")),h(r,null,{default:y(()=>a[9]||(a[9]=[k("⌘S")])),_:1})]),_:1}),h(d(Ba),null,{default:y(()=>[h(d(Ha),{"as-child":""},{default:y(()=>[h(i,{variant:"outline",size:"iconSm",class:"rounded-l-none border-l-0 px-2"},{default:y(()=>[h(o,{name:"hugeicons:arrow-down-01",class:"size-4! min-w-4"})]),_:1})]),_:1}),h(d(qa),{align:"end",class:"min-w-44"},{default:y(()=>[h(d(Ea),{class:"py-0"},{default:y(()=>a[11]||(a[11]=[k("Format Options ")])),_:1}),h(d(Na)),h(d(Vt),{onClick:a[1]||(a[1]=l=>e.$emit("onFormatCurrentStatement")),class:"h-6 cursor-pointer"},{default:y(()=>[a[13]||(a[13]=k(" Current Statement ")),h(r,null,{default:y(()=>a[12]||(a[12]=[k("⌘S")])),_:1})]),_:1}),h(d(Vt),{onClick:a[2]||(a[2]=l=>e.$emit("onFormatAll")),class:"h-6 cursor-pointer"},{default:y(()=>[a[15]||(a[15]=k(" All Statement ")),h(r,null,{default:y(()=>a[14]||(a[14]=[k("⇧⌥F")])),_:1})]),_:1})]),_:1})]),_:1})])]),_:1}),h(d(Ve),null,{default:y(()=>a[16]||(a[16]=[S("p",null,"Format current statement (⌘S)",-1)])),_:1})]),_:1})):K("",!0),e.isExplainSupported?(C(),F(d(Pe),{key:1},{default:y(()=>[h(d(Oe),null,{default:y(()=>[S("div",Xl,[h(i,{onClick:a[3]||(a[3]=l=>e.$emit("onExplainAnalyzeCurrent")),variant:"outline",size:"xxs",class:"rounded-r-none"},{default:y(()=>[h(o,{name:"hugeicons:analytics-up"}),a[18]||(a[18]=k(" Explain ")),h(r,null,{default:y(()=>a[17]||(a[17]=[k("⌘E")])),_:1})]),_:1}),h(d(Ba),{open:d(t),"onUpdate:open":a[6]||(a[6]=l=>_e(t)?t.value=l:null)},{default:y(()=>[h(d(Ha),{"as-child":""},{default:y(()=>[h(i,{variant:"outline",size:"iconSm",class:"rounded-l-none border-l-0 px-2"},{default:y(()=>[h(o,{name:"hugeicons:arrow-down-01",class:"size-4! min-w-4"})]),_:1})]),_:1}),h(d(qa),{align:"end",class:"min-w-52"},{default:y(()=>[h(d(Ea),{class:"py-0"},{default:y(()=>a[19]||(a[19]=[k("Explain Analyze Options")])),_:1}),h(d(Na)),(C(!0),z(ae,null,ue(e.explainAnalyzeOptionItems,l=>(C(),F(d(Ml),{key:l.key,"model-value":l.checked,onSelect:a[4]||(a[4]=sn(()=>{},["prevent"])),"onUpdate:modelValue":c=>e.$emit("toggleExplainOption",l.key),class:"h-6 cursor-pointer"},{default:y(()=>[k(U(l.label),1)]),_:2},1032,["model-value","onUpdate:modelValue"]))),128)),h(d(Na)),h(d(Ea),{class:"py-0"},{default:y(()=>a[20]||(a[20]=[k("Serialize")])),_:1}),h(d(Zr),{"model-value":e.serializeMode,"onUpdate:modelValue":a[5]||(a[5]=l=>e.$emit("update:serializeMode",l))},{default:y(()=>[h(d(Ta),{value:"NONE",class:"h-6 cursor-pointer"},{default:y(()=>a[21]||(a[21]=[k("None")])),_:1}),h(d(Ta),{value:"TEXT",class:"h-6 cursor-pointer"},{default:y(()=>a[22]||(a[22]=[k("Text")])),_:1}),h(d(Ta),{value:"BINARY",class:"h-6 cursor-pointer"},{default:y(()=>a[23]||(a[23]=[k("Binary")])),_:1})]),_:1},8,["model-value"])]),_:1})]),_:1},8,["open"])])]),_:1}),h(d(Ve),null,{default:y(()=>a[24]||(a[24]=[S("p",null,"Run Explain Analyze (⌘E) or open options",-1)])),_:1})]),_:1})):K("",!0),h(d(Pe),null,{default:y(()=>[h(d(Oe),{"as-child":""},{default:y(()=>[e.isStreaming||e.executeLoading?(C(),F(i,{key:0,onClick:a[7]||(a[7]=l=>e.$emit("onCancelQuery")),variant:"outline",size:"xxs"},{default:y(()=>[h(o,{name:"hugeicons:stop",class:"size-4! text-red-500"}),a[25]||(a[25]=k(" Cancel query "))]),_:1})):(C(),F(i,{key:1,onClick:a[8]||(a[8]=l=>e.$emit("onExecuteCurrent")),variant:"outline",size:"xxs"},{default:y(()=>[h(o,{name:"hugeicons:play"}),a[27]||(a[27]=k(" Execute current ")),h(r,null,{default:y(()=>a[26]||(a[26]=[k("⌘↵")])),_:1})]),_:1}))]),_:1}),h(d(Ve),null,{default:y(()=>[e.isStreaming||e.executeLoading?(C(),z("p",Zl,"Cancel query")):(C(),z("p",Jl,"Execute Query (⌘↵)"))]),_:1})]),_:1})])])}}}),Us=se({__name:"VariableEditor",props:{fileVariables:{}},emits:["updateVariables"],setup(n,{emit:t}){const e=t,a=j({line:1,column:1}),s=[Ao(`Please input your json variable
|
|
6
|
+
{
|
|
7
|
+
"key": "value"
|
|
8
|
+
}`),ii(r=>{try{return Io(r,{type:"space",size:2})}catch{return r}}),Mo(),xs(),Ss(Lo())],o=r=>{e("updateVariables",r)};return(r,i)=>(C(),F(Cs,{"onUpdate:modelValue":o,"onUpdate:cursorInfo":i[0]||(i[0]=l=>a.value=l),modelValue:r.fileVariables,extensions:s,disabled:!1,ref:"codeEditorRef"},null,8,["modelValue"]))}}),tu={class:"h-full flex flex-col overflow-y-auto"},au=se({__name:"AddVariableModal",props:{open:{},fileVariables:{}},emits:["update:open","updateVariables"],setup(n,{emit:t}){const e=t,a=async s=>{e("updateVariables",s)};return(s,o)=>(C(),F(d(en),{class:"",open:!!s.open,"onUpdate:open":o[1]||(o[1]=r=>e("update:open",r))},{default:y(()=>[h(d(tn),{class:"w-[60vw] h-[50vh] flex flex-col justify-between min-w-[60vw]"},{default:y(()=>[h(d(an),null,{default:y(()=>[h(d(nn),null,{default:y(()=>o[2]||(o[2]=[k(" Add Variable "),S("a",{class:"underline",href:"https://www.w3schools.com/js/js_json_syntax.asp",target:"_blank"}," (JSON format)",-1)])),_:1})]),_:1}),S("div",tu,[h(Us,{onUpdateVariables:a,fileVariables:s.fileVariables},null,8,["fileVariables"])]),h(d(bs),{class:"mt-2"},{default:y(()=>[h(d(Le),{onClick:o[0]||(o[0]=r=>e("update:open",!1))},{default:y(()=>o[3]||(o[3]=[k(" Save ")])),_:1})]),_:1})]),_:1})]),_:1},8,["open"]))}}),nu=se({__name:"RawQueryConfigModal",props:{open:{}},emits:["update:open"],setup(n,{emit:t}){const e=t;return(a,s)=>(C(),F(d(en),{class:"",open:!!a.open,"onUpdate:open":s[0]||(s[0]=o=>e("update:open",o))},{default:y(()=>[h(d(tn),{class:"w-[50vw] h-[70vh] flex flex-col justify-between min-w-[50vw]"},{default:y(()=>[h(d(an),null,{default:y(()=>[h(d(nn),null,{default:y(()=>s[1]||(s[1]=[k(" Editor configs ")])),_:1})]),_:1}),h(ko)]),_:1})]),_:1},8,["open"]))}}),su={class:"flex items-center justify-between p-1 rounded-md bg-muted"},ou={class:"flex gap-2 items-center"},ru={key:0},iu={key:1},lu=se({__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(n){const t=j(!1),e=j(!1),a=j(!1),s=()=>{t.value=!0},o=()=>{e.value=!0};return(r,i)=>{const l=be,c=Jr,m=Oo,u=$o,p=zo,f=Le;return C(),z(ae,null,[h(au,{onUpdateVariables:i[0]||(i[0]=g=>r.$emit("update:updateFileVariables",g)),"file-variables":r.fileVariables,open:d(t),"onUpdate:open":i[1]||(i[1]=g=>_e(t)?t.value=g:null)},null,8,["file-variables","open"]),h(nu,{open:d(e),"onUpdate:open":i[2]||(i[2]=g=>_e(e)?e.value=g:null)},null,8,["open"]),S("div",su,[S("div",null,[h(p,null,{default:y(()=>[h(u,{class:"gap-0!"},{default:y(()=>[h(m,null,{default:y(()=>[h(c,{class:"flex items-center gap-0.5"},{default:y(()=>{var g,b;return[h(l,{name:(g=r.currentFileInfo)==null?void 0:g.icon},null,8,["name"]),k(" "+U((b=r.currentFileInfo)==null?void 0:b.title),1)]}),_:1})]),_:1})]),_:1})]),_:1})]),S("div",ou,[r.isSupportVariable&&r.codeEditorLayout===d(zt).horizontal?(C(),F(d(Pe),{key:0},{default:y(()=>[h(d(Oe),{"as-child":""},{default:y(()=>[h(f,{onClick:s,variant:"outline",size:"xxs",class:"relative"},{default:y(()=>[d(a)?(C(),F(l,{key:0,name:"lucide:triangle-alert",class:"absolute -top-1 -right-1 text-red-400"})):K("",!0),h(l,{name:"hugeicons:absolute"}),i[5]||(i[5]=k(" Add variables "))]),_:1})]),_:1}),h(d(Ve),null,{default:y(()=>i[6]||(i[6]=[S("p",null,"Add variables",-1)])),_:1})]),_:1})):K("",!0),h(d(Pe),null,{default:y(()=>[h(d(Oe),{"as-child":""},{default:y(()=>[h(ri,{connectionId:r.selectedConnectionId,"onUpdate:connectionId":i[3]||(i[3]=g=>r.$emit("update:connectionId",g)),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}),h(d(Ve),null,{default:y(()=>[r.disableConnectionSwitch?(C(),z("p",ru," Connection switch is locked because the current connection has a strict mode tag ")):(C(),z("p",iu,"Select connection"))]),_:1})]),_:1}),r.isRedisConnection?(C(),F(kr,{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]=g=>r.$emit("update:redisDatabaseIndex",g))},null,8,["databases","database-index"])):K("",!0),h(d(Pe),null,{default:y(()=>[h(d(Oe),{"as-child":""},{default:y(()=>[h(f,{onClick:o,variant:"outline",size:"iconSm"},{default:y(()=>[h(l,{name:"hugeicons:dashboard-square-02"})]),_:1})]),_:1}),h(d(Ve),null,{default:y(()=>i[7]||(i[7]=[S("p",null,"Query Settings",-1)])),_:1})]),_:1})])])],64)}}}),Gt={__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(n,{emit:t}){const e=t,a=n,s=Vo(),o=j([]),r=O(()=>o.value.reduce((I,D)=>(I[~~D.id]=D)&&I,{})),i=O(()=>o.value.length),l=j(null),c=j(!1),m=j({mouseDown:!1,dragging:!1,activeSplitter:null,cursorOffset:0}),u=j({splitter:null,timeoutId:null}),p=O(()=>({[`splitpanes splitpanes--${a.horizontal?"horizontal":"vertical"}`]:!0,"splitpanes--dragging":m.value.dragging})),f=()=>{document.addEventListener("mousemove",v,{passive:!1}),document.addEventListener("mouseup",w),"ontouchstart"in window&&(document.addEventListener("touchmove",v,{passive:!1}),document.addEventListener("touchend",w))},g=()=>{document.removeEventListener("mousemove",v,{passive:!1}),document.removeEventListener("mouseup",w),"ontouchstart"in window&&(document.removeEventListener("touchmove",v,{passive:!1}),document.removeEventListener("touchend",w))},b=(I,D)=>{const H=I.target.closest(".splitpanes__splitter");if(H){const{left:B,top:q}=H.getBoundingClientRect(),{clientX:V,clientY:Q}="ontouchstart"in window&&I.touches?I.touches[0]:I;m.value.cursorOffset=a.horizontal?Q-q:V-B}f(),m.value.mouseDown=!0,m.value.activeSplitter=D},v=I=>{m.value.mouseDown&&(I.preventDefault(),m.value.dragging=!0,requestAnimationFrame(()=>{T(_(I)),he("resize",{event:I},!0)}))},w=I=>{m.value.dragging&&(window.getSelection().removeAllRanges(),he("resized",{event:I},!0)),m.value.mouseDown=!1,m.value.activeSplitter=null,setTimeout(()=>{m.value.dragging=!1,g()},100)},x=(I,D)=>{"ontouchstart"in window&&(I.preventDefault(),u.value.splitter===D?(clearTimeout(u.value.timeoutId),u.value.timeoutId=null,N(I,D),u.value.splitter=null):(u.value.splitter=D,u.value.timeoutId=setTimeout(()=>u.value.splitter=null,500))),m.value.dragging||he("splitter-click",{event:I,index:D},!0)},N=(I,D)=>{if(he("splitter-dblclick",{event:I,index:D},!0),a.maximizePanes){let H=0;o.value=o.value.map((B,q)=>(B.size=q===D?B.max:B.min,q!==D&&(H+=B.min),B)),o.value[D].size-=H,he("pane-maximize",{event:I,index:D,pane:o.value[D]}),he("resized",{event:I,index:D},!0)}},R=(I,D)=>{he("pane-click",{event:I,index:r.value[D].index,pane:r.value[D]})},_=I=>{const D=l.value.getBoundingClientRect(),{clientX:H,clientY:B}="ontouchstart"in window&&I.touches?I.touches[0]:I;return{x:H-(a.horizontal?0:m.value.cursorOffset)-D.left,y:B-(a.horizontal?m.value.cursorOffset:0)-D.top}},E=I=>{I=I[a.horizontal?"y":"x"];const D=l.value[a.horizontal?"clientHeight":"clientWidth"];return a.rtl&&!a.horizontal&&(I=D-I),I*100/D},T=I=>{const D=m.value.activeSplitter;let H={prevPanesSize:$(D),nextPanesSize:P(D),prevReachedMinPanes:0,nextReachedMinPanes:0};const B=0+(a.pushOtherPanes?0:H.prevPanesSize),q=100-(a.pushOtherPanes?0:H.nextPanesSize),V=Math.max(Math.min(E(I),q),B);let Q=[D,D+1],J=o.value[Q[0]]||null,ie=o.value[Q[1]]||null;const Be=J.max<100&&V>=J.max+H.prevPanesSize,rt=ie.max<100&&V<=100-(ie.max+P(D+1));if(Be||rt){Be?(J.size=J.max,ie.size=Math.max(100-J.max-H.prevPanesSize-H.nextPanesSize,0)):(J.size=Math.max(100-ie.max-H.prevPanesSize-P(D+1),0),ie.size=ie.max);return}if(a.pushOtherPanes){const ct=A(H,V);if(!ct)return;({sums:H,panesToResize:Q}=ct),J=o.value[Q[0]]||null,ie=o.value[Q[1]]||null}J!==null&&(J.size=Math.min(Math.max(V-H.prevPanesSize-H.prevReachedMinPanes,J.min),J.max)),ie!==null&&(ie.size=Math.min(Math.max(100-V-H.nextPanesSize-H.nextReachedMinPanes,ie.min),ie.max))},A=(I,D)=>{const H=m.value.activeSplitter,B=[H,H+1];return D<I.prevPanesSize+o.value[B[0]].min&&(B[0]=L(H).index,I.prevReachedMinPanes=0,B[0]<H&&o.value.forEach((q,V)=>{V>B[0]&&V<=H&&(q.size=q.min,I.prevReachedMinPanes+=q.min)}),I.prevPanesSize=$(B[0]),B[0]===void 0)?(I.prevReachedMinPanes=0,o.value[0].size=o.value[0].min,o.value.forEach((q,V)=>{V>0&&V<=H&&(q.size=q.min,I.prevReachedMinPanes+=q.min)}),o.value[B[1]].size=100-I.prevReachedMinPanes-o.value[0].min-I.prevPanesSize-I.nextPanesSize,null):D>100-I.nextPanesSize-o.value[B[1]].min&&(B[1]=M(H).index,I.nextReachedMinPanes=0,B[1]>H+1&&o.value.forEach((q,V)=>{V>H&&V<B[1]&&(q.size=q.min,I.nextReachedMinPanes+=q.min)}),I.nextPanesSize=P(B[1]-1),B[1]===void 0)?(I.nextReachedMinPanes=0,o.value.forEach((q,V)=>{V<i.value-1&&V>=H+1&&(q.size=q.min,I.nextReachedMinPanes+=q.min)}),o.value[B[0]].size=100-I.prevPanesSize-P(B[0]-1),null):{sums:I,panesToResize:B}},$=I=>o.value.reduce((D,H,B)=>D+(B<I?H.size:0),0),P=I=>o.value.reduce((D,H,B)=>D+(B>I+1?H.size:0),0),L=I=>[...o.value].reverse().find(D=>D.index<I&&D.size>D.min)||{},M=I=>o.value.find(D=>D.index>I+1&&D.size>D.min)||{},W=()=>{var I;const D=Array.from(((I=l.value)==null?void 0:I.children)||[]);for(const H of D){const B=H.classList.contains("splitpanes__pane"),q=H.classList.contains("splitpanes__splitter");!B&&!q&&(H.remove(),console.warn("Splitpanes: Only <pane> elements are allowed at the root of <splitpanes>. One of your DOM nodes was removed."))}},Z=(I,D,H=!1)=>{const B=I-1,q=document.createElement("div");q.classList.add("splitpanes__splitter"),H||(q.onmousedown=V=>b(V,B),typeof window<"u"&&"ontouchstart"in window&&(q.ontouchstart=V=>b(V,B)),q.onclick=V=>x(V,B+1)),q.ondblclick=V=>N(V,B+1),D.parentNode.insertBefore(q,D)},oe=I=>{I.onmousedown=void 0,I.onclick=void 0,I.ondblclick=void 0,I.remove()},le=()=>{var I;const D=Array.from(((I=l.value)==null?void 0:I.children)||[]);for(const B of D)B.className.includes("splitpanes__splitter")&&oe(B);let H=0;for(const B of D)B.className.includes("splitpanes__pane")&&(!H&&a.firstSplitter?Z(H,B,!0):H&&Z(H,B),H++)},de=({uid:I,...D})=>{const H=r.value[I];for(const[B,q]of Object.entries(D))H[B]=q},me=I=>{var D;let H=-1;Array.from(((D=l.value)==null?void 0:D.children)||[]).some(B=>(B.className.includes("splitpanes__pane")&&H++,B.isSameNode(I.el))),o.value.splice(H,0,{...I,index:H}),o.value.forEach((B,q)=>B.index=q),c.value&&Rt(()=>{le(),ze({addedPane:o.value[H]}),he("pane-add",{pane:o.value[H]})})},Fe=I=>{const D=o.value.findIndex(B=>B.id===I);o.value[D].el=null;const H=o.value.splice(D,1)[0];o.value.forEach((B,q)=>B.index=q),Rt(()=>{le(),he("pane-remove",{pane:H}),ze({removedPane:{...H}})})},ze=(I={})=>{!I.addedPane&&!I.removedPane?Ce():o.value.some(D=>D.givenSize!==null||D.min||D.max<100)?Je(I):ut(),c.value&&he("resized")},ut=()=>{const I=100/i.value;let D=0;const H=[],B=[];for(const q of o.value)q.size=Math.max(Math.min(I,q.max),q.min),D-=q.size,q.size>=q.max&&H.push(q.id),q.size<=q.min&&B.push(q.id);D>.1&&Ge(D,H,B)},Ce=()=>{let I=100;const D=[],H=[];let B=0;for(const V of o.value)I-=V.size,V.givenSize!==null&&B++,V.size>=V.max&&D.push(V.id),V.size<=V.min&&H.push(V.id);let q=100;if(I>.1){for(const V of o.value)V.givenSize===null&&(V.size=Math.max(Math.min(I/(i.value-B),V.max),V.min)),q-=V.size;q>.1&&Ge(q,D,H)}},Je=({addedPane:I,removedPane:D}={})=>{let H=100/i.value,B=0;const q=[],V=[];((I==null?void 0:I.givenSize)??null)!==null&&(H=(100-I.givenSize)/(i.value-1));for(const Q of o.value)B-=Q.size,Q.size>=Q.max&&q.push(Q.id),Q.size<=Q.min&&V.push(Q.id);if(!(Math.abs(B)<.1)){for(const Q of o.value)(I==null?void 0:I.givenSize)!==null&&(I==null?void 0:I.id)===Q.id||(Q.size=Math.max(Math.min(H,Q.max),Q.min)),B-=Q.size,Q.size>=Q.max&&q.push(Q.id),Q.size<=Q.min&&V.push(Q.id);B>.1&&Ge(B,q,V)}},Ge=(I,D,H)=>{let B;I>0?B=I/(i.value-D.length):B=I/(i.value-H.length),o.value.forEach((q,V)=>{if(I>0&&!D.includes(q.id)){const Q=Math.max(Math.min(q.size+B,q.max),q.min),J=Q-q.size;I-=J,q.size=Q}else if(!H.includes(q.id)){const Q=Math.max(Math.min(q.size+B,q.max),q.min),J=Q-q.size;I-=J,q.size=Q}}),Math.abs(I)>.1&&Rt(()=>{c.value&&console.warn("Splitpanes: Could not resize panes correctly due to their constraints.")})},he=(I,D=void 0,H=!1)=>{const B=(D==null?void 0:D.index)??m.value.activeSplitter??null;e(I,{...D,...B!==null&&{index:B},...H&&B!==null&&{prevPane:o.value[B-(a.firstSplitter?1:0)],nextPane:o.value[B+(a.firstSplitter?0:1)]},panes:o.value.map(q=>({min:q.min,max:q.max,size:q.size}))})};ce(()=>a.firstSplitter,()=>le()),ha(()=>{W(),le(),ze(),he("ready"),c.value=!0}),on(()=>c.value=!1);const ot=()=>{var I;return Fo("div",{ref:l,class:p.value},(I=s.default)==null?void 0:I.call(s))};return dt("panes",o),dt("indexedPanes",r),dt("horizontal",O(()=>a.horizontal)),dt("requestUpdate",de),dt("onPaneAdd",me),dt("onPaneRemove",Fe),dt("onPaneClick",R),(I,D)=>(C(),F(Po(ot)))}},mt={__name:"pane",props:{size:{type:[Number,String]},minSize:{type:[Number,String],default:0},maxSize:{type:[Number,String],default:100}},setup(n){var t;const e=n,a=pt("requestUpdate"),s=pt("onPaneAdd"),o=pt("horizontal"),r=pt("onPaneRemove"),i=pt("onPaneClick"),l=(t=Do())==null?void 0:t.uid,c=pt("indexedPanes"),m=O(()=>c.value[l]),u=j(null),p=O(()=>{const v=isNaN(e.size)||e.size===void 0?0:parseFloat(e.size);return Math.max(Math.min(v,g.value),f.value)}),f=O(()=>{const v=parseFloat(e.minSize);return isNaN(v)?0:v}),g=O(()=>{const v=parseFloat(e.maxSize);return isNaN(v)?100:v}),b=O(()=>{var v;return`${o.value?"height":"width"}: ${(v=m.value)==null?void 0:v.size}%`});return ce(()=>p.value,v=>a({uid:l,size:v})),ce(()=>f.value,v=>a({uid:l,min:v})),ce(()=>g.value,v=>a({uid:l,max:v})),ha(()=>{s({id:l,el:u.value,min:f.value,max:g.value,givenSize:e.size===void 0?null:p.value,size:p.value})}),on(()=>r(l)),(v,w)=>(C(),z("div",{ref_key:"paneEl",ref:u,class:"splitpanes__pane",onClick:w[0]||(w[0]=x=>d(i)(x,v._.uid)),style:Ct(b.value)},[Ke(v.$slots,"default")],4))}},uu={class:"w-full h-full"},cu={class:"flex flex-col w-full h-full overflow-y-auto"},du={class:"flex flex-col flex-1 h-full p-1"},mu={class:"flex flex-col flex-1 h-full p-1 pl-0 relative"},pu=se({__name:"RawQueryLayout",props:{layout:{},customLayout:{},showResultPanel:{type:Boolean}},setup(n){const t=n,e=ws(),{editorLayoutSizes:a,editorLayoutInnerVariableSizes:s}=ga(e),o=_=>{a.value=[_[0].size,_[1].size]},r=_=>{s.value=[_[0].size,_[1].size]},i=O(()=>a.value[0]),l=O(()=>s.value[0]),c=O(()=>s.value[1]),m=O(()=>a.value[1]),u=O(()=>t.layout===zt.horizontalWithVariables||t.layout===zt.vertical),p=O(()=>t.layout===zt.horizontalWithVariables),f=O(()=>!!t.customLayout),g=O(()=>{var _;return((_=t.customLayout)==null?void 0:_.direction)==="vertical"}),b=O(()=>{var _,E;return((E=(_=t.customLayout)==null?void 0:_.innerSplit)==null?void 0:E.direction)==="vertical"}),v=_=>{var A,$,P,L,M;const E=(A=t.customLayout)==null?void 0:A.id;if(!E)return((P=($=t.customLayout)==null?void 0:$.panels[_])==null?void 0:P.defaultSize)??50;const T=e.customLayoutSizes[E];return(T==null?void 0:T.panels[_])??((M=(L=t.customLayout)==null?void 0:L.panels[_])==null?void 0:M.defaultSize)??50},w=_=>{var A,$,P,L,M,W,Z;const E=(A=t.customLayout)==null?void 0:A.id;if(!E)return((L=(P=($=t.customLayout)==null?void 0:$.innerSplit)==null?void 0:P.panels[_])==null?void 0:L.defaultSize)??50;const T=e.customLayoutSizes[E];return(T==null?void 0:T.innerPanels[_])??((Z=(W=(M=t.customLayout)==null?void 0:M.innerSplit)==null?void 0:W.panels[_])==null?void 0:Z.defaultSize)??50},x=_=>{var T;const E=(T=t.customLayout)==null?void 0:T.id;E&&e.updateCustomLayoutSizes(E,_.map(A=>A.size))},N=_=>{var A,$,P;const E=(A=t.customLayout)==null?void 0:A.id;if(!E)return;const T=(($=e.customLayoutSizes[E])==null?void 0:$.panels)??((P=t.customLayout)==null?void 0:P.panels.map(L=>L.defaultSize))??[];e.updateCustomLayoutSizes(E,T,_.map(L=>L.size))},R={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(_,E)=>(C(),z("div",uu,[d(f)&&_.customLayout?(C(),F(d(Gt),{key:0,class:"default-theme",horizontal:d(g),onResize:E[1]||(E[1]=T=>x(T.panes))},{default:y(()=>[(C(!0),z(ae,null,ue(_.customLayout.panels,(T,A)=>(C(),z(ae,{key:A},[_.customLayout.innerSplit&&_.customLayout.innerSplit.panelIndex===A?(C(),F(d(mt),{key:0,size:v(A),"min-size":T.minSize,"max-size":T.maxSize},{default:y(()=>[h(d(Gt),{horizontal:d(b),class:"default-theme",onResize:E[0]||(E[0]=$=>N($.panes))},{default:y(()=>[(C(!0),z(ae,null,ue(_.customLayout.innerSplit.panels,($,P)=>(C(),F(d(mt),{key:`inner-${P}`,size:w(P),"min-size":$.minSize,"max-size":$.maxSize},{default:y(()=>[S("div",{class:ye(R[$.slot])},[Ke(_.$slots,$.slot)],2)]),_:2},1032,["size","min-size","max-size"]))),128))]),_:3},8,["horizontal"])]),_:2},1032,["size","min-size","max-size"])):(C(),F(d(mt),{key:1,size:v(A),"min-size":T.minSize,"max-size":T.maxSize},{default:y(()=>[S("div",{class:ye(R[T.slot])},[Ke(_.$slots,T.slot)],2)]),_:2},1032,["size","min-size","max-size"]))],64))),128))]),_:3},8,["horizontal"])):(C(),F(d(Gt),{key:1,onResize:E[3]||(E[3]=T=>o(T.panes)),class:"default-theme",horizontal:_.layout===d(zt).vertical},{default:y(()=>[h(d(mt),{size:d(i)},{default:y(()=>[h(d(Gt),{horizontal:d(p),onResize:E[2]||(E[2]=T=>d(u)?r(T.panes):null)},{default:y(()=>[h(d(mt),{size:d(u)?d(l):100,"min-size":"30"},{default:y(()=>[S("div",cu,[Ke(_.$slots,"content")])]),_:3},8,["size"]),d(u)?(C(),F(d(mt),{key:0,size:d(c),"min-size":"0","max-size":"70"},{default:y(()=>[S("div",du,[Ke(_.$slots,"variables")])]),_:3},8,["size"])):K("",!0)]),_:3},8,["horizontal"])]),_:3},8,["size"]),t.showResultPanel!==!1?(C(),F(d(mt),{key:0,size:d(m),"min-size":"0","max-size":"80"},{default:y(()=>[S("div",mu,[Ke(_.$slots,"result")])]),_:3},8,["size"])):K("",!0)]),_:3},8,["horizontal"]))]))}});var ee=(n=>(n.RESULT="result",n.ERROR="error",n.INFO="info",n.RAW="raw",n.EXPLAIN="explain",n.CHART="chart",n))(ee||{}),G=(n=>(n.LINE="line",n.BAR="bar",n.HORIZONTAL_BAR="horizontal-bar",n.AREA="area",n.STACKED_BAR="stacked-bar",n.PIE="pie",n.DONUT="donut",n.SCATTER="scatter",n.HEATMAP="heatmap",n.RADAR="radar",n))(G||{}),ne=(n=>(n.NONE="none",n.SUM="sum",n.AVG="avg",n.COUNT="count",n.MIN="min",n.MAX="max",n))(ne||{}),ve=(n=>(n.NONE="none",n.X_ASC="x-asc",n.X_DESC="x-desc",n.Y_ASC="y-asc",n.Y_DESC="y-desc",n))(ve||{}),Re=(n=>(n.COMPARISON="comparison",n.COMPOSITION="composition",n.DISTRIBUTION="distribution",n.RELATIONSHIP="relationship",n.SPATIAL="spatial",n))(Re||{});G.LINE,G.BAR,G.HORIZONTAL_BAR,G.AREA,G.STACKED_BAR,G.PIE,G.DONUT,G.SCATTER,G.HEATMAP,G.RADAR;const wt={xAxisLabel:!1,xAxisNumeric:!1,yAxis:!1,yAxisHiddenOnCount:!1,categoryX:!1,categoryY:!1,valueColumn:!1,aggregation:!1,groupBy:!1,groupByRequired:!1,sortBy:!1,limitRows:!1,smoothLine:!1,showLabels:!1,showLegend:!1},It={...wt,xAxisLabel:!0,yAxis:!0,aggregation:!0,groupBy:!0,sortBy:!0,limitRows:!0,showLabels:!0,showLegend:!0},$e=new Map([[G.LINE,{value:G.LINE,label:"Line",icon:"hugeicons:chart-line-data-01",category:Re.COMPARISON,description:"Show trends over time or ordered categories",fields:{...It,smoothLine:!0}}],[G.BAR,{value:G.BAR,label:"Bar",icon:"hugeicons:chart-column",category:Re.COMPARISON,description:"Compare values across categories",fields:{...It}}],[G.HORIZONTAL_BAR,{value:G.HORIZONTAL_BAR,label:"Horizontal Bar",icon:"hugeicons:chart-histogram",category:Re.COMPARISON,description:"Compare values with long category labels",fields:{...It}}],[G.AREA,{value:G.AREA,label:"Area",icon:"hugeicons:chart-area",category:Re.COMPARISON,description:"Show volume and trends over time",fields:{...It,smoothLine:!0}}],[G.STACKED_BAR,{value:G.STACKED_BAR,label:"Stacked Bar",icon:"hugeicons:chart-histogram",category:Re.COMPOSITION,description:"Show part-to-whole across categories",fields:{...It,groupByRequired:!0}}],[G.PIE,{value:G.PIE,label:"Pie",icon:"hugeicons:pie-chart",category:Re.COMPOSITION,description:"Show proportions of a whole",fields:{...wt,xAxisLabel:!0,yAxis:!0,yAxisHiddenOnCount:!0,aggregation:!0,sortBy:!0,limitRows:!0,showLabels:!0,showLegend:!0}}],[G.DONUT,{value:G.DONUT,label:"Donut",icon:"hugeicons:circle",category:Re.COMPOSITION,description:"Show proportions with center metric",fields:{...wt,xAxisLabel:!0,yAxis:!0,yAxisHiddenOnCount:!0,aggregation:!0,sortBy:!0,limitRows:!0,showLabels:!0,showLegend:!0}}],[G.SCATTER,{value:G.SCATTER,label:"Scatter",icon:"hugeicons:chart-scatter",category:Re.RELATIONSHIP,description:"Discover correlations between two numeric fields",fields:{...wt,xAxisNumeric:!0,yAxis:!0,limitRows:!0,showLabels:!0}}],[G.HEATMAP,{value:G.HEATMAP,label:"Heatmap",icon:"hugeicons:grid",category:Re.SPATIAL,description:"Visualise density across two category dimensions",fields:{...wt,categoryX:!0,categoryY:!0,valueColumn:!0,showLabels:!0}}],[G.RADAR,{value:G.RADAR,label:"Radar",icon:"hugeicons:chart-relationship",category:Re.COMPARISON,description:"Compare multiple metrics on a radial grid",fields:{...wt,xAxisLabel:!0,yAxis:!0,aggregation:!0,limitRows:!0,showLabels:!0}}]]),fu=[{category:Re.COMPARISON,label:"Comparison",types:[$e.get(G.LINE),$e.get(G.BAR),$e.get(G.HORIZONTAL_BAR),$e.get(G.AREA),$e.get(G.RADAR)]},{category:Re.COMPOSITION,label:"Composition",types:[$e.get(G.STACKED_BAR),$e.get(G.PIE),$e.get(G.DONUT)]},{category:Re.RELATIONSHIP,label:"Relationship",types:[$e.get(G.SCATTER)]},{category:Re.SPATIAL,label:"Spatial",types:[$e.get(G.HEATMAP)]}],vu={class:"flex items-center gap-2"},hu={class:"text-[10px] text-muted-foreground/50 ml-auto"},gu=se({__name:"ChartTypeSelector",props:{modelValue:{required:!0},modelModifiers:{}},emits:["update:modelValue"],setup(n){const t=Me(n,"modelValue");return(e,a)=>{const s=be;return C(),F(d(We),{modelValue:t.value,"onUpdate:modelValue":a[0]||(a[0]=o=>t.value=o),size:"xs"},{default:y(()=>[h(d(je),{class:"w-full cursor-pointer"},{default:y(()=>[h(d(Qe),{placeholder:"Select Chart Type"})]),_:1}),h(d(Ye),{class:"max-h-72"},{default:y(()=>[(C(!0),z(ae,null,ue(d(fu),o=>(C(),F(d(Bo),{key:o.category},{default:y(()=>[h(d(Ho),{class:"text-[10px] uppercase tracking-wider text-muted-foreground/60"},{default:y(()=>[k(U(o.label),1)]),_:2},1024),(C(!0),z(ae,null,ue(o.types,r=>(C(),F(d(fe),{key:r.value,value:r.value,class:"cursor-pointer"},{default:y(()=>[S("div",vu,[h(s,{name:r.icon,class:"size-3.5"},null,8,["name"]),S("span",null,U(r.label),1),S("span",hu,U(r.description),1)])]),_:2},1032,["value"]))),128))]),_:2},1024))),128))]),_:1})]),_:1},8,["modelValue"])}}}),yu={class:"w-80 border-l border-border flex h-full shrink-0 flex-col overflow-y-auto bg-background"},bu={class:"flex items-center justify-between border-b border-border px-3 py-2.5"},xu={class:"flex items-center gap-2"},Su={class:"flex items-center gap-1.5"},Cu={class:"flex-1 space-y-3 p-3"},wu={class:"space-y-2"},_u={class:"space-y-1.5"},Ru={class:"space-y-1.5"},Tu={key:0,class:"space-y-2"},Eu={key:0,class:"space-y-1.5"},Nu={key:1,class:"space-y-1.5"},Au={key:2,class:"space-y-1.5"},Mu={key:3,class:"space-y-1.5"},Iu={key:4,class:"space-y-1.5"},Lu={key:5,class:"space-y-1.5"},ku={key:1,class:"space-y-2"},zu={key:0,class:"space-y-1.5"},$u={key:1,class:"space-y-1.5"},Ou={class:"text-xs font-medium text-muted-foreground"},Vu={key:0,class:"text-amber-500 text-xs ml-1"},Pu={key:2,class:"space-y-1.5"},Du={key:3,class:"space-y-1.5"},Fu={key:2,class:"space-y-2"},Bu={key:0,class:"flex items-center justify-between"},Hu={key:1,class:"flex items-center justify-between"},qu=se({__name:"ChartSettingsSidebar",props:ia({activeTabColumns:{}},{chartTitle:{required:!0},chartTitleModifiers:{},chartType:{required:!0},chartTypeModifiers:{},xAxisField:{required:!0},xAxisFieldModifiers:{},yAxisField:{required:!0},yAxisFieldModifiers:{},valueField:{required:!0},valueFieldModifiers:{},categoryYField:{required:!0},categoryYFieldModifiers:{},aggregation:{required:!0},aggregationModifiers:{},groupByField:{required:!0},groupByFieldModifiers:{},sortBy:{required:!0},sortByModifiers:{},limitRows:{required:!0},limitRowsModifiers:{},showLabels:{type:Boolean,required:!0},showLabelsModifiers:{},smoothLine:{type:Boolean,required:!0},smoothLineModifiers:{}}),emits:ia(["reset","export"],["update:chartTitle","update:chartType","update:xAxisField","update:yAxisField","update:valueField","update:categoryYField","update:aggregation","update:groupByField","update:sortBy","update:limitRows","update:showLabels","update:smoothLine"]),setup(n){const t=Me(n,"chartTitle"),e=Me(n,"chartType"),a=Me(n,"xAxisField"),s=Me(n,"yAxisField"),o=Me(n,"valueField"),r=Me(n,"categoryYField"),i=Me(n,"aggregation"),l=Me(n,"groupByField"),c=Me(n,"sortBy"),m=Me(n,"limitRows"),u=Me(n,"showLabels"),p=Me(n,"smoothLine"),f=O(()=>{const b=$e.get(e.value);return(b==null?void 0:b.fields)??null}),g=O(()=>{var b;return!(!((b=f.value)!=null&&b.yAxis)||f.value.yAxisHiddenOnCount&&i.value===ne.COUNT)});return(b,v)=>{const w=be;return C(),z("div",yu,[S("div",bu,[S("div",xu,[h(w,{name:"hugeicons:chart-column",class:"size-4! text-muted-foreground"}),v[16]||(v[16]=S("span",{class:"text-sm font-medium"},"Chart Settings",-1))]),S("div",Su,[a.value?(C(),F(d(Le),{key:0,variant:"ghost",size:"iconSm",onClick:v[0]||(v[0]=x=>b.$emit("export")),title:"Export chart as image"},{default:y(()=>[h(w,{name:"hugeicons:download-04",class:"size-4!"})]),_:1})):K("",!0),h(d(Le),{variant:"ghost",size:"iconSm",onClick:v[1]||(v[1]=x=>b.$emit("reset")),title:"Reset configuration"},{default:y(()=>[h(w,{name:"hugeicons:reload",class:"size-4!"})]),_:1})])]),S("div",Cu,[S("div",wu,[S("div",_u,[v[17]||(v[17]=S("p",{class:"text-xs font-medium text-muted-foreground"},"Chart Title",-1)),h(d(xn),{modelValue:t.value,"onUpdate:modelValue":v[2]||(v[2]=x=>t.value=x),size:"sm",type:"text",placeholder:"Chart Title"},null,8,["modelValue"])]),S("div",Ru,[v[18]||(v[18]=S("p",{class:"text-xs font-medium text-muted-foreground"},"Chart Type",-1)),h(gu,{modelValue:e.value,"onUpdate:modelValue":v[3]||(v[3]=x=>e.value=x)},null,8,["modelValue"])])]),f.value?(C(),z("div",Tu,[v[25]||(v[25]=S("p",{class:"text-sm font-medium"},"Data Mapping",-1)),f.value.xAxisLabel?(C(),z("div",Eu,[v[19]||(v[19]=S("p",{class:"text-xs font-medium text-muted-foreground"}," X-Axis (Label) ",-1)),h(d(We),{modelValue:a.value,"onUpdate:modelValue":v[4]||(v[4]=x=>a.value=x),size:"xs"},{default:y(()=>[h(d(je),{class:"w-full cursor-pointer"},{default:y(()=>[h(d(Qe),{placeholder:"Select X-Axis Column"})]),_:1}),h(d(Ye),{class:"max-h-60"},{default:y(()=>[(C(!0),z(ae,null,ue(b.activeTabColumns,x=>(C(),F(d(fe),{key:x.aliasFieldName,value:x.aliasFieldName,class:"cursor-pointer"},{default:y(()=>[k(U(x.aliasFieldName),1)]),_:2},1032,["value"]))),128))]),_:1})]),_:1},8,["modelValue"])])):K("",!0),f.value.xAxisNumeric?(C(),z("div",Nu,[v[20]||(v[20]=S("p",{class:"text-xs font-medium text-muted-foreground"}," X-Axis (Numeric) ",-1)),h(d(We),{modelValue:a.value,"onUpdate:modelValue":v[5]||(v[5]=x=>a.value=x),size:"xs"},{default:y(()=>[h(d(je),{class:"w-full cursor-pointer"},{default:y(()=>[h(d(Qe),{placeholder:"Select X-Axis Column"})]),_:1}),h(d(Ye),{class:"max-h-60"},{default:y(()=>[(C(!0),z(ae,null,ue(b.activeTabColumns,x=>(C(),F(d(fe),{key:x.aliasFieldName,value:x.aliasFieldName,class:"cursor-pointer"},{default:y(()=>[k(U(x.aliasFieldName),1)]),_:2},1032,["value"]))),128))]),_:1})]),_:1},8,["modelValue"])])):K("",!0),g.value?(C(),z("div",Au,[v[21]||(v[21]=S("p",{class:"text-xs font-medium text-muted-foreground"}," Y-Axis (Values) ",-1)),h(d(We),{modelValue:s.value,"onUpdate:modelValue":v[6]||(v[6]=x=>s.value=x),size:"xs"},{default:y(()=>[h(d(je),{class:"w-full cursor-pointer"},{default:y(()=>[h(d(Qe),{placeholder:"Select Y-Axis Column"})]),_:1}),h(d(Ye),{class:"max-h-60"},{default:y(()=>[(C(!0),z(ae,null,ue(b.activeTabColumns,x=>(C(),F(d(fe),{key:x.aliasFieldName,value:x.aliasFieldName,class:"cursor-pointer"},{default:y(()=>[k(U(x.aliasFieldName),1)]),_:2},1032,["value"]))),128))]),_:1})]),_:1},8,["modelValue"])])):K("",!0),f.value.categoryX?(C(),z("div",Mu,[v[22]||(v[22]=S("p",{class:"text-xs font-medium text-muted-foreground"}," Category X (Columns) ",-1)),h(d(We),{modelValue:a.value,"onUpdate:modelValue":v[7]||(v[7]=x=>a.value=x),size:"xs"},{default:y(()=>[h(d(je),{class:"w-full cursor-pointer"},{default:y(()=>[h(d(Qe),{placeholder:"Select X Category Column"})]),_:1}),h(d(Ye),{class:"max-h-60"},{default:y(()=>[(C(!0),z(ae,null,ue(b.activeTabColumns,x=>(C(),F(d(fe),{key:x.aliasFieldName,value:x.aliasFieldName,class:"cursor-pointer"},{default:y(()=>[k(U(x.aliasFieldName),1)]),_:2},1032,["value"]))),128))]),_:1})]),_:1},8,["modelValue"])])):K("",!0),f.value.categoryY?(C(),z("div",Iu,[v[23]||(v[23]=S("p",{class:"text-xs font-medium text-muted-foreground"}," Category Y (Rows) ",-1)),h(d(We),{modelValue:r.value,"onUpdate:modelValue":v[8]||(v[8]=x=>r.value=x),size:"xs"},{default:y(()=>[h(d(je),{class:"w-full cursor-pointer"},{default:y(()=>[h(d(Qe),{placeholder:"Select Y Category Column"})]),_:1}),h(d(Ye),{class:"max-h-60"},{default:y(()=>[(C(!0),z(ae,null,ue(b.activeTabColumns,x=>(C(),F(d(fe),{key:x.aliasFieldName,value:x.aliasFieldName,class:"cursor-pointer"},{default:y(()=>[k(U(x.aliasFieldName),1)]),_:2},1032,["value"]))),128))]),_:1})]),_:1},8,["modelValue"])])):K("",!0),f.value.valueColumn?(C(),z("div",Lu,[v[24]||(v[24]=S("p",{class:"text-xs font-medium text-muted-foreground"}," Value Column (Numeric) ",-1)),h(d(We),{modelValue:o.value,"onUpdate:modelValue":v[9]||(v[9]=x=>o.value=x),size:"xs"},{default:y(()=>[h(d(je),{class:"w-full cursor-pointer"},{default:y(()=>[h(d(Qe),{placeholder:"Select Value Column"})]),_:1}),h(d(Ye),{class:"max-h-60"},{default:y(()=>[(C(!0),z(ae,null,ue(b.activeTabColumns,x=>(C(),F(d(fe),{key:x.aliasFieldName,value:x.aliasFieldName,class:"cursor-pointer"},{default:y(()=>[k(U(x.aliasFieldName),1)]),_:2},1032,["value"]))),128))]),_:1})]),_:1},8,["modelValue"])])):K("",!0)])):K("",!0),f.value?(C(),z("div",ku,[v[42]||(v[42]=S("p",{class:"text-sm font-medium"},"Transform",-1)),f.value.aggregation?(C(),z("div",zu,[v[32]||(v[32]=S("p",{class:"text-xs font-medium text-muted-foreground"},"Aggregation",-1)),h(d(We),{modelValue:i.value,"onUpdate:modelValue":v[10]||(v[10]=x=>i.value=x),size:"xs"},{default:y(()=>[h(d(je),{class:"w-full cursor-pointer"},{default:y(()=>[h(d(Qe),{placeholder:"Select Aggregation"})]),_:1}),h(d(Ye),null,{default:y(()=>[h(d(fe),{value:d(ne).NONE,class:"cursor-pointer"},{default:y(()=>v[26]||(v[26]=[k("None (Raw Rows)")])),_:1},8,["value"]),h(d(fe),{value:d(ne).SUM,class:"cursor-pointer"},{default:y(()=>v[27]||(v[27]=[k("Sum")])),_:1},8,["value"]),h(d(fe),{value:d(ne).AVG,class:"cursor-pointer"},{default:y(()=>v[28]||(v[28]=[k("Average")])),_:1},8,["value"]),h(d(fe),{value:d(ne).COUNT,class:"cursor-pointer"},{default:y(()=>v[29]||(v[29]=[k("Count")])),_:1},8,["value"]),h(d(fe),{value:d(ne).MIN,class:"cursor-pointer"},{default:y(()=>v[30]||(v[30]=[k("Min")])),_:1},8,["value"]),h(d(fe),{value:d(ne).MAX,class:"cursor-pointer"},{default:y(()=>v[31]||(v[31]=[k("Max")])),_:1},8,["value"])]),_:1})]),_:1},8,["modelValue"])])):K("",!0),f.value.groupBy?(C(),z("div",$u,[S("p",Ou,[v[33]||(v[33]=k(" Group By (Legend) ")),f.value.groupByRequired?(C(),z("span",Vu,"(Required)")):K("",!0)]),h(d(We),{modelValue:l.value,"onUpdate:modelValue":v[11]||(v[11]=x=>l.value=x),size:"xs"},{default:y(()=>[h(d(je),{class:"w-full cursor-pointer"},{default:y(()=>[h(d(Qe),{placeholder:"No Grouping"})]),_:1}),h(d(Ye),{class:"max-h-60"},{default:y(()=>[h(d(fe),{value:"",class:"cursor-pointer"},{default:y(()=>v[34]||(v[34]=[k("No Grouping")])),_:1}),(C(!0),z(ae,null,ue(b.activeTabColumns,x=>(C(),F(d(fe),{key:x.aliasFieldName,value:x.aliasFieldName,class:"cursor-pointer"},{default:y(()=>[k(U(x.aliasFieldName),1)]),_:2},1032,["value"]))),128))]),_:1})]),_:1},8,["modelValue"])])):K("",!0),f.value.sortBy?(C(),z("div",Pu,[v[40]||(v[40]=S("p",{class:"text-xs font-medium text-muted-foreground"},"Sorting",-1)),h(d(We),{modelValue:c.value,"onUpdate:modelValue":v[12]||(v[12]=x=>c.value=x),size:"xs"},{default:y(()=>[h(d(je),{class:"w-full cursor-pointer"},{default:y(()=>[h(d(Qe),{placeholder:"No Sorting"})]),_:1}),h(d(Ye),null,{default:y(()=>[h(d(fe),{value:d(ve).NONE,class:"cursor-pointer"},{default:y(()=>v[35]||(v[35]=[k("No Sorting")])),_:1},8,["value"]),h(d(fe),{value:d(ve).X_ASC,class:"cursor-pointer"},{default:y(()=>v[36]||(v[36]=[k("X-Axis (Ascending)")])),_:1},8,["value"]),h(d(fe),{value:d(ve).X_DESC,class:"cursor-pointer"},{default:y(()=>v[37]||(v[37]=[k("X-Axis (Descending)")])),_:1},8,["value"]),h(d(fe),{value:d(ve).Y_ASC,class:"cursor-pointer"},{default:y(()=>v[38]||(v[38]=[k("Y-Axis (Ascending)")])),_:1},8,["value"]),h(d(fe),{value:d(ve).Y_DESC,class:"cursor-pointer"},{default:y(()=>v[39]||(v[39]=[k("Y-Axis (Descending)")])),_:1},8,["value"])]),_:1})]),_:1},8,["modelValue"])])):K("",!0),f.value.limitRows?(C(),z("div",Du,[v[41]||(v[41]=S("p",{class:"text-xs font-medium text-muted-foreground"},"Limit Rows",-1)),h(d(xn),{"model-value":m.value===null?"":m.value,"onUpdate:modelValue":v[13]||(v[13]=x=>{const N=String(x);m.value=N===""?null:Math.max(1,parseInt(N,10)||1)}),size:"sm",type:"number",min:"1",placeholder:"All"},null,8,["model-value"])])):K("",!0)])):K("",!0),f.value?(C(),z("div",Fu,[v[45]||(v[45]=S("p",{class:"text-sm font-medium"},"Display",-1)),f.value.showLabels?(C(),z("div",Bu,[v[43]||(v[43]=S("div",{class:"flex flex-col gap-0.5"},[S("p",{class:"text-xs font-medium text-muted-foreground"}," Show Value Labels "),S("span",{class:"text-xs text-muted-foreground"},"Render values directly on series")],-1)),h(d(Sn),{modelValue:u.value,"onUpdate:modelValue":v[14]||(v[14]=x=>u.value=x),class:"cursor-pointer"},null,8,["modelValue"])])):K("",!0),f.value.smoothLine?(C(),z("div",Hu,[v[44]||(v[44]=S("div",{class:"flex flex-col gap-0.5"},[S("p",{class:"text-xs font-medium text-muted-foreground"},"Smooth Line"),S("span",{class:"text-xs text-muted-foreground"},"Curved lines instead of straight")],-1)),h(d(Sn),{modelValue:p.value,"onUpdate:modelValue":v[15]||(v[15]=x=>p.value=x),class:"cursor-pointer"},null,8,["modelValue"])])):K("",!0)])):K("",!0)])])}}});function Uu(n){n.eachSeriesByType("radar",function(t){var e=t.getData(),a=[],s=t.coordinateSystem;if(s){var o=s.getIndicatorAxes();X(o,function(r,i){e.each(e.mapDimension(o[i].dim),function(l,c){a[c]=a[c]||[];var m=s.dataToPoint(l,i);a[c][i]=On(m)?m:Vn(s)})}),e.each(function(r){var i=li(a[r],function(l){return On(l)})||Vn(s);a[r].push(i.slice()),e.setItemLayout(r,a[r])})}})}function On(n){return!isNaN(n[0])&&!isNaN(n[1])}function Vn(n){return[n.cx,n.cy]}function Ku(n){var t=n.polar;if(t){ke(t)||(t=[t]);var e=[];X(t,function(a,s){a.indicator?(a.type&&!a.shape&&(a.shape=a.type),n.radar=n.radar||[],ke(n.radar)||(n.radar=[n.radar]),n.radar.push(a)):e.push(a)}),n.polar=e}X(n.series,function(a){a&&a.type==="radar"&&a.polarIndex&&(a.radarIndex=a.polarIndex)})}var Gu=function(n){De(t,n);function t(){var e=n!==null&&n.apply(this,arguments)||this;return e.type=t.type,e}return t.prototype.render=function(e,a,s){var o=e.coordinateSystem,r=this.group,i=e.getData(),l=this._data;function c(p,f){var g=p.getItemVisual(f,"symbol")||"circle";if(g!=="none"){var b=ci(p.getItemVisual(f,"symbolSize")),v=la(g,-1,-1,2,2),w=p.getItemVisual(f,"symbolRotate")||0;return v.attr({style:{strokeNoScale:!0},z2:100,scaleX:b[0]/2,scaleY:b[1]/2,rotation:w*Math.PI/180||0}),v}}function m(p,f,g,b,v,w){g.removeAll();for(var x=0;x<f.length-1;x++){var N=c(b,v);N&&(N.__dimIdx=x,p[x]?(N.setPosition(p[x]),ui[w?"initProps":"updateProps"](N,{x:f[x][0],y:f[x][1]},e,v)):N.setPosition(f[x]),g.add(N))}}function u(p){return qe(p,function(f){return[o.cx,o.cy]})}i.diff(l).add(function(p){var f=i.getItemLayout(p);if(f){var g=new un,b=new Ls,v={shape:{points:f}};g.shape.points=u(f),b.shape.points=u(f),_n(g,v,e,p),_n(b,v,e,p);var w=new Tt,x=new Tt;w.add(b),w.add(g),w.add(x),m(b.shape.points,f,x,i,p,!0),i.setItemGraphicEl(p,w)}}).update(function(p,f){var g=l.getItemGraphicEl(f),b=g.childAt(0),v=g.childAt(1),w=g.childAt(2),x={shape:{points:i.getItemLayout(p)}};x.shape.points&&(m(b.shape.points,x.shape.points,w,i,p,!1),Rn(v),Rn(b),Tn(b,x,e),Tn(v,x,e),i.setItemGraphicEl(p,g))}).remove(function(p){r.remove(l.getItemGraphicEl(p))}).execute(),i.eachItemGraphicEl(function(p,f){var g=i.getItemModel(f),b=p.childAt(0),v=p.childAt(1),w=p.childAt(2),x=i.getItemVisual(f,"style"),N=x.fill;r.add(p),b.useStyle(Et(g.getModel("lineStyle").getLineStyle(),{fill:"none",stroke:N})),En(b,g,"lineStyle"),En(v,g,"areaStyle");var R=g.getModel("areaStyle"),_=R.isEmpty()&&R.parentModel.isEmpty();v.ignore=_,X(["emphasis","select","blur"],function(A){var $=g.getModel([A,"areaStyle"]),P=$.isEmpty()&&$.parentModel.isEmpty();v.ensureState(A).ignore=P&&_}),v.useStyle(Et(R.getAreaStyle(),{fill:N,opacity:.7,decal:x.decal}));var E=g.getModel("emphasis"),T=E.getModel("itemStyle").getItemStyle();w.eachChild(function(A){if(A instanceof cn){var $=A.style;A.useStyle(ks({image:$.image,x:$.x,y:$.y,width:$.width,height:$.height},x))}else A.useStyle(x),A.setColor(N),A.style.strokeNoScale=!0;var P=A.ensureState("emphasis");P.style=He(T);var L=i.getStore().get(i.getDimensionIndex(A.__dimIdx),f);(L==null||isNaN(L))&&(L=""),zs(A,Ua(g),{labelFetcher:i.hostModel,labelDataIndex:f,labelDimIndex:A.__dimIdx,defaultText:L,inheritColor:N,defaultOpacity:x.opacity})}),$s(p,E.get("focus"),E.get("blurScope"),E.get("disabled"))}),this._data=i},t.prototype.remove=function(){this.group.removeAll(),this._data=null},t.type="radar",t}(Os),Wu=function(n){De(t,n);function t(){var e=n!==null&&n.apply(this,arguments)||this;return e.type=t.type,e.hasSymbolVisual=!0,e}return t.prototype.init=function(e){n.prototype.init.apply(this,arguments),this.legendVisualProvider=new Ji(Ie(this.getData,this),Ie(this.getRawData,this))},t.prototype.getInitialData=function(e,a){return el(this,{generateCoord:"indicator_",generateCoordCount:1/0})},t.prototype.formatTooltip=function(e,a,s){var o=this.getData(),r=this.coordinateSystem,i=r.getIndicatorAxes(),l=this.getData().getName(e),c=l===""?this.name:l,m=di(this,e);return Nn("section",{header:c,sortBlocks:!0,blocks:qe(i,function(u){var p=o.get(o.mapDimension(u.dim),e);return Nn("nameValue",{markerType:"subItem",markerColor:m,name:u.name,value:p,sortParam:p})})})},t.prototype.getTooltipPosition=function(e){if(e!=null){for(var a=this.getData(),s=this.coordinateSystem,o=a.getValues(qe(s.dimensions,function(c){return a.mapDimension(c)}),e),r=0,i=o.length;r<i;r++)if(!isNaN(o[r])){var l=s.getIndicatorAxes();return s.coordToPoint(l[r].dataToCoord(o[r]),r)}}},t.type="series.radar",t.dependencies=["radar"],t.defaultOption={z:2,colorBy:"data",coordinateSystem:"radar",legendHoverLink:!0,radarIndex:0,lineStyle:{width:2,type:"solid",join:"round"},label:{position:"top"},symbolSize:8},t}(Vs),Lt=vi.value;function Wt(n,t){return Et({show:t},n)}var ju=function(n){De(t,n);function t(){var e=n!==null&&n.apply(this,arguments)||this;return e.type=t.type,e}return t.prototype.optionUpdated=function(){var e=this.get("boundaryGap"),a=this.get("splitNumber"),s=this.get("scale"),o=this.get("axisLine"),r=this.get("axisTick"),i=this.get("axisLabel"),l=this.get("axisName"),c=this.get(["axisName","show"]),m=this.get(["axisName","formatter"]),u=this.get("axisNameGap"),p=this.get("triggerEvent"),f=qe(this.get("indicator")||[],function(g){g.max!=null&&g.max>0&&!g.min?g.min=0:g.min!=null&&g.min<0&&!g.max&&(g.max=0);var b=l;g.color!=null&&(b=Et({color:g.color},l));var v=ua(He(g),{boundaryGap:e,splitNumber:a,scale:s,axisLine:o,axisTick:r,axisLabel:i,name:g.text,showName:c,nameLocation:"end",nameGap:u,nameTextStyle:b,triggerEvent:p},!1);if(ba(m)){var w=v.name;v.name=m.replace("{value}",w??"")}else Ps(m)&&(v.name=m(v.name,v));var x=new mi(v,null,this.ecModel);return pi(x,fi.prototype),x.mainType="radar",x.componentIndex=this.componentIndex,x},this);this._indicatorModels=f},t.prototype.getIndicatorModels=function(){return this._indicatorModels},t.type="radar",t.defaultOption={z:0,center:["50%","50%"],radius:"75%",startAngle:90,axisName:{show:!0},boundaryGap:[0,0],splitNumber:5,axisNameGap:15,scale:!1,shape:"polygon",axisLine:ua({lineStyle:{color:"#bbb"}},Lt.axisLine),axisLabel:Wt(Lt.axisLabel,!1),axisTick:Wt(Lt.axisTick,!1),splitLine:Wt(Lt.splitLine,!0),splitArea:Wt(Lt.splitArea,!0),indicator:[]},t}(Ds),Qu=["axisLine","axisTickLabel","axisName"],Yu=function(n){De(t,n);function t(){var e=n!==null&&n.apply(this,arguments)||this;return e.type=t.type,e}return t.prototype.render=function(e,a,s){var o=this.group;o.removeAll(),this._buildAxes(e),this._buildSplitLineAndArea(e)},t.prototype._buildAxes=function(e){var a=e.coordinateSystem,s=a.getIndicatorAxes(),o=qe(s,function(r){var i=r.model.get("showName")?r.name:"",l=new hi(r.model,{axisName:i,position:[a.cx,a.cy],rotation:r.angle,labelDirection:-1,tickDirection:-1,nameDirection:1});return l});X(o,function(r){X(Qu,r.add,r),this.group.add(r.getGroup())},this)},t.prototype._buildSplitLineAndArea=function(e){var a=e.coordinateSystem,s=a.getIndicatorAxes();if(!s.length)return;var o=e.get("shape"),r=e.getModel("splitLine"),i=e.getModel("splitArea"),l=r.getModel("lineStyle"),c=i.getModel("areaStyle"),m=r.get("show"),u=i.get("show"),p=l.get("color"),f=c.get("color"),g=ke(p)?p:[p],b=ke(f)?f:[f],v=[],w=[];function x(oe,le,de){var me=de%le.length;return oe[me]=oe[me]||[],me}if(o==="circle")for(var N=s[0].getTicksCoords(),R=a.cx,_=a.cy,E=0;E<N.length;E++){if(m){var T=x(v,g,E);v[T].push(new gi({shape:{cx:R,cy:_,r:N[E].coord}}))}if(u&&E<N.length-1){var T=x(w,b,E);w[T].push(new yi({shape:{cx:R,cy:_,r0:N[E].coord,r:N[E+1].coord}}))}}else for(var A,$=qe(s,function(oe,le){var de=oe.getTicksCoords();return A=A==null?de.length-1:Math.min(de.length-1,A),qe(de,function(me){return a.coordToPoint(me.coord,le)})}),P=[],E=0;E<=A;E++){for(var L=[],M=0;M<s.length;M++)L.push($[M][E]);if(L[0]&&L.push(L[0].slice()),m){var T=x(v,g,E);v[T].push(new Ls({shape:{points:L}}))}if(u&&P){var T=x(w,b,E-1);w[T].push(new un({shape:{points:L.concat(P)}}))}P=L.slice().reverse()}var W=l.getLineStyle(),Z=c.getAreaStyle();X(w,function(oe,le){this.group.add(An(oe,{style:Et({stroke:"none",fill:b[le%b.length]},Z),silent:!0}))},this),X(v,function(oe,le){this.group.add(An(oe,{style:Et({fill:"none",stroke:g[le%g.length]},W),silent:!0}))},this)},t.type="radar",t}(Fs),Xu=function(n){De(t,n);function t(e,a,s){var o=n.call(this,e,a,s)||this;return o.type="value",o.angle=0,o.name="",o}return t}(bi),Zu=function(){function n(t,e,a){this.dimensions=[],this._model=t,this._indicatorAxes=qe(t.getIndicatorModels(),function(s,o){var r="indicator_"+o,i=new Xu(r,new Mn);return i.name=s.get("name"),i.model=s,s.axis=i,this.dimensions.push(r),i},this),this.resize(t,a)}return n.prototype.getIndicatorAxes=function(){return this._indicatorAxes},n.prototype.dataToPoint=function(t,e){var a=this._indicatorAxes[e];return this.coordToPoint(a.dataToCoord(t),e)},n.prototype.coordToPoint=function(t,e){var a=this._indicatorAxes[e],s=a.angle,o=this.cx+t*Math.cos(s),r=this.cy-t*Math.sin(s);return[o,r]},n.prototype.pointToData=function(t){var e=t[0]-this.cx,a=t[1]-this.cy,s=Math.sqrt(e*e+a*a);e/=s,a/=s;for(var o=Math.atan2(-a,e),r=1/0,i,l=-1,c=0;c<this._indicatorAxes.length;c++){var m=this._indicatorAxes[c],u=Math.abs(o-m.angle);u<r&&(i=m,l=c,r=u)}return[l,+(i&&i.coordToData(s))]},n.prototype.resize=function(t,e){var a=t.get("center"),s=e.getWidth(),o=e.getHeight(),r=Math.min(s,o)/2;this.cx=Ut(a[0],s),this.cy=Ut(a[1],o),this.startAngle=t.get("startAngle")*Math.PI/180;var i=t.get("radius");(ba(i)||Si(i))&&(i=[0,i]),this.r0=Ut(i[0],r),this.r=Ut(i[1],r),X(this._indicatorAxes,function(l,c){l.setExtent(this.r0,this.r);var m=this.startAngle+c*Math.PI*2/this._indicatorAxes.length;m=Math.atan2(Math.sin(m),Math.cos(m)),l.angle=m},this)},n.prototype.update=function(t,e){var a=this._indicatorAxes,s=this._model;X(a,function(i){i.scale.setExtent(1/0,-1/0)}),t.eachSeriesByType("radar",function(i,l){if(!(i.get("coordinateSystem")!=="radar"||t.getComponent("radar",i.get("radarIndex"))!==s)){var c=i.getData();X(a,function(m){m.scale.unionExtentFromData(c,c.mapDimension(m.dim))})}},this);var o=s.get("splitNumber"),r=new Mn;r.setExtent(0,o),r.setInterval(1),X(a,function(i,l){xi(i.scale,i.model,r)})},n.prototype.convertToPixel=function(t,e,a){return console.warn("Not implemented."),null},n.prototype.convertFromPixel=function(t,e,a){return console.warn("Not implemented."),null},n.prototype.containPoint=function(t){return console.warn("Not implemented."),!1},n.create=function(t,e){var a=[];return t.eachComponent("radar",function(s){var o=new n(s,t,e);a.push(o),s.coordinateSystem=o}),t.eachSeriesByType("radar",function(s){s.get("coordinateSystem")==="radar"&&(s.coordinateSystem=a[s.get("radarIndex")||0])}),a},n.dimensions=[],n}();function Ks(n){n.registerCoordinateSystem("radar",Zu),n.registerComponentModel(ju),n.registerComponentView(Yu),n.registerVisual({seriesType:"radar",reset:function(t){var e=t.getData();e.each(function(a){e.setItemVisual(a,"legendIcon","roundRect")}),e.setVisual("legendIcon","roundRect")}})}function Ju(n){ca(Ks),n.registerChartView(Gu),n.registerSeriesModel(Wu),n.registerLayout(Uu),n.registerProcessor(tl("radar")),n.registerPreprocessor(Ku)}var Ft=X,ec=gt,ma=-1,Se=function(){function n(t){var e=t.mappingMethod,a=t.type,s=this.option=He(t);this.type=a,this.mappingMethod=e,this._normalizeData=nc[e];var o=n.visualHandlers[a];this.applyVisual=o.applyVisual,this.getColorMapper=o.getColorMapper,this._normalizedToVisual=o._normalizedToVisual[e],e==="piecewise"?(Va(s),tc(s)):e==="category"?s.categories?ac(s):Va(s,!0):(_i(e!=="linear"||s.dataExtent),Va(s))}return n.prototype.mapValueToVisual=function(t){var e=this._normalizeData(t);return this._normalizedToVisual(e,t)},n.prototype.getNormalizer=function(){return Ie(this._normalizeData,this)},n.listVisualTypes=function(){return Ci(n.visualHandlers)},n.isValidType=function(t){return n.visualHandlers.hasOwnProperty(t)},n.eachVisual=function(t,e,a){gt(t)?X(t,e,a):e.call(a,t)},n.mapVisual=function(t,e,a){var s,o=ke(t)?[]:gt(t)?{}:(s=!0,null);return n.eachVisual(t,function(r,i){var l=e.call(a,r,i);s?o=l:o[i]=l}),o},n.retrieveVisuals=function(t){var e={},a;return t&&Ft(n.visualHandlers,function(s,o){t.hasOwnProperty(o)&&(e[o]=t[o],a=!0)}),a?e:null},n.prepareVisualTypes=function(t){if(ke(t))t=t.slice();else if(ec(t)){var e=[];Ft(t,function(a,s){e.push(s)}),t=e}else return[];return t.sort(function(a,s){return s==="color"&&a!=="color"&&a.indexOf("color")===0?1:-1}),t},n.dependsOn=function(t,e){return e==="color"?!!(t&&t.indexOf(e)===0):t===e},n.findPieceIndex=function(t,e,a){for(var s,o=1/0,r=0,i=e.length;r<i;r++){var l=e[r].value;if(l!=null){if(l===t||ba(l)&&l===t+"")return r;a&&p(l,r)}}for(var r=0,i=e.length;r<i;r++){var c=e[r],m=c.interval,u=c.close;if(m){if(m[0]===-1/0){if(Qt(u[1],t,m[1]))return r}else if(m[1]===1/0){if(Qt(u[0],m[0],t))return r}else if(Qt(u[0],m[0],t)&&Qt(u[1],t,m[1]))return r;a&&p(m[0],r),a&&p(m[1],r)}}if(a)return t===1/0?e.length-1:t===-1/0?0:s;function p(f,g){var b=Math.abs(f-t);b<o&&(o=b,s=g)}},n.visualHandlers={color:{applyVisual:kt("color"),getColorMapper:function(){var t=this.option;return Ie(t.mappingMethod==="category"?function(e,a){return!a&&(e=this._normalizeData(e)),$t.call(this,e)}:function(e,a,s){var o=!!s;return!a&&(e=this._normalizeData(e)),s=Ma(e,t.parsedVisual,s),o?s:Aa(s,"rgba")},this)},_normalizedToVisual:{linear:function(t){return Aa(Ma(t,this.option.parsedVisual),"rgba")},category:$t,piecewise:function(t,e){var a=ja.call(this,e);return a==null&&(a=Aa(Ma(t,this.option.parsedVisual),"rgba")),a},fixed:ft}},colorHue:jt(function(t,e){return Ia(t,e)}),colorSaturation:jt(function(t,e){return Ia(t,null,e)}),colorLightness:jt(function(t,e){return Ia(t,null,null,e)}),colorAlpha:jt(function(t,e){return Ti(t,e)}),decal:{applyVisual:kt("decal"),_normalizedToVisual:{linear:null,category:$t,piecewise:null,fixed:null}},opacity:{applyVisual:kt("opacity"),_normalizedToVisual:Wa([0,1])},liftZ:{applyVisual:kt("liftZ"),_normalizedToVisual:{linear:ft,category:ft,piecewise:ft,fixed:ft}},symbol:{applyVisual:function(t,e,a){var s=this.mapValueToVisual(t);a("symbol",s)},_normalizedToVisual:{linear:Pn,category:$t,piecewise:function(t,e){var a=ja.call(this,e);return a==null&&(a=Pn.call(this,t)),a},fixed:ft}},symbolSize:{applyVisual:kt("symbolSize"),_normalizedToVisual:Wa([0,1])}},n}();function tc(n){var t=n.pieceList;n.hasSpecialVisual=!1,X(t,function(e,a){e.originIndex=a,e.visual!=null&&(n.hasSpecialVisual=!0)})}function ac(n){var t=n.categories,e=n.categoryMap={},a=n.visual;if(Ft(t,function(r,i){e[r]=i}),!ke(a)){var s=[];gt(a)?Ft(a,function(r,i){var l=e[i];s[l??ma]=r}):s[ma]=a,a=Gs(n,s)}for(var o=t.length-1;o>=0;o--)a[o]==null&&(delete e[t[o]],t.pop())}function Va(n,t){var e=n.visual,a=[];gt(e)?Ft(e,function(o){a.push(o)}):e!=null&&a.push(e);var s={color:1,symbol:1};!t&&a.length===1&&!s.hasOwnProperty(n.type)&&(a[1]=a[0]),Gs(n,a)}function jt(n){return{applyVisual:function(t,e,a){var s=this.mapValueToVisual(t);a("color",n(e("color"),s))},_normalizedToVisual:Wa([0,1])}}function Pn(n){var t=this.option.visual;return t[Math.round(yt(n,[0,1],[0,t.length-1],!0))]||{}}function kt(n){return function(t,e,a){a(n,this.mapValueToVisual(t))}}function $t(n){var t=this.option.visual;return t[this.option.loop&&n!==ma?n%t.length:n]}function ft(){return this.option.visual[0]}function Wa(n){return{linear:function(t){return yt(t,n,this.option.visual,!0)},category:$t,piecewise:function(t,e){var a=ja.call(this,e);return a==null&&(a=yt(t,n,this.option.visual,!0)),a},fixed:ft}}function ja(n){var t=this.option,e=t.pieceList;if(t.hasSpecialVisual){var a=Se.findPieceIndex(n,e),s=e[a];if(s&&s.visual)return s.visual[this.type]}}function Gs(n,t){return n.visual=t,n.type==="color"&&(n.parsedVisual=qe(t,function(e){var a=Ri(e);return a||[0,0,0,1]})),t}var nc={linear:function(n){return yt(n,this.option.dataExtent,[0,1],!0)},piecewise:function(n){var t=this.option.pieceList,e=Se.findPieceIndex(n,t,!0);if(e!=null)return yt(e,[0,t.length-1],[0,1],!0)},category:function(n){var t=this.option.categories?this.option.categoryMap[n]:n;return t??ma},fixed:wi};function Qt(n,t,e){return n?t<=e:t<e}function sc(n,t,e,a,s,o){n=n||0;var r=e[1]-e[0];if(s!=null&&(s=xt(s,[0,r])),o!=null&&(o=Math.max(o,s??0)),a==="all"){var i=Math.abs(t[1]-t[0]);i=xt(i,[0,r]),s=o=xt(i,[s,o]),a=0}t[0]=xt(t[0],e),t[1]=xt(t[1],e);var l=Pa(t,a);t[a]+=n;var c=s||0,m=e.slice();l.sign<0?m[0]+=c:m[1]-=c,t[a]=xt(t[a],m);var u;return u=Pa(t,a),s!=null&&(u.sign!==l.sign||u.span<s)&&(t[1-a]=t[a]+l.sign*s),u=Pa(t,a),o!=null&&u.span>o&&(t[1-a]=t[a]+u.sign*o),t}function Pa(n,t){var e=n[t]-n[1-t];return{span:Math.abs(e),sign:e>0?-1:e<0?1:t?-1:1}}function xt(n,t){return Math.min(t[1]!=null?t[1]:1/0,Math.max(t[0]!=null?t[0]:-1/0,n))}var oc=256,rc=function(){function n(){this.blurSize=30,this.pointSize=20,this.maxOpacity=1,this.minOpacity=0,this._gradientPixels={inRange:null,outOfRange:null};var t=In.createCanvas();this.canvas=t}return n.prototype.update=function(t,e,a,s,o,r){var i=this._getBrush(),l=this._getGradient(o,"inRange"),c=this._getGradient(o,"outOfRange"),m=this.pointSize+this.blurSize,u=this.canvas,p=u.getContext("2d"),f=t.length;u.width=e,u.height=a;for(var g=0;g<f;++g){var b=t[g],v=b[0],w=b[1],x=b[2],N=s(x);p.globalAlpha=N,p.drawImage(i,v-m,w-m)}if(!u.width||!u.height)return u;for(var R=p.getImageData(0,0,u.width,u.height),_=R.data,E=0,T=_.length,A=this.minOpacity,$=this.maxOpacity,P=$-A;E<T;){var N=_[E+3]/256,L=Math.floor(N*(oc-1))*4;if(N>0){var M=r(N)?l:c;N>0&&(N=N*P+A),_[E++]=M[L],_[E++]=M[L+1],_[E++]=M[L+2],_[E++]=M[L+3]*N*256}else E+=4}return p.putImageData(R,0,0),u},n.prototype._getBrush=function(){var t=this._brushCanvas||(this._brushCanvas=In.createCanvas()),e=this.pointSize+this.blurSize,a=e*2;t.width=a,t.height=a;var s=t.getContext("2d");return s.clearRect(0,0,a,a),s.shadowOffsetX=a,s.shadowBlur=this.blurSize,s.shadowColor="#000",s.beginPath(),s.arc(-e,e,this.pointSize,0,Math.PI*2,!0),s.closePath(),s.fill(),t},n.prototype._getGradient=function(t,e){for(var a=this._gradientPixels,s=a[e]||(a[e]=new Uint8ClampedArray(256*4)),o=[0,0,0,0],r=0,i=0;i<256;i++)t[e](i/255,!0,o),s[r++]=o[0],s[r++]=o[1],s[r++]=o[2],s[r++]=o[3];return s},n}();function ic(n,t,e){var a=n[1]-n[0];t=qe(t,function(r){return{interval:[(r.interval[0]-n[0])/a,(r.interval[1]-n[0])/a]}});var s=t.length,o=0;return function(r){var i;for(i=o;i<s;i++){var l=t[i].interval;if(l[0]<=r&&r<=l[1]){o=i;break}}if(i===s)for(i=o-1;i>=0;i--){var l=t[i].interval;if(l[0]<=r&&r<=l[1]){o=i;break}}return i>=0&&i<s&&e[i]}}function lc(n,t){var e=n[1]-n[0];return t=[(t[0]-n[0])/e,(t[1]-n[0])/e],function(a){return a>=t[0]&&a<=t[1]}}function Dn(n){var t=n.dimensions;return t[0]==="lng"&&t[1]==="lat"}var uc=function(n){De(t,n);function t(){var e=n!==null&&n.apply(this,arguments)||this;return e.type=t.type,e}return t.prototype.render=function(e,a,s){var o;a.eachComponent("visualMap",function(i){i.eachTargetSeries(function(l){l===e&&(o=i)})}),this._progressiveEls=null,this.group.removeAll();var r=e.coordinateSystem;r.type==="cartesian2d"||r.type==="calendar"?this._renderOnCartesianAndCalendar(e,s,0,e.getData().count()):Dn(r)&&this._renderOnGeo(r,e,o,s)},t.prototype.incrementalPrepareRender=function(e,a,s){this.group.removeAll()},t.prototype.incrementalRender=function(e,a,s,o){var r=a.coordinateSystem;r&&(Dn(r)?this.render(a,s,o):(this._progressiveEls=[],this._renderOnCartesianAndCalendar(a,o,e.start,e.end,!0)))},t.prototype.eachRendered=function(e){Ei(this._progressiveEls||this.group,e)},t.prototype._renderOnCartesianAndCalendar=function(e,a,s,o,r){var i=e.coordinateSystem,l=Ni(i,"cartesian2d"),c,m,u,p;if(l){var f=i.getAxis("x"),g=i.getAxis("y");c=f.getBandWidth()+.5,m=g.getBandWidth()+.5,u=f.scale.getExtent(),p=g.scale.getExtent()}for(var b=this.group,v=e.getData(),w=e.getModel(["emphasis","itemStyle"]).getItemStyle(),x=e.getModel(["blur","itemStyle"]).getItemStyle(),N=e.getModel(["select","itemStyle"]).getItemStyle(),R=e.get(["itemStyle","borderRadius"]),_=Ua(e),E=e.getModel("emphasis"),T=E.get("focus"),A=E.get("blurScope"),$=E.get("disabled"),P=l?[v.mapDimension("x"),v.mapDimension("y"),v.mapDimension("value")]:[v.mapDimension("time"),v.mapDimension("value")],L=s;L<o;L++){var M=void 0,W=v.getItemVisual(L,"style");if(l){var Z=v.get(P[0],L),oe=v.get(P[1],L);if(isNaN(v.get(P[2],L))||isNaN(Z)||isNaN(oe)||Z<u[0]||Z>u[1]||oe<p[0]||oe>p[1])continue;var le=i.dataToPoint([Z,oe]);M=new da({shape:{x:le[0]-c/2,y:le[1]-m/2,width:c,height:m},style:W})}else{if(isNaN(v.get(P[1],L)))continue;M=new da({z2:1,shape:i.dataToRect([v.get(P[0],L)]).contentShape,style:W})}if(v.hasItemOption){var de=v.getItemModel(L),me=de.getModel("emphasis");w=me.getModel("itemStyle").getItemStyle(),x=de.getModel(["blur","itemStyle"]).getItemStyle(),N=de.getModel(["select","itemStyle"]).getItemStyle(),R=de.get(["itemStyle","borderRadius"]),T=me.get("focus"),A=me.get("blurScope"),$=me.get("disabled"),_=Ua(de)}M.shape.r=R;var Fe=e.getRawValue(L),ze="-";Fe&&Fe[2]!=null&&(ze=Fe[2]+""),zs(M,_,{labelFetcher:e,labelDataIndex:L,defaultOpacity:W.opacity,defaultText:ze}),M.ensureState("emphasis").style=w,M.ensureState("blur").style=x,M.ensureState("select").style=N,$s(M,T,A,$),M.incremental=r,r&&(M.states.emphasis.hoverLayer=!0),b.add(M),v.setItemGraphicEl(L,M),this._progressiveEls&&this._progressiveEls.push(M)}},t.prototype._renderOnGeo=function(e,a,s,o){var r=s.targetVisuals.inRange,i=s.targetVisuals.outOfRange,l=a.getData(),c=this._hmLayer||this._hmLayer||new rc;c.blurSize=a.get("blurSize"),c.pointSize=a.get("pointSize"),c.minOpacity=a.get("minOpacity"),c.maxOpacity=a.get("maxOpacity");var m=e.getViewRect().clone(),u=e.getRoamTransform();m.applyTransform(u);var p=Math.max(m.x,0),f=Math.max(m.y,0),g=Math.min(m.width+m.x,o.getWidth()),b=Math.min(m.height+m.y,o.getHeight()),v=g-p,w=b-f,x=[l.mapDimension("lng"),l.mapDimension("lat"),l.mapDimension("value")],N=l.mapArray(x,function(T,A,$){var P=e.dataToPoint([T,A]);return P[0]-=p,P[1]-=f,P.push($),P}),R=s.getExtent(),_=s.type==="visualMap.continuous"?lc(R,s.option.range):ic(R,s.getPieceList(),s.option.selected);c.update(N,v,w,r.color.getNormalizer(),{inRange:r.color.getColorMapper(),outOfRange:i.color.getColorMapper()},_);var E=new cn({style:{width:v,height:w,x:p,y:f,image:c.canvas},silent:!0});this.group.add(E)},t.type="heatmap",t}(Os),cc=function(n){De(t,n);function t(){var e=n!==null&&n.apply(this,arguments)||this;return e.type=t.type,e}return t.prototype.getInitialData=function(e,a){return Ai(null,this,{generateCoord:"value"})},t.prototype.preventIncremental=function(){var e=Mi.get(this.get("coordinateSystem"));if(e&&e.dimensions)return e.dimensions[0]==="lng"&&e.dimensions[1]==="lat"},t.type="series.heatmap",t.dependencies=["grid","geo","calendar"],t.defaultOption={coordinateSystem:"cartesian2d",z:2,geoIndex:0,blurSize:30,pointSize:20,maxOpacity:1,minOpacity:0,select:{itemStyle:{borderColor:"#212121"}}},t}(Vs);function dc(n){n.registerChartView(uc),n.registerSeriesModel(cc)}var Fn=X;function Bn(n){if(n){for(var t in n)if(n.hasOwnProperty(t))return!0}}function Hn(n,t,e){var a={};return Fn(t,function(o){var r=a[o]=s();Fn(n[o],function(i,l){if(Se.isValidType(l)){var c={type:l,visual:i};e&&e(c,o),r[l]=new Se(c),l==="opacity"&&(c=He(c),c.type="colorAlpha",r.__hidden.__alphaForOpacity=new Se(c))}})}),a;function s(){var o=function(){};o.prototype.__hidden=o.prototype;var r=new o;return r}}function mc(n,t,e){var a;X(e,function(s){t.hasOwnProperty(s)&&Bn(t[s])&&(a=!0)}),a&&X(e,function(s){t.hasOwnProperty(s)&&Bn(t[s])?n[s]=He(t[s]):delete n[s]})}function pc(n,t,e,a){var s={};return X(n,function(o){var r=Se.prepareVisualTypes(t[o]);s[o]=r}),{progress:function(r,i){var l;a!=null&&(l=i.getDimensionIndex(a));function c(_){return Ii(i,u,_)}function m(_,E){Li(i,u,_,E)}for(var u,p=i.getStore();(u=r.next())!=null;){var f=i.getRawDataItem(u);if(!(f&&f.visualMap===!1))for(var g=a!=null?p.get(l,u):u,b=e(g),v=t[b],w=s[b],x=0,N=w.length;x<N;x++){var R=w[x];v[R]&&v[R].applyVisual(g,c,m)}}}}}var Ws={get:function(n,t,e){var a=He((fc[n]||{})[t]);return e&&ke(a)?a[a.length-1]:a}},fc={color:{active:["#006edd","#e0ffff"],inactive:["rgba(0,0,0,0)"]},colorHue:{active:[0,360],inactive:[0,0]},colorSaturation:{active:[.3,1],inactive:[0,0]},colorLightness:{active:[.9,.5],inactive:[0,0]},colorAlpha:{active:[.3,1],inactive:[0,0]},opacity:{active:[.3,1],inactive:[0,0]},symbol:{active:["circle","roundRect","diamond"],inactive:["none"]},symbolSize:{active:[10,50],inactive:[0,0]}},qn=Se.mapVisual,vc=Se.eachVisual,hc=ke,Un=X,gc=Bs,yc=yt,pa=function(n){De(t,n);function t(){var e=n!==null&&n.apply(this,arguments)||this;return e.type=t.type,e.stateList=["inRange","outOfRange"],e.replacableOptionKeys=["inRange","outOfRange","target","controller","color"],e.layoutMode={type:"box",ignoreSize:!0},e.dataBound=[-1/0,1/0],e.targetVisuals={},e.controllerVisuals={},e}return t.prototype.init=function(e,a,s){this.mergeDefaultAndTheme(e,s)},t.prototype.optionUpdated=function(e,a){var s=this.option;!a&&mc(s,e,this.replacableOptionKeys),this.textStyleModel=this.getModel("textStyle"),this.resetItemSize(),this.completeVisualOption()},t.prototype.resetVisual=function(e){var a=this.stateList;e=Ie(e,this),this.controllerVisuals=Hn(this.option.controller,a,e),this.targetVisuals=Hn(this.option.target,a,e)},t.prototype.getItemSymbol=function(){return null},t.prototype.getTargetSeriesIndices=function(){var e=this.option.seriesIndex,a=[];return e==null||e==="all"?this.ecModel.eachSeries(function(s,o){a.push(o)}):a=ki(e),a},t.prototype.eachTargetSeries=function(e,a){X(this.getTargetSeriesIndices(),function(s){var o=this.ecModel.getSeriesByIndex(s);o&&e.call(a,o)},this)},t.prototype.isTargetSeries=function(e){var a=!1;return this.eachTargetSeries(function(s){s===e&&(a=!0)}),a},t.prototype.formatValueText=function(e,a,s){var o=this.option,r=o.precision,i=this.dataBound,l=o.formatter,c;s=s||["<",">"],ke(e)&&(e=e.slice(),c=!0);var m=a?e:c?[u(e[0]),u(e[1])]:u(e);if(ba(l))return l.replace("{value}",c?m[0]:m).replace("{value2}",c?m[1]:m);if(Ps(l))return c?l(e[0],e[1]):l(e);if(c)return e[0]===i[0]?s[0]+" "+m[1]:e[1]===i[1]?s[1]+" "+m[0]:m[0]+" - "+m[1];return m;function u(p){return p===i[0]?"min":p===i[1]?"max":(+p).toFixed(Math.min(r,20))}},t.prototype.resetExtent=function(){var e=this.option,a=gc([e.min,e.max]);this._dataExtent=a},t.prototype.getDataDimensionIndex=function(e){var a=this.option.dimension;if(a!=null)return e.getDimensionIndex(a);for(var s=e.dimensions,o=s.length-1;o>=0;o--){var r=s[o],i=e.getDimensionInfo(r);if(!i.isCalculationCoord)return i.storeDimIndex}},t.prototype.getExtent=function(){return this._dataExtent.slice()},t.prototype.completeVisualOption=function(){var e=this.ecModel,a=this.option,s={inRange:a.inRange,outOfRange:a.outOfRange},o=a.target||(a.target={}),r=a.controller||(a.controller={});ua(o,s),ua(r,s);var i=this.isCategory();l.call(this,o),l.call(this,r),c.call(this,o,"inRange","outOfRange"),m.call(this,r);function l(u){hc(a.color)&&!u.inRange&&(u.inRange={color:a.color.slice().reverse()}),u.inRange=u.inRange||{color:e.get("gradientColor")}}function c(u,p,f){var g=u[p],b=u[f];g&&!b&&(b=u[f]={},Un(g,function(v,w){if(Se.isValidType(w)){var x=Ws.get(w,"inactive",i);x!=null&&(b[w]=x,w==="color"&&!b.hasOwnProperty("opacity")&&!b.hasOwnProperty("colorAlpha")&&(b.opacity=[0,0]))}}))}function m(u){var p=(u.inRange||{}).symbol||(u.outOfRange||{}).symbol,f=(u.inRange||{}).symbolSize||(u.outOfRange||{}).symbolSize,g=this.get("inactiveColor"),b=this.getItemSymbol(),v=b||"roundRect";Un(this.stateList,function(w){var x=this.itemSize,N=u[w];N||(N=u[w]={color:i?g:[g]}),N.symbol==null&&(N.symbol=p&&He(p)||(i?v:[v])),N.symbolSize==null&&(N.symbolSize=f&&He(f)||(i?x[0]:[x[0],x[0]])),N.symbol=qn(N.symbol,function(E){return E==="none"?v:E});var R=N.symbolSize;if(R!=null){var _=-1/0;vc(R,function(E){E>_&&(_=E)}),N.symbolSize=qn(R,function(E){return yc(E,[0,_],[0,x[0]],!0)})}},this)}},t.prototype.resetItemSize=function(){this.itemSize=[parseFloat(this.get("itemWidth")),parseFloat(this.get("itemHeight"))]},t.prototype.isCategory=function(){return!!this.option.categories},t.prototype.setSelected=function(e){},t.prototype.getSelected=function(){return null},t.prototype.getValueState=function(e){return null},t.prototype.getVisualMeta=function(e){return null},t.type="visualMap",t.dependencies=["series"],t.defaultOption={show:!0,z:4,seriesIndex:"all",min:0,max:200,left:0,right:null,top:null,bottom:0,itemWidth:null,itemHeight:null,inverse:!1,orient:"vertical",backgroundColor:"rgba(0,0,0,0)",borderColor:"#ccc",contentColor:"#5793f3",inactiveColor:"#aaa",borderWidth:0,padding:5,textGap:10,precision:0,textStyle:{color:"#333"}},t}(Ds),Kn=[20,140],bc=function(n){De(t,n);function t(){var e=n!==null&&n.apply(this,arguments)||this;return e.type=t.type,e}return t.prototype.optionUpdated=function(e,a){n.prototype.optionUpdated.apply(this,arguments),this.resetExtent(),this.resetVisual(function(s){s.mappingMethod="linear",s.dataExtent=this.getExtent()}),this._resetRange()},t.prototype.resetItemSize=function(){n.prototype.resetItemSize.apply(this,arguments);var e=this.itemSize;(e[0]==null||isNaN(e[0]))&&(e[0]=Kn[0]),(e[1]==null||isNaN(e[1]))&&(e[1]=Kn[1])},t.prototype._resetRange=function(){var e=this.getExtent(),a=this.option.range;!a||a.auto?(e.auto=1,this.option.range=e):ke(a)&&(a[0]>a[1]&&a.reverse(),a[0]=Math.max(a[0],e[0]),a[1]=Math.min(a[1],e[1]))},t.prototype.completeVisualOption=function(){n.prototype.completeVisualOption.apply(this,arguments),X(this.stateList,function(e){var a=this.option.controller[e].symbolSize;a&&a[0]!==a[1]&&(a[0]=a[1]/3)},this)},t.prototype.setSelected=function(e){this.option.range=e.slice(),this._resetRange()},t.prototype.getSelected=function(){var e=this.getExtent(),a=Bs((this.get("range")||[]).slice());return a[0]>e[1]&&(a[0]=e[1]),a[1]>e[1]&&(a[1]=e[1]),a[0]<e[0]&&(a[0]=e[0]),a[1]<e[0]&&(a[1]=e[0]),a},t.prototype.getValueState=function(e){var a=this.option.range,s=this.getExtent();return(a[0]<=s[0]||a[0]<=e)&&(a[1]>=s[1]||e<=a[1])?"inRange":"outOfRange"},t.prototype.findTargetDataIndices=function(e){var a=[];return this.eachTargetSeries(function(s){var o=[],r=s.getData();r.each(this.getDataDimensionIndex(r),function(i,l){e[0]<=i&&i<=e[1]&&o.push(l)},this),a.push({seriesId:s.id,dataIndex:o})},this),a},t.prototype.getVisualMeta=function(e){var a=Gn(this,"outOfRange",this.getExtent()),s=Gn(this,"inRange",this.option.range.slice()),o=[];function r(f,g){o.push({value:f,color:e(f,g)})}for(var i=0,l=0,c=s.length,m=a.length;l<m&&(!s.length||a[l]<=s[0]);l++)a[l]<s[i]&&r(a[l],"outOfRange");for(var u=1;i<c;i++,u=0)u&&o.length&&r(s[i],"outOfRange"),r(s[i],"inRange");for(var u=1;l<m;l++)(!s.length||s[s.length-1]<a[l])&&(u&&(o.length&&r(o[o.length-1].value,"outOfRange"),u=0),r(a[l],"outOfRange"));var p=o.length;return{stops:o,outerColors:[p?o[0].color:"transparent",p?o[p-1].color:"transparent"]}},t.type="visualMap.continuous",t.defaultOption=Hs(pa.defaultOption,{align:"auto",calculable:!1,hoverLink:!0,realtime:!0,handleIcon:"path://M-11.39,9.77h0a3.5,3.5,0,0,1-3.5,3.5h-22a3.5,3.5,0,0,1-3.5-3.5h0a3.5,3.5,0,0,1,3.5-3.5h22A3.5,3.5,0,0,1-11.39,9.77Z",handleSize:"120%",handleStyle:{borderColor:"#fff",borderWidth:1},indicatorIcon:"circle",indicatorSize:"50%",indicatorStyle:{borderColor:"#fff",borderWidth:2,shadowBlur:2,shadowOffsetX:1,shadowOffsetY:1,shadowColor:"rgba(0,0,0,0.2)"}}),t}(pa);function Gn(n,t,e){if(e[0]===e[1])return e.slice();for(var a=200,s=(e[1]-e[0])/a,o=e[0],r=[],i=0;i<=a&&o<e[1];i++)r.push(o),o+=s;return r.push(e[1]),r}var js=function(n){De(t,n);function t(){var e=n!==null&&n.apply(this,arguments)||this;return e.type=t.type,e.autoPositionValues={left:1,right:1,top:1,bottom:1},e}return t.prototype.init=function(e,a){this.ecModel=e,this.api=a},t.prototype.render=function(e,a,s,o){if(this.visualMapModel=e,e.get("show")===!1){this.group.removeAll();return}this.doRender(e,a,s,o)},t.prototype.renderBackground=function(e){var a=this.visualMapModel,s=zi(a.get("padding")||0),o=e.getBoundingRect();e.add(new da({z2:-1,silent:!0,shape:{x:o.x-s[3],y:o.y-s[0],width:o.width+s[3]+s[1],height:o.height+s[0]+s[2]},style:{fill:a.get("backgroundColor"),stroke:a.get("borderColor"),lineWidth:a.get("borderWidth")}}))},t.prototype.getControllerVisual=function(e,a,s){s=s||{};var o=s.forceState,r=this.visualMapModel,i={};if(a==="color"){var l=r.get("contentColor");i.color=l}function c(f){return i[f]}function m(f,g){i[f]=g}var u=r.controllerVisuals[o||r.getValueState(e)],p=Se.prepareVisualTypes(u);return X(p,function(f){var g=u[f];s.convertOpacityToAlpha&&f==="opacity"&&(f="colorAlpha",g=u.__alphaForOpacity),Se.dependsOn(f,a)&&g&&g.applyVisual(e,c,m)}),i[a]},t.prototype.positionGroup=function(e){var a=this.visualMapModel,s=this.api;$i(e,a.getBoxLayoutParams(),{width:s.getWidth(),height:s.getHeight()})},t.prototype.doRender=function(e,a,s,o){},t.type="visualMap",t}(Fs),Wn=[["left","right","width"],["top","bottom","height"]];function Qs(n,t,e){var a=n.option,s=a.align;if(s!=null&&s!=="auto")return s;for(var o={width:t.getWidth(),height:t.getHeight()},r=a.orient==="horizontal"?1:0,i=Wn[r],l=[0,null,10],c={},m=0;m<3;m++)c[Wn[1-r][m]]=l[m],c[i[m]]=m===2?e[0]:a[i[m]];var u=[["x","width",3],["y","height",0]][r],p=Oi(c,o,a.padding);return i[(p.margin[u[2]]||0)+p[u[0]]+p[u[1]]*.5<o[u[1]]*.5?0:1]}function aa(n,t){return X(n||[],function(e){e.dataIndex!=null&&(e.dataIndexInside=e.dataIndex,e.dataIndex=null),e.highlightKey="visualMap"+(t?t.componentIndex:"")}),n}var Xe=yt,xc=X,jn=Math.min,Da=Math.max,Sc=12,Cc=6,wc=function(n){De(t,n);function t(){var e=n!==null&&n.apply(this,arguments)||this;return e.type=t.type,e._shapes={},e._dataInterval=[],e._handleEnds=[],e._hoverLinkDataIndices=[],e}return t.prototype.init=function(e,a){n.prototype.init.call(this,e,a),this._hoverLinkFromSeriesMouseOver=Ie(this._hoverLinkFromSeriesMouseOver,this),this._hideIndicator=Ie(this._hideIndicator,this)},t.prototype.doRender=function(e,a,s,o){(!o||o.type!=="selectDataRange"||o.from!==this.uid)&&this._buildView()},t.prototype._buildView=function(){this.group.removeAll();var e=this.visualMapModel,a=this.group;this._orient=e.get("orient"),this._useHandle=e.get("calculable"),this._resetInterval(),this._renderBar(a);var s=e.get("text");this._renderEndsText(a,s,0),this._renderEndsText(a,s,1),this._updateView(!0),this.renderBackground(a),this._updateView(),this._enableHoverLinkToSeries(),this._enableHoverLinkFromSeries(),this.positionGroup(a)},t.prototype._renderEndsText=function(e,a,s){if(a){var o=a[1-s];o=o!=null?o+"":"";var r=this.visualMapModel,i=r.get("textGap"),l=r.itemSize,c=this._shapes.mainGroup,m=this._applyTransform([l[0]/2,s===0?-i:l[1]+i],c),u=this._applyTransform(s===0?"bottom":"top",c),p=this._orient,f=this.visualMapModel.textStyleModel;this.group.add(new Pt({style:ea(f,{x:m[0],y:m[1],verticalAlign:p==="horizontal"?"middle":u,align:p==="horizontal"?u:"center",text:o})}))}},t.prototype._renderBar=function(e){var a=this.visualMapModel,s=this._shapes,o=a.itemSize,r=this._orient,i=this._useHandle,l=Qs(a,this.api,o),c=s.mainGroup=this._createBarGroup(l),m=new Tt;c.add(m),m.add(s.outOfRange=Qn()),m.add(s.inRange=Qn(null,i?Xn(this._orient):null,Ie(this._dragHandle,this,"all",!1),Ie(this._dragHandle,this,"all",!0))),m.setClipPath(new da({shape:{x:0,y:0,width:o[0],height:o[1],r:3}}));var u=a.textStyleModel.getTextRect("国"),p=Da(u.width,u.height);i&&(s.handleThumbs=[],s.handleLabels=[],s.handleLabelPoints=[],this._createHandle(a,c,0,o,p,r),this._createHandle(a,c,1,o,p,r)),this._createIndicator(a,c,o,p,r),e.add(c)},t.prototype._createHandle=function(e,a,s,o,r,i){var l=Ie(this._dragHandle,this,s,!1),c=Ie(this._dragHandle,this,s,!0),m=Ln(e.get("handleSize"),o[0]),u=la(e.get("handleIcon"),-m/2,-m/2,m,m,null,!0),p=Xn(this._orient);u.attr({cursor:p,draggable:!0,drift:l,ondragend:c,onmousemove:function(w){Ka(w.event)}}),u.x=o[0]/2,u.useStyle(e.getModel("handleStyle").getItemStyle()),u.setStyle({strokeNoScale:!0,strokeFirst:!0}),u.style.lineWidth*=2,u.ensureState("emphasis").style=e.getModel(["emphasis","handleStyle"]).getItemStyle(),Vi(u,!0),a.add(u);var f=this.visualMapModel.textStyleModel,g=new Pt({cursor:p,draggable:!0,drift:l,onmousemove:function(w){Ka(w.event)},ondragend:c,style:ea(f,{x:0,y:0,text:""})});g.ensureState("blur").style={opacity:.1},g.stateTransition={duration:200},this.group.add(g);var b=[m,0],v=this._shapes;v.handleThumbs[s]=u,v.handleLabelPoints[s]=b,v.handleLabels[s]=g},t.prototype._createIndicator=function(e,a,s,o,r){var i=Ln(e.get("indicatorSize"),s[0]),l=la(e.get("indicatorIcon"),-i/2,-i/2,i,i,null,!0);l.attr({cursor:"move",invisible:!0,silent:!0,x:s[0]/2});var c=e.getModel("indicatorStyle").getItemStyle();if(l instanceof cn){var m=l.style;l.useStyle(ks({image:m.image,x:m.x,y:m.y,width:m.width,height:m.height},c))}else l.useStyle(c);a.add(l);var u=this.visualMapModel.textStyleModel,p=new Pt({silent:!0,invisible:!0,style:ea(u,{x:0,y:0,text:""})});this.group.add(p);var f=[(r==="horizontal"?o/2:Cc)+s[0]/2,0],g=this._shapes;g.indicator=l,g.indicatorLabel=p,g.indicatorLabelPoint=f,this._firstShowIndicator=!0},t.prototype._dragHandle=function(e,a,s,o){if(this._useHandle){if(this._dragging=!a,!a){var r=this._applyTransform([s,o],this._shapes.mainGroup,!0);this._updateInterval(e,r[1]),this._hideIndicator(),this._updateView()}a===!this.visualMapModel.get("realtime")&&this.api.dispatchAction({type:"selectDataRange",from:this.uid,visualMapId:this.visualMapModel.id,selected:this._dataInterval.slice()}),a?!this._hovering&&this._clearHoverLinkToSeries():Yn(this.visualMapModel)&&this._doHoverLinkToSeries(this._handleEnds[e],!1)}},t.prototype._resetInterval=function(){var e=this.visualMapModel,a=this._dataInterval=e.getSelected(),s=e.getExtent(),o=[0,e.itemSize[1]];this._handleEnds=[Xe(a[0],s,o,!0),Xe(a[1],s,o,!0)]},t.prototype._updateInterval=function(e,a){a=a||0;var s=this.visualMapModel,o=this._handleEnds,r=[0,s.itemSize[1]];sc(a,o,r,e,0);var i=s.getExtent();this._dataInterval=[Xe(o[0],r,i,!0),Xe(o[1],r,i,!0)]},t.prototype._updateView=function(e){var a=this.visualMapModel,s=a.getExtent(),o=this._shapes,r=[0,a.itemSize[1]],i=e?r:this._handleEnds,l=this._createBarVisual(this._dataInterval,s,i,"inRange"),c=this._createBarVisual(s,s,r,"outOfRange");o.inRange.setStyle({fill:l.barColor}).setShape("points",l.barPoints),o.outOfRange.setStyle({fill:c.barColor}).setShape("points",c.barPoints),this._updateHandle(i,l)},t.prototype._createBarVisual=function(e,a,s,o){var r={forceState:o,convertOpacityToAlpha:!0},i=this._makeColorGradient(e,r),l=[this.getControllerVisual(e[0],"symbolSize",r),this.getControllerVisual(e[1],"symbolSize",r)],c=this._createBarPoints(s,l);return{barColor:new Pi(0,0,0,1,i),barPoints:c,handlesColor:[i[0].color,i[i.length-1].color]}},t.prototype._makeColorGradient=function(e,a){var s=100,o=[],r=(e[1]-e[0])/s;o.push({color:this.getControllerVisual(e[0],"color",a),offset:0});for(var i=1;i<s;i++){var l=e[0]+r*i;if(l>e[1])break;o.push({color:this.getControllerVisual(l,"color",a),offset:i/s})}return o.push({color:this.getControllerVisual(e[1],"color",a),offset:1}),o},t.prototype._createBarPoints=function(e,a){var s=this.visualMapModel.itemSize;return[[s[0]-a[0],e[0]],[s[0],e[0]],[s[0],e[1]],[s[0]-a[1],e[1]]]},t.prototype._createBarGroup=function(e){var a=this._orient,s=this.visualMapModel.get("inverse");return new Tt(a==="horizontal"&&!s?{scaleX:e==="bottom"?1:-1,rotation:Math.PI/2}:a==="horizontal"&&s?{scaleX:e==="bottom"?-1:1,rotation:-Math.PI/2}:a==="vertical"&&!s?{scaleX:e==="left"?1:-1,scaleY:-1}:{scaleX:e==="left"?1:-1})},t.prototype._updateHandle=function(e,a){if(this._useHandle){var s=this._shapes,o=this.visualMapModel,r=s.handleThumbs,i=s.handleLabels,l=o.itemSize,c=o.getExtent(),m=this._applyTransform("left",s.mainGroup);xc([0,1],function(u){var p=r[u];p.setStyle("fill",a.handlesColor[u]),p.y=e[u];var f=Xe(e[u],[0,l[1]],c,!0),g=this.getControllerVisual(f,"symbolSize");p.scaleX=p.scaleY=g/l[0],p.x=l[0]-g/2;var b=La(s.handleLabelPoints[u],ka(p,this.group));if(this._orient==="horizontal"){var v=m==="left"||m==="top"?(l[0]-g)/2:(l[0]-g)/-2;b[1]+=v}i[u].setStyle({x:b[0],y:b[1],text:o.formatValueText(this._dataInterval[u]),verticalAlign:"middle",align:this._orient==="vertical"?this._applyTransform("left",s.mainGroup):"center"})},this)}},t.prototype._showIndicator=function(e,a,s,o){var r=this.visualMapModel,i=r.getExtent(),l=r.itemSize,c=[0,l[1]],m=this._shapes,u=m.indicator;if(u){u.attr("invisible",!1);var p={convertOpacityToAlpha:!0},f=this.getControllerVisual(e,"color",p),g=this.getControllerVisual(e,"symbolSize"),b=Xe(e,i,c,!0),v=l[0]-g/2,w={x:u.x,y:u.y};u.y=b,u.x=v;var x=La(m.indicatorLabelPoint,ka(u,this.group)),N=m.indicatorLabel;N.attr("invisible",!1);var R=this._applyTransform("left",m.mainGroup),_=this._orient,E=_==="horizontal";N.setStyle({text:(s||"")+r.formatValueText(a),verticalAlign:E?R:"middle",align:E?"center":R});var T={x:v,y:b,style:{fill:f}},A={style:{x:x[0],y:x[1]}};if(r.ecModel.isAnimationEnabled()&&!this._firstShowIndicator){var $={duration:100,easing:"cubicInOut",additive:!0};u.x=w.x,u.y=w.y,u.animateTo(T,$),N.animateTo(A,$)}else u.attr(T),N.attr(A);this._firstShowIndicator=!1;var P=this._shapes.handleLabels;if(P)for(var L=0;L<P.length;L++)this.api.enterBlur(P[L])}},t.prototype._enableHoverLinkToSeries=function(){var e=this;this._shapes.mainGroup.on("mousemove",function(a){if(e._hovering=!0,!e._dragging){var s=e.visualMapModel.itemSize,o=e._applyTransform([a.offsetX,a.offsetY],e._shapes.mainGroup,!0,!0);o[1]=jn(Da(0,o[1]),s[1]),e._doHoverLinkToSeries(o[1],0<=o[0]&&o[0]<=s[0])}}).on("mouseout",function(){e._hovering=!1,!e._dragging&&e._clearHoverLinkToSeries()})},t.prototype._enableHoverLinkFromSeries=function(){var e=this.api.getZr();this.visualMapModel.option.hoverLink?(e.on("mouseover",this._hoverLinkFromSeriesMouseOver,this),e.on("mouseout",this._hideIndicator,this)):this._clearHoverLinkFromSeries()},t.prototype._doHoverLinkToSeries=function(e,a){var s=this.visualMapModel,o=s.itemSize;if(s.option.hoverLink){var r=[0,o[1]],i=s.getExtent();e=jn(Da(r[0],e),r[1]);var l=_c(s,i,r),c=[e-l,e+l],m=Xe(e,r,i,!0),u=[Xe(c[0],r,i,!0),Xe(c[1],r,i,!0)];c[0]<r[0]&&(u[0]=-1/0),c[1]>r[1]&&(u[1]=1/0),a&&(u[0]===-1/0?this._showIndicator(m,u[1],"< ",l):u[1]===1/0?this._showIndicator(m,u[0],"> ",l):this._showIndicator(m,m,"≈ ",l));var p=this._hoverLinkDataIndices,f=[];(a||Yn(s))&&(f=this._hoverLinkDataIndices=s.findTargetDataIndices(u));var g=Di(p,f);this._dispatchHighDown("downplay",aa(g[0],s)),this._dispatchHighDown("highlight",aa(g[1],s))}},t.prototype._hoverLinkFromSeriesMouseOver=function(e){var a;if(Fi(e.target,function(l){var c=Bi(l);if(c.dataIndex!=null)return a=c,!0},!0),!!a){var s=this.ecModel.getSeriesByIndex(a.seriesIndex),o=this.visualMapModel;if(o.isTargetSeries(s)){var r=s.getData(a.dataType),i=r.getStore().get(o.getDataDimensionIndex(r),a.dataIndex);isNaN(i)||this._showIndicator(i,i)}}},t.prototype._hideIndicator=function(){var e=this._shapes;e.indicator&&e.indicator.attr("invisible",!0),e.indicatorLabel&&e.indicatorLabel.attr("invisible",!0);var a=this._shapes.handleLabels;if(a)for(var s=0;s<a.length;s++)this.api.leaveBlur(a[s])},t.prototype._clearHoverLinkToSeries=function(){this._hideIndicator();var e=this._hoverLinkDataIndices;this._dispatchHighDown("downplay",aa(e,this.visualMapModel)),e.length=0},t.prototype._clearHoverLinkFromSeries=function(){this._hideIndicator();var e=this.api.getZr();e.off("mouseover",this._hoverLinkFromSeriesMouseOver),e.off("mouseout",this._hideIndicator)},t.prototype._applyTransform=function(e,a,s,o){var r=ka(a,o?null:this.group);return ke(e)?La(e,r,s):Hi(e,r,s)},t.prototype._dispatchHighDown=function(e,a){a&&a.length&&this.api.dispatchAction({type:e,batch:a})},t.prototype.dispose=function(){this._clearHoverLinkFromSeries(),this._clearHoverLinkToSeries()},t.type="visualMap.continuous",t}(js);function Qn(n,t,e,a){return new un({shape:{points:n},draggable:!!e,cursor:t,drift:e,onmousemove:function(s){Ka(s.event)},ondragend:a})}function _c(n,t,e){var a=Sc/2,s=n.get("hoverLinkDataSize");return s&&(a=Xe(s,t,e,!0)/2),a}function Yn(n){var t=n.get("hoverLinkOnHandle");return!!(t??n.get("realtime"))}function Xn(n){return n==="vertical"?"ns-resize":"ew-resize"}var Rc={type:"selectDataRange",event:"dataRangeSelected",update:"update"},Tc=function(n,t){t.eachComponent({mainType:"visualMap",query:n},function(e){e.setSelected(n.selected)})},Ec=[{createOnAllSeries:!0,reset:function(n,t){var e=[];return t.eachComponent("visualMap",function(a){var s=n.pipelineContext;!a.isTargetSeries(n)||s&&s.large||e.push(pc(a.stateList,a.targetVisuals,Ie(a.getValueState,a),a.getDataDimensionIndex(n.getData())))}),e}},{createOnAllSeries:!0,reset:function(n,t){var e=n.getData(),a=[];t.eachComponent("visualMap",function(s){if(s.isTargetSeries(n)){var o=s.getVisualMeta(Ie(Nc,null,n,s))||{stops:[],outerColors:[]},r=s.getDataDimensionIndex(e);r>=0&&(o.dimension=r,a.push(o))}}),n.getData().setVisual("visualMeta",a)}}];function Nc(n,t,e,a){for(var s=t.targetVisuals[a],o=Se.prepareVisualTypes(s),r={color:qi(n.getData(),"color")},i=0,l=o.length;i<l;i++){var c=o[i],m=s[c==="opacity"?"__alphaForOpacity":c];m&&m.applyVisual(e,u,p)}return r.color;function u(f){return r[f]}function p(f,g){r[f]=g}}var Zn=X;function Ac(n){var t=n&&n.visualMap;ke(t)||(t=t?[t]:[]),Zn(t,function(e){if(e){St(e,"splitList")&&!St(e,"pieces")&&(e.pieces=e.splitList,delete e.splitList);var a=e.pieces;a&&ke(a)&&Zn(a,function(s){gt(s)&&(St(s,"start")&&!St(s,"min")&&(s.min=s.start),St(s,"end")&&!St(s,"max")&&(s.max=s.end))})}})}function St(n,t){return n&&n.hasOwnProperty&&n.hasOwnProperty(t)}var Jn=!1;function Ys(n){Jn||(Jn=!0,n.registerSubTypeDefaulter("visualMap",function(t){return!t.categories&&(!(t.pieces?t.pieces.length>0:t.splitNumber>0)||t.calculable)?"continuous":"piecewise"}),n.registerAction(Rc,Tc),X(Ec,function(t){n.registerVisual(n.PRIORITY.VISUAL.COMPONENT,t)}),n.registerPreprocessor(Ac))}function Mc(n){n.registerComponentModel(bc),n.registerComponentView(wc),Ys(n)}var Ic=function(n){De(t,n);function t(){var e=n!==null&&n.apply(this,arguments)||this;return e.type=t.type,e._pieceList=[],e}return t.prototype.optionUpdated=function(e,a){n.prototype.optionUpdated.apply(this,arguments),this.resetExtent();var s=this._mode=this._determineMode();this._pieceList=[],Lc[this._mode].call(this,this._pieceList),this._resetSelected(e,a);var o=this.option.categories;this.resetVisual(function(r,i){s==="categories"?(r.mappingMethod="category",r.categories=He(o)):(r.dataExtent=this.getExtent(),r.mappingMethod="piecewise",r.pieceList=qe(this._pieceList,function(l){return l=He(l),i!=="inRange"&&(l.visual=null),l}))})},t.prototype.completeVisualOption=function(){var e=this.option,a={},s=Se.listVisualTypes(),o=this.isCategory();X(e.pieces,function(i){X(s,function(l){i.hasOwnProperty(l)&&(a[l]=1)})}),X(a,function(i,l){var c=!1;X(this.stateList,function(m){c=c||r(e,m,l)||r(e.target,m,l)},this),!c&&X(this.stateList,function(m){(e[m]||(e[m]={}))[l]=Ws.get(l,m==="inRange"?"active":"inactive",o)})},this);function r(i,l,c){return i&&i[l]&&i[l].hasOwnProperty(c)}n.prototype.completeVisualOption.apply(this,arguments)},t.prototype._resetSelected=function(e,a){var s=this.option,o=this._pieceList,r=(a?s:e).selected||{};if(s.selected=r,X(o,function(l,c){var m=this.getSelectedMapKey(l);r.hasOwnProperty(m)||(r[m]=!0)},this),s.selectedMode==="single"){var i=!1;X(o,function(l,c){var m=this.getSelectedMapKey(l);r[m]&&(i?r[m]=!1:i=!0)},this)}},t.prototype.getItemSymbol=function(){return this.get("itemSymbol")},t.prototype.getSelectedMapKey=function(e){return this._mode==="categories"?e.value+"":e.index+""},t.prototype.getPieceList=function(){return this._pieceList},t.prototype._determineMode=function(){var e=this.option;return e.pieces&&e.pieces.length>0?"pieces":this.option.categories?"categories":"splitNumber"},t.prototype.setSelected=function(e){this.option.selected=He(e)},t.prototype.getValueState=function(e){var a=Se.findPieceIndex(e,this._pieceList);return a!=null&&this.option.selected[this.getSelectedMapKey(this._pieceList[a])]?"inRange":"outOfRange"},t.prototype.findTargetDataIndices=function(e){var a=[],s=this._pieceList;return this.eachTargetSeries(function(o){var r=[],i=o.getData();i.each(this.getDataDimensionIndex(i),function(l,c){var m=Se.findPieceIndex(l,s);m===e&&r.push(c)},this),a.push({seriesId:o.id,dataIndex:r})},this),a},t.prototype.getRepresentValue=function(e){var a;if(this.isCategory())a=e.value;else if(e.value!=null)a=e.value;else{var s=e.interval||[];a=s[0]===-1/0&&s[1]===1/0?0:(s[0]+s[1])/2}return a},t.prototype.getVisualMeta=function(e){if(this.isCategory())return;var a=[],s=["",""],o=this;function r(m,u){var p=o.getRepresentValue({interval:m});u||(u=o.getValueState(p));var f=e(p,u);m[0]===-1/0?s[0]=f:m[1]===1/0?s[1]=f:a.push({value:m[0],color:f},{value:m[1],color:f})}var i=this._pieceList.slice();if(!i.length)i.push({interval:[-1/0,1/0]});else{var l=i[0].interval[0];l!==-1/0&&i.unshift({interval:[-1/0,l]}),l=i[i.length-1].interval[1],l!==1/0&&i.push({interval:[l,1/0]})}var c=-1/0;return X(i,function(m){var u=m.interval;u&&(u[0]>c&&r([c,u[0]],"outOfRange"),r(u.slice()),c=u[1])},this),{stops:a,outerColors:s}},t.type="visualMap.piecewise",t.defaultOption=Hs(pa.defaultOption,{selected:null,minOpen:!1,maxOpen:!1,align:"auto",itemWidth:20,itemHeight:14,itemSymbol:"roundRect",pieces:null,categories:null,splitNumber:5,selectedMode:"multiple",itemGap:10,hoverLink:!0}),t}(pa),Lc={splitNumber:function(n){var t=this.option,e=Math.min(t.precision,20),a=this.getExtent(),s=t.splitNumber;s=Math.max(parseInt(s,10),1),t.splitNumber=s;for(var o=(a[1]-a[0])/s;+o.toFixed(e)!==o&&e<5;)e++;t.precision=e,o=+o.toFixed(e),t.minOpen&&n.push({interval:[-1/0,a[0]],close:[0,0]});for(var r=0,i=a[0];r<s;i+=o,r++){var l=r===s-1?a[1]:i+o;n.push({interval:[i,l],close:[1,1]})}t.maxOpen&&n.push({interval:[a[1],1/0],close:[0,0]}),kn(n),X(n,function(c,m){c.index=m,c.text=this.formatValueText(c.interval)},this)},categories:function(n){var t=this.option;X(t.categories,function(e){n.push({text:this.formatValueText(e,!0),value:e})},this),es(t,n)},pieces:function(n){var t=this.option;X(t.pieces,function(e,a){gt(e)||(e={value:e});var s={text:"",index:a};if(e.label!=null&&(s.text=e.label),e.hasOwnProperty("value")){var o=s.value=e.value;s.interval=[o,o],s.close=[1,1]}else{for(var r=s.interval=[],i=s.close=[0,0],l=[1,0,1],c=[-1/0,1/0],m=[],u=0;u<2;u++){for(var p=[["gte","gt","min"],["lte","lt","max"]][u],f=0;f<3&&r[u]==null;f++)r[u]=e[p[f]],i[u]=l[f],m[u]=f===2;r[u]==null&&(r[u]=c[u])}m[0]&&r[1]===1/0&&(i[0]=0),m[1]&&r[0]===-1/0&&(i[1]=0),r[0]===r[1]&&i[0]&&i[1]&&(s.value=r[0])}s.visual=Se.retrieveVisuals(e),n.push(s)},this),es(t,n),kn(n),X(n,function(e){var a=e.close,s=[["<","≤"][a[1]],[">","≥"][a[0]]];e.text=e.text||this.formatValueText(e.value!=null?e.value:e.interval,!1,s)},this)}};function es(n,t){var e=n.inverse;(n.orient==="vertical"?!e:e)&&t.reverse()}var kc=function(n){De(t,n);function t(){var e=n!==null&&n.apply(this,arguments)||this;return e.type=t.type,e}return t.prototype.doRender=function(){var e=this.group;e.removeAll();var a=this.visualMapModel,s=a.get("textGap"),o=a.textStyleModel,r=o.getFont(),i=o.getTextColor(),l=this._getItemAlign(),c=a.itemSize,m=this._getViewData(),u=m.endsText,p=Ui(a.get("showLabel",!0),!u),f=!a.get("selectedMode");u&&this._renderEndsText(e,u[0],c,p,l),X(m.viewPieceList,function(g){var b=g.piece,v=new Tt;v.onclick=Ie(this._onItemClick,this,b),this._enableHoverLink(v,g.indexInModelPieceList);var w=a.getRepresentValue(b);if(this._createItemSymbol(v,w,[0,0,c[0],c[1]],f),p){var x=this.visualMapModel.getValueState(w);v.add(new Pt({style:{x:l==="right"?-s:c[0]+s,y:c[1]/2,text:b.text,verticalAlign:"middle",align:l,font:r,fill:i,opacity:x==="outOfRange"?.5:1},silent:f}))}e.add(v)},this),u&&this._renderEndsText(e,u[1],c,p,l),Ki(a.get("orient"),e,a.get("itemGap")),this.renderBackground(e),this.positionGroup(e)},t.prototype._enableHoverLink=function(e,a){var s=this;e.on("mouseover",function(){return o("highlight")}).on("mouseout",function(){return o("downplay")});var o=function(r){var i=s.visualMapModel;i.option.hoverLink&&s.api.dispatchAction({type:r,batch:aa(i.findTargetDataIndices(a),i)})}},t.prototype._getItemAlign=function(){var e=this.visualMapModel,a=e.option;if(a.orient==="vertical")return Qs(e,this.api,e.itemSize);var s=a.align;return(!s||s==="auto")&&(s="left"),s},t.prototype._renderEndsText=function(e,a,s,o,r){if(a){var i=new Tt,l=this.visualMapModel.textStyleModel;i.add(new Pt({style:ea(l,{x:o?r==="right"?s[0]:0:s[0]/2,y:s[1]/2,verticalAlign:"middle",align:o?r:"center",text:a})})),e.add(i)}},t.prototype._getViewData=function(){var e=this.visualMapModel,a=qe(e.getPieceList(),function(i,l){return{piece:i,indexInModelPieceList:l}}),s=e.get("text"),o=e.get("orient"),r=e.get("inverse");return(o==="horizontal"?r:!r)?a.reverse():s&&(s=s.slice().reverse()),{viewPieceList:a,endsText:s}},t.prototype._createItemSymbol=function(e,a,s,o){var r=la(this.getControllerVisual(a,"symbol"),s[0],s[1],s[2],s[3],this.getControllerVisual(a,"color"));r.silent=o,e.add(r)},t.prototype._onItemClick=function(e){var a=this.visualMapModel,s=a.option,o=s.selectedMode;if(o){var r=He(s.selected),i=a.getSelectedMapKey(e);o==="single"||o===!0?(r[i]=!0,X(r,function(l,c){r[c]=c===i})):r[i]=!r[i],this.api.dispatchAction({type:"selectDataRange",from:this.uid,visualMapId:this.visualMapModel.id,selected:r})}},t.type="visualMap.piecewise",t}(js);function zc(n){n.registerComponentModel(Ic),n.registerComponentView(kc),Ys(n)}function $c(n){ca(Mc),ca(zc)}const Oc={class:"flex-grow flex flex-col h-full bg-background relative p-3"},Vc={key:0,class:"mb-4"},Pc={key:1,class:"mb-4"},Dc={key:2,class:"mb-4"},Fc={key:3,class:"flex-grow flex items-center justify-center"},Bc={key:4,class:"flex-grow w-full relative min-h-0"},Hc=se({__name:"ChartRenderer",props:{chartOption:{},chartType:{},xAxisField:{},categoryYField:{},groupByField:{},hasDataMismatchWarning:{type:Boolean},isScatterNumericWarning:{type:Boolean}},setup(n,{expose:t}){ca([Gi,Wi,ji,al,nl,dc,Ju,Qi,Yi,Xi,$c,Ks]);const e=n,a=j(null),s=O(()=>{const o=$e.get(e.chartType);if(!o)return!1;const r=o.fields;return r.categoryX?!!e.xAxisField&&!!e.categoryYField:r.xAxisLabel||r.xAxisNumeric?!!e.xAxisField:!1});return t({chartRef:a}),(o,r)=>{const i=be,l=Bt;return C(),z("div",Oc,[o.hasDataMismatchWarning?(C(),z("div",Vc,[h(d(za),{variant:"destructive",class:"py-2.5 px-4"},{default:y(()=>[h(i,{name:"hugeicons:alert-02",class:"size-4 text-destructive absolute left-4 top-3"}),h(d(Oa),{class:"text-xs font-semibold pl-6"},{default:y(()=>r[0]||(r[0]=[k("Data Mismatch Warning")])),_:1}),h(d($a),{class:"text-[11px] text-muted-foreground pl-6 mt-1"},{default:y(()=>r[1]||(r[1]=[k(" The selected Y-Axis / Value column contains non-numeric strings. ECharts might not render these values correctly. ")])),_:1})]),_:1})])):K("",!0),o.isScatterNumericWarning?(C(),z("div",Pc,[h(d(za),{variant:"destructive",class:"py-2.5 px-4"},{default:y(()=>[h(i,{name:"hugeicons:alert-02",class:"size-4 text-destructive absolute left-4 top-3"}),h(d(Oa),{class:"text-xs font-semibold pl-6"},{default:y(()=>r[2]||(r[2]=[k("Numeric X-Axis Required")])),_:1}),h(d($a),{class:"text-[11px] text-muted-foreground pl-6 mt-1"},{default:y(()=>r[3]||(r[3]=[k(" Scatter plot requires numeric data for the X-Axis. Some string values in your selected column could prevent correct rendering. ")])),_:1})]),_:1})])):K("",!0),o.chartType===d(G).STACKED_BAR&&!o.groupByField?(C(),z("div",Dc,[h(d(za),{class:"py-2.5 px-4 bg-amber-500/10 border-amber-500/20 text-amber-500"},{default:y(()=>[h(i,{name:"hugeicons:information-circle",class:"size-4 text-amber-500 absolute left-4 top-3"}),h(d(Oa),{class:"text-xs font-semibold pl-6"},{default:y(()=>r[4]||(r[4]=[k("Group By Field Recommended")])),_:1}),h(d($a),{class:"text-[11px] text-amber-500/90 pl-6 mt-1"},{default:y(()=>r[5]||(r[5]=[k(' Stacked Bar charts are best utilized when a "Group By" field is specified to create segment stacks. ')])),_:1})]),_:1})])):K("",!0),s.value?(C(),z("div",Bc,[o.chartOption?(C(),F(d(Zi),{key:0,ref_key:"chartRef",ref:a,option:o.chartOption,class:"w-full h-full",autoresize:!0},null,8,["option"])):K("",!0)])):(C(),z("div",Fc,[h(l,{title:"Setup your Chart",desc:"Select the required columns in the settings pane to start visualising your data."},{icon:y(()=>[h(i,{name:"hugeicons:chart-column",class:"size-12 text-muted-foreground/40"})]),_:1})]))])}}});function qc(n,t){const e=j(G.BAR),a=j(""),s=j(""),o=j(""),r=j(""),i=j(ne.NONE),l=j(""),c=j(ve.NONE),m=j(null),u=j(!1),p=j(!0),f=j(""),g=()=>{var b,v;e.value=G.BAR,a.value=((b=t.value[0])==null?void 0:b.aliasFieldName)||"",s.value=((v=t.value[1])==null?void 0:v.aliasFieldName)||"",o.value="",r.value="",i.value=ne.NONE,l.value="",c.value=ve.NONE,m.value=null,u.value=!1,p.value=!0,f.value=`Query ${n.value.seqIndex} Chart`};return ce(e,(b,v)=>{var R;if(b===v)return;const w=$e.get(b);if(!w)return;const x=w.fields;x.categoryX||(a.value=a.value),x.categoryY||(r.value=""),x.valueColumn||(o.value=""),x.groupBy||(l.value=""),x.sortBy||(c.value=ve.NONE);const N=t.value;!a.value&&N.length>0&&(a.value=((R=N[0])==null?void 0:R.aliasFieldName)||"")}),ce(t,b=>{var v,w;b&&b.length>0&&(a.value||(a.value=((v=b[0])==null?void 0:v.aliasFieldName)||""),!s.value&&b.length>1&&(s.value=((w=b[1])==null?void 0:w.aliasFieldName)||""))},{immediate:!0}),ce(n,b=>{f.value=`Query ${b.seqIndex} Chart`},{immediate:!0}),{chartType:e,xAxisField:a,yAxisField:s,valueField:o,categoryYField:r,aggregation:i,groupByField:l,sortBy:c,limitRows:m,showLabels:u,smoothLine:p,chartTitle:f,resetConfig:g}}function Uc({rows:n,xAxisField:t,yAxisField:e,groupByField:a,aggregation:s,sortBy:o=ve.NONE,limitRows:r}){if(!t||!n)return[];const i={};n.forEach(c=>{const m=String(c[t]??"Null"),u=a?String(c[a]??"Default"):void 0;let p=0;if(s===ne.COUNT)p=1;else if(e){const g=Number(c[e]);p=isNaN(g)?0:g}const f=a?`${m}||${u}`:m;i[f]||(i[f]={x:m,group:u,values:[]}),i[f].values.push(p)});let l=Object.values(i).map(c=>{let m=0;if(s===ne.NONE)return c.values.map(u=>({x:c.x,y:u,group:c.group}));if(s===ne.SUM)m=c.values.reduce((u,p)=>u+p,0);else if(s===ne.COUNT)m=c.values.length;else if(s===ne.AVG){const u=c.values.reduce((p,f)=>p+f,0);m=c.values.length?u/c.values.length:0}else s===ne.MIN?m=Math.min(...c.values):s===ne.MAX&&(m=Math.max(...c.values));return{x:c.x,y:parseFloat(m.toFixed(4)),group:c.group}}).flat();return o===ve.X_ASC?l.sort((c,m)=>c.x.localeCompare(m.x)):o===ve.X_DESC?l.sort((c,m)=>m.x.localeCompare(c.x)):o===ve.Y_ASC?l.sort((c,m)=>c.y-m.y):o===ve.Y_DESC&&l.sort((c,m)=>m.y-c.y),r&&(l=l.slice(0,r)),l}function Kc({rows:n,xAxisField:t,yAxisField:e,aggregation:a,sortBy:s=ve.NONE,limitRows:o}){if(!t||!n)return[];const r={};n.forEach(l=>{const c=String(l[t]??"Null");let m=0;if(a===ne.COUNT)m=1;else if(e){const u=Number(l[e]);m=isNaN(u)?0:u}r[c]||(r[c]=[]),r[c].push(m)});let i=Object.entries(r).map(([l,c])=>{let m=0;if(a===ne.NONE||a===ne.SUM)m=c.reduce((u,p)=>u+p,0);else if(a===ne.COUNT)m=c.length;else if(a===ne.AVG){const u=c.reduce((p,f)=>p+f,0);m=c.length?u/c.length:0}else a===ne.MIN?m=Math.min(...c):a===ne.MAX&&(m=Math.max(...c));return{name:l,value:parseFloat(m.toFixed(4))}});return s===ve.X_ASC?i.sort((l,c)=>l.name.localeCompare(c.name)):s===ve.X_DESC?i.sort((l,c)=>c.name.localeCompare(l.name)):s===ve.Y_ASC?i.sort((l,c)=>l.value-c.value):s===ve.Y_DESC&&i.sort((l,c)=>c.value-l.value),o&&(i=i.slice(0,o)),i}function Gc({rows:n,xAxisField:t,categoryYField:e,valueField:a}){if(!t||!e||!n)return{xData:[],yData:[],data:[]};const s=new Set,o=new Set,r=new Map;n.forEach(m=>{const u=String(m[t]??"Null"),p=String(m[e]??"Null"),f=a?Number(m[a]??0):1;s.add(u),o.add(p);const g=`${u}||${p}`;r.set(g,(r.get(g)||0)+(isNaN(f)?0:f))});const i=Array.from(s),l=Array.from(o),c=[];return i.forEach((m,u)=>{l.forEach((p,f)=>{const g=`${m}||${p}`;r.has(g)?c.push([u,f,parseFloat(r.get(g).toFixed(2))]):c.push([u,f,0])})}),{xData:i,yData:l,data:c}}function Wc({rows:n,xAxisField:t,yAxisField:e,aggregation:a,limitRows:s}){if(!t||!n)return{categories:[],values:[],maxVal:1};const o={};n.forEach(m=>{const u=String(m[t]??"Null");let p=0;if(a===ne.COUNT)p=1;else if(e){const f=Number(m[e]);p=isNaN(f)?0:f}o[u]||(o[u]=[]),o[u].push(p)});let r=Object.entries(o).map(([m,u])=>{let p=0;if(a===ne.NONE||a===ne.SUM)p=u.reduce((f,g)=>f+g,0);else if(a===ne.COUNT)p=u.length;else if(a===ne.AVG){const f=u.reduce((g,b)=>g+b,0);p=u.length?f/u.length:0}else a===ne.MIN?p=Math.min(...u):a===ne.MAX&&(p=Math.max(...u));return{name:m,value:parseFloat(p.toFixed(4))}});s&&(r=r.slice(0,s));const i=r.map(m=>m.name),l=r.map(m=>m.value),c=Math.max(...l,1)*1.1;return{categories:i,values:l,maxVal:c}}const ts=n=>String(n??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),jc=n=>Number.isInteger(n)?n.toLocaleString():n.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:2}),Ee=(n,t,e)=>{const a=typeof t=="number"?jc(t):ts(t),s=e!=null&&e.colorDot?`<span style="display:inline-block;width:8px;height:8px;border-radius:50%;background:${e.colorDot};margin-right:6px;"></span>`:"",o=e!=null&&e.bold?"font-weight:600;":"";return`<div style="display:flex;align-items:center;justify-content:space-between;gap:16px;font-weight:400;line-height:1.7;">
|
|
9
|
+
<span style="opacity:.72;">${s}${ts(n)}</span>
|
|
10
|
+
<span style="${o}">${a}</span>
|
|
11
|
+
</div>`},Nt=n=>`<div style="min-width:140px;">${n.join("")}</div>`;function Qc(n,t,e,a){const s=Array.isArray(n)?n:[n],o=s[0]??{},r=o.axisValueLabel??o.axisValue??o.name??"",i=[Ee(t||"X",r)];return s.forEach(l=>{const c=Array.isArray(l.data)?l.data[1]:l.value??l.data;a&&l.seriesName?i.push(Ee(String(l.seriesName),c,{colorDot:l.color})):i.push(Ee(e||"Value",c))}),Nt(i)}function Yc(n,t){const e=Array.isArray(n)?n:[n],a=e[0]??{},s=a.axisValueLabel??a.axisValue??a.name??"",o=[Ee(t||"Category",s)];let r=0;return e.forEach(i=>{const l=Array.isArray(i.data)?i.data[1]:i.value??i.data,c=typeof l=="number"?l:Number(l)||0;r+=c,o.push(Ee(String(i.seriesName??""),l,{colorDot:i.color}))}),o.push(Ee("Total",r,{bold:!0})),Nt(o)}function Xc(n,t,e){const a=[Ee(t||"Category",n.name,{colorDot:n.color}),Ee(e||"Value",n.value),Ee("Percent",`${n.percent}%`,{bold:!0})];return Nt(a)}function Zc(n,t,e){const a=n.data??[],s=[Ee(t||"X",a[0]),Ee(e||"Y",a[1])];return Nt(s)}function Jc(n,t,e,a,s,o){const[r,i,l]=n.data??[],c=[Ee(a||"X",t[r]),Ee(s||"Y",e[i]),Ee(o||"Value",l,{bold:!0})];return Nt(c)}function ed(n,t,e){const a=t.map((s,o)=>{var r;return Ee(s,((r=n.value)==null?void 0:r[o])??e[o])});return Nt(a)}const as=[],ns=[],ss={xData:[],yData:[],data:[]},os={categories:[],values:[],maxVal:1};function Yt(n,t){let e=null;return(...a)=>{e&&clearTimeout(e),e=setTimeout(()=>n(...a),t)}}function td(n,t,e,a,s,o,r,i,l,c){const m=O(()=>{const E=t.value,T=E===G.HEATMAP?s.value:a.value,A=r.value;return(E===G.PIE||E===G.DONUT||E===G.RADAR)&&A===ne.COUNT||!T?!1:n.value.some($=>{const P=$[T];return P==null||P===""?!1:isNaN(Number(P))})}),u=O(()=>t.value!==G.SCATTER||!e.value?!1:n.value.some(E=>{const T=E[e.value];return T==null||T===""?!1:isNaN(Number(T))})),p=new Set([G.LINE,G.BAR,G.HORIZONTAL_BAR,G.AREA,G.STACKED_BAR,G.SCATTER]),f=new Set([G.PIE,G.DONUT]),g=nt(as),b=Yt(()=>{if(!p.has(t.value)){g.value=as;return}g.value=Uc({rows:n.value,xAxisField:e.value,yAxisField:a.value,groupByField:i.value,aggregation:r.value,sortBy:l.value,limitRows:c.value??void 0})},80);ce([n,t,e,a,i,r,l,c],b,{immediate:!0});const v=nt(ns),w=Yt(()=>{if(!f.has(t.value)){v.value=ns;return}v.value=Kc({rows:n.value,xAxisField:e.value,yAxisField:a.value,aggregation:r.value,sortBy:l.value,limitRows:c.value??void 0})},80);ce([n,t,e,a,r,l,c],w,{immediate:!0});const x=nt(ss),N=Yt(()=>{if(t.value!==G.HEATMAP){x.value=ss;return}x.value=Gc({rows:n.value,xAxisField:e.value,categoryYField:o.value,valueField:s.value})},80);ce([n,t,e,o,s],N,{immediate:!0});const R=nt(os),_=Yt(()=>{if(t.value!==G.RADAR){R.value=os;return}R.value=Wc({rows:n.value,xAxisField:e.value,yAxisField:a.value,aggregation:r.value,limitRows:c.value??void 0})},80);return ce([n,t,e,a,r,c],_,{immediate:!0}),{hasDataMismatchWarning:m,isScatterNumericWarning:u,processedData:g,pieData:v,processedHeatmapData:x,processedRadarData:R}}function ad(n){const t=n?"#e2e8f0":"#1e293b";return{isDark:n,labelColor:t,lineColor:n?"rgba(255, 255, 255, 0.08)":"rgba(0, 0, 0, 0.06)",tooltipBg:n?"#1e293b":"#ffffff",tooltipBorderColor:n?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)",tooltipTextStyle:{color:t,fontWeight:400}}}function Ht(n){return{backgroundColor:"transparent",textStyle:{fontFamily:"Outfit, Inter, system-ui, sans-serif",color:n.labelColor},legend:{textStyle:{color:n.labelColor},bottom:5}}}function nd(n){const{theme:t,data:e,xAxisField:a,yAxisField:s,groupByField:o,showLabels:r,smoothLine:i,chartTitle:l,isArea:c=!1,isStacked:m=!1,isHorizontal:u=!1,isLine:p=!1}=n,f=Ht(t),g=Array.from(new Set(e.map(_=>_.group).filter(Boolean))),b=Array.from(new Set(e.map(_=>_.x))),v=()=>m||u?"bar":c||p?"line":"bar";let w=[];if(g.length>0)g.forEach(_=>{const E=b.map(A=>{const $=e.find(P=>P.x===A&&P.group===_);return $?$.y:0}),T=v();w.push({name:String(_),type:T,stack:m?"total":void 0,smooth:i&&T==="line",areaStyle:c?{opacity:.3}:void 0,label:{show:r,position:u?"right":"top",color:t.labelColor},data:E})});else{const _=v();w.push({name:l||s||"Values",type:_,smooth:i&&_==="line",areaStyle:c?{opacity:.3}:void 0,label:{show:r,position:u?"right":"top",color:t.labelColor},data:e.map(E=>E.y)})}let x,N;u?(x={type:"value",axisLabel:{color:t.labelColor},splitLine:{lineStyle:{color:t.lineColor}}},N={type:"category",data:b,axisLabel:{color:t.labelColor},splitLine:{show:!1}}):(x={type:"category",data:b,axisLabel:{color:t.labelColor},splitLine:{show:!1}},N={type:"value",name:s,nameTextStyle:{color:t.labelColor},axisLabel:{color:t.labelColor},splitLine:{lineStyle:{color:t.lineColor}}});const R=m?_=>Yc(_,a):_=>Qc(_,a,s,o);return{...f,tooltip:{trigger:"axis",backgroundColor:t.tooltipBg,borderColor:t.tooltipBorderColor,borderWidth:1,borderRadius:8,textStyle:t.tooltipTextStyle,formatter:R},grid:{left:"10px",right:"15px",top:"30px",bottom:"40px",containLabel:!0},xAxis:x,yAxis:N,series:w}}function sd(n){const{theme:t,data:e,xAxisField:a,yAxisField:s,showLabels:o,isDonut:r}=n;return{...Ht(t),tooltip:{trigger:"item",formatter:l=>Xc(l,a,s),backgroundColor:t.tooltipBg,borderColor:t.tooltipBorderColor,borderWidth:1,borderRadius:8,textStyle:t.tooltipTextStyle},series:[{type:"pie",radius:r?["50%","80%"]:"80%",avoidLabelOverlap:!0,label:{show:o,position:"outside",color:t.labelColor},data:e}]}}function od(n){const{theme:t,data:e,xAxisField:a,yAxisField:s,showLabels:o,chartTitle:r}=n;return{...Ht(t),tooltip:{trigger:"item",formatter:l=>Zc(l,a,s),backgroundColor:t.tooltipBg,borderColor:t.tooltipBorderColor,borderWidth:1,borderRadius:8,textStyle:t.tooltipTextStyle},grid:{left:"10px",right:"15px",top:"30px",bottom:"40px",containLabel:!0},xAxis:{type:"value",name:a,nameTextStyle:{color:t.labelColor},axisLabel:{color:t.labelColor},splitLine:{lineStyle:{color:t.lineColor}}},yAxis:{type:"value",name:s,nameTextStyle:{color:t.labelColor},axisLabel:{color:t.labelColor},splitLine:{lineStyle:{color:t.lineColor}}},series:[{name:r||s||"Values",type:"scatter",label:{show:o,position:"top",color:t.labelColor},data:e.map(l=>[Number(l.x),l.y])}]}}function rd(n){const{theme:t,xData:e,yData:a,data:s,xAxisField:o,categoryYField:r,valueField:i,showLabels:l,chartTitle:c}=n,m=Ht(t),u=s.length?Math.min(...s.map(f=>f[2])):0,p=s.length?Math.max(...s.map(f=>f[2])):100;return{...m,tooltip:{trigger:"item",formatter:f=>Jc(f,e,a,o,r,i),backgroundColor:t.tooltipBg,borderColor:t.tooltipBorderColor,borderWidth:1,borderRadius:8,textStyle:t.tooltipTextStyle},grid:{left:"10px",right:"15px",top:"20px",bottom:"60px",containLabel:!0},xAxis:{type:"category",data:e,splitArea:{show:!0},axisLabel:{color:t.labelColor}},yAxis:{type:"category",data:a,splitArea:{show:!0},axisLabel:{color:t.labelColor}},visualMap:{min:u,max:p,calculable:!0,orient:"horizontal",left:"center",bottom:25,textStyle:{color:t.labelColor},inRange:{color:t.isDark?["#1e3a8a","#3b82f6","#60a5fa","#93c5fd"]:["#eff6ff","#bfdbfe","#60a5fa","#1d4ed8"]}},series:[{name:c||"Heatmap Value",type:"heatmap",data:s,label:{show:l,color:t.isDark?"#fff":"#000"},emphasis:{itemStyle:{shadowBlur:10,shadowColor:"rgba(0, 0, 0, 0.5)"}}}]}}function id(n){const{theme:t,categories:e,values:a,maxVal:s,showLabels:o,chartTitle:r}=n;return{...Ht(t),tooltip:{trigger:"item",formatter:l=>ed(l,e,a),backgroundColor:t.tooltipBg,borderColor:t.tooltipBorderColor,borderWidth:1,borderRadius:8,textStyle:t.tooltipTextStyle},radar:{indicator:e.map(l=>({name:l,max:s})),splitArea:{show:!0,areaStyle:{color:t.isDark?["rgba(255,255,255,0.02)","rgba(255,255,255,0.04)"]:["rgba(0,0,0,0.01)","rgba(0,0,0,0.02)"]}},axisLine:{lineStyle:{color:t.lineColor}},splitLine:{lineStyle:{color:t.lineColor}}},series:[{name:r||"Radar Chart",type:"radar",data:[{value:a,name:r||"Radar Data"}],label:{show:o,color:t.labelColor},areaStyle:{opacity:.2}}]}}function ld(n,t,e,a,s,o,r,i,l,c,m,u,p,f){return{chartOption:O(()=>{const b=ad(c.value),v=n.value;if(v===G.PIE||v===G.DONUT)return sd({theme:b,data:u.value,xAxisField:t.value,yAxisField:e.value,showLabels:r.value,isDonut:v===G.DONUT});if(v===G.HEATMAP){const{xData:w,yData:x,data:N}=p.value;return rd({theme:b,xData:w,yData:x,data:N,xAxisField:t.value,categoryYField:s.value,valueField:a.value,showLabels:r.value,chartTitle:l.value})}if(v===G.RADAR){const{categories:w,values:x,maxVal:N}=f.value;return id({theme:b,categories:w,values:x,maxVal:N,showLabels:r.value,chartTitle:l.value})}return v===G.SCATTER?od({theme:b,data:m.value,xAxisField:t.value,yAxisField:e.value,showLabels:r.value,chartTitle:l.value}):nd({theme:b,data:m.value,xAxisField:t.value,yAxisField:e.value,groupByField:o.value,showLabels:r.value,smoothLine:i.value,chartTitle:l.value,isLine:v===G.LINE,isArea:v===G.AREA,isStacked:v===G.STACKED_BAR,isHorizontal:v===G.HORIZONTAL_BAR})})}}const ud={class:"h-full flex w-full overflow-hidden text-sm"},cd=se({__name:"ChartBuilderContainer",props:{activeTab:{},activeTabColumns:{},formattedData:{}},setup(n){const t=n,e=qo(),a=O(()=>e.value==="dark"),{chartType:s,xAxisField:o,yAxisField:r,valueField:i,categoryYField:l,aggregation:c,groupByField:m,sortBy:u,limitRows:p,showLabels:f,smoothLine:g,chartTitle:b,resetConfig:v}=qc(_a(t,"activeTab"),_a(t,"activeTabColumns")),{hasDataMismatchWarning:w,isScatterNumericWarning:x,processedData:N,pieData:R,processedHeatmapData:_,processedRadarData:E}=td(_a(t,"formattedData"),s,o,r,i,l,c,m,u,p),{chartOption:T}=ld(s,o,r,i,l,m,f,g,b,a,N,R,_,E),A=j(null),$=()=>{var Z;const P=(Z=A.value)==null?void 0:Z.chartRef;if(!P)return;const L=P.getDataURL({type:"png",pixelRatio:2,backgroundColor:a.value?"#1e293b":"#ffffff"}),M=document.createElement("a"),W=new Date().toISOString().slice(0,19).replace(/:/g,"-");M.download=`chart_${b.value||"builder"}_${W}.png`,M.href=L,M.click()};return(P,L)=>(C(),z("div",ud,[h(d(Hc),{ref_key:"chartRendererRef",ref:A,"chart-option":d(T),"chart-type":d(s),"x-axis-field":d(o),"category-y-field":d(l),"group-by-field":d(m),"has-data-mismatch-warning":d(w),"is-scatter-numeric-warning":d(x)},null,8,["chart-option","chart-type","x-axis-field","category-y-field","group-by-field","has-data-mismatch-warning","is-scatter-numeric-warning"]),h(d(qu),{chartTitle:d(b),"onUpdate:chartTitle":L[0]||(L[0]=M=>_e(b)?b.value=M:null),chartType:d(s),"onUpdate:chartType":L[1]||(L[1]=M=>_e(s)?s.value=M:null),xAxisField:d(o),"onUpdate:xAxisField":L[2]||(L[2]=M=>_e(o)?o.value=M:null),yAxisField:d(r),"onUpdate:yAxisField":L[3]||(L[3]=M=>_e(r)?r.value=M:null),valueField:d(i),"onUpdate:valueField":L[4]||(L[4]=M=>_e(i)?i.value=M:null),categoryYField:d(l),"onUpdate:categoryYField":L[5]||(L[5]=M=>_e(l)?l.value=M:null),aggregation:d(c),"onUpdate:aggregation":L[6]||(L[6]=M=>_e(c)?c.value=M:null),groupByField:d(m),"onUpdate:groupByField":L[7]||(L[7]=M=>_e(m)?m.value=M:null),sortBy:d(u),"onUpdate:sortBy":L[8]||(L[8]=M=>_e(u)?u.value=M:null),limitRows:d(p),"onUpdate:limitRows":L[9]||(L[9]=M=>_e(p)?p.value=M:null),showLabels:d(f),"onUpdate:showLabels":L[10]||(L[10]=M=>_e(f)?f.value=M:null),smoothLine:d(g),"onUpdate:smoothLine":L[11]||(L[11]=M=>_e(g)?g.value=M:null),"active-tab-columns":P.activeTabColumns,onReset:d(v),onExport:$},null,8,["chartTitle","chartType","xAxisField","yAxisField","valueField","categoryYField","aggregation","groupByField","sortBy","limitRows","showLabels","smoothLine","active-tab-columns","onReset"])]))}});let fa=0;const dd=()=>(fa+=1,`ep-${fa}`),rs=n=>n==null?"":typeof n=="string"?n:typeof n=="number"||typeof n=="boolean"?String(n):JSON.stringify(n),md=n=>{const t=(n["Shared Hit Blocks"]??0)+(n["Local Hit Blocks"]??0),e=(n["Shared Read Blocks"]??0)+(n["Local Read Blocks"]??0),a=t+e;if(!(a<=0))return Number((t/a).toFixed(4))},pd=(n,t)=>{const e=t["Plan Rows"],a=t["Actual Rows"];if(e!==void 0&&a!==void 0&&e>0&&a>=0){n.estimateRatio=Number((a/e).toFixed(2));const s=a/e;s>10?n.rowEstimateAccuracy="underestimate":s<.1?n.rowEstimateAccuracy="overestimate":n.rowEstimateAccuracy="accurate"}n.hitReadRatio=md(t),(t["Total Cost"]!==void 0&&t["Total Cost"]>1e3||t["Actual Total Time"]!==void 0&&t["Actual Total Time"]>100)&&(n.isExpensive=!0)},fd=n=>{let t=0,e="";for(const s of n){const o=s.children.reduce((i,l)=>i+(l["Actual Total Time"]??0)*(l["Actual Loops"]??1),0)/(s["Actual Loops"]??1),r=Math.max(0,(s["Actual Total Time"]??0)-o);r>t&&(t=r,e=s.id)}const a=n.find(s=>s.id===e);a&&(a.isSlowest=!0)},Xs=(n,t,e)=>{const{Plans:a,...s}=n,o=n["Node Type"]||"Unknown Node",r=n["Relation Name"],i={...s,id:dd(),index:fa,label:r?`${o} on ${r}`:o,estimateRatio:void 0,hitReadRatio:void 0,isExpensive:!1,isSlowest:!1,rowEstimateAccuracy:void 0,depth:t,children:(a??[]).map(l=>Xs(l,t+1,e))};return e.push(i),pd(i,n),i},vd=(n,t)=>{fa=0;const e=[],a=Xs(n.Plan,0,e),s={"Planning Time":n["Planning Time"],"Execution Time":n["Execution Time"],totalCost:a["Total Cost"],triggersInfo:(n.Triggers??[]).map(rs),jitInfo:[],settingsInfo:n.Settings?Object.entries(n.Settings).map(([r,i])=>`${r}: ${rs(i)}`):[],rawText:t};fd(e);const o=[...e].sort((r,i)=>r.index-i.index);return{root:a,summary:s,allNodes:o}},hd=n=>{const t={triggersInfo:[],jitInfo:[],settingsInfo:[],rawText:n},e=n.match(/Planning Time:\s*(\d+\.?\d*)\s*ms/i),a=n.match(/Execution Time:\s*(\d+\.?\d*)\s*ms/i);return e&&(t["Planning Time"]=Number.parseFloat(e[1])),a&&(t["Execution Time"]=Number.parseFloat(a[1])),{root:null,summary:t,allNodes:[]}},Qa=n=>{if(!n)return null;if(typeof n=="string")try{return Qa(JSON.parse(n))}catch{return null}return Array.isArray(n)?n.length?Qa(n[0]):null:typeof n=="object"&&n!==null&&"Plan"in n&&typeof n.Plan=="object"?n:null},Zs=(n,t)=>{var e;if(!(n!=null&&n.length))return null;if(Array.isArray(n[0]))return n[0][0]??null;if(typeof n[0]=="object"&&n[0]!==null){const a=n[0],s=Object.keys(a).find(o=>o.toUpperCase()==="QUERY PLAN")||((e=t==null?void 0:t[0])==null?void 0:e.name)||Object.keys(a)[0];return s?a[s]??null:null}return n[0]??null},gd=(n,t)=>{const e=Zs(n,t);return e==null?"":typeof e=="string"?e:JSON.stringify(e,null,2)},yd=n=>{const t=typeof n=="string"?n:JSON.stringify(n,null,2),e=Qa(n);return e?vd(e,t):hd(t)},is={"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"},Ae=n=>n?String(n).replace(/^[\[]|[\]]$/g,"").replace(/"/g,"").trim():"",bd=n=>n==="Seq Scan"?"bad":is[n]?is[n]:n.includes("Join")?"join":n.includes("Scan")?"scan":n.includes("Aggregate")?"agg":n.includes("Sort")?"sort":"other",ls=(n,t,e)=>{for(let a=t+1;a<n.length;a++){const s=n[a].depth??0;if(s<e)return!1;if(s===e)return!0}return!1},xd=(n,t)=>{const a=n[t].depth??0;if(a===0)return"";const s=[];for(let r=1;r<a;r++)s.push(ls(n,t,r)?"│ ":" ");const o=!ls(n,t,a);return s.push(o?"└─ ":"├─ "),s.join("")},Sd=n=>{const t=Ae(n.hashCond),e=Ae(n.mergeCond),a=Ae(n.joinFilter),s=Ae(n.joinType).toLowerCase();if(s||t||e||a){const b=t||e||a,v=s?`${s} `:"";return{label:b?`${v}on ${b}`.trim():`${v}join`.trim(),kind:"join"}}const o=Ae(n.indexCond),r=Ae(n.recheckCond),i=Ae(n.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 l=Ae(n.sortKey);if(l)return{label:`by ${l}`,kind:"sort"};const c=Ae(n.groupKey),m=Ae(n.hashKey);if(c||m)return{label:`by ${c||m}`,kind:"group"};const u=Ae(n.oneTimeFilter);if(u)return{label:`one-time: ${u}`,kind:"relation"};const p=Ae(n.filter);if(p)return{label:`filter: ${p}`,kind:"relation"};const f=Ae(n.cteName);if(f)return{label:`cte: ${f}`,kind:"relation"};const g=Ae(n.subplanName);if(g)return{label:`subplan: ${g}`,kind:"relation"};if(n.relation){const b=n.alias&&n.alias!==n.relation?` (${n.alias})`:"";return{label:`on ${n.relation}${b}`,kind:"relation"}}return{label:"",kind:""}},Cd=n=>[...n].map(t=>{var c,m;const e=t["Plan Rows"]||0,a=t["Actual Rows"]||0,s=t.estimateRatio,o=t["Actual Startup Time"]||0,r=t["Plan Width"]||0,i=t.rowEstimateAccuracy||"accurate",l=[`Node: ${t["Node Type"]}`,t["Relation Name"]?`Relation: ${t["Relation Name"]}`:"",`Depth: ${t.depth}`,`Startup time: ${o.toFixed(3)} ms`,`Total time: ${(t["Actual Total Time"]||0).toFixed(3)} ms`,`Actual rows: ${a.toLocaleString()}`,`Plan rows: ${e.toLocaleString()}`,s!==void 0?`Estimate ratio: ${s}x (${i})`:"Estimate ratio: -",`Total cost: ${(t["Total Cost"]||0).toFixed(2)}`,`Plan width: ${r}`,`Loops: ${(t["Actual Loops"]||0).toLocaleString()}`,`Slowest: ${t.isSlowest?"yes":"no"}`,`Expensive: ${t.isExpensive?"yes":"no"}`].filter(Boolean).join(`
|
|
12
|
+
`);return{id:t.id,order:t.index,nodeType:t["Node Type"],relation:t["Relation Name"],alias:t.Alias,sortKey:((c=t["Sort Key"])==null?void 0:c.join(", "))??"",joinType:t["Join Type"]??"",groupKey:((m=t["Group Key"])==null?void 0:m.join(", "))??"",hashKey:"",filter:t.Filter??"",joinFilter:"",oneTimeFilter:"",indexCond:"",hashCond:t["Hash Cond"]??"",mergeCond:t["Merge Cond"]??"",recheckCond:"",tidCond:"",cteName:"",subplanName:"",timeMs:t["Actual Total Time"]||0,rows:a,planRows:e,estimateRatio:s,cost:t["Total Cost"]||0,width:r,loops:t["Actual Loops"]||0,depth:t.depth,indentPx:t.depth*16,hitReadRatio:t.hitReadRatio,isSlowest:t.isSlowest,isExpensive:t.isExpensive,tooltipLines:l}}),wd=n=>{const t=n.reduce((e,a)=>e+(a.timeMs||0),0)||1;return n.map((e,a)=>{const s=xd(n,a),{label:o,kind:r}=Sd(e),i=e.isSlowest?"slowest":e.isExpensive?"expensive":"normal";return{order:e.order,timeMs:e.timeMs,rows:e.rows,planRows:e.planRows,estimateRatioValue:e.estimateRatio,cost:e.cost,width:e.width,loops:e.loops,hitReadRatio:e.hitReadRatio,isSlowest:e.isSlowest,isExpensive:e.isExpensive,orderLabel:`${e.order}`,queryPercentLabel:`${(e.timeMs/t*100).toFixed(2)}%`,timeSpentLabel:`${e.timeMs.toFixed(3)} ms`,rowsLabel:e.rows.toLocaleString(),planRowsLabel:e.planRows.toLocaleString(),estimateLabel:e.estimateRatio!==void 0?`${e.estimateRatio}×`:"-",costLabel:e.cost.toFixed(2),widthLabel:e.width,loopsLabel:e.loops.toLocaleString(),hitReadRatioLabel:e.hitReadRatio!==void 0?`${(e.hitReadRatio*100).toFixed(2)}%`:"-",statusLabel:i,treePrefix:s,nodeType:e.nodeType,nodeTypeCategory:bd(e.nodeType),contextLabel:o,contextKind:r}})},_d={class:"flex items-center text-xs h-full w-full overflow-hidden whitespace-nowrap"},Rd={key:0,class:"text-muted-foreground shrink-0 whitespace-pre",style:{"font-family":"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace !important"}},Td={key:1,class:"font-normal shrink-0"},Ed={key:2,class:"text-xxs pl-0.5 text-muted-foreground truncate shrink min-w-0"},Nd=se({__name:"ExplainOperationCell",props:{params:{}},setup(n){const t=n,e=O(()=>{var a;return((a=t.params)==null?void 0:a.data)??{}});return(a,s)=>(C(),z("div",_d,[e.value.treePrefix?(C(),z("span",Rd,U(e.value.treePrefix),1)):K("",!0),e.value.nodeType?(C(),z("span",Td,U(e.value.nodeType),1)):K("",!0),e.value.contextLabel?(C(),z("span",Ed,U(e.value.contextLabel),1)):K("",!0)]))}}),Ad={class:"h-full p-2"},Md=se({__name:"ExplainGridPane",props:{nodes:{}},setup(n){const t=n,e=O(()=>Cd(t.nodes)),a=O(()=>wd(e.value)),s=O(()=>[{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 l;const i=Number((l=r.data)==null?void 0:l.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:Nd};return(r,i)=>{const l=qs;return C(),z("div",Ad,[h(l,{class:"h-full","column-defs":s.value,"row-data":a.value,components:o,"enable-copy-hotkey":!1},null,8,["column-defs","row-data"])])}}});var ht=(n=>(n.GRID="grid",n.TIMELINE="time-line",n.RAW="raw",n))(ht||{});const Id=[{value:ht.TIMELINE,label:"Timeline",icon:"hugeicons:chart-line-data-01"},{value:ht.GRID,label:"Grid",icon:"hugeicons:grid-table"},{value:ht.RAW,label:"Raw",icon:"hugeicons:3rd-bracket"}],Ld={class:"flex items-center justify-between px-3 py-2 border-b shrink-0"},kd={class:"flex items-center gap-3 min-w-0"},zd={class:"flex items-center gap-2 flex-wrap"},$d={class:"flex flex-col gap-1 max-w-[250px] sm:max-w-xs"},Od={class:"text-[11px] text-muted-foreground list-disc pl-3 break-words whitespace-normal"},Vd={class:"flex flex-col gap-1 max-w-[250px] sm:max-w-xs"},Pd={class:"text-[11px] text-muted-foreground list-disc pl-3 break-words whitespace-normal"},Dd={class:"flex flex-col gap-1 max-w-[250px] sm:max-w-xs"},Fd={class:"text-[11px] text-muted-foreground list-disc pl-3 break-words whitespace-normal"},Bd={class:"flex items-center gap-2 shrink-0"},Hd=se({__name:"ExplainPlanHeader",props:ia({summaryStats:{},isExpanded:{type:Boolean}},{modelValue:{required:!0},modelModifiers:{}}),emits:ia(["toggle-expand"],["update:modelValue"]),setup(n,{emit:t}){const e=t,a=Me(n,"modelValue");return(s,o)=>{const r=be,i=Uo,l=Oe,c=Ve,m=Pe,u=Wo,p=Go,f=Ko,g=Le;return C(),z("div",Ld,[S("div",kd,[h(r,{name:"hugeicons:analytics-up",class:"size-4 text-muted-foreground"}),o[6]||(o[6]=S("span",{class:"text-sm font-medium"},"Execution Plan",-1)),S("div",zd,[s.summaryStats.executionTime!==void 0?(C(),F(i,{key:0,variant:"outline",class:"text-[11px] h-5 gap-1"},{default:y(()=>[h(r,{name:"hugeicons:clock-01",class:"size-3"}),k(" "+U(d(Dt)(s.summaryStats.executionTime)),1)]),_:1})):K("",!0),s.summaryStats.planningTime!==void 0?(C(),F(i,{key:1,variant:"outline",class:"text-[11px] h-5 gap-1"},{default:y(()=>[k(" Planning: "+U(d(Dt)(s.summaryStats.planningTime)),1)]),_:1})):K("",!0),s.summaryStats.nodeCount>0?(C(),F(m,{key:2},{default:y(()=>{var b;return[h(l,{"as-child":""},{default:y(()=>[h(i,{variant:"outline",class:"text-[11px] h-5 gap-1 cursor-help"},{default:y(()=>[k(U(s.summaryStats.nodeCount)+" nodes ",1)]),_:1})]),_:1}),(b=s.summaryStats.allNodes)!=null&&b.length?(C(),F(c,{key:0},{default:y(()=>[S("div",$d,[o[2]||(o[2]=S("span",{class:"font-medium text-xs"},"Nodes:",-1)),S("ul",Od,[(C(!0),z(ae,null,ue(s.summaryStats.allNodes,v=>(C(),z("li",{key:v.id},U(v.label),1))),128))])])]),_:1})):K("",!0)]}),_:1})):(C(),F(i,{key:3,variant:"outline",class:"text-[11px] h-5 gap-1"},{default:y(()=>o[3]||(o[3]=[k(" 0 nodes ")])),_:1})),s.summaryStats.expensiveCount>0?(C(),F(m,{key:4},{default:y(()=>{var b;return[h(l,{"as-child":""},{default:y(()=>[h(i,{variant:"outline",class:"text-[11px] h-5 gap-1 border-amber-300 text-amber-700 dark:text-amber-400 cursor-help"},{default:y(()=>[k(U(s.summaryStats.expensiveCount)+" expensive ",1)]),_:1})]),_:1}),(b=s.summaryStats.expensiveNodes)!=null&&b.length?(C(),F(c,{key:0},{default:y(()=>[S("div",Vd,[o[4]||(o[4]=S("span",{class:"font-medium text-xs"},"Expensive Nodes:",-1)),S("ul",Pd,[(C(!0),z(ae,null,ue(s.summaryStats.expensiveNodes,v=>(C(),z("li",{key:v.id},U(v.label),1))),128))])])]),_:1})):K("",!0)]}),_:1})):K("",!0),s.summaryStats.slowCount>0?(C(),F(m,{key:5},{default:y(()=>{var b;return[h(l,{"as-child":""},{default:y(()=>[h(i,{variant:"outline",class:"text-[11px] h-5 gap-1 border-red-300 text-red-700 dark:text-red-400 cursor-help"},{default:y(()=>[k(U(s.summaryStats.slowCount)+" slowest ",1)]),_:1})]),_:1}),(b=s.summaryStats.slowNodes)!=null&&b.length?(C(),F(c,{key:0},{default:y(()=>[S("div",Dd,[o[5]||(o[5]=S("span",{class:"font-medium text-xs"},"Slowest Node(s):",-1)),S("ul",Fd,[(C(!0),z(ae,null,ue(s.summaryStats.slowNodes,v=>(C(),z("li",{key:v.id},U(v.label),1))),128))])])]),_:1})):K("",!0)]}),_:1})):K("",!0)])]),S("div",Bd,[h(f,{modelValue:a.value,"onUpdate:modelValue":o[0]||(o[0]=b=>a.value=b),class:"gap-0"},{default:y(()=>[h(p,{size:"xxs"},{default:y(()=>[(C(!0),z(ae,null,ue(d(Id),b=>(C(),F(u,{size:"xxs",key:b.value,value:b.value,class:"rounded-sm cursor-pointer"},{default:y(()=>[h(r,{name:b.icon,class:"size-3.5!"},null,8,["name"]),k(" "+U(b.label),1)]),_:2},1032,["value"]))),128))]),_:1})]),_:1},8,["modelValue"]),h(g,{variant:"outline",size:"iconSm",onClick:o[1]||(o[1]=b=>e("toggle-expand"))},{default:y(()=>[h(r,{name:s.isExpanded?"hugeicons:arrow-shrink":"hugeicons:arrow-expand",class:"size-3.5"},null,8,["name"])]),_:1})])])}}}),qd={class:"h-full overflow-auto p-2"},Ud=se({__name:"ExplainRawPane",props:{rawText:{}},setup(n){const t=n,e=O(()=>{const a=t.rawText.trim();return a.startsWith("{")||a.startsWith("[")?"json":"sql"});return(a,s)=>{const o=xa;return C(),z("div",qd,[h(o,{code:a.rawText,language:e.value,"max-height":"100%"},null,8,["code","language"])])}}}),Kd={class:"h-full p-2"},Gd={class:"rounded-lg border p-2 flex flex-col h-full min-h-0"},Wd={class:"flex justify-between items-center mb-4"},jd={class:"text-sm font-bold text-muted-foreground uppercase flex items-center gap-2"},Qd={key:0,class:"h-full grid place-items-center text-sm text-muted-foreground"},Yd={key:1,class:"flex-1 overflow-auto relative"},Xd={class:"min-w-[680px] text-xs"},Zd={class:"flex border-b pb-2 mb-2 sticky top-0 bg-background z-10 font-medium text-muted-foreground"},Jd={class:"flex-1 relative h-4"},em={class:"absolute right-0"},tm={class:"pb-2"},am=["onMouseenter"],nm={class:"w-[28%] min-w-[190px] max-w-[260px] px-2 flex items-center overflow-hidden"},sm={class:"truncate flex items-center gap-1"},om={class:"font-mono text-xxs text-right shrink-0 text-muted-foreground"},rm={class:"flex flex-col truncate"},im=["title"],lm={key:0,class:"text-muted-foreground text-xxs truncate"},um={key:0},cm={class:"flex-1 relative h-6 mx-2"},dm={class:"space-y-2 text-xs"},mm={class:"font-semibold flex items-center gap-1"},pm={class:"grid grid-cols-2 gap-x-3 gap-y-1 text-[11px]"},fm={class:"font-mono"},vm={class:"font-mono"},hm={class:"font-mono"},gm={class:"font-mono"},ym={class:"font-mono"},bm={class:"font-mono"},xm={class:"font-mono"},Sm={class:"font-mono"},Cm={key:0,class:"text-[11px] text-muted-foreground"},wm={key:0},Xt=14,_m=se({__name:"ExplainTimelineChartPane",props:{nodes:{},totalTime:{}},setup(n){const t=n,e=j(null),a=O(()=>{const u=[...t.nodes].filter(f=>typeof f["Actual Startup Time"]=="number"&&typeof f["Actual Total Time"]=="number").map(f=>{const g=f["Actual Startup Time"]||0,b=f["Actual Total Time"]||0,v=Math.max(0,b-g);return{id:f.id,nodeType:f["Node Type"],relation:f["Relation Name"],alias:f.Alias,depth:f.depth,actualRows:f["Actual Rows"],actualLoops:f["Actual Loops"],planRows:f["Plan Rows"],totalCost:f["Total Cost"],start:g,end:b,duration:v}}),p=(f,g)=>{for(let b=f+1;b<u.length;b+=1){const v=u[b].depth;if(v<g)return!1;if(v===g)return!0}return!1};return u.map((f,g)=>{const b=[];for(let v=1;v<f.depth;v+=1)p(g,v)&&b.push(v);return{...f,continuationLevels:b,hasNextSibling:f.depth>0?p(g,f.depth):!1}})}),s=O(()=>{const u=a.value.length?Math.max(...a.value.map(p=>p.end)):0;return Math.max(t.totalTime||0,u,1)}),o=(u,p)=>{const f=s.value>0?s.value:1,g=u/f*100,b=Math.max(p/f*100,.5);return{left:`${g}%`,width:`${b}%`}},r=u=>{const p=s.value>0?s.value:1;return(u/p*100).toFixed(2)},i=u=>`${Math.max(u,0)*Xt}px`,l=u=>`${(u-1)*Xt+Xt/2}px`,c=`${Xt/2}px`,m=u=>u==="Seq Scan"?"bg-gray-400 dark:bg-gray-600":u.includes("Scan")?"bg-gray-300 dark:bg-gray-700":u.includes("Join")?"bg-gray-500 dark:bg-gray-500":u==="Sort"?"bg-gray-300 dark:bg-gray-600":(u.includes("Aggregate"),"bg-gray-400 dark:bg-gray-600");return(u,p)=>{const f=be,g=Oe,b=Ve,v=Pe;return C(),z("div",Kd,[S("div",Gd,[S("div",Wd,[S("h3",jd,[h(f,{name:"hugeicons:clock-01",class:"size-4"}),p[1]||(p[1]=k(" Execution Plan Timeline "))]),p[2]||(p[2]=S("span",{class:"text-xs text-muted-foreground"},"Hover for details",-1))]),a.value.length===0?(C(),z("div",Qd," No timeline data available ")):(C(),z("div",Yd,[S("div",Xd,[S("div",Zd,[p[7]||(p[7]=S("div",{class:"w-[28%] min-w-[190px] max-w-[260px] pl-2"}," Node Hierarchy ",-1)),S("div",Jd,[p[3]||(p[3]=S("div",{class:"absolute left-0"},"0ms",-1)),S("div",em,U(d(Kt)(s.value)),1),p[4]||(p[4]=S("div",{class:"absolute left-1/4 border-l h-full"},null,-1)),p[5]||(p[5]=S("div",{class:"absolute left-1/2 border-l h-full"},null,-1)),p[6]||(p[6]=S("div",{class:"absolute left-3/4 border-l h-full"},null,-1))])]),S("div",tm,[(C(!0),z(ae,null,ue(a.value,w=>(C(),z("div",{key:w.id,class:ye(["flex items-center group rounded transition-colors hover:bg-muted",e.value===w.id?"bg-muted/40":""]),onMouseenter:x=>e.value=w.id,onMouseleave:p[0]||(p[0]=x=>e.value=null)},[S("div",nm,[S("div",{class:"relative shrink-0 h-7",style:Ct({width:i(w.depth)})},[(C(!0),z(ae,null,ue(w.continuationLevels,x=>(C(),z("div",{key:`${w.id}-v-${x}`,class:"absolute top-0 bottom-0 border-l border-dashed border-muted-foreground/35",style:Ct({left:l(x)})},null,4))),128)),w.depth>0?(C(),z(ae,{key:0},[S("div",{class:"absolute top-0 border-l border-dashed border-muted-foreground/45",style:Ct({left:l(w.depth),height:w.hasNextSibling?"100%":"50%"})},null,4),S("div",{class:"absolute top-1/2 -translate-y-1/2 border-t border-dashed border-muted-foreground/45",style:Ct({left:l(w.depth),width:c})},null,4)],64)):K("",!0)],4),S("div",sm,[S("span",om," #"+U(w.id.replace("ep-","")),1),S("div",rm,[S("span",{class:"truncate font-medium text-sm",title:w.nodeType},U(w.nodeType),9,im),w.relation?(C(),z("span",lm,[k(U(w.relation)+" ",1),w.alias&&w.alias!==w.relation?(C(),z("span",um,"("+U(w.alias)+")",1)):K("",!0)])):K("",!0)])])]),S("div",cm,[p[16]||(p[16]=jo('<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)),h(v,null,{default:y(()=>[h(g,{"as-child":""},{default:y(()=>[S("div",{class:ye(["absolute top-1 bottom-1 rounded-sm transition-all shadow-sm opacity-90 cursor-default",[m(w.nodeType),e.value===w.id?"brightness-105 ring-2 ring-border z-10":""]]),style:Ct(o(w.start,w.duration))},null,6)]),_:2},1024),h(b,{side:"top","side-offset":8,class:"max-w-[360px]"},{default:y(()=>{var x,N,R,_;return[S("div",dm,[S("div",mm,[h(f,{name:"hugeicons:flow-square",class:"size-3.5"}),k(" "+U(w.nodeType),1)]),S("div",pm,[p[8]||(p[8]=S("span",{class:"text-muted-foreground"},"Start",-1)),S("span",fm,U(d(Kt)(w.start)),1),p[9]||(p[9]=S("span",{class:"text-muted-foreground"},"End",-1)),S("span",vm,U(d(Kt)(w.end)),1),p[10]||(p[10]=S("span",{class:"text-muted-foreground"},"Duration",-1)),S("span",hm,U(d(Kt)(w.duration)),1),p[11]||(p[11]=S("span",{class:"text-muted-foreground"},"Share",-1)),S("span",gm,U(r(w.duration))+"%",1),p[12]||(p[12]=S("span",{class:"text-muted-foreground"},"Rows",-1)),S("span",ym,U(((x=w.actualRows)==null?void 0:x.toLocaleString())??"-"),1),p[13]||(p[13]=S("span",{class:"text-muted-foreground"},"Plan Rows",-1)),S("span",bm,U(((N=w.planRows)==null?void 0:N.toLocaleString())??"-"),1),p[14]||(p[14]=S("span",{class:"text-muted-foreground"},"Loops",-1)),S("span",xm,U(((R=w.actualLoops)==null?void 0:R.toLocaleString())??"-"),1),p[15]||(p[15]=S("span",{class:"text-muted-foreground"},"Total Cost",-1)),S("span",Sm,U(((_=w.totalCost)==null?void 0:_.toFixed(2))??"-"),1)]),w.relation?(C(),z("div",Cm,[k(" Relation: "+U(w.relation)+" ",1),w.alias&&w.alias!==w.relation?(C(),z("span",wm,"("+U(w.alias)+")",1)):K("",!0)])):K("",!0)])]}),_:2},1024)]),_:2},1024)])],42,am))),128))])])]))])])}}}),Rm={class:"h-full min-h-0"},Tm={key:0,class:"h-full flex flex-col items-center justify-center gap-2 text-muted-foreground"},Em=se({__name:"ExplainQueryContainer",props:{activeTab:{}},setup(n){const t=n,e=j(ht.GRID),a=j(!1),s=O(()=>Zs(t.activeTab.result,t.activeTab.metadata.fieldDefs)),o=O(()=>gd(t.activeTab.result,t.activeTab.metadata.fieldDefs)),r=O(()=>yd(s.value)),i=O(()=>{const l=r.value.allNodes,c=l.filter(u=>u.isExpensive),m=l.filter(u=>u.isSlowest);return{planningTime:r.value.summary["Planning Time"],executionTime:r.value.summary["Execution Time"],nodeCount:l.length,expensiveCount:c.length,slowCount:m.length,allNodes:l,expensiveNodes:c,slowNodes:m}});return(l,c)=>{const m=be;return C(),z("div",Rm,[a.value?(C(),z("div",{key:0,class:"fixed inset-0 z-40 bg-background/70 backdrop-blur-[1px]",onClick:c[0]||(c[0]=u=>a.value=!1)})):K("",!0),S("div",{class:ye(["flex flex-col",a.value?"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"])},[h(d(Hd),{modelValue:e.value,"onUpdate:modelValue":c[1]||(c[1]=u=>e.value=u),"summary-stats":i.value,"is-expanded":a.value,onToggleExpand:c[2]||(c[2]=u=>a.value=!a.value)},null,8,["modelValue","summary-stats","is-expanded"]),S("div",{class:ye(["flex-1 min-h-0",a.value?"overflow-hidden":"overflow-y-auto"])},[r.value.root?e.value===d(ht).GRID?(C(),F(d(Md),{key:1,nodes:r.value.allNodes},null,8,["nodes"])):e.value===d(ht).TIMELINE?(C(),F(d(_m),{key:2,nodes:r.value.allNodes,"total-time":i.value.executionTime},null,8,["nodes","total-time"])):(C(),F(d(Ud),{key:3,"raw-text":o.value},null,8,["raw-text"])):(C(),z("div",Tm,[h(m,{name:"hugeicons:alert-02",class:"size-8 opacity-50"}),c[3]||(c[3]=S("p",{class:"text-sm"},"Could not parse execution plan",-1))]))],2)],2)])}}}),Ze='(?:`[^`]+`|"(?:[^"]|"")+"|[A-Za-z_][A-Za-z0-9_$]*)',Nm=`\\b(?:FROM|JOIN)\\s+(${Ze}(?:\\s*\\.\\s*${Ze})*)(?:\\s+(?:AS\\s+)?(${Ze}))?`,Js=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 Am(n){return Js.has(xe(n))}function va(n){const t=n.trim();return t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1).replace(/""/g,'"'):t.startsWith("`")&&t.endsWith("`")?t.slice(1,-1).replace(/``/g,"`"):t}function xe(n){if(!n)return"";const t=n.trim(),e=va(t);return t.startsWith('"')&&t.endsWith('"')||t.startsWith("`")&&t.endsWith("`")?e:e.toLowerCase()}function Sa(n){if(!n)return[];const t=[];let e="",a=null;for(let s=0;s<n.length;s++){const o=n[s];if(a){if(e+=o,o===a&&n[s+1]===a){e+=n[s+1],s++;continue}o===a&&(a=null);continue}if(o==='"'||o==="`"){a=o,e+=o;continue}if(o==="."){e.trim()&&t.push(e.trim()),e="";continue}e+=o}return e.trim()&&t.push(e.trim()),t}function na({schemas:n,tableName:t,schemaName:e}){if(!(n!=null&&n.length)||!t)return;const a=xe(t),s=e?xe(e):void 0;for(const o of n)if(!(s&&xe(o.name)!==s)){for(const[r,i]of Object.entries(o.tableDetails||{}))if(xe(r)===a)return{schemaName:o.name,tableName:r,tableInfo:i}}}function Ca({tableReference:n,schemas:t,defaultSchemaName:e}){if(!(t!=null&&t.length))return;const a=Sa(n).map(r=>xe(r));if(!a.length)return;const s=a[a.length-1],o=a.length>1?a[a.length-2]:void 0;if(o){const r=na({schemas:t,tableName:s,schemaName:o});if(r)return r}if(e){const r=na({schemas:t,tableName:s,schemaName:e});if(r)return r}return na({schemas:t,tableName:s})}function eo(n,t){var s;const e=new RegExp(Nm,"gi");let a=e.exec(n);for(;a!==null;)t({tableReference:(s=a[1])==null?void 0:s.trim(),rawAlias:a[2]}),a=e.exec(n)}function to(n){const t=new Map;return eo(n,({tableReference:e,rawAlias:a})=>{if(!e)return;const o=Sa(e).at(-1);if(o&&t.set(xe(o),e),!a)return;const r=xe(a);Js.has(r)||t.set(r,e)}),t}function Mm(n){const t=[],e=new Set;return eo(n,({tableReference:a})=>{!a||e.has(a)||(e.add(a),t.push(a))}),t}const ao=new RegExp(`^${Ze}(?:\\s*\\.\\s*${Ze}){0,2}$`,"i"),Im=new RegExp(`^([\\s\\S]*?)(?:\\s+AS\\s+)(${Ze})$`,"i"),Lm=new RegExp(`^([\\s\\S]*\\S)\\s+(${Ze})$`,"i"),mn=new RegExp(`^(${Ze}(?:\\s*\\.\\s*${Ze}){0,2})\\s*\\.\\s*\\*$`,"i");function us(n){return!n||!/[A-Za-z0-9_$]/.test(n)}function km(n,t,e){const a=e.toUpperCase();return n.slice(t,t+a.length).toUpperCase()!==a?!1:us(n[t-1])&&us(n[t+e.length])}function no(n,t){const e=n[t],a=n[t+1];if(e==="-"&&a==="-"){let s=t+2;for(;s<n.length&&n[s]!==`
|
|
13
|
+
`;)s++;return s}if(e==="/"&&a==="*"){const s=n.indexOf("*/",t+2);return s===-1?n.length:s+2}if(e==="'"||e==='"'||e==="`"){let s=t+1;for(;s<n.length;){if(n[s]===e){if(n[s+1]===e){s+=2;continue}return s+1}s++}return n.length}return t+1}function cs(n,t,e=0){let a=0;for(let s=e;s<n.length;){const o=n[s],r=n[s+1];if(o==="'"||o==='"'||o==="`"||o==="-"&&r==="-"||o==="/"&&r==="*"){s=no(n,s);continue}if(o==="("){a++,s++;continue}if(o===")"){a=Math.max(0,a-1),s++;continue}if(a===0&&km(n,s,t))return s;s++}return-1}function zm(n){const t=[];let e=0,a=0;for(let o=0;o<n.length;){const r=n[o],i=n[o+1];if(r==="'"||r==='"'||r==="`"||r==="-"&&i==="-"||r==="/"&&i==="*"){o=no(n,o);continue}if(r==="("){e++,o++;continue}if(r===")"){e=Math.max(0,e-1),o++;continue}if(e===0&&r===","){const l=n.slice(a,o).trim();l&&t.push(l),a=o+1}o++}const s=n.slice(a).trim();return s&&t.push(s),t}function $m(n){const t=cs(n,"SELECT");if(t===-1)return[];const e=cs(n,"FROM",t+6);if(e===-1)return[];const a=n.slice(t+6,e);return zm(a)}function so(n){return[...n.columns||[]].sort((t,e)=>(t.ordinal_position||0)-(e.ordinal_position||0))}function Om(n,t){const e=xe(t);return n.find(a=>xe(a.name)===e)}function Vm(n){const t=n.trim(),e=Im.exec(t);if(e)return{expression:e[1].trim(),outputName:va(e[2])};if(t==="*"||mn.test(t)||ao.test(t))return{expression:t,outputName:void 0};const a=Lm.exec(t);if(a){const s=xe(a[2]);if(!Am(s))return{expression:a[1].trim(),outputName:va(a[2])}}return{expression:t,outputName:void 0}}function oo({resolvedTableDetails:n,columnName:t,outputName:e}){const a=Om(n.tableInfo.columns||[],t);if(a)return{outputName:e,schemaName:n.schemaName,tableName:n.tableName,sourceColumnName:a.name}}function Pm({sourceColumnName:n,resolvedTables:t,outputName:e}){const a=t.map(s=>oo({resolvedTableDetails:s,columnName:n,outputName:e})).filter(Boolean);if(a.length===1)return a[0]}function Dm({expression:n,outputName:t,aliasMappings:e,resolvedTables:a,schemas:s}){if(!ao.test(n))return;const o=Sa(n);if(!o.length)return;const r=va(o[o.length-1]);if(o.length===1)return Pm({sourceColumnName:r,resolvedTables:a,outputName:t});const i=o.slice(0,-1).join("."),l=xe(o[o.length-2]||o[0]),c=e.get(l)||i,m=Ca({tableReference:c,schemas:s});if(m)return oo({resolvedTableDetails:m,columnName:r,outputName:t})}function Fm({expression:n,aliasMappings:t,schemas:e}){const a=mn.exec(n);if(!a)return[];const s=a[1].trim(),o=Sa(s),r=xe(o[o.length-1]||s),i=t.get(r)||s,l=Ca({tableReference:i,schemas:e});return l?so(l.tableInfo).map(c=>({outputName:c.name,schemaName:l.schemaName,tableName:l.tableName,sourceColumnName:c.name})):[]}function Bm({statementQuery:n,schemas:t}){const e=to(n),a=Mm(n).map(s=>Ca({tableReference:s,schemas:t})).filter(Boolean);return $m(n).flatMap(s=>{const{expression:o,outputName:r}=Vm(s);if(o==="*")return a.flatMap(l=>so(l.tableInfo).map(c=>({outputName:c.name,schemaName:l.schemaName,tableName:l.tableName,sourceColumnName:c.name})));if(mn.test(o))return Fm({expression:o,aliasMappings:e,schemas:t});const i=Dm({expression:o,outputName:r,aliasMappings:e,resolvedTables:a,schemas:t});return i?[{...i,outputName:r||i.sourceColumnName}]:r?[{outputName:r}]:[]})}function ds(n,t){return t?{...n,schemaName:n.schemaName??t.schemaName,tableName:n.tableName??t.tableName,sourceColumnName:n.sourceColumnName??t.sourceColumnName}:n}function Hm({fieldDefs:n,statementQuery:t,schemas:e}){if(!n.length||!t||!e.length)return n;const a=Bm({statementQuery:t,schemas:e});if(!a.length)return n;if(a.length===n.length)return n.map((o,r)=>ds(o,a[r]));const s=new Map;return a.forEach(o=>{const r=o.outputName;if(!r)return;const i=xe(r),l=s.get(i)||[];l.push(o),s.set(i,l)}),n.map(o=>{const r=xe(o.name),i=s.get(r),l=i==null?void 0:i.shift();return ds(o,l)})}const ms=({fieldDefs:n,statementQuery:t,schemas:e,getTableInfoById:a})=>{const s=Hm({fieldDefs:n,statementQuery:t,schemas:e}),o=new Map,r=new Set,i=new Set;return s.map(l=>{var T,A;const c=`${l.tableID}`,m=l.tableID&&l.tableID>0?`id:${c}`:`name:${l.schemaName||""}.${l.tableName||""}`,u=l.name,p=l.sourceColumnName||l.name;let f=o.get(m);const g=r.has(u);if(r.add(u),!f){if(l.tableName&&(f=na({schemas:e,tableName:l.tableName,schemaName:l.schemaName})),!f&&l.tableID)for(const $ of e){const P=a(c,$);if(P){f={schemaName:$.name,tableName:P.tableName,tableInfo:P.tableInfo};break}}f&&o.set(m,f)}const b=((f==null?void 0:f.tableInfo.columns)||[]).find($=>$.name===p),v=!!((T=f==null?void 0:f.tableInfo.primary_keys)!=null&&T.find($=>$.column===p)),w=(A=f==null?void 0:f.tableInfo.foreign_keys)==null?void 0:A.find($=>$.column===p),x=!!w;let N=g?`${(f==null?void 0:f.tableName)||l.tableName||"table"}.${l.name}`:l.name,R=N,_=1;for(;i.has(R);)R=`${N}_${_}`,_++;return i.add(R),N=R,{tableName:(f==null?void 0:f.tableName)||l.tableName||"",schemaName:(f==null?void 0:f.schemaName)||l.schemaName,...b,aliasFieldName:N,queryFieldName:l.name,originalName:l.name,sourceColumnName:p,canMutate:!!b,isPrimaryKey:v,isForeignKey:x,foreignKey:w}})};function ps(n,t){return Object.prototype.hasOwnProperty.call(n,t)}function qm(n,t){const e=i=>i.aliasFieldName||i.name||i.originalName||i.queryFieldName||"",a=i=>i.name||i.originalName||i.queryFieldName||"";if(Array.isArray(n))return Object.fromEntries(t.map((i,l)=>[e(i),n[l]]));const s=n;if(!t.length)return{...s};const o={};let r=!1;return t.forEach((i,l)=>{const c=e(i),m=a(i);if(ps(s,m)){o[c]=s[m],r=!0;return}const u=String(l);ps(s,u)&&(o[c]=s[u],r=!0)}),r?o:{...s}}function Um(n,t){return(n||[]).map(e=>qm(e,t))}const Km={class:"h-full p-2 overflow-y-auto"},Gm={key:0,class:"space-y-2"},Wm={class:"flex items-center justify-between gap-2"},jm={class:"flex items-center gap-1"},Qm={class:"text-sm pl-5 text-muted-foreground decoration-wavy underline decoration-red-600"},Ym={key:0,class:"pl-5 mt-1 text-sm text-amber-600/90 font-medium"},Xm={class:"pt-2 border-t"},Zm={class:"error-query-container"},Jm={key:0,class:"pt-2 border-t"},ep=se({__name:"ResultTabErrorView",props:{activeTab:{}},emits:["onChangeView"],setup(n,{emit:t}){const e=n,a=u=>!!u.metadata.executeErrors,s=O(()=>{var p,f;const u=(p=e.activeTab.metadata.executeErrors)==null?void 0:p.data;return((f=u==null?void 0:u.normalizeError)==null?void 0:f.position)||null}),o=O(()=>{var f;const u=e.activeTab.metadata.executeErrors,p=u==null?void 0:u.data;return((f=p==null?void 0:p.normalizeError)==null?void 0:f.message)||(u==null?void 0:u.message)||""}),r=O(()=>{var p,f;const u=(p=e.activeTab.metadata.executeErrors)==null?void 0:p.data;return((f=u==null?void 0:u.normalizeError)==null?void 0:f.hint)||null}),i=O(()=>{const u=e.activeTab.metadata.statementQuery;if(!u)return[];const p=s.value,f=[];if(p&&p>0){const g=p-1;let b=g;for(;b<u.length&&u[b]!==`
|
|
14
|
+
`&&u[b]!=="\r"&&u[b]!==" "&&u[b]!==" ";)b++;b<=g&&(b=Math.min(g+1,u.length)),f.push({start:g,end:b,properties:{class:"error-highlight"}})}return f}),l=async()=>{if(typeof window>"u")return;await Rt();const u=document.querySelector(".error-query-container .error-highlight");u&&u.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"})};ce(()=>i.value,()=>{l()},{flush:"post"});const c=O(()=>{var p;const u={...((p=e.activeTab.metadata.executeErrors)==null?void 0:p.data)||{}};return u==null||delete u.normalizeError,u?typeof u=="string"?u:JSON.stringify(u,null,2):""}),m=O(()=>e.activeTab.metadata.statementQuery||"");return(u,p)=>{var b;const f=be,g=xa;return C(),z("div",Km,[a(u.activeTab)?(C(),z("div",Gm,[S("div",Wm,[S("div",null,[S("div",jm,[h(f,{name:"hugeicons:alert-02",class:"size-4 text-red-500 mt-0.5"}),p[0]||(p[0]=S("div",{class:"font-medium text-red-600"},"Error Message",-1))]),S("span",Qm,U(o.value),1),r.value?(C(),z("div",Ym," Hint: "+U(r.value),1)):K("",!0)])]),S("div",Xm,[p[1]||(p[1]=S("div",{class:"mb-2"},[S("span",{class:"font-normal text-sm text-muted-foreground flex items-center gap-1"}," View executed query : ")],-1)),S("div",Zm,[h(g,{code:m.value,decorations:i.value,"show-copy-button":""},null,8,["code","decorations"])])]),(b=u.activeTab.metadata.executeErrors)!=null&&b.data?(C(),z("div",Jm,[p[2]||(p[2]=S("div",{class:"flex items-center justify-between mb-2"},[S("div",{class:"text-sm text-muted-foreground"},"Error Details:")],-1)),h(g,{code:c.value,language:"json"},null,8,["code"])])):K("",!0)])):K("",!0)])}}}),tp=Ja(ep,[["__scopeId","data-v-3dcef677"]]),ap={class:"h-full p-4 space-y-3 overflow-y-auto"},np={class:"space-y-2"},sp={class:"flex items-center gap-2 text-sm"},op={class:"font-medium"},rp={class:"flex items-center gap-2 text-sm"},ip={class:"font-medium"},lp={class:"flex items-center gap-2 text-sm"},up={class:"font-medium"},cp={class:"flex items-center gap-2 text-sm"},dp={class:"font-medium"},mp={class:"flex items-center gap-2 text-sm"},pp={class:"font-medium"},fp={key:0,class:"flex items-center gap-2 text-sm"},vp={class:"font-medium"},hp={class:"pt-3 border-t"},gp={key:0,class:"pt-3 border-t"},yp={class:"flex flex-wrap gap-1"},bp=se({__name:"ResultTabInfoView",props:{activeTab:{}},setup(n){const t=n,e=typeof TextEncoder<"u"?new TextEncoder:null,a=O(()=>{var o;const s=((o=t.activeTab)==null?void 0:o.result)??[];if(!e)return{bytes:0,formatted:"N/A"};try{const r=JSON.stringify(s),i=r?e.encode(r).length:0;return{bytes:i,formatted:Qo(i)}}catch{return{bytes:0,formatted:"N/A"}}});return(s,o)=>{var l,c,m,u;const r=be,i=xa;return C(),z("div",ap,[S("div",np,[S("div",sp,[h(r,{name:"hugeicons:clock-01",class:"size-4 text-muted-foreground"}),o[0]||(o[0]=S("span",{class:"text-muted-foreground"},"Query Time:",-1)),S("span",op,U(d(Dt)(s.activeTab.metadata.queryTime)),1)]),S("div",rp,[h(r,{name:"hugeicons:summation-01",class:"size-4 text-muted-foreground"}),o[1]||(o[1]=S("span",{class:"text-muted-foreground"},"Rows:",-1)),S("span",ip,U(d(Ga)(((l=s.activeTab.result)==null?void 0:l.length)||0)),1)]),S("div",lp,[h(r,{name:"hugeicons:file-02",class:"size-4 text-muted-foreground"}),o[2]||(o[2]=S("span",{class:"text-muted-foreground"},"Result Size:",-1)),S("span",up,U(a.value.formatted),1)]),S("div",cp,[h(r,{name:"hugeicons:chart-column",class:"size-4 text-muted-foreground"}),o[3]||(o[3]=S("span",{class:"text-muted-foreground"},"Columns:",-1)),S("span",dp,U(((c=s.activeTab.metadata.fieldDefs)==null?void 0:c.length)||0),1)]),S("div",mp,[h(r,{name:"hugeicons:calendar-03",class:"size-4 text-muted-foreground"}),o[4]||(o[4]=S("span",{class:"text-muted-foreground"},"Executed At:",-1)),S("span",pp,U(((m=s.activeTab.metadata.executedAt)==null?void 0:m.toLocaleString())||"N/A"),1)]),s.activeTab.metadata.connection?(C(),z("div",fp,[h(r,{name:"hugeicons:plug-socket",class:"size-4 text-muted-foreground"}),o[5]||(o[5]=S("span",{class:"text-muted-foreground"},"Connection:",-1)),S("span",vp,U(s.activeTab.metadata.connection.name||"Unknown"),1)])):K("",!0)]),S("div",hp,[o[6]||(o[6]=S("div",{class:"text-sm text-muted-foreground mb-2"},"Query:",-1)),h(i,{code:s.activeTab.metadata.statementQuery||""},null,8,["code"])]),(u=s.activeTab.metadata.fieldDefs)!=null&&u.length?(C(),z("div",gp,[o[7]||(o[7]=S("div",{class:"text-sm text-muted-foreground mb-2"},"Fields:",-1)),S("div",yp,[(C(!0),z(ae,null,ue(s.activeTab.metadata.fieldDefs,p=>(C(),z("span",{key:p.name,class:"text-xs bg-muted px-2 py-1 rounded"},U(p.name),1))),128))])])):K("",!0)])}}}),xp={class:"h-full flex flex-col flex-1 overflow-hidden"},Sp=se({__name:"ResultTabRawView",props:{formattedData:{},executeLoading:{type:Boolean},isStreaming:{type:Boolean}},setup(n){const t=n;return(e,a)=>{const s=Bt;return C(),z("div",xp,[t.formattedData.length===0&&!e.executeLoading&&!e.isStreaming?(C(),F(s,{key:0,title:"No Raw Data",desc:"The query returned no records to display as JSON."})):(C(),F(d(ml),{key:1,modelValue:t.formattedData,mode:"text",readOnly:!0,navigationBar:!1,class:"h-full"},null,8,["modelValue"]))])}}});function Cp({query:n,dbConnectionString:t,type:e,providerKind:a,managedSqlite:s,params:o,onMeta:r,onRows:i,onDone:l,onError:c}){const m=new AbortController;let u=0;return(async()=>{var f;try{const g=await fetch("/api/query/raw-execute-stream",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:n,dbConnectionString:t,type:e,providerKind:a,managedSqlite:s,params:o||{}}),signal:m.signal});if(!g.ok){const x=await g.text();c==null||c(x||`HTTP ${g.status}`);return}const b=(f=g.body)==null?void 0:f.getReader();if(!b){c==null||c("No readable stream available");return}const v=new TextDecoder;let w="";for(;;){const{done:x,value:N}=await b.read();if(x)break;w+=v.decode(N,{stream:!0});const R=w.split(`
|
|
15
|
+
`);w=R.pop()||"";for(const _ of R){const E=_.trim();if(E)try{const T=JSON.parse(E);switch(T.type){case"meta":r==null||r(T.fields,T.command);break;case"rows":u+=T.data.length,i==null||i(T.data,u);break;case"done":l==null||l(T.rowCount,T.queryTime);break;case"error":c==null||c(T.message,T.error);break}}catch{console.warn("[StreamingQuery] Malformed NDJSON line:",E)}}}if(w.trim())try{const x=JSON.parse(w.trim());x.type==="done"?l==null||l(x.rowCount,x.queryTime):x.type==="error"&&(c==null||c(x.message))}catch{}}catch(g){if(g.name==="AbortError")return;c==null||c(g.message||"Stream connection failed")}})(),{abort:()=>m.abort()}}const fs=n=>{if(n===null||typeof n!="object")return!1;const t=Object.getPrototypeOf(n);return t===Object.prototype||t===null},Zt=n=>n.map(t=>({name:t})),wp=n=>{if(Array.isArray(n)){if(n.every(t=>fs(t))){const t=n,e=Array.from(new Set(t.flatMap(a=>Object.keys(a))));return{rows:t,fields:Zt(e)}}return{rows:n.map((t,e)=>({index:e,value:t})),fields:Zt(["index","value"])}}return fs(n)?{rows:[n],fields:Zt(Object.keys(n))}:{rows:[{value:n}],fields:Zt(["value"])}};function _p({getEditorView:n,connection:t,redisDatabaseIndex:e,fileVariables:a,fieldDefs:s,resultTabs:o,buildExplainAnalyzePrefix:r,beforeExecute:i}){const l=nt([]),c=nt({}),m=nt(0),u=Yo({isHaveOneExecute:!1,executeLoading:!1,isStreaming:!1,streamingRowCount:0,queryTime:0,executeErrors:void 0,currentStatementQuery:""});let p=null;const f=async({currentStatements:w,queryPrefix:x})=>{var L,M,W,Z,oe,le,de,me,Fe,ze,ut,Ce,Je,Ge,he,ot,I,D,H,B,q;if(!w.length)return;const N=w[0];if(i&&!await i())return;u.isHaveOneExecute=!0,u.currentStatementQuery=N.text;let R=N.text,_={};try{_=JSON.parse(a.value||"{}")}catch(V){console.log("fileParameters error::",V)}let E=ee.RESULT;const T=((L=t.value)==null?void 0:L.type)===re.REDIS;x&&!T&&(R=`${x} ${R}`,x.startsWith("EXPLAIN")&&(E=ee.EXPLAIN)),s.value=[],l.value=[],c.value={},u.executeLoading=!0,u.isStreaming=!1,u.streamingRowCount=0,p&&(p(),p=null),m.value++;const A={id:Xo(),metadata:{queryTime:0,statementQuery:R,executedAt:new Date,executeErrors:void 0,fieldDefs:void 0,connection:void 0},result:[],view:E,seqIndex:m.value};o.addResultTab(A),Nl(n());const $=[];if(T){try{const V=Date.now(),Q=await $fetch("/api/redis/workbench/execute",{method:"POST",body:{method:(M=t.value)==null?void 0:M.method,stringConnection:(W=t.value)==null?void 0:W.connectionString,host:(Z=t.value)==null?void 0:Z.host,port:(oe=t.value)==null?void 0:oe.port,username:(le=t.value)==null?void 0:le.username,password:(de=t.value)==null?void 0:de.password,database:(me=t.value)==null?void 0:me.database,databaseIndex:e==null?void 0:e.value,ssl:(Fe=t.value)==null?void 0:Fe.ssl,ssh:(ze=t.value)==null?void 0:ze.ssh,command:R}}),J=wp(Q.result),ie=Date.now()-V;s.value=J.fields,A.metadata.fieldDefs=J.fields,A.metadata.connection=t.value,A.metadata.command=((ut=Q.command)==null?void 0:ut[0])||((Ce=R.trim().split(/\s+/)[0])==null?void 0:Ce.toUpperCase())||"REDIS",A.metadata.queryTime=ie,A.metadata.rowCount=J.rows.length,A.result=J.rows,c.value={rows:J.rows,fields:J.fields,queryTime:ie},l.value=J.rows,u.executeLoading=!1,u.isStreaming=!1,u.streamingRowCount=J.rows.length,u.queryTime=ie,u.executeErrors=void 0,o.refreshResultTab(A.id,A)}catch(V){const Q=((Je=V==null?void 0:V.data)==null?void 0:Je.message)||(V==null?void 0:V.message)||"Failed to execute Redis command.";u.executeLoading=!1,u.isStreaming=!1,u.executeErrors={message:Q,data:(V==null?void 0:V.data)||{message:Q}},A.metadata.executeErrors=u.executeErrors,A.view=ee.ERROR,o.refreshResultTab(A.id,A)}return}if(x&&E===ee.EXPLAIN){try{const V=await $fetch("/api/query/raw-execute",{method:"POST",body:{dbConnectionString:(Ge=t.value)==null?void 0:Ge.connectionString,type:(he=t.value)==null?void 0:he.type,providerKind:(ot=t.value)==null?void 0:ot.providerKind,managedSqlite:(I=t.value)==null?void 0:I.managedSqlite,query:R,params:_},onResponseError:({response:Q})=>{var Be,rt;const J=(Be=Q._data)==null?void 0:Be.data,ie=n();ie&&J&&$n({editorView:ie,originalSql:N.text,statementFrom:Number(N.from),fileParameters:_,errorDetail:J,clientType:((rt=t.value)==null?void 0:rt.type)||re.POSTGRES,queryPrefix:x})}});s.value=V.fields,A.metadata.fieldDefs=V.fields,A.result=V.rows,A.metadata.queryTime=V.queryTime||0,A.metadata.connection=t.value,c.value=V,l.value=V.rows,u.executeErrors=void 0,u.queryTime=V.queryTime||0}catch(V){u.executeErrors=V.data,A.metadata.executeErrors=V.data,A.view=ee.ERROR}u.executeLoading=!1,o.refreshResultTab(A.id,A);return}u.isStreaming=!0,u.executeLoading=!1;const{abort:P}=Cp({query:R,dbConnectionString:((D=t.value)==null?void 0:D.connectionString)||"",type:(H=t.value)==null?void 0:H.type,providerKind:(B=t.value)==null?void 0:B.providerKind,managedSqlite:(q=t.value)==null?void 0:q.managedSqlite,params:_,onMeta:(V,Q)=>{s.value=V,A.metadata.fieldDefs=V,A.metadata.connection=t.value,A.metadata.command=Q,o.refreshResultTab(A.id,A)},onRows:(V,Q)=>{$.push(...V),u.streamingRowCount=Q,A.result=$,A.metadata.rowCount=Q,l.value=$,o.refreshResultTab(A.id,A)},onDone:(V,Q)=>{u.executeLoading=!1,u.isStreaming=!1,u.queryTime=Q,u.executeErrors=void 0,u.streamingRowCount=V,A.metadata.queryTime=Q,A.metadata.rowCount=V,c.value={rows:A.result,fields:s.value,queryTime:Q},o.refreshResultTab(A.id,A),p=null},onError:(V,Q)=>{var Be;const J={message:V,data:Q||{message:V}};u.executeLoading=!1,u.isStreaming=!1,u.executeErrors=J,A.metadata.executeErrors=J,A.view=ee.ERROR;const ie=n();ie&&Q&&$n({editorView:ie,originalSql:N.text,statementFrom:Number(N.from),fileParameters:_,errorDetail:Q,clientType:((Be=t.value)==null?void 0:Be.type)||re.POSTGRES}),o.refreshResultTab(A.id,A),p=null}});p=P};return{currentRawQueryResult:l,rawResponse:c,queryProcessState:u,executeCurrentStatement:f,onExecuteCurrent:()=>{const w=n();if(!w)return;const{currentStatements:x}=ra(w);f({currentStatements:x})},onExplainAnalyzeCurrent:()=>{const w=n();if(!w)return;const{currentStatements:x}=ra(w);f({currentStatements:x,queryPrefix:r()})},cancelStreamingQuery:()=>{p&&(p(),p=null,u.executeLoading=!1,u.isStreaming=!1)}}}function Rp(){const n=j({BUFFERS:!0,COSTS:!0,GENERIC_PLAN:!1,MEMORY:!1,SETTINGS:!0,SUMMARY:!0,TIMING:!0,VERBOSE:!0,WAL:!0}),t=j("NONE"),e=r=>{n.value[r]=!n.value[r]},a=r=>{t.value=r};return{explainAnalyzeOptionItems:O(()=>Cn.filter(r=>r.key!=="SERIALIZE").map(r=>({key:r.key,label:r.label,checked:n.value[r.key]}))),serializeMode:t,toggleExplainOption:e,setSerializeMode:a,buildExplainAnalyzePrefix:()=>{const r=Cn.filter(c=>c.key!=="SERIALIZE"&&n.value[c.key]).map(c=>c.key).flatMap(c=>c==="GENERIC_PLAN"?[]:[c]),i=t.value==="NONE"?[]:[`SERIALIZE ${t.value}`];return`EXPLAIN (${["ANALYZE","FORMAT JSON",...r,...i].join(", ")})`}}}function Tp(){const n=nt(new Map),t=j(null),e=m=>{const u=new Map;u.set(m.id,m),n.value.forEach((p,f)=>{u.set(f,p)}),n.value=u,t.value=m.id},a=(m,u)=>{const p=new Map(n.value);p.set(m,{...u}),n.value=p};return{executedResults:n,activeResultTabId:t,addResultTab:e,refreshResultTab:a,setActiveResultTab:m=>{n.value.has(m)&&(t.value=m)},closeResultTab:m=>{const u=new Map(n.value);if(u.delete(m),n.value=u,t.value===m){const p=Array.from(u.keys());t.value=p.length>0?p[p.length-1]:null}},updateResultTabView:(m,u)=>{const p=n.value.get(m);p&&a(m,{...p,view:u})},closeOtherResultTabs:m=>{const u=n.value.get(m);if(!u)return;const p=new Map;p.set(m,u),n.value=p,t.value=m},closeResultTabsToRight:m=>{const u=Array.from(n.value.keys()),p=u.indexOf(m);if(p<0)return;const f=new Map;for(let g=0;g<=p;g++){const b=u[g],v=n.value.get(b);v&&f.set(b,v)}n.value=f,f.has(t.value||"")||(t.value=m)},updateResultTabResult:(m,u)=>{const f=new Map(n.value).get(m);f&&(f.result=u)}}}function Ot(n,...t){}const Ep=n=>{let t;return async()=>(t||(t=n()),await t)};class pn{constructor(t={}){we(this,"opts");we(this,"parser",null);we(this,"offsetRecord",{});we(this,"getParser",Ep(async()=>{if(this.parser)return this.parser;const t=await _s(()=>import("./9PqzQzi0.js").then(a=>a.i),__vite__mapDeps([0,1,2]),import.meta.url),{Parser:e}=t.default||t;return this.parser=new e,this.parser}));this.opts=t}async parse(t,e){var o,r;this.offsetRecord={};const a=(r=(o=this.opts).getParserOptions)==null?void 0:r.call(o,e.state),s=await this.sanitizeSql(t,a);try{const i=await this.getParser();if((a==null?void 0:a.database)==="DuckDB")return this.parseWithDuckDBSupport(s,a);const l=i.astify(s,a);return{success:!0,errors:[],ast:l}}catch(i){return{success:!1,errors:[this.extractErrorInfo(i,s)]}}}async sanitizeSql(t,e){if(e!=null&&e.ignoreBrackets){const{sql:a,offsetRecord:s}=Mp(t);return this.offsetRecord=s,a}return t}async parseWithDuckDBSupport(t,e){const a=await this.getParser(),s=Np(t).trimStart().toLowerCase();if(s.startsWith("from")||s.includes("macro"))return Ot(),{success:!0,errors:[]};let o=t;s.includes("create or replace table")&&(this.offsetRecord[t.indexOf("create or replace table")]=-11,o=t.replace(/create or replace table/i,"create table"));try{const r={...e,database:"PostgreSQL"},i=a.astify(o,r);return{success:!0,errors:[],ast:i}}catch(r){return{success:!1,errors:[this.extractErrorInfo(r,t)]}}}extractErrorInfo(t,e){var i,l,c;let a=1,s=1;const o=(t==null?void 0:t.message)||"SQL parsing error",r=t;if(r!=null&&r.location)a=((i=r.location.start)==null?void 0:i.line)||1,s=((l=r.location.start)==null?void 0:l.column)||1;else if(r!=null&&r.hash)a=r.hash.line||1,s=((c=r.hash.loc)==null?void 0:c.first_column)||1;else{const m=o.match(/line (\d+)/i),u=o.match(/column (\d+)/i);m!=null&&m[1]&&(a=parseInt(m[1],10)),u!=null&&u[1]&&(s=parseInt(u[1],10))}for(const[m,u]of Object.entries(this.offsetRecord))s>parseInt(m,10)&&(s-=u);return s>e.length&&(s=e.length),{message:this.cleanErrorMessage(o),line:Math.max(1,a),column:s,severity:"error"}}cleanErrorMessage(t){return t.replace(/^Error: /,"").replace(/Expected .* but .* found\./i,e=>e.replace(/but .* found/,"found unexpected token")).trim()}async validateSql(t,e){return(await this.parse(t,e)).errors}async extractTableReferences(t,e){var s,o;const a=e?(o=(s=this.opts).getParserOptions)==null?void 0:o.call(s,e.state):void 0;try{return(await this.getParser()).tableList(t,a).map(l=>{const c=l.split("::");return c[c.length-1]||l})}catch{return[]}}async extractColumnReferences(t,e){var s,o;const a=e!=null&&e.state?(o=(s=this.opts).getParserOptions)==null?void 0:o.call(s,e.state):void 0;try{return(await this.getParser()).columnList(t,a).map(c=>{const m=c.split("::");return m[m.length-1]||c})}catch{return[]}}}function Np(n,t=["/*","--"]){const e=[];if(t.includes("/*")&&e.push("/\\*[\\s\\S]*?\\*/"),t.includes("--")&&e.push("--[^\\n]*"),e.length===0)return n;const a=new RegExp(`^\\s*(${e.join("|")})\\s*`,"");let s=n,o="";for(;s!==o;)o=s,s=s.replace(a,"");return s}const Ap=2;function Mp(n){const t={};return{sql:n.replace(/("(?:[^"\\]|\\.)*")|('(?:[^'\\]|\\.)*')|(\{[^}]*\})/g,(a,s,o,r,i)=>s||o?a:r?(t[i]=Ap,`'${r}'`):a),offsetRecord:t}}const Ip=750;function Lp(n,t){const a=t.line(n.line).from+Math.max(0,n.column-1),s=a+1;return{from:a,to:s,severity:n.severity,message:n.message,source:"sql-parser"}}function kp(n={}){const t=n.parser||new pn;return Ss(async e=>{const a=e.state.doc,s=a.toString();return s.trim()?(await t.validateSql(s,{state:e.state})).map(r=>Lp(r,a)):[]},{delay:n.delay||Ip})}function bt(n){return typeof n=="object"&&!Array.isArray(n)&&!("self"in n)}function st(n){return typeof n=="object"&&!Array.isArray(n)&&"self"in n&&"children"in n}function Ue(n){return Array.isArray(n)}function Te(n,t,e,a){const s=n.length;if(t==="string"||t==="completion"&&a&&Ue(a))return"column";if(t==="namespace"&&e){if(Ue(e))return"table";if(bt(e))return Object.values(e).some(r=>Ue(r)||st(r)&&Ue(r.children))?s<=1?"database":"schema":s===0?"database":"namespace"}if(t==="completion"&&e)return Ue(e)?"table":(bt(e)&&Object.values(e).some(r=>Ue(r)||st(r)&&Ue(r.children)),s<=1?"database":"schema");switch(s){case 0:return"database";case 1:return"schema";default:return"namespace"}}function ro(n,t,e={}){const{maxDepth:a=10}=e;if(t===""&&st(n)){const o=Te([],"completion",n.children);return{completion:n.self,path:[],type:"completion",semanticType:o,namespace:n.children}}const s=t.split(".").filter(o=>o.length>0);return s.length===0||s.length>a?null:Ya(n,s,[],e)}function Ya(n,t,e,a,s){if(t.length===0){if(st(n)){const c=Te(e,"completion",n.children,s);return{completion:n.self,path:e,type:"completion",semanticType:c,namespace:n.children}}const l=Te(e,"namespace",n,s);return{path:e,type:"namespace",semanticType:l,namespace:n}}const[o,...r]=t,{caseSensitive:i=!1}=a;if(!o)return null;if(bt(n)){const l=i?Object.keys(n).find(c=>c===o):Object.keys(n).find(c=>c.toLowerCase()===o.toLowerCase());if(l){const c=n[l];if(c)return Ya(c,r,[...e,l],a,n)}}else{if(st(n))return Ya(n.children,t,e,a,n);if(Ue(n)){for(const l of n)if(typeof l=="string"){if((i?l===o:l.toLowerCase()===o.toLowerCase())&&r.length===0){const m=Te([...e,l],"string",void 0,n);return{value:l,path:[...e,l],type:"string",semanticType:m}}}else if((i?l.label===o:l.label.toLowerCase()===o.toLowerCase())&&r.length===0){const m=Te([...e,l.label],"completion",void 0,n);return{completion:l,path:[...e,l.label],type:"completion",semanticType:m}}}}return null}function zp(n,t,e={}){const a=[];if(t.includes(".")){const s=t.lastIndexOf("."),o=t.substring(0,s),r=t.substring(s+1),i=ro(n,o,e);if(i!=null&&i.namespace)return Xa(i.namespace,r,i.path,e)}else return Xa(n,t,[],e);return a}function Xa(n,t,e,a){const s=[],{caseSensitive:o=!1,allowPartialMatch:r=!0}=a;if(bt(n)){for(const[i,l]of Object.entries(n))if(r?o?i.startsWith(t):i.toLowerCase().startsWith(t.toLowerCase()):o?i===t:i.toLowerCase()===t.toLowerCase())if(st(l)){const m=Te([...e,i],"completion",l.children,n);s.push({completion:l.self,path:[...e,i],type:"completion",semanticType:m,namespace:l.children})}else{const m=Te([...e,i],"namespace",l,n);s.push({path:[...e,i],type:"namespace",semanticType:m,namespace:l})}}else if(st(n)){if(r?o?n.self.label.startsWith(t):n.self.label.toLowerCase().startsWith(t.toLowerCase()):o?n.self.label===t:n.self.label.toLowerCase()===t.toLowerCase()){const l=Te([...e,n.self.label],"completion",n.children);s.push({completion:n.self,path:[...e,n.self.label],type:"completion",semanticType:l,namespace:n.children})}s.push(...Xa(n.children,t,e,a))}else if(Ue(n)){for(const i of n)if(typeof i=="string"){if(r?o?i.startsWith(t):i.toLowerCase().startsWith(t.toLowerCase()):o?i===t:i.toLowerCase()===t.toLowerCase()){const c=Te([...e,i],"string",void 0,n);s.push({value:i,path:[...e,i],type:"string",semanticType:c})}}else if(r?o?i.label.startsWith(t):i.label.toLowerCase().startsWith(t.toLowerCase()):o?i.label===t:i.label.toLowerCase()===t.toLowerCase()){const c=Te([...e,i.label],"completion",void 0,n);s.push({completion:i,path:[...e,i.label],type:"completion",semanticType:c})}}return s}function $p(n,t,e={}){const a=[],{maxDepth:s=10}=e;sa(n,[],a,s);const{caseSensitive:o=!1}=e;return a.filter(i=>i.path.some(l=>o?l===t:l.toLowerCase()===t.toLowerCase())).sort((i,l)=>{var u,p;const c=o?i.path[i.path.length-1]===t:((u=i.path[i.path.length-1])==null?void 0:u.toLowerCase())===t.toLowerCase(),m=o?l.path[l.path.length-1]===t:((p=l.path[l.path.length-1])==null?void 0:p.toLowerCase())===t.toLowerCase();return c&&!m?-1:!c&&m?1:i.path.length-l.path.length})}function sa(n,t,e,a){if(!(t.length>=a)){if(bt(n))for(const[s,o]of Object.entries(n)){const r=[...t,s];if(st(o)){const i=Te(r,"completion",o.children,n);e.push({completion:o.self,path:r,type:"completion",semanticType:i,namespace:o.children}),sa(o.children,r,e,a)}else{const i=Te(r,"namespace",o,n);e.push({path:r,type:"namespace",semanticType:i,namespace:o}),sa(o,r,e,a)}}else if(st(n)){const s=Te(t,"completion",n.children);e.push({completion:n.self,path:t,type:"completion",semanticType:s,namespace:n.children}),sa(n.children,t,e,a)}else if(Ue(n))for(const s of n)if(typeof s=="string"){const o=Te([...t,s],"string",void 0,n);e.push({value:s,path:[...t,s],type:"string",semanticType:o})}else{const o=Te([...t,s.label],"completion",void 0,n);e.push({completion:s,path:[...t,s.label],type:"completion",semanticType:o})}}}function vs(n,t,e={}){const{enableFuzzySearch:a=!1}=e,s=ro(n,t,e);if(s)return s;const o=zp(n,t,e);if(o.length>0)return o[0]||null;if(a){const r=$p(n,t,e);if(r.length>0)return r[0]||null}return null}function io(n,t){if(t.size===0)return{};if(bt(n)){const e={};for(const[a,s]of Object.entries(n))if(Array.from(t).some(r=>r.toLowerCase()===a.toLowerCase()))e[a]=s;else if(bt(s)){const r=io(s,t);Object.keys(r).length>0&&(e[a]=r)}return e}return n}function Op(n={}){const{schema:t={},keywords:e={},hoverTime:a=300,enableKeywords:s=!0,enableTables:o=!0,enableColumns:r=!0,enableFuzzySearch:i=!0,parser:l=new pn,tooltipRender:c,tooltipRenderers:m={}}=n;let u=null;return Zo(async(p,f,g)=>{const{from:b,to:v,text:w}=p.state.doc.lineAt(f);let x=f,N=f;u===null&&(u=typeof e=="function"?e(p):Promise.resolve(e));const R=await u;for(;x>b&&/[\w.]/.test(w[x-b-1]??"");)x--;for(;N<v&&/[\w.]/.test(w[N-b]??"");)N++;if(x===f&&g<0||N===f&&g>0)return null;const _=w.slice(x-b,N-b).toLowerCase();if(!_||_.length===0)return null;const E=typeof t=="function"?t(p):t;let T=null;if(Ot(),!T&&s&&R[_]){Ot("keywordResult",_,R[_]);const A={keyword:_,info:R[_]};T={word:_,view:p,pos:f,tooltipType:"keyword",keywordData:A}}if(!T&&(o||r)&&E){const A=p.state.doc.toString(),$=await l.extractTableReferences(A),P=new Set($.map(W=>W.toLowerCase())),L=io(E,P);let M=vs(L,_,{enableFuzzySearch:i});if(!M&&P.size===0&&(M=vs(E,_,{enableFuzzySearch:i})),M){Ot("namespaceResult (query-aware)",_,M,"tableRefs:",Array.from(P));const W={item:M,word:_,resolvedSchema:P.size>0?L:E};T={word:_,view:p,pos:f,tooltipType:"namespace",namespaceData:W}}else Ot("No namespace item found for:",_)}return T?{pos:x,end:N,above:!0,create(A){if(c){const L=c(_,A,f);if(L)return{dom:L}}let $=null;if(T.tooltipType==="keyword"&&T.keywordData)$=m.keyword?m.keyword(T.keywordData):Pp(T.keywordData);else if(T.tooltipType==="namespace"&&T.namespaceData){const L=T.namespaceData,{semanticType:M}=L.item;M==="table"&&m.table?$=m.table(L):M==="column"&&m.column?$=m.column(L):(M==="database"||M==="schema"||M==="namespace")&&m.namespace?$=m.namespace(L):$=Vp(L.item)}if(!$)return{dom:document.createElement("div")};const P=document.createElement("div");return P.className="cm-sql-hover-tooltip",P.innerHTML=$,{dom:P}}}:null},{hoverTime:a})}function Vp(n){var s,o,r,i,l,c,m;const t=n.path.join("."),e=((s=n.completion)==null?void 0:s.label)||n.value||n.path[n.path.length-1]||"unknown";let a=`<div class="sql-hover-${n.semanticType}">`;switch(a+=`<div class="sql-hover-header"><strong>${e}</strong> <span class="sql-hover-type">${n.semanticType}</span></div>`,n.semanticType){case"database":if(a+=`<div class="sql-hover-description">Database${(o=n.completion)!=null&&o.detail?`: ${n.completion.detail}`:""}</div>`,n.namespace){const u=oa(n.namespace);u>0&&(a+=`<div class="sql-hover-children">Contains ${u} schema${u!==1?"s":""}</div>`)}break;case"schema":if(a+=`<div class="sql-hover-description">Schema${(r=n.completion)!=null&&r.detail?`: ${n.completion.detail}`:""}</div>`,t&&(a+=`<div class="sql-hover-path"><strong>Path:</strong> <code>${t}</code></div>`),n.namespace){const u=oa(n.namespace);u>0&&(a+=`<div class="sql-hover-children">Contains ${u} table${u!==1?"s":""}</div>`)}break;case"table":if(a+=`<div class="sql-hover-description">Table${(i=n.completion)!=null&&i.detail?`: ${n.completion.detail}`:""}</div>`,t){const u=n.path;u.length>1&&(a+=`<div class="sql-hover-path"><strong>Schema:</strong> <code>${u.slice(0,-1).join(".")}</code></div>`)}if(n.namespace&&Ue(n.namespace)){const u=n.namespace;if(u.length>0){a+=`<div class="sql-hover-columns"><strong>Columns (${u.length}):</strong><br>`;const f=u.slice(0,8).map(g=>typeof g=="string"?g:g.label);a+=f.map(g=>`<code>${g}</code>`).join(", "),u.length>8&&(a+=`, <em>and ${u.length-8} more...</em>`),a+="</div>"}}break;case"column":if(a+=`<div class="sql-hover-description">Column${(l=n.completion)!=null&&l.detail?`: ${n.completion.detail}`:""}</div>`,t){const u=n.path;u.length>1&&(a+=`<div class="sql-hover-path"><strong>Table:</strong> <code>${u.slice(0,-1).join(".")}</code></div>`)}break;default:if(a+=`<div class="sql-hover-description">Namespace${(c=n.completion)!=null&&c.detail?`: ${n.completion.detail}`:""}</div>`,t&&(a+=`<div class="sql-hover-path"><strong>Path:</strong> <code>${t}</code></div>`),n.namespace){const u=oa(n.namespace);u>0&&(a+=`<div class="sql-hover-children">Contains ${u} item${u!==1?"s":""}</div>`)}break}return(m=n.completion)!=null&&m.info&&typeof n.completion.info=="string"&&(a+=`<div class="sql-hover-info">${n.completion.info}</div>`),a+="</div>",a}function oa(n){return Array.isArray(n)?n.length:typeof n=="object"&&n!==null?"self"in n&&"children"in n?1+oa(n.children):Object.keys(n).length:0}function Pp(n){const{keyword:t,info:e}=n;let a='<div class="sql-hover-keyword">';if(a+=`<div class="sql-hover-header"><strong>${t.toUpperCase()}</strong> <span class="sql-hover-type">keyword</span></div>`,a+=`<div class="sql-hover-description">${e.description}</div>`,e.syntax&&(a+=`<div class="sql-hover-syntax"><strong>Syntax:</strong> <code>${e.syntax}</code></div>`),e.example&&(a+=`<div class="sql-hover-example"><strong>Example:</strong><br><code>${e.example}</code></div>`),e.metadata&&typeof e.metadata=="object"&&Object.keys(e.metadata).length>0){a+='<div class="sql-hover-metadata">';for(const[s,o]of Object.entries(e.metadata))a+=`<span class="sql-hover-tag" title="${s}">${o}</span> `;a+="</div>"}return a+="</div>",a}const Dp=(n="light")=>{const a=n==="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 rn.theme({".cm-sql-hover-tooltip":{padding:"8px 12px",backgroundColor:a.tooltipBg,border:`1px solid ${a.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:a.tooltipText},".cm-sql-hover-tooltip .sql-hover-header":{marginBottom:"6px",display:"flex",alignItems:"center",gap:"6px",color:a.header},".cm-sql-hover-tooltip .sql-hover-type":{fontSize:"11px",padding:"2px 6px",backgroundColor:a.tooltipTypeBg,color:a.tooltipTypeText,borderRadius:"4px",fontWeight:"500"},".cm-sql-hover-tooltip .sql-hover-description":{color:a.info,marginBottom:"8px"},".cm-sql-hover-tooltip .sql-hover-syntax":{marginBottom:"8px",color:a.syntax},".cm-sql-hover-tooltip .sql-hover-example":{marginBottom:"4px",color:a.example},".cm-sql-hover-tooltip .sql-hover-columns":{marginBottom:"4px",color:a.columns},".cm-sql-hover-tooltip .sql-hover-related":{marginBottom:"4px",color:a.related},".cm-sql-hover-tooltip .sql-hover-path":{marginBottom:"4px",color:a.path},".cm-sql-hover-tooltip .sql-hover-info":{marginBottom:"4px",color:a.info},".cm-sql-hover-tooltip .sql-hover-children":{marginBottom:"4px",color:a.tooltipChildren,fontSize:"12px"},".cm-sql-hover-tooltip code":{backgroundColor:a.codeBg,padding:"1px 4px",borderRadius:"3px",fontSize:"12px",fontFamily:"ui-monospace, 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', monospace",color:a.codeText},".cm-sql-hover-tooltip strong":{fontWeight:"600",color:a.strong},".cm-sql-hover-tooltip em":{fontStyle:"italic",color:a.em}})};class Fp{constructor(t){we(this,"parser");we(this,"cache",new Map);we(this,"MAX_CACHE_SIZE",10);this.parser=t}async analyzeDocument(t){const e=t.doc.toString(),a=this.generateCacheKey(e),s=this.cache.get(a);if(s)return s;const o=await this.extractStatements(e,t);if(this.cache.set(a,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(t,e){return(await this.analyzeDocument(t)).find(s=>e>=s.from&&e<=s.to)||null}async getStatementsInRange(t,e,a){return(await this.analyzeDocument(t)).filter(o=>o.from<=a&&o.to>=e)}async extractStatements(t,e){const a=[],s=this.splitByStatementSeparators(t);let o=0;for(const r of s){const i=r.trim();if(i.length===0){o+=r.length;continue}const l=o+r.indexOf(i),c=l+i.length,m=e.doc.lineAt(l),u=e.doc.lineAt(c),p=this.stripComments(i);if(p.trim().length===0||p.trim()===";"){o+=r.length;continue}const f=await this.parser.parse(p,{state:e}),g=this.determineStatementType(p),b=p.endsWith(";")?p.slice(0,-1).trim():p.trim();a.push({from:l,to:c,lineFrom:m.number,lineTo:u.number,content:b,type:g,isValid:f.success}),o+=r.length}return a}splitByStatementSeparators(t){const e=[];let a="",s=!1,o="",r=!1,i=!1,l=0;for(;l<t.length;){const c=t[l],m=t[l+1];if(!s&&!i&&c==="-"&&m==="-"){r=!0,a+=c+m,l+=2;continue}if(!s&&!r&&c==="/"&&m==="*"){i=!0,a+=c+m,l+=2;continue}if(i&&c==="*"&&m==="/"){i=!1,a+=c+m,l+=2;continue}if(r&&(c===`
|
|
16
|
+
`||c==="\r")){r=!1,a+=c,l++;continue}if(r||i){a+=c,l++;continue}if(!s&&(c==="'"||c==='"'||c==="`"))s=!0,o=c,a+=c;else if(s&&c===o){if(m===o){a+=c+m,l+=2;continue}s=!1,o="",a+=c}else!s&&c===";"?(a+=c,e.push(a),a=""):a+=c;l++}return a.trim()&&e.push(a),e}determineStatementType(t){const e=t.trim().toLowerCase();return e.startsWith("select")?"select":e.startsWith("insert")?"insert":e.startsWith("update")?"update":e.startsWith("delete")?"delete":e.startsWith("create")?"create":e.startsWith("drop")?"drop":e.startsWith("alter")?"alter":e.startsWith("use")?"use":"other"}stripComments(t){let e="",a=!1,s="",o=!1,r=!1,i=0;for(;i<t.length;){const l=t[i],c=t[i+1];if(!a&&!r&&l==="-"&&c==="-"){o=!0,i+=2;continue}if(!a&&!o&&l==="/"&&c==="*"){r=!0,i+=2;continue}if(r&&l==="*"&&c==="/"){r=!1,i+=2;continue}if(o&&(l===`
|
|
17
|
+
`||l==="\r")){o=!1,e+=l,i++;continue}if(o||r){i++;continue}if(!a&&(l==="'"||l==='"'||l==="`"))a=!0,s=l,e+=l;else if(a&&l===s){if(c===s){e+=l+c,i+=2;continue}a=!1,s="",e+=l}else e+=l;i++}return e}generateCacheKey(t){let e=0;for(let a=0;a<t.length;a++){const s=t.charCodeAt(a);e=(e<<5)-e+s,e=e&e}return e.toString()}clearCache(){this.cache.clear()}}const lo=er.define(),uo=Jo.define({create(){return{currentStatement:null,allStatements:[],cursorPosition:0,isFocused:!0}},update(n,t){for(const e of t.effects)if(e.is(lo))return e.value;return n}});class Bp extends nr{constructor(e,a,s=!0,o=!0){super();we(this,"config");we(this,"isCurrent");we(this,"isValid");we(this,"isFocused");this.config=e,this.isCurrent=a,this.isValid=s,this.isFocused=o}toDOM(){const e=document.createElement("div");e.className="cm-sql-gutter-marker";let a=this.config.backgroundColor||"#3b82f6";!this.isValid&&this.config.showInvalid!==!1&&(a=this.config.errorBackgroundColor||"#ef4444");let s;return this.isFocused?s=this.isCurrent?"1":(this.config.inactiveOpacity||"0.3").toString():this.config.unfocusedOpacity!==void 0?s=this.config.unfocusedOpacity.toString():this.config.hideWhenNotFocused?s="0":s=this.isCurrent?"1":(this.config.inactiveOpacity||"0.3").toString(),e.style.cssText=`
|
|
18
|
+
background: ${a};
|
|
19
|
+
height: 100%;
|
|
20
|
+
width: 100%;
|
|
21
|
+
opacity: ${s};
|
|
22
|
+
transition: opacity 150ms ease-in-out;
|
|
23
|
+
border-radius: 1px;
|
|
24
|
+
`,e}eq(e){return this.isCurrent===e.isCurrent&&this.isValid===e.isValid&&this.isFocused===e.isFocused&&this.config===e.config}}function Hp(n,t){var i;let e=ar.empty;if((i=t.whenHide)!=null&&i.call(t,n))return e;const a=n.state.field(uo,!1);if(!a)return e;const{currentStatement:s,allStatements:o,isFocused:r}=a;try{for(const l of o){const c=(s==null?void 0:s.from)===l.from&&(s==null?void 0:s.to)===l.to;if(!l.isValid&&t.showInvalid===!1)continue;const m=new Bp(t,c,l.isValid,r);for(let u=l.lineFrom;u<=l.lineTo;u++)try{if(u<1||u>n.state.doc.lines)continue;const p=n.state.doc.line(u);e=e.update({add:[m.range(p.from)]})}catch(p){console.warn("SqlGutter: Invalid line number",u,p)}}}catch(l){console.warn("SqlGutter: Error creating markers",l)}return e}function qp(n){return rn.updateListener.of(async t=>{if(!t.docChanged&&!t.selectionSet&&!t.focusChanged)return;const{state:e}=t.view,{main:a}=e.selection,s=a.head,o=await n.analyzeDocument(e),i={currentStatement:await n.getStatementAtPosition(e,s),allStatements:o,cursorPosition:s,isFocused:t.view.hasFocus};t.view.dispatch({effects:lo.of(i)})})}function Up(n){const t=n.width||3;return rn.baseTheme({".cm-sql-gutter":{width:`${t}px`,minWidth:`${t}px`},".cm-sql-gutter .cm-gutterElement":{width:`${t}px`,padding:"0",margin:"0"},".cm-sql-gutter-marker":{width:"100%",height:"100%",display:"block"},".cm-lineNumbers .cm-gutterElement":{paddingLeft:"8px",paddingRight:"8px"}})}function Kp(n){return tr({class:`cm-sql-gutter ${n.className||""}`,markers:t=>Hp(t,n)})}function Gp(n={}){const t=n.parser||new pn,e=new Fp(t);return[uo,qp(e),Up(n),Kp(n)]}function Wp(n={}){const t=[],{enableLinting:e=!0,enableGutterMarkers:a=!0,enableHover:s=!0,linterConfig:o,gutterConfig:r,hoverConfig:i}=n;return e&&t.push(kp(o)),a&&t.push(Gp(r)),s&&(t.push(Op(i)),i!=null&&i.theme?t.push(i.theme):t.push(Dp())),t}const jp=new RegExp(`(${Ze})\\s*\\.\\s*([A-Za-z_][A-Za-z0-9_$]*)?$`);function Qp(n,t){let a=Rs(n).resolveInner(t,-1);for(;a;){if(a.type.name==="Statement")return a;a=a.parent}return null}function Yp(n){return/Comment|String/.test(n.type.name)}function Xp({tableReference:n,tableName:t,schemaName:e,tableInfo:a}){var s,o;return{tableName:t,schemaName:e,tableReference:n,columns:a.columns||[],primaryKeyColumns:new Set(((s=a.primary_keys)==null?void 0:s.map(r=>r.column))||[]),foreignKeysByColumn:new Map(((o=a.foreign_keys)==null?void 0:o.map(r=>[r.column,r]))||[])}}function Zp({tableReference:n,schemas:t,defaultSchemaName:e}){const a=Ca({tableReference:n,schemas:t,defaultSchemaName:e});return a?Xp({tableReference:n,tableName:a.tableName,schemaName:a.schemaName,tableInfo:a.tableInfo}):null}function Jp(n){return[...n.columns].sort((e,a)=>(e.ordinal_position||0)-(a.ordinal_position||0)).map(e=>hl({column:e,tableName:n.tableName,schemaName:n.schemaName,isPrimaryKey:n.primaryKeyColumns.has(e.name),foreignKey:n.foreignKeysByColumn.get(e.name)}))}function ef(n,t){const e=Rs(n.state).resolveInner(n.pos,-1);if(Yp(e))return null;const a=Qp(n.state,n.pos);if(!a)return null;const s=n.state.doc.sliceString(a.from,n.pos),o=jp.exec(s);if(!o)return null;const r=o[1],i=o[2]||"",l=xe(r),c=n.state.doc.sliceString(a.from,a.to),u=to(c).get(l)||r,p=Zp({tableReference:u,schemas:t.schemas,defaultSchemaName:t.defaultSchemaName});return p?{from:n.pos-i.length,options:Jp(p),validFor:/^[A-Za-z0-9_$]*$/}:null}function tf(n,t){if(!t.fileVariables)return null;const e=n.matchBefore(/:\w*$/);if(!e)return null;try{const a=JSON.parse(t.fileVariables),s=[];for(const o in a)s.push({label:`:${o}`,type:sr.Variable,boost:120,detail:"variable",info:()=>vl(o,a[o]),apply(r,i,l,c){const u=r.state.doc.sliceString(l-1,l)===":"?l-1:l;r.dispatch({changes:{from:u,to:c,insert:i.label}})}});return{from:e.from,options:s,validFor:/^:\w*$/}}catch{return null}}function af(n){return t=>{const e=tf(t,n);return e||ef(t,n)}}const nf=async()=>(await _s(()=>import("./BiOIaWuc.js"),[],import.meta.url)).default.keywords;function sf({codeEditorRef:n,fileVariables:t,connection:e,onExecuteStatement:a,onExplainAnalyzeCurrent:s}){const o=ln(),{schemasByContext:r,activeSchema:i}=ga(o),l=j({line:1,column:1}),c=()=>{var W;return(W=n.value)==null?void 0:W.editorView},m=O(()=>{var W,Z,oe;return((W=i.value)==null?void 0:W.name)||((oe=(Z=r.value)==null?void 0:Z[0])==null?void 0:oe.name)}),u=O(()=>{var W;return((W=e==null?void 0:e.value)==null?void 0:W.type)===re.REDIS}),p=O(()=>!u.value),f=O(()=>{var W;return((W=e==null?void 0:e.value)==null?void 0:W.type)===re.POSTGRES}),g=O(()=>gl({schemas:r.value,defaultSchemaName:m.value,fileVariables:t.value})),b=new Ra,v=new Ra,w=new Ra,x=()=>{var W,Z;return mr({dialect:wn((W=e==null?void 0:e.value)==null?void 0:W.type),upperCaseKeywords:!0,keywordCompletion:!((Z=e==null?void 0:e.value)!=null&&Z.type)||e.value.type===re.POSTGRES?vr:void 0,schema:g.value.schema,defaultSchema:g.value.defaultSchema})},N=()=>u.value?dr():x(),R=()=>{var W;return u.value?[]:wn((W=e==null?void 0:e.value)==null?void 0:W.type).language.data.of({autocomplete:E()})},_=()=>u.value?[]:Wp({enableLinting:!1,enableGutterMarkers:!1,enableHover:!0,hoverConfig:{hoverTime:250,enableKeywords:!0,keywords:async()=>await nf(),enableTables:!1,enableColumns:!1,enableFuzzySearch:!1}}),E=()=>af({schemas:r.value,defaultSchemaName:m.value,fileVariables:t.value}),{onHandleFormatCurrentStatement:T,onHandleFormatCode:A}=fl({getEditorView:()=>c()}),$=()=>{p.value&&T()},P=()=>{p.value&&A()},L=[Al(a),ys.of([{key:"Mod-s",run:()=>($(),!0),preventDefault:!0},{key:"Shift-Alt-f",run:()=>(P(),!0),preventDefault:!0},{key:"Mod-e",run:()=>(f.value&&s(),!0),preventDefault:!0},{key:"Mod-i",run:ur},{key:"Tab",run:cr}]),b.of(N()),v.of(R()),or,rr,...ir(),xs(),w.of(_()),lr],M=()=>{var le;const W=c();if(!W)return;const Z=pr((le=e==null?void 0:e.value)==null?void 0:le.type),oe=u.value?"line":"sql";W.dispatch({effects:[fr.of({dialect:Z,isEnable:!u.value,statementMode:oe}),b.reconfigure(N()),v.reconfigure(R()),w.reconfigure(_())]})};return ce(()=>{var W;return[(W=i.value)==null?void 0:W.name,r.value]},()=>{var W;(W=i.value)!=null&&W.name&&M()},{deep:!0,immediate:!0}),e&&ce(()=>{var W;return(W=e.value)==null?void 0:W.type},()=>{M()}),ce(()=>{var W;return(W=n.value)==null?void 0:W.editorView},W=>{W&&M()},{immediate:!0}),{extensions:L,sqlCompartment:b,cursorInfo:l,onHandleFormatCode:P,onHandleFormatCurrentStatement:$,reloadSqlCompartment:M}}function of({fileVariables:n,connection:t,redisDatabaseIndex:e,fieldDefs:a,beforeExecute:s}){const o=j(null),{explainAnalyzeOptionItems:r,serializeMode:i,toggleExplainOption:l,setSerializeMode:c,buildExplainAnalyzePrefix:m}=Rp(),u=Tp(),f=_p({getEditorView:()=>{var b;return((b=o.value)==null?void 0:b.editorView)??null},connection:t,redisDatabaseIndex:e,fileVariables:n,fieldDefs:a,resultTabs:u,buildExplainAnalyzePrefix:m,beforeExecute:s}),g=sf({codeEditorRef:o,fileVariables:n,connection:t,onExecuteStatement:f.executeCurrentStatement,onExplainAnalyzeCurrent:f.onExplainAnalyzeCurrent});return{codeEditorRef:o,currentRawQueryResult:f.currentRawQueryResult,rawResponse:f.rawResponse,queryProcessState:f.queryProcessState,onExecuteCurrent:f.onExecuteCurrent,extensions:g.extensions,sqlCompartment:g.sqlCompartment,cursorInfo:g.cursorInfo,onHandleFormatCode:g.onHandleFormatCode,onHandleFormatCurrentStatement:g.onHandleFormatCurrentStatement,onExplainAnalyzeCurrent:f.onExplainAnalyzeCurrent,explainAnalyzeOptionItems:r,serializeMode:i,toggleExplainOption:l,setSerializeMode:c,reloadSqlCompartment:g.reloadSqlCompartment,cancelStreamingQuery:f.cancelStreamingQuery,executedResults:u.executedResults,activeResultTabId:u.activeResultTabId,setActiveResultTab:u.setActiveResultTab,closeResultTab:u.closeResultTab,closeOtherResultTabs:u.closeOtherResultTabs,closeResultTabsToRight:u.closeResultTabsToRight,updateResultTabView:u.updateResultTabView}}const Fa=n=>{const{currentStatements:t}=ra(n);if(!t.length)return null;const e=Math.min(...t.map(o=>o.from)),a=Math.max(...t.map(o=>o.to));return{text:t.map(o=>o.text).join(`
|
|
25
|
+
`),from:e,to:a}};function rf(n){const t=j(!1),e=j(!1),a=()=>{const l=n.getEditorView();if(!l)return;const c=Fa(l);c&&navigator.clipboard.writeText(c.text)},s=()=>{const l=n.getEditorView();if(!l)return;const c=l.state.doc.toString();c&&navigator.clipboard.writeText(c)},o=()=>{const l=n.getEditorView();if(!l)return;const c=Fa(l);if(!c)return;let m=c.to;const u=l.state.doc.length;for(;m<u;){const p=l.state.sliceDoc(m,m+1);if(p===`
|
|
26
|
+
`||p==="\r"){m++;break}if(p===" "||p===" ")m++;else break}l.dispatch({changes:{from:c.from,to:m,insert:""},annotations:[hr.addToHistory.of(!0)]}),l.focus()};return{contextMenuItems:O(()=>{var m,u;const l=!t.value,c=!e.value;return[{type:ge.ACTION,title:"Execute",icon:"hugeicons:play",shortcut:"⌘↵",select:n.onExecuteCurrent,disabled:l},...(m=n.isExplainSupported)!=null&&m.value?[{type:ge.ACTION,title:"Analyze Query",icon:"hugeicons:analytics-01",shortcut:"⌘E",select:n.onExplainAnalyzeCurrent,disabled:l}]:[],{type:ge.SEPARATOR},...(u=n.isSupportFormat)!=null&&u.value?[{type:ge.ACTION,title:"Format Current",icon:"hugeicons:magic-wand-01",shortcut:"⌘S",select:n.onHandleFormatCurrentStatement,disabled:l},{type:ge.ACTION,title:"Format All",icon:"hugeicons:text-align-left",shortcut:"⇧⌥F",select:n.onHandleFormatCode,disabled:c}]:[],{type:ge.SEPARATOR},{type:ge.ACTION,title:"Copy Statement",icon:"hugeicons:copy-02",select:a,disabled:l},{type:ge.ACTION,title:"Copy All",icon:"hugeicons:copy-01",select:s,disabled:c},{type:ge.SEPARATOR},{type:ge.ACTION,title:"Delete Statement",icon:"hugeicons:delete-02",select:o,disabled:l}]}),onContextMenuOpen:l=>{if(!l)return;const c=n.getEditorView();if(!c){t.value=!1,e.value=!1;return}e.value=c.state.doc.length>0,t.value=!!Fa(c)}}}function lf(){const{workspaceId:n,connectionId:t}=gr(),e=Ts(),a=yr(),s=br(),o=a.getFileContentByIdSync(e.params.fileId),r=j((o==null?void 0:o.contents)??""),i=j(""),l=j(""),c=j([]),m=O(()=>{var R;return(R=a==null?void 0:a.flatNodes)==null?void 0:R.find(_=>_.id===e.params.fileId)});ce(()=>{var R;return(R=m.value)==null?void 0:R.variables},R=>{i.value=R||""},{immediate:!0});const u=O(()=>s.getConnectionsByWorkspaceId(n.value)),p=O(()=>u.value.find(R=>R.id===t.value));ce([()=>e.params.fileId,t],()=>{l.value=t.value},{immediate:!0});const f=O(()=>u.value.find(R=>R.id===l.value));return{fieldDefs:c,fileContents:r,fileVariables:i,currentFile:m,selectedConnectionId:l,updateSelectedConnection:R=>{l.value=R},updateFileContent:async R=>{var _;(_=m.value)!=null&&_.id&&(r.value=R,a.updateFileContent({contents:R,id:m.value.id}))},updateFileVariables:async R=>{var _;(_=m.value)!=null&&_.id&&(i.value=R,a.updateFile({id:m.value.id,variables:R}))},connection:f,currentOpenedConnection:p,connectionsByWsId:u,updateFileCursorPos:R=>{var _;(_=m.value)!=null&&_.id&&a.updateFile({id:m.value.id,cursorPos:R})},loadFileContent:async()=>{var _;const{contents:R}=await a.getFileContentById(e.params.fileId);r.value=R,i.value=((_=m.value)==null?void 0:_.variables)||""},isFromCache:o!==null}}const uf=()=>{const n=j(null),{previewRelationBreadcrumbs:t,onOpenBackReferencedTableModal:e,onOpenForwardReferencedTableModal:a,onUpdateSelectedTabInBreadcrumb:s,onClearBreadcrumbs:o,onBackPreviousBreadcrumb:r,onBackPreviousBreadcrumbByIndex:i}=ei();return{relationRoot:n,previewRelationBreadcrumbs:t,openRelationPreview:(m,u)=>{if(u==null||u==="")return;const{schemaName:p,tableName:f}=m;if(!p||!f)return;n.value={schemaName:p,tableName:f};const g=String(u);if(m.isForeignKey&&m.foreignKey){a({id:g,tableName:m.foreignKey.referenced_table,columnName:m.foreignKey.referenced_column,schemaName:m.foreignKey.referenced_table_schema});return}e({id:g,tableName:f,schemaName:p,columnName:m.sourceColumnName||m.originalName})},clearRelationPreview:()=>{o(),n.value=null},onOpenBackReferencedTableModal:e,onOpenForwardReferencedTableModal:a,onUpdateSelectedTabInBreadcrumb:s,onBackPreviousBreadcrumb:r,onBackPreviousBreadcrumbByIndex:i}},cf=({columns:n,originalRows:t})=>{const e=j([]),a=O(()=>new Map(n.value.map(l=>[l.aliasFieldName,l]))),s=l=>{var c,m;return((c=a.value.get(l))==null?void 0:c.short_type_name)||((m=a.value.get(l))==null?void 0:m.type)||""},o=l=>{var _;const{colDef:c,newValue:m,node:u}=l,p=c.field,f=u.rowIndex;if(!p||f===null||f===void 0||!a.value.get(p))return;const b=s(p),v=Is(b),w=(_=t.value[f])==null?void 0:_[p],{hasChanged:x,normalizedValue:N}=sl({fieldType:b,isObjectColumn:v,oldValue:w,newValue:m}),R=e.value.findIndex(E=>E.rowId===f&&E.fieldId===p);if(!x){R>=0&&(e.value=e.value.filter((E,T)=>T!==R));return}if(R>=0){const E=e.value.slice();E[R]={rowId:f,fieldId:p,newValue:N},e.value=E;return}e.value=[...e.value,{rowId:f,fieldId:p,newValue:N}]},r=()=>{e.value=[]},i=O(()=>e.value.length>0);return{editedCells:e,hasEditedCells:i,onCellValueChanged:o,clearEditedCells:r}},wa=n=>{const t=new Map;for(const e of n){if(!e.tableName||!e.schemaName)continue;const a=`${e.schemaName}.${e.tableName}`;let s=t.get(a);s||(s={schemaName:e.schemaName,tableName:e.tableName,primaryKeyColumns:[],primaryKeyFields:[]},t.set(a,s)),e.isPrimaryKey&&(s.primaryKeyColumns.push(e),s.primaryKeyFields.push(e.aliasFieldName))}return t},co=({column:n,row:t,tableGroups:e})=>{if(!t||!n.tableName||!n.schemaName||n.isPrimaryKey)return!1;const a=e.get(`${n.schemaName}.${n.tableName}`);return!a||a.primaryKeyFields.length===0?!1:a.primaryKeyFields.every(s=>{const o=t[s];return o!=null})},df=({column:n,tableGroups:t})=>{if(!n.tableName||!n.schemaName||n.isPrimaryKey)return!1;const e=t.get(`${n.schemaName}.${n.tableName}`);return!!e&&e.primaryKeyFields.length>0},mf=({editedCells:n,columns:t,rows:e,dbType:a})=>{const s=new Map(t.map(c=>[c.aliasFieldName,c])),o=wa(t),r=[],i=new Map;for(const c of n){const m=s.get(c.fieldId),u=e[c.rowId];if(!m||!u){r.push(c);continue}if(!co({column:m,row:u,tableGroups:o})){r.push(c);continue}const p=`${m.schemaName}.${m.tableName}`,f=o.get(p);if(!f){r.push(c);continue}let g=i.get(p);g||(g={table:f,rows:new Map},i.set(p,g));let b=g.rows.get(c.rowId);b||(b={},g.rows.set(c.rowId,b)),b[m.sourceColumnName||m.originalName]=c.newValue}const l=[];for(const[,c]of i){const m={schemaName:c.table.schemaName,tableName:c.table.tableName,pKeys:c.table.primaryKeyColumns.map(u=>u.sourceColumnName||u.originalName),updates:[],sqlStatements:[],hasNoPkWarning:!1};for(const[u,p]of c.rows){const f=e[u];if(!f)continue;const g={};for(const w of c.table.primaryKeyColumns)g[w.sourceColumnName||w.originalName]=f[w.aliasFieldName];const{sql:b,noPkWarning:v}=ti({schemaName:c.table.schemaName,tableName:c.table.tableName,pKeys:c.table.primaryKeyColumns.map(w=>w.sourceColumnName||w.originalName),pKeyValue:g,update:p,dbType:a});m.updates.push({pKeyValue:g,update:p}),m.sqlStatements.push(b),v&&(m.hasNoPkWarning=!0)}m.updates.length&&l.push(m)}return{groups:l,skipped:r}},pf=({selectedRows:n,columns:t,dbType:e})=>{const a=wa(t),s=[];for(const[,o]of a){if(!o.primaryKeyFields.length)continue;const r={schemaName:o.schemaName,tableName:o.tableName,pKeys:o.primaryKeyColumns.map(i=>i.sourceColumnName||i.originalName),pKeyValues:[],sqlStatements:[],hasNoPkWarning:!1};for(const i of n){if(!o.primaryKeyColumns.every(p=>{const f=i[p.aliasFieldName];return f!=null}))continue;const c={};for(const p of o.primaryKeyColumns)c[p.sourceColumnName||p.originalName]=i[p.aliasFieldName];const{sql:m,noPkWarning:u}=ai({schemaName:o.schemaName,tableName:o.tableName,pKeys:o.primaryKeyColumns.map(p=>p.sourceColumnName||p.originalName),pKeyValue:c,dbType:e});r.pKeyValues.push(c),r.sqlStatements.push(m),u&&(r.hasNoPkWarning=!0)}r.pKeyValues.length&&s.push(r)}return{groups:s}},ff=({connection:n,columns:t,rows:e,editedCells:a,selectedRows:s,onSaved:o,onDeleted:r})=>{const i=j(!1),l=j(!1),c=j("update"),m=O(()=>{var T;return mf({editedCells:a.value,columns:t.value,rows:e.value,dbType:(T=n.value)==null?void 0:T.type})}),u=O(()=>m.value.groups),p=O(()=>u.value.flatMap(T=>T.sqlStatements).join(`
|
|
27
|
+
`)),f=O(()=>u.value.some(T=>T.hasNoPkWarning)),g=O(()=>u.value.reduce((T,A)=>T+A.updates.length,0)),b=()=>{if(!a.value.length){lt.info("No changes to save.");return}if(!u.value.length){lt.warning("No safely updatable rows detected. Edits target columns that lack primary keys in the result.");return}c.value="update",i.value=!0},v=O(()=>{var T;return pf({selectedRows:s.value,columns:t.value,dbType:(T=n.value)==null?void 0:T.type})}),w=O(()=>v.value.groups),x=O(()=>w.value.some(T=>T.hasNoPkWarning)),N=O(()=>w.value.reduce((T,A)=>T+A.pKeyValues.length,0)),R=()=>{if(!s.value.length){lt.info("No rows selected for deletion.");return}if(!w.value.length){lt.warning("Selected rows cannot be safely deleted — columns lack primary-key metadata.");return}c.value="delete",i.value=!0},_=()=>{i.value=!1},E=async()=>{var A;if(!n.value){lt.error("No active connection.");return}l.value=!0;const T=xr(n.value);try{if(c.value==="update"){const $=u.value.map(P=>$fetch("/api/tables/bulk-update",{method:"POST",body:{tableName:P.tableName,schemaName:P.schemaName,pKeys:P.pKeys,updates:P.updates,...T}}));await Promise.all($),lt.success(`Saved ${g.value} row${g.value===1?"":"s"} successfully.`),i.value=!1,o()}else{const $=w.value.map(P=>$fetch("/api/tables/bulk-delete",{method:"POST",body:{tableName:P.tableName,schemaName:P.schemaName,pKeys:P.pKeys,pKeyValues:P.pKeyValues,...T}}));await Promise.all($),lt.success(`Deleted ${N.value} row${N.value===1?"":"s"} successfully.`),i.value=!1,r()}}catch($){const P=((A=$==null?void 0:$.data)==null?void 0:A.message)||($==null?void 0:$.message)||"Unknown error while executing.";console.error("Raw query mutation failed:",$),lt.error(P)}finally{l.value=!1}};return{isPreviewOpen:i,isMutating:l,pendingAction:c,previewGroups:u,previewSql:p,hasNoPkWarning:f,totalUpdateCount:g,skippedEdits:O(()=>m.value.skipped),requestSave:b,deleteGroups:w,deleteHasNoPkWarning:x,totalDeleteCount:N,requestDelete:R,cancelPreview:_,confirmAndExecute:E}},vf=(n,t)=>{if(!n.tableName||!n.schemaName)return!1;const e=n.sourceColumnName||n.originalName;return t.some(a=>{var s;return a.schema===n.schemaName&&a.table===n.tableName&&((s=a.used_by)==null?void 0:s.some(o=>o.referenced_column===e))})},hf=(n,t)=>!n.tableName||!n.schemaName?!1:n.isForeignKey&&n.foreignKey?!0:vf(n,t),gf=10,yf=({columns:n,rows:t,reservedTables:e,isEditingEnabled:a,dirtyTracker:s,onOpenRelationPreview:o})=>{if(!n.length)return[];const r=wa(n),i=t.slice(0,gf),l=[ol()];for(const c of n){const m=hf(c,e),u=a&&df({column:c,tableGroups:r}),p=rl({headerName:c.aliasFieldName,rows:i,field:c.aliasFieldName,isKey:m||c.isPrimaryKey}),f=u?b=>co({column:c,row:b.data,tableGroups:r}):!1,g=b=>{const v=b.colDef.field??"";if(!v)return;const w=Number(b.node.id??b.node.rowIndex),x=u&&s.cells.some(R=>R.rowId===w&&R.fieldId===v),N={backgroundColor:"unset"};return x?(N.backgroundColor="var(--color-orange-200)",N):(b.value===null&&(N.color="var(--muted-foreground)"),N)};l.push({headerName:c.aliasFieldName,field:c.aliasFieldName,colId:c.aliasFieldName,filter:!0,resizable:!0,sortable:!0,type:"editableColumn",editable:f,cellStyle:g,cellEditorSelector:b=>{var x;const v=(x=b.data)==null?void 0:x[c.aliasFieldName],w=c.short_type_name||c.type||"";if(si(w)||typeof v=="object"&&v!==null)return{component:"AgJsonCellEditor",popup:!0,popupPosition:"under"}},valueSetter:b=>{const v=c.short_type_name||c.type||"";return ul({params:b,fieldId:c.aliasFieldName,isObjectColumn:Is(v),emptyAsNull:!0})},headerComponentParams:{innerHeaderComponent:ll,isPrimaryKey:c.isPrimaryKey,isForeignKey:c.isForeignKey},cellRenderer:m?ni:void 0,cellRendererParams:m?{isPrimaryKey:!0,onOpenPreviewReverseTableModal:b=>o(c,b)}:void 0,valueFormatter:il,width:p})}return l},fn={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"},bf=Object.keys(fn).sort((n,t)=>t.length-n.length),mo=n=>{if(!n)return"";const t=n.toUpperCase().trim().replace(/;$/,"");for(const e of bf)if(t===e||t.startsWith(`${e} `))return e;return t.split(/\s+/)[0]||t},xf=n=>{if(!n)return!1;const t=n.toUpperCase().trim(),e=mo(t);if(["SELECT","VALUES","SHOW","EXPLAIN","TABLE"].includes(e))return!1;const s=fn[e];return!!(["INSERT","UPDATE","DELETE","TRUNCATE","COPY","MERGE","CALL","DO"].includes(e)||s==="DDL"||s==="DCL"||["SET","RESET","GRANT","REVOKE","COMMENT","ANALYZE","VACUUM","REINDEX","CLUSTER"].includes(e)||["CREATE","DROP","ALTER"].includes(e))},Sf=(n,t)=>{const e=n||"Query",a=t??0;return["INSERT","UPDATE","DELETE"].includes(e.toUpperCase())?`${e} successful. ${a} rows affected.`:`${e} successful.`};class At{constructor(t,e){we(this,"cmd");we(this,"commandKey");we(this,"rowCount");this.cmd=(t||"").toUpperCase().trim(),this.commandKey=mo(this.cmd),this.rowCount=e}isMutation(){return xf(this.cmd)}getMessage(t){return t?Sf(this.cmd,this.rowCount):""}getCategory(){return fn[this.commandKey]??"UNKNOWN"}build(){const t=this.isMutation();return{isMutation:t,message:this.getMessage(t),category:this.getCategory()}}}class Cf extends At{isMutation(){return["VACUUM","ANALYZE","REINDEX","CLUSTER"].includes(this.commandKey)?!0:super.isMutation()}}class Za extends At{isMutation(){return this.commandKey==="OPTIMIZE"?!0:super.isMutation()}getMessage(t){return this.commandKey==="TRUNCATE"?"TRUNCATE successful.":super.getMessage(t)}}class wf extends Za{}class po extends At{isMutation(){return this.commandKey==="TRUNCATE"?!0:super.isMutation()}getMessage(t){return this.commandKey==="INSERT"?`INSERT successful. ${this.rowCount} row(s) affected.`:super.getMessage(t)}}class _f extends po{}class hs extends At{}class Rf extends At{getMessage(t){return this.commandKey==="MERGE"?`MERGE successful. ${this.rowCount} rows affected.`:super.getMessage(t)}}class Tf extends At{getMessage(t){return this.commandKey==="TRUNCATE"?"TRUNCATE successful.":this.commandKey==="MERGE"?`MERGE successful. ${this.rowCount} rows affected.`:super.getMessage(t)}}const Ef={[re.POSTGRES]:Cf,[re.MARIADB]:Za,[re.MYSQL]:Za,[re.MYSQL2]:wf,[re.REDIS]:hs,[re.SQLITE3]:po,[re.SNOWFLAKE]:hs,[re.BETTER_SQLITE3]:_f,[re.MSSQL]:Rf,[re.ORACLE]:Tf},Nf=(n,t=0,e=re.POSTGRES)=>{const a=Ef[e];if(!a)throw new Error(`Unsupported database client type: "${e}"`);return new a(n,t).build()},Af=se({__name:"RawQueryContextMenu",props:{cellContextMenu:{},cellHeaderContextMenu:{},data:{},selectedRows:{},tableName:{},schemaName:{}},emits:["onClearContextMenu"],setup(n,{emit:t}){const e=t;return(a,s)=>(C(),F(cl,{"cell-context-menu":a.cellContextMenu,"cell-header-context-menu":a.cellHeaderContextMenu,data:a.data,"selected-rows":a.selectedRows,"table-name":a.tableName,"schema-name":a.schemaName,"enable-copy-as-sql":"",onOnClearContextMenu:s[0]||(s[0]=o=>e("onClearContextMenu"))},{default:y(()=>[Ke(a.$slots,"default")]),_:3},8,["cell-context-menu","cell-header-context-menu","data","selected-rows","table-name","schema-name"]))}}),Mf={class:"w-full select-none h-9 flex items-center justify-between px-1"},If={class:"flex items-center gap-1"},Lf={class:"absolute -right-1.5 -top-1.5 min-w-4 rounded-full bg-green-700 px-1 text-xxs font-medium leading-4 text-white"},kf={class:"flex items-center gap-2"},zf={class:"flex items-center gap-2"},$f={key:3,class:"font-normal text-xs text-primary/60"},Of={key:4,class:"font-normal text-sm text-primary"},Vf={class:"font-normal select-text text-xs text-muted-foreground"},Pf={key:0,class:"flex items-center gap-1"},Df={key:1,class:"flex items-center gap-1"},Ff={key:2},Bf={key:3},Hf={class:"flex items-center gap-2"},qf={class:"flex items-center gap-1"},Uf=se({__name:"RawQueryResultControlBar",props:{pendingCount:{},isMutating:{type:Boolean},isEditingEnabled:{type:Boolean},totalSelectedRows:{},queryTime:{},totalRows:{},executeLoading:{type:Boolean},isStreaming:{type:Boolean},streamingRowCount:{},hasError:{type:Boolean}},emits:["save","discard","delete","download"],setup(n,{emit:t}){const e=t;return(a,s)=>{const o=be;return C(),z("div",Mf,[S("div",If,[a.isEditingEnabled?(C(),z(ae,{key:0},[a.pendingCount>0?(C(),F(d(Pe),{key:0},{default:y(()=>[h(d(Oe),{"as-child":""},{default:y(()=>[h(d(Le),{variant:"outline",size:"xxs",class:"relative overflow-visible font-normal",disabled:a.isMutating,onClick:s[0]||(s[0]=r=>e("save"))},{default:y(()=>[a.isMutating?(C(),F(o,{key:0,name:"lucide:loader-circle",class:"animate-spin"})):(C(),F(o,{key:1,name:"lucide:save"})),S("span",Lf,U(a.pendingCount),1),h(d(vt),null,{default:y(()=>s[6]||(s[6]=[k("⌘S")])),_:1})]),_:1},8,["disabled"])]),_:1}),h(d(Ve),null,{default:y(()=>[S("p",kf,[s[8]||(s[8]=k(" Preview & execute UPDATE statements ")),h(d(vt),null,{default:y(()=>s[7]||(s[7]=[k("⌘S")])),_:1})])]),_:1})]),_:1})):K("",!0),a.pendingCount>0?(C(),F(d(Pe),{key:1},{default:y(()=>[h(d(Oe),{"as-child":""},{default:y(()=>[h(d(Le),{variant:"outline",size:"xxs",class:"font-normal",disabled:a.isMutating,onClick:s[1]||(s[1]=r=>e("discard"))},{default:y(()=>[h(o,{name:"hugeicons:undo-02"}),s[9]||(s[9]=k(" Discard "))]),_:1},8,["disabled"])]),_:1}),h(d(Ve),null,{default:y(()=>s[10]||(s[10]=[S("p",null,"Discard pending edits",-1)])),_:1})]),_:1})):K("",!0),a.totalSelectedRows>0?(C(),F(d(Pe),{key:2},{default:y(()=>[h(d(Oe),{"as-child":""},{default:y(()=>[h(d(Le),{variant:"outline",size:"xxs",disabled:a.isMutating,onClick:s[2]||(s[2]=r=>e("delete"))},{default:y(()=>[h(o,{name:"lucide:trash"}),h(d(vt),null,{default:y(()=>s[11]||(s[11]=[k("⌥⌘⌫")])),_:1})]),_:1},8,["disabled"])]),_:1}),h(d(Ve),null,{default:y(()=>[S("p",zf,[k(" Delete "+U(a.totalSelectedRows)+" selected row"+U(a.totalSelectedRows===1?"":"s")+" ",1),h(d(vt),null,{default:y(()=>s[12]||(s[12]=[k("⌥⌘⌫")])),_:1})])]),_:1})]),_:1})):K("",!0),a.totalSelectedRows>0?(C(),z("p",$f," Selected ")):K("",!0),a.totalSelectedRows>0?(C(),z("p",Of,U(a.totalSelectedRows),1)):K("",!0)],64)):K("",!0)]),S("div",Vf,[a.isStreaming?(C(),z("span",Pf,[h(o,{name:"hugeicons:loading-03",class:"size-4! animate-spin"}),k(" Streaming... "+U(d(Ga)(a.streamingRowCount))+" rows ",1)])):a.executeLoading?(C(),z("span",Df,[s[13]||(s[13]=k(" Processing ")),h(o,{name:"hugeicons:loading-03",class:"size-4! animate-spin"})])):a.hasError?(C(),z("span",Ff," Query: 1 error in "+U(d(Dt)(a.queryTime)),1)):(C(),z("span",Bf," Query success: "+U(d(Ga)(a.totalRows))+" rows in "+U(d(Dt)(a.queryTime)),1))]),S("div",Hf,[S("div",qf,[a.isEditingEnabled?(C(),z(ae,{key:0},[h(o,{name:"hugeicons:pencil-edit-02",class:"size-3.5 text-muted-foreground"}),s[14]||(s[14]=S("span",{class:"font-normal text-xs text-primary/60"},"Editable",-1))],64)):(C(),z(ae,{key:1},[h(o,{name:"hugeicons:lock-01",class:"size-3.5 text-muted-foreground"}),s[15]||(s[15]=S("span",{class:"font-normal text-xs text-primary/60"},"Read-only",-1))],64))]),h(d(Ba),null,{default:y(()=>[h(d(Ha),{"as-child":""},{default:y(()=>[h(d(Le),{variant:"outline",size:"xxs",class:"font-normal flex items-center gap-1 cursor-pointer"},{default:y(()=>[h(o,{name:"hugeicons:download-04",class:"size-3.5"}),s[16]||(s[16]=S("span",null,"Export",-1))]),_:1})]),_:1}),h(d(qa),{align:"end",class:"w-36"},{default:y(()=>[h(d(Vt),{onClick:s[3]||(s[3]=r=>e("download","csv")),class:"text-xs cursor-pointer"},{default:y(()=>[h(o,{name:"hugeicons:file-01",class:"mr-2 size-3.5"}),s[17]||(s[17]=k(" Export CSV "))]),_:1}),h(d(Vt),{onClick:s[4]||(s[4]=r=>e("download","json")),class:"text-xs cursor-pointer"},{default:y(()=>[h(o,{name:"hugeicons:code",class:"mr-2 size-3.5"}),s[18]||(s[18]=k(" Export JSON "))]),_:1}),h(d(Vt),{onClick:s[5]||(s[5]=r=>e("download","text")),class:"text-xs cursor-pointer"},{default:y(()=>[h(o,{name:"hugeicons:file-01",class:"mr-2 size-3.5"}),s[19]||(s[19]=k(" Export TSV "))]),_:1})]),_:1})]),_:1})])])}}}),Kf=se({__name:"RawQueryUpdatePreviewDialog",props:{open:{type:Boolean},action:{},updateGroups:{},totalUpdates:{},updateHasNoPkWarning:{type:Boolean},deleteGroups:{},totalDeletes:{},deleteHasNoPkWarning:{type:Boolean},isMutating:{type:Boolean}},emits:["confirm","cancel"],setup(n,{emit:t}){const e=n,a=t,s=O(()=>e.action==="delete"),o=O(()=>s.value?e.deleteHasNoPkWarning??!1:e.updateHasNoPkWarning??!1),r=O(()=>o.value?s.value?"High-Risk: Confirm Delete":"High-Risk: Confirm Save":s.value?"Confirm Delete":"Confirm Save"),i=O(()=>o.value?"Caution: No primary key detected. To identify the record, this operation will match all columns in the WHERE clause. This carries a risk of affecting multiple rows if they share identical data. Please verify the SQL below carefully before proceeding:":s.value?"The following SQL will be executed to delete the selected rows:":"The following SQL will be executed to save your changes:"),l=O(()=>s.value?"Delete":"Save"),c=O(()=>{const p=s.value?e.deleteGroups??[]:e.updateGroups??[];return p.length===0?"":p.map(f=>`${`-- ${f.schemaName}.${f.tableName}`}
|
|
28
|
+
${f.sqlStatements.join(`
|
|
29
|
+
`)}`).join(`
|
|
30
|
+
|
|
31
|
+
`)}),m=()=>{a("confirm")},u=()=>{a("cancel")};return(p,f)=>{const g=be;return C(),F(d(Sr),{open:p.open,"onUpdate:open":f[0]||(f[0]=b=>!b&&!p.isMutating&&a("cancel"))},{default:y(()=>[h(d(Cr),{size:"preview"},{default:y(()=>[h(d(ya),{visible:!!p.isMutating},null,8,["visible"]),h(d(wr),null,{default:y(()=>[h(d(_r),{class:ye(["flex items-center gap-2 text-base font-medium",{"text-destructive":d(o)||d(s)}])},{default:y(()=>[d(o)||d(s)?(C(),F(g,{key:0,name:d(o)?"lucide:alert-triangle":"lucide:trash-2",class:ye(["size-5",(d(o),"text-destructive")])},null,8,["name","class"])):K("",!0),k(" "+U(d(r)),1)]),_:1},8,["class"]),h(d(Rr),{class:ye({"text-destructive font-normal":d(o)})},{default:y(()=>[k(U(d(i)),1)]),_:1},8,["class"])]),_:1}),h(d(xa),{code:d(c),language:"sql","show-copy-button":"","max-height":"24rem"},null,8,["code"]),h(d(Tr),null,{default:y(()=>[h(d(Er),{class:"border font-normal",onClick:u},{default:y(()=>f[1]||(f[1]=[k(" Cancel ")])),_:1}),h(d(Nr),{class:ye(["border font-normal flex gap-1",{"bg-destructive hover:bg-destructive/90":d(s)}]),onClick:m},{default:y(()=>[h(g,{name:d(s)?"lucide:trash-2":"lucide:save",class:"size-4"},null,8,["name"]),k(" "+U(d(l)),1)]),_:1},8,["class"])]),_:1})]),_:1})]),_:1},8,["open"])}}}),Gf=se({__name:"ResultTabResultView",props:{activeTab:{},activeTabColumns:{},formattedData:{},executeLoading:{type:Boolean},isStreaming:{type:Boolean}},setup(n){const t=n,e=j(),a=j(),s=ln(),{reservedSchemas:o}=ga(s),r=j([]),i=Y=>{r.value=Y},l=Y=>{const pe=t.formattedData,tt=new Date().toISOString().slice(0,19).replace(/:/g,"-"),at=`query_result_tab_${t.activeTab.seqIndex}_${tt}`,qt={csv:ta.CSV_WITH_HEADER,json:ta.JSON,text:ta.TSV};pl(pe,`query_result_tab_${t.activeTab.seqIndex}`,qt[Y],"all",void 0,at)},c=O(()=>{var Y;return Nf(t.activeTab.metadata.command||"",t.activeTab.metadata.rowCount||0,(Y=t.activeTab.metadata.connection)==null?void 0:Y.type)}),m=O(()=>c.value.isMutation),u=O(()=>c.value.message),p=O(()=>t.activeTabColumns.length>0),f=O(()=>t.activeTab.result.length===0&&!p.value&&!t.executeLoading&&!t.isStreaming),g=O(()=>{var pe;const Y=(pe=t.activeTab.metadata.connection)==null?void 0:pe.id;return Y?o.value[Y]||[]:[]}),b=O(()=>wa(t.activeTabColumns)),v=O(()=>{if(t.isStreaming)return!1;for(const[,Y]of b.value)if(Y.primaryKeyFields.length>0)return!0;return!1}),w=Y=>Y.map(pe=>({...pe})),x=Y=>dl(Y),N=Y=>Y.map(pe=>{const{[zn]:tt,...at}=pe;return{...at}}),R=(...Y)=>{const pe=new Map;for(const tt of Y)for(const at of tt)pe.set(`${at.rowId}:${at.fieldId}`,at);return[...pe.values()]},_=O(()=>t.activeTabColumns),E=O(()=>t.formattedData||[]),T=j(w(E.value)),A=j(x(T.value)),$=j([]),{editedCells:P,onCellValueChanged:L,clearEditedCells:M}=cf({columns:_,originalRows:T});function W(){var Y,pe;(pe=(Y=e.value)==null?void 0:Y.gridApi)==null||pe.refreshCells({force:!0})}const Z=O(()=>R($.value,P.value)),oe=()=>{A.value=x(T.value)},le=()=>{P.value.slice().length&&(T.value=N(A.value),$.value=[],M())},de=()=>{M(),oe(),W()};ce([E,()=>t.activeTab.id],([Y])=>{T.value=w(Y),$.value=[],M(),oe()});const me={cells:[]};ce(Z,Y=>{me.cells=Y,W()},{immediate:!0});const Fe=O(()=>t.activeTab.metadata.connection),ze=O(()=>r.value),{isPreviewOpen:ut,isMutating:Ce,pendingAction:Je,previewGroups:Ge,hasNoPkWarning:he,totalUpdateCount:ot,requestSave:I,deleteGroups:D,deleteHasNoPkWarning:H,totalDeleteCount:B,requestDelete:q,cancelPreview:V,confirmAndExecute:Q}=ff({connection:Fe,columns:_,rows:T,editedCells:P,selectedRows:ze,onSaved:le,onDeleted:()=>{const Y=new Set(r.value.map(pe=>pe[zn]));T.value=T.value.filter((pe,tt)=>!Y.has(tt+1)),$.value=[],M(),oe(),r.value=[]}}),{relationRoot:J,previewRelationBreadcrumbs:ie,openRelationPreview:Be,clearRelationPreview:rt,onOpenBackReferencedTableModal:ct,onOpenForwardReferencedTableModal:Mt,onUpdateSelectedTabInBreadcrumb:te,onBackPreviousBreadcrumb:Ne,onBackPreviousBreadcrumbByIndex:et}=uf(),it=O(()=>yf({columns:t.activeTabColumns,rows:T.value,reservedTables:g.value,isEditingEnabled:v.value,dirtyTracker:me,onOpenRelationPreview:Be}));return Es([{key:"meta+s",callback:()=>{!v.value||Ce.value||I()},isPreventDefault:!0},{key:"meta+alt+backspace",callback:()=>{!v.value||Ce.value||q()},isPreventDefault:!0}],{target:a}),(Y,pe)=>{var qt,vn,hn,gn;const tt=Bt,at=qs;return C(),z("div",{ref_key:"containerRef",ref:a,class:"h-full w-full flex flex-col relative"},[h(d(ya),{visible:d(Ce)},null,8,["visible"]),d(J)&&d(ie).length?(C(),F(oi,{key:0,open:d(ie).length>0,breadcrumbs:d(ie),currentTableName:d(J).tableName,connectionId:((qt=Y.activeTab.metadata.connection)==null?void 0:qt.id)||"",workspaceId:((vn=Y.activeTab.metadata.connection)==null?void 0:vn.workspaceId)||"",rootSchemaName:d(J).schemaName,onClearBreadcrumb:d(rt),onOnOpenBackReferencedTableModal:d(ct),onOnOpenForwardReferencedTableModal:d(Mt),onOnUpdateSelectedTabInBreadcrumb:d(te),onOnBackPreviousBreadcrumb:d(Ne),onOnBackPreviousBreadcrumbByIndex:d(et)},null,8,["open","breadcrumbs","currentTableName","connectionId","workspaceId","rootSchemaName","onClearBreadcrumb","onOnOpenBackReferencedTableModal","onOnOpenForwardReferencedTableModal","onOnUpdateSelectedTabInBreadcrumb","onOnBackPreviousBreadcrumb","onOnBackPreviousBreadcrumbByIndex"])):K("",!0),h(Kf,{open:d(ut),action:d(Je),"update-groups":d(Ge),"total-updates":d(ot),"update-has-no-pk-warning":d(he),"delete-groups":d(D),"total-deletes":d(B),"delete-has-no-pk-warning":d(H),"is-mutating":d(Ce),onConfirm:d(Q),onCancel:d(V)},null,8,["open","action","update-groups","total-updates","update-has-no-pk-warning","delete-groups","total-deletes","delete-has-no-pk-warning","is-mutating","onConfirm","onCancel"]),Y.activeTab.result.length===0&&d(m)&&!Y.executeLoading&&!Y.isStreaming?(C(),F(tt,{key:1,desc:d(u),hiddenIcon:"",class:"h-full"},null,8,["desc"])):d(f)?(C(),F(tt,{key:2,title:"No Results",desc:"The query returned no records.",class:"h-full"})):(C(),z(ae,{key:3},[d(A).length?(C(),F(Uf,{key:0,"pending-count":d(P).length,"is-mutating":d(Ce),"is-editing-enabled":d(v),"total-selected-rows":d(r).length,"query-time":Y.activeTab.metadata.queryTime,"total-rows":Y.formattedData.length,"execute-loading":Y.executeLoading,"is-streaming":Y.isStreaming,"streaming-row-count":Y.formattedData.length,"has-error":!!Y.activeTab.metadata.executeErrors,onSave:d(I),onDiscard:de,onDelete:d(q),onDownload:l},null,8,["pending-count","is-mutating","is-editing-enabled","total-selected-rows","query-time","total-rows","execute-loading","is-streaming","streaming-row-count","has-error","onSave","onDelete"])):K("",!0),h(Af,{data:Y.formattedData||[],selectedRows:d(r),cellContextMenu:(hn=d(e))==null?void 0:hn.cellContextMenu,cellHeaderContextMenu:(gn=d(e))==null?void 0:gn.cellHeaderContextMenu,onOnClearContextMenu:pe[0]||(pe[0]=dv=>{var yn;return(yn=d(e))==null?void 0:yn.clearCellContextMenu()}),class:"flex-1 min-h-0"},{default:y(()=>[h(at,{ref_key:"rawQueryTableRef",ref:e,"column-defs":d(it),"row-data":d(A),"selected-rows":d(r),"enable-simple-copy-context-menu":!1,"empty-title":"No Results","empty-description":"The query returned no records.",class:"h-full","allow-editing":d(v),"suppress-scroll-on-new-data":!0,onSelectionChanged:i,onCellValueChanged:d(L)},null,8,["column-defs","row-data","selected-rows","allow-editing","onCellValueChanged"])]),_:1},8,["data","selectedRows","cellContextMenu","cellHeaderContextMenu"])],64))],512)}}}),Wf={key:0,class:"flex mt-7 [writing-mode:vertical-rl]"},jf=["onClick"],Qf={class:"h-full w-full flex flex-col min-w-0"},Yf={class:"flex items-end justify-between flex-shrink-0 w-full"},Xf={class:"flex items-end overflow-x-auto pt-0.5 flex-1 min-w-0 pr-4"},Zf=["onClick","onContextmenu"],Jf={class:"truncate text-xs font-medium"},ev=["onClick"],tv={class:"flex items-center gap-1.5 px-2 pb-1.5 flex-shrink-0"},av={class:"h-full w-full border rounded-md rounded-tl-none overflow-hidden"},nv=se({__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(n,{emit:t}){const e=n,a=ln(),{schemas:s}=ga(a),o=t,r=j(null),i=j(!1),l=R=>{R.key==="Escape"&&i.value&&(i.value=!1)},c=O(()=>{if(!r.value)return!1;const R=Array.from(e.executedResults.keys()),_=R.indexOf(r.value);return _>=0&&_<R.length-1}),m=[{value:ee.RESULT,label:"Result"},{value:ee.EXPLAIN,label:"Explain"},{value:ee.RAW,label:"Raw"},{value:ee.INFO,label:"Info"},{value:ee.CHART,label:"Chart"},{value:ee.ERROR,label:"Errors"}],u=new Map,p=nt([]);let f=null;const g=O(()=>e.activeTabId&&e.executedResults.get(e.activeTabId)||null);ce(()=>{var R;return(R=g.value)==null?void 0:R.metadata.connection},async R=>{var _;if(R)try{(_=s.value[R.id])!=null&&_.length||await a.fetchSchemas({connectionId:R.id,workspaceId:R.workspaceId,connection:R}),await a.fetchReservedSchemas({connectionId:R.id,connection:R})}catch(E){console.error("[RawQueryResultTabs] Failed to load schema metadata",E)}},{immediate:!0});const b=O(()=>{var R;return((R=g.value)==null?void 0:R.view)||ee.RESULT}),v=O(()=>{var _,E;if(!((_=g.value)!=null&&_.metadata.fieldDefs))return[];const R=(E=g.value.metadata.connection)==null?void 0:E.id;return ms({fieldDefs:g.value.metadata.fieldDefs,statementQuery:g.value.metadata.statementQuery,schemas:R?s.value[R]||[]:[],getTableInfoById:a.getTableInfoById})}),w=R=>{var P,L;const _=((P=R.result)==null?void 0:P.length)||0,E=`${R.id}_${_}`;if(u.has(E))return u.get(E);const T=(L=R.metadata.connection)==null?void 0:L.id,A=ms({fieldDefs:R.metadata.fieldDefs||[],statementQuery:R.metadata.statementQuery,schemas:T?s.value[T]||[]:[],getTableInfoById:a.getTableInfoById}),$=Um(R.result||[],A);u.set(E,$);for(const M of u.keys())M.startsWith(`${R.id}_`)&&M!==E&&u.delete(M);return $};ce(g,R=>{f&&cancelAnimationFrame(f),f=requestAnimationFrame(()=>{p.value=R?w(R):[],f=null})},{immediate:!0}),ha(()=>{window.addEventListener("keydown",l)}),Ar(()=>{window.removeEventListener("keydown",l),f&&cancelAnimationFrame(f)});const x=R=>{e.activeTabId&&o("update:view",e.activeTabId,R)},N=R=>!!R.metadata.executeErrors;return(R,_)=>{const E=be,T=Oe,A=Ve,$=Pe,P=ya,L=Bt;return C(),z("div",{class:ye(d(_t)("h-full flex w-full bg-background transition-all duration-200",d(i)?"fixed inset-0 z-[999] pt-10 px-0 pb-0":""))},[d(g)?(C(),z("div",Wf,[(C(),z(ae,null,ue(m,M=>S("div",{key:M.value,onClick:W=>N(d(g))&&(M.value===d(ee).RESULT||M.value===d(ee).RAW||M.value===d(ee).CHART)||M.value===d(ee).ERROR&&!N(d(g))?null:x(M.value),class:ye(d(_t)("border px-1 text-xs font-normal transition-colors",d(b)===M.value?"bg-muted border-transparent border-r-border":"border-transparent",M.value===d(ee).ERROR&&N(d(g))?"hover:bg-muted cursor-pointer":M.value===d(ee).EXPLAIN&&!d(g).metadata.statementQuery.startsWith("EXPLAIN")?null:"",M.value===d(ee).ERROR&&!N(d(g))?"opacity-40 cursor-not-allowed":"",(M.value===d(ee).RESULT||M.value===d(ee).RAW||M.value===d(ee).CHART)&&N(d(g))?"opacity-40 cursor-not-allowed":"",M.value===d(ee).EXPLAIN&&!d(g).metadata.statementQuery.startsWith("EXPLAIN")?"opacity-40 cursor-not-allowed":"",M.value===d(ee).ERROR&&!N(d(g))||(M.value===d(ee).RESULT||M.value===d(ee).RAW||M.value===d(ee).CHART)&&N(d(g))||M.value===d(ee).EXPLAIN&&!d(g).metadata.statementQuery.startsWith("EXPLAIN")?"":"hover:bg-muted cursor-pointer"))},U(M.label),11,jf)),64))])):K("",!0),S("div",Qf,[S("div",Yf,[S("div",Xf,[h(d(Ns),null,{default:y(()=>[h(d(As),{class:"flex items-end"},{default:y(()=>[(C(!0),z(ae,null,ue(R.executedResults,([M,W])=>(C(),F($,{key:M},{default:y(()=>[h(T,{"as-child":""},{default:y(()=>[S("div",{onClick:Z=>R.$emit("update:activeTab",M),onContextmenu:Z=>r.value=M,class:ye(d(_t)("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",M===R.activeTabId?"border-b-transparent bg-background dark:bg-accent":"border-transparent bg-muted/30"))},[h(E,{name:N(W)?"hugeicons:alert-02":"hugeicons:sql",class:ye(d(_t)("min-w-4",N(W)?"text-red-500":""))},null,8,["name","class"]),S("div",Jf," Query "+U(W.seqIndex)+" - "+U(W.metadata.statementQuery),1),S("div",{onClick:sn(Z=>R.$emit("close-tab",M),["stop"]),class:"hover:bg-accent h-5 w-5 flex items-center justify-center rounded-full opacity-0"},[h(E,{name:"lucide:x",class:"stroke-[2.5]! size-3!"})],8,ev)],42,Zf)]),_:2},1024),h(A,{class:"max-w-xl"},{default:y(()=>[S("p",null,U(W.metadata.statementQuery),1)]),_:2},1024)]),_:2},1024))),128))]),_:1}),d(r)?(C(),F(d(Ms),{key:0,hideWhenDetached:"",class:"w-56"},{default:y(()=>[h(d(Jt),{onSelect:_[0]||(_[0]=M=>R.$emit("close-tab",d(r)))},{default:y(()=>_[5]||(_[5]=[k(" Close ")])),_:1}),h(d(Jt),{onSelect:_[1]||(_[1]=M=>R.$emit("close-other-tabs",d(r)))},{default:y(()=>_[6]||(_[6]=[k(" Close Others ")])),_:1}),h(d(Jt),{disabled:!d(c),onSelect:_[2]||(_[2]=M=>R.$emit("close-tabs-to-right",d(r)))},{default:y(()=>_[7]||(_[7]=[k(" Close to the Right ")])),_:1},8,["disabled"])]),_:1})):K("",!0)]),_:1})]),S("div",tv,[h($,null,{default:y(()=>[h(T,{"as-child":""},{default:y(()=>[h(d(Le),{onClick:_[3]||(_[3]=M=>i.value=!d(i)),variant:d(i)?"secondary":"ghost",size:"icon",class:"size-5 rounded border border-border cursor-pointer"},{default:y(()=>[h(E,{name:"hugeicons:full-screen",class:"size-3.5!"})]),_:1},8,["variant"])]),_:1}),h(A,{align:"end",side:"top"},{default:y(()=>[k(U(d(i)?"Zoom In (Restore Normal)":"Zoom Out (Full Screen)"),1)]),_:1})]),_:1})])]),S("div",av,[R.executeLoading&&R.activeTabId?(C(),F(P,{key:0,visible:""})):K("",!0),d(g)?d(g)&&d(b)===d(ee).RESULT?(C(),F(Gf,{"active-tab":d(g),"active-tab-columns":d(v),"formatted-data":d(p),"execute-loading":R.executeLoading,"is-streaming":R.isStreaming,key:d(g).id},null,8,["active-tab","active-tab-columns","formatted-data","execute-loading","is-streaming"])):d(g)&&d(b)===d(ee).EXPLAIN?(C(),F(d(Em),{key:3,"active-tab":d(g)},null,8,["active-tab"])):d(g)&&d(b)===d(ee).RAW?(C(),F(Sp,{key:4,"formatted-data":d(p),"execute-loading":R.executeLoading,"is-streaming":R.isStreaming},null,8,["formatted-data","execute-loading","is-streaming"])):d(g)&&d(b)===d(ee).CHART?(C(),F(d(cd),{key:5,"active-tab":d(g),"active-tab-columns":d(v),"formatted-data":d(p)},null,8,["active-tab","active-tab-columns","formatted-data"])):d(g)&&d(b)===d(ee).INFO?(C(),F(bp,{key:6,"active-tab":d(g)},null,8,["active-tab"])):d(g)&&d(b)===d(ee).ERROR?(C(),F(tp,{key:7,"active-tab":d(g),onOnChangeView:_[4]||(_[4]=M=>x(M))},null,8,["active-tab"])):K("",!0):(C(),F(L,{key:1,title:"No results",desc:"Execute a query to see results"}))])])],2)}}}),sv={class:"flex flex-col h-full p-1"},ov={class:"flex flex-col h-full border rounded-md"},rv={class:"h-full flex flex-col overflow-y-auto"},iv={class:"flex flex-col h-full border rounded-md bg-muted"},lv={class:"flex items-center gap-1 font-normal text-sm px-2 py-1"},uv={class:"h-full flex flex-col overflow-y-auto"},cv=se({__name:"RawQuery",props:{isSupportVariable:{type:Boolean,default:!0}},setup(n){const t=n,e=Ts(),a=O(()=>{const te=e.params.workspaceId;return Array.isArray(te)?te[0]??"":te??""}),s=ws(),o=Mr(),r=lf(),{connection:i,currentFile:l,currentOpenedConnection:c,fileContents:m,fileVariables:u,selectedConnectionId:p,updateSelectedConnection:f,updateFileContent:g,updateFileVariables:b,connectionsByWsId:v,fieldDefs:w}=r,x=O(()=>{var te;return((te=i.value)==null?void 0:te.type)===re.REDIS}),N=O(()=>!x.value),R=O(()=>{var te;return[re.SQLITE3,re.BETTER_SQLITE3].includes((te=i.value)==null?void 0:te.type)}),_=O(()=>t.isSupportVariable&&!x.value&&!R.value),E=O(()=>{var te;return((te=i.value)==null?void 0:te.type)===re.POSTGRES}),T=j("");Ir(()=>{T.value=_.value?u.value:""});const A=O(()=>x.value?i.value:void 0),$=zr({connection:A,mode:"meta"}),P=te=>{$.selectedDatabaseIndex.value=te},L=of({connection:i,redisDatabaseIndex:$.selectedDatabaseIndex,fieldDefs:w,fileVariables:T,beforeExecute:()=>J()}),{cursorInfo:M,extensions:W,codeEditorRef:Z,onExecuteCurrent:oe,onHandleFormatCode:le,onHandleFormatCurrentStatement:de,onExplainAnalyzeCurrent:me,explainAnalyzeOptionItems:Fe,serializeMode:ze,currentRawQueryResult:ut,queryProcessState:Ce,executedResults:Je,activeResultTabId:Ge}=L,{contextMenuItems:he,onContextMenuOpen:ot}=rf({onExecuteCurrent:L.onExecuteCurrent,onExplainAnalyzeCurrent:L.onExplainAnalyzeCurrent,onHandleFormatCurrentStatement:L.onHandleFormatCurrentStatement,onHandleFormatCode:L.onHandleFormatCode,isSupportFormat:N,isExplainSupported:E,getEditorView:()=>{var te;return(te=Z.value)==null?void 0:te.editorView}}),I=j(0),D=j(!0),H=j(!1),B=j(""),q=j("");let V=null;const Q=O(()=>c.value?o.getTagsByIds(c.value.tagIds??[]).some(te=>te.strictMode):!1),J=()=>{const te=i.value,Ne=c.value;return!te||!Ne||te.id===Ne.id?Promise.resolve(!0):H.value?Promise.resolve(!1):(B.value=te.name,q.value=Ne.name,H.value=!0,new Promise(et=>{V=et}))},ie=()=>{H.value=!1,V==null||V(!0),V=null},Be=()=>{H.value=!1,V==null||V(!1),V=null};Es([{key:"mod+j",callback:()=>{D.value=!D.value}},{key:"ctrl+j",callback:()=>{D.value=!D.value}}]),ce(T,()=>{L.reloadSqlCompartment()});const rt=({column:te,from:Ne,line:et,to:it})=>{M.value={column:te,line:et},r.updateFileCursorPos({from:Ne,to:it})},ct=(te=!0)=>{var it,Y;if(!((it=l.value)!=null&&it.cursorPos)||!((Y=Z.value)!=null&&Y.editorView))return;const Ne=l.value.cursorPos.from??0,et=l.value.cursorPos.to||0;Z.value.setCursorPosition({from:Ne,to:et,allowScroll:te})},Mt=j(!r.isFromCache);return ha(async()=>{Mt.value&&(await r.loadFileContent(),Mt.value=!1,await Rt()),ct()}),Lr(async()=>{var te;await Rt(),ct(!1),(te=Z.value)!=null&&te.editorView&&(Z.value.editorView.scrollDOM.scrollTop=I.value)}),on(()=>{V&&(V(!1),V=null)}),(te,Ne)=>{const et=be,it=Bt;return C(),z(ae,null,[h(Dl,{open:d(H),"target-connection-name":d(B),"current-connection-name":d(q),onConfirm:ie,onCancel:Be},null,8,["open","target-connection-name","current-connection-name"]),h(pu,{layout:d(s).codeEditorLayout,customLayout:d(s).activeCustomLayout,"show-result-panel":d(D)},{content:y(()=>[S("div",sv,[S("div",ov,[h(lu,{"onUpdate:connectionId":d(f),connections:d(v),connection:d(i),"selected-connection-id":d(p),"disable-connection-switch":d(Q),"is-redis-connection":d(x),"redis-databases":d($).databases.value,"redis-database-index":d($).selectedDatabaseIndex.value,workspaceId:d(a),"file-variables":d(u),"code-editor-layout":d(s).codeEditorLayout,currentFileInfo:d(l),"is-support-variable":d(_),"onUpdate:redisDatabaseIndex":P,"onUpdate:updateFileVariables":d(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"]),S("div",rv,[h(Bl,{"context-menu-items":d(he),"onUpdate:open":d(ot)},{default:y(()=>[d(Mt)?(C(),F(d(ya),{key:0,visible:""})):(C(),F(Cs,{key:1,"onUpdate:modelValue":d(g),"onUpdate:cursorInfo":rt,"onUpdate:onScrollTop":Ne[0]||(Ne[0]=Y=>I.value=Y),modelValue:d(m),extensions:d(W),ref_key:"codeEditorRef",ref:Z},null,8,["onUpdate:modelValue","modelValue","extensions"]))]),_:1},8,["context-menu-items","onUpdate:open"])]),h(eu,{"cursor-info":d(M),"execute-loading":d(Ce).executeLoading,"is-streaming":d(Ce).isStreaming,"explain-analyze-option-items":d(Fe),"serialize-mode":d(ze),"is-support-format":d(N),"is-support-variable":d(_),"is-explain-supported":d(E),onOnFormatCurrentStatement:d(de),onOnFormatAll:d(le),onOnExplainAnalyzeCurrent:d(me),onToggleExplainOption:d(L).toggleExplainOption,"onUpdate:serializeMode":d(L).setSerializeMode,onOnExecuteCurrent:d(oe),onOnCancelQuery:d(L).cancelStreamingQuery},null,8,["cursor-info","execute-loading","is-streaming","explain-analyze-option-items","serialize-mode","is-support-format","is-support-variable","is-explain-supported","onOnFormatCurrentStatement","onOnFormatAll","onOnExplainAnalyzeCurrent","onToggleExplainOption","onUpdate:serializeMode","onOnExecuteCurrent","onOnCancelQuery"])])])]),variables:y(()=>[S("div",iv,[S("div",lv,[h(et,{name:"hugeicons:absolute"}),Ne[1]||(Ne[1]=k(" Variables "))]),S("div",uv,[d(_)?(C(),F(Us,{key:1,variables:d(u),"onUpdate:variables":d(b),onUpdateVariables:d(b),"file-variables":d(u)},null,8,["variables","onUpdate:variables","onUpdateVariables","file-variables"])):(C(),F(it,{key:0,title:"Variables not supported",desc:"Variables are not available for Redis and SQLite connections.",icon:"icons:ghost"}))])])]),result:y(()=>[d(Je).size===0?(C(),F(Ol,{key:0})):(C(),F(nv,{key:1,"executed-results":d(Je),"active-tab-id":d(Ge),"execute-loading":d(Ce).executeLoading,"is-streaming":d(Ce).isStreaming,"onUpdate:activeTab":d(L).setActiveResultTab,onCloseTab:d(L).closeResultTab,onCloseOtherTabs:d(L).closeOtherResultTabs,onCloseTabsToRight:d(L).closeResultTabsToRight,"onUpdate:view":d(L).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)}}}),Zv=se({__name:"[fileId]",setup(n){return(t,e)=>(C(),F(cv))}});export{Zv as default};
|