const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./Alert-1.0.63-BLYiE2Yx.js","./cm-1.0.63-CSIRHMXC.js","./redux-1.0.63-Df-eBzJn.js","./vendor-1.0.63-CN03Eozo.js","./index-1.0.63-BbQj9wqD.js","./iconBase-1.0.63-CFvHhC4t.js","./Typography-1.0.63-mecuj_Wl.js","./lib-1.0.63-DJZPtMem.js","./loglevel-1.0.63-BZ7XahX3.js","./lodash-1.0.63-hMxolcpJ.js","./moment-1.0.63-C5S46NFB.js","./ButtonBase-1.0.63-CF10PFMS.js","./useEnhancedEffect-1.0.63-DnR0ZFqV.js","./AlertTitle-1.0.63-B6QMQB-K.js","./createSvgIcon-1.0.63-DWL3J-DK.js","./Close-1.0.63-Dvbopfj5.js","./QueryBuilder-1.0.63-DtyYMIMt.js","./cmJson-1.0.63-CyZ2MfFg.js","./rehyperaw-1.0.63-AkovKNCK.js","./markdown-1.0.63-BJvkzZkj.js","./index-1.0.63-oIDff4nA.js","./ThemeProvider-1.0.63-Cq0KMgkh.js","./Modal-1.0.63-fMXTbfks.js","./notistack-1.0.63-B49ULGrj.js","./ConfirmDialog-1.0.63-eXgm3P8b.js","./cjs-1.0.63-4A2xol4v.js","./AdminTheme-1.0.63-DhJ0rrw5.js","./DialogContent-1.0.63-B3W-DlSe.js","./hooks-1.0.63-CWs3kTdT.js","./StartQueryBuilder-1.0.63-REjvqyiC.js","./useViewHeight-1.0.63-C7T4FLFa.js","./RestApi-1.0.63-BUfzocgq.js","./Spinner-1.0.63-zcgIyS7Z.js","./TabPanel-1.0.63-CSMGfwNU.js","./InputAdornment-1.0.63-q8tTbJxw.js","./getThemeProps-1.0.63-5ZzcWe3G.js","./Select-1.0.63-BMejr8a7.js","./Menu-1.0.63-DLh4HkF0.js","./SanitizeComponent-1.0.63-CtRxRbku.js","./dompurify-1.0.63-DhD2mIk-.js","./TextField-1.0.63-C35Mfi1Q.js","./FormControlLabel-1.0.63-DpYUdUm6.js","./Checkbox-1.0.63-DPBXeOde.js","./SwitchBase-1.0.63-Br-lbcZ1.js","./Divider-1.0.63-dQ0q4iIX.js","./MenuItem-1.0.63-Bvb3IjMP.js","./TabList-1.0.63-z7zNziDb.js","./Tabs-1.0.63-6c0rSlLk.js","./Switch-1.0.63-m0NqOO9s.js","./main-1.0.63-CGp-2hVp.css"])))=>i.map(i=>d[i]);
import{_ as E}from"./cmJson-1.0.63-CyZ2MfFg.js";import{j as r}from"./cm-1.0.63-CSIRHMXC.js";import{r as t,u as x}from"./redux-1.0.63-Df-eBzJn.js";import{a as w}from"./AdminTheme-1.0.63-DhJ0rrw5.js";import{a as T}from"./hooks-1.0.63-CWs3kTdT.js";import{s as B,a as A}from"./StartQueryBuilder-1.0.63-REjvqyiC.js";import{l as I}from"./ActionsExplorer-1.0.63-DQojhfpy.js";import{D as P}from"./DatabaseTypeEnum-1.0.63-DeJfpW1u.js";import{l as c}from"./lib-1.0.63-DJZPtMem.js";import{S as Q}from"./Spinner-1.0.63-zcgIyS7Z.js";import{T as g}from"./ThemeProvider-1.0.63-Cq0KMgkh.js";const q=()=>{const s=T(),[o,m]=t.useState(!1),[i,S]=t.useState(!1),[p,j]=t.useState({databases:[],defaultDatabase:"",wpDatabase:""});return c.debug("databases",p),t.useEffect(()=>{I(a=>{var y;const b=a==null?void 0:a.data,l=a==null?void 0:a.context;c.debug("response",b,l);const d=[];b.map(e=>{d.push({dbs:e.dbs,dbsType:e.dbs_type,pdsDbs:e.pds})}),d.sort((e,u)=>{var D,_,h,L;return((D=e==null?void 0:e.dbs)==null?void 0:D.toLocaleLowerCase())>((_=u==null?void 0:u.dbs)==null?void 0:_.toLocaleLowerCase())?1:((h=u==null?void 0:u.dbs)==null?void 0:h.toLocaleLowerCase())>((L=e==null?void 0:e.dbs)==null?void 0:L.toLocaleLowerCase())?-1:0}),c.debug(d);const f=d.filter(e=>e.dbsType===P.WP),n=f.length===1?f[0].dbs:"";j({databases:d,defaultDatabase:n,wpDatabase:n}),s(B({databases:{databases:d,defaultDatabase:n,wpDatabase:n}})),m(!0),s(A({queryId:((y=l==null?void 0:l.env)==null?void 0:y.id)??0}))},a=>{console.error("error",a),S(!0)})},[]),{isLoaded:o,hasErrors:i,databases:p}},v=x,C=()=>{const s=v(o=>o.sql);return c.debug("queryBuilder",s),s},M=t.lazy(()=>E(()=>import("./Alert-1.0.63-BLYiE2Yx.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]),import.meta.url)),O=t.lazy(()=>E(()=>import("./QueryBuilder-1.0.63-DtyYMIMt.js").then(s=>s.Q),__vite__mapDeps([16,17,1,2,3,7,8,9,10,18,19,20,6,11,12,21,22,23,5,24,25,26,27,28,29,30,31,32,33,34,35,36,37,14,4,38,39,40,41,42,43,44,45,46,47,48,49]),import.meta.url)),z=()=>{const s=C(),{isLoaded:o,hasErrors:m}=q(),i=w();return o?m||o&&s.databases.databases.length===0?r.jsx(t.Suspense,{children:r.jsx(M,{severity:"error",message:"Error loading databases",close:!0})}):r.jsx(g,{theme:i,children:r.jsx(t.Suspense,{children:r.jsx(O,{queryBuilderState:s})})}):r.jsx(g,{theme:i,children:r.jsx(Q,{title:"Loading databases..."})})},U=Object.freeze(Object.defineProperty({__proto__:null,default:z},Symbol.toStringTag,{value:"Module"}));export{U as M,C as u};
