const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./CodeField-1.0.63-BzCoj5Vr.js","./cm-1.0.63-CSIRHMXC.js","./redux-1.0.63-Df-eBzJn.js","./vendor-1.0.63-CN03Eozo.js","./index-1.0.63-oIDff4nA.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","./ThemeProvider-1.0.63-Cq0KMgkh.js","./Modal-1.0.63-fMXTbfks.js","./notistack-1.0.63-B49ULGrj.js","./iconBase-1.0.63-CFvHhC4t.js","./cmJs-1.0.63-CzmnAR2E.js","./cmJson-1.0.63-CyZ2MfFg.js","./rehyperaw-1.0.63-AkovKNCK.js","./markdown-1.0.63-BJvkzZkj.js","./cmHtml-1.0.63-BoYNtd6o.js","./cmSql-1.0.63-OKh4Zrzn.js","./Spinner-1.0.63-zcgIyS7Z.js","./FormControlLabel-1.0.63-DpYUdUm6.js","./Select-1.0.63-BMejr8a7.js","./Menu-1.0.63-DLh4HkF0.js","./createSvgIcon-1.0.63-DWL3J-DK.js","./Switch-1.0.63-m0NqOO9s.js","./SwitchBase-1.0.63-Br-lbcZ1.js","./DialogContent-1.0.63-B3W-DlSe.js","./ConfirmDialog-1.0.63-eXgm3P8b.js","./cjs-1.0.63-4A2xol4v.js","./AdminTheme-1.0.63-DhJ0rrw5.js"])))=>i.map(i=>d[i]);
import{_ as N}from"./cmJson-1.0.63-CyZ2MfFg.js";import{j as a}from"./cm-1.0.63-CSIRHMXC.js";import{r as p}from"./redux-1.0.63-Df-eBzJn.js";import{l as x,o as q}from"./lib-1.0.63-DJZPtMem.js";import{a as g}from"./hooks-1.0.63-CWs3kTdT.js";import{l as H,u,k as _,f as b,g as E}from"./StartQueryBuilder-1.0.63-REjvqyiC.js";import{e as I,u as j,a as B}from"./QueryBuilder-1.0.63-DtyYMIMt.js";import{u as S}from"./MainQueryBuilder-1.0.63-B0m2zVpP.js";import{e as l}from"./notistack-1.0.63-B49ULGrj.js";import{B as k}from"./Spinner-1.0.63-zcgIyS7Z.js";import"./vendor-1.0.63-CN03Eozo.js";import"./rehyperaw-1.0.63-AkovKNCK.js";import"./markdown-1.0.63-BJvkzZkj.js";import"./loglevel-1.0.63-BZ7XahX3.js";import"./lodash-1.0.63-hMxolcpJ.js";import"./moment-1.0.63-C5S46NFB.js";import"./useViewHeight-1.0.63-C7T4FLFa.js";import"./index-1.0.63-oIDff4nA.js";import"./Typography-1.0.63-mecuj_Wl.js";import"./ButtonBase-1.0.63-CF10PFMS.js";import"./useEnhancedEffect-1.0.63-DnR0ZFqV.js";import"./ThemeProvider-1.0.63-Cq0KMgkh.js";import"./Modal-1.0.63-fMXTbfks.js";import"./iconBase-1.0.63-CFvHhC4t.js";import"./ConfirmDialog-1.0.63-eXgm3P8b.js";import"./cjs-1.0.63-4A2xol4v.js";import"./AdminTheme-1.0.63-DhJ0rrw5.js";import"./DialogContent-1.0.63-B3W-DlSe.js";import"./RestApi-1.0.63-BUfzocgq.js";import"./TabPanel-1.0.63-CSMGfwNU.js";import"./InputAdornment-1.0.63-q8tTbJxw.js";import"./getThemeProps-1.0.63-5ZzcWe3G.js";import"./Select-1.0.63-BMejr8a7.js";import"./Menu-1.0.63-DLh4HkF0.js";import"./createSvgIcon-1.0.63-DWL3J-DK.js";import"./index-1.0.63-BbQj9wqD.js";import"./SanitizeComponent-1.0.63-CtRxRbku.js";import"./dompurify-1.0.63-DhD2mIk-.js";import"./TextField-1.0.63-C35Mfi1Q.js";import"./FormControlLabel-1.0.63-DpYUdUm6.js";import"./Checkbox-1.0.63-DPBXeOde.js";import"./SwitchBase-1.0.63-Br-lbcZ1.js";import"./Divider-1.0.63-dQ0q4iIX.js";import"./MenuItem-1.0.63-Bvb3IjMP.js";import"./TabList-1.0.63-z7zNziDb.js";import"./Tabs-1.0.63-6c0rSlLk.js";import"./Switch-1.0.63-m0NqOO9s.js";/* empty css                    */import"./ActionsExplorer-1.0.63-DQojhfpy.js";import"./DatabaseTypeEnum-1.0.63-DeJfpW1u.js";const C=()=>{const e=g(),r=S();return t=>{const s=r.queries[r.tabIndex];r.sqlSchemas[s==null?void 0:s.schemaName]===void 0&&I(t,i=>{x.debug(i),(i==null?void 0:i.code)==="ok"&&e(H({sqlSchemaName:t,sqlSchema:i==null?void 0:i.data}))},i=>{console.error(i)})}},R=p.lazy(()=>N(()=>import("./CodeField-1.0.63-BzCoj5Vr.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32]),import.meta.url)),Be=({queryKey:e,query:r,fullScreen:f})=>{const t=g(),s=S(),i=C(),{getQueryKey:Q}=j(),[d,h]=p.useState(q(r.query)),n=p.useRef();n.current=d,p.useEffect(()=>{s.showSqlHints&&i(s.queries[e].schemaName)},[s.showSqlHints,s.queries[e].schemaName]),p.useEffect(()=>{s.copyQuery&&(h(s.copyQuery),t(u({queryKey:e,query:{access:r.access,queryName:r.queryName,query:s.copyQuery,schemaName:r.schemaName,isVisual:r.isVisual,isInserting:r.isInserting,params:r.params}})),t(_({copyQuery:void 0})))},[s.copyQuery]);const v=()=>{var c;if(n.current){const o=b.getSelectors().selectQueryBuilder(E.getState().sql);(c=o==null?void 0:o.queries)!=null&&c[e]&&B(o.queries[e].access,o.queries[e].schemaName,o.queries[e].queryName,q(n.current),!1,"",o.queries[e].isInserting,o.queries[e].params,m=>{x.debug(m),(m==null?void 0:m.code)==="ok"&&(t(u({queryKey:e,query:{...o.queries[e],isInserting:void 0},isUpdated:!1})),l("Query succesfully saved",{variant:"success"}))},m=>{console.error(m),l(m,{variant:"error"})})}else l("Invalid code reference",{variant:"error"})};return a.jsx(k,{className:"pp-sql-query-builder-editor",children:a.jsx(p.Suspense,{children:a.jsx(R,{code:d,setCode:c=>{h(c),t(u({queryKey:e,query:{...r,query:c}}))},dialogTitle:Q(e),extension:"sql",sqlSchema:s.showSqlHints?s.sqlSchemas[s.queries[e].schemaName]:void 0,initialHeight:f?"calc(((calc(var(--ppViewHeight, 1vh) * 100) - 69px - 48px - 69px - 48px - 5px) / 2) - 28px - 5px)":"270px",saveCode:v})})})};export{Be as default};
