import{f as u,eG as I,d as x,eB as q,r as c,o as k,S as b,b as p,ev as g,w as f,u as i,c as A,ex as B,e as S,bV as D,ar as h,a$ as R,eC as j,eD as P,cH as V,eE as E,eF as N,v as $}from"./outputWidgets.84fe9cdf.js";import"./router.55b997dc.js";import"./index.46fac088.js";import{P as F}from"./project.27c9517e.js";import{e as L}from"./toggleHighContrast.b68478fe.js";import{A as M}from"./index.7b2adc4e.js";import{A as Q}from"./index.dfb164b3.js";import"./FormItem.3f0afd7c.js";import"./hasIn.892e96d0.js";import"./index.cf4c23b9.js";import"./record.d584e714.js";import"./pubsub.e099f5f1.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},t=new Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1b979f85-7e56-493d-8d08-0825686a82af",e._sentryDebugIdIdentifier="sentry-dbid-1b979f85-7e56-493d-8d08-0825686a82af")}catch{}})();var z={icon:{tag:"svg",attrs:{viewBox:"0 0 1024 1024",focusable:"false"},children:[{tag:"path",attrs:{d:"M715.8 493.5L335 165.1c-14.2-12.2-35-1.2-35 18.5v656.8c0 19.7 20.8 30.7 35 18.5l380.8-328.4c10.9-9.4 10.9-27.6 0-37z"}}]},name:"caret-right",theme:"outlined"};const H=z;function O(e){for(var t=1;t<arguments.length;t++){var a=arguments[t]!=null?Object(arguments[t]):{},n=Object.keys(a);typeof Object.getOwnPropertySymbols=="function"&&(n=n.concat(Object.getOwnPropertySymbols(a).filter(function(r){return Object.getOwnPropertyDescriptor(a,r).enumerable}))),n.forEach(function(r){T(e,r,a[r])})}return e}function T(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}var _=function(t,a){var n=O({},t,a.attrs);return u(I,O({},n,{icon:H}),null)};_.displayName="CaretRightOutlined";_.inheritAttrs=!1;const G=_,J=e=>(E("data-v-16ac5c6e"),e=e(),N(),e),U={class:"container"},W=J(()=>S("br",null,null,-1)),X=x({__name:"Sql",setup(e){const a=q().params.projectId,n=c(null),r=c(""),v=c([]),y=c([]),m=c([]),w=async()=>{const o=await F.executeQuery(a,r.value,[]);if(b.set("lastQuery",r.value),!o)return;const{returns:s,errors:d}=o;m.value=d,y.value=s.fields.map(l=>({title:l.name,key:l.name,dataIndex:l.name})),v.value=s.result.map((l,C)=>({key:`${C+1}`,...l}))};return k(()=>{const o=L.create(n.value,{language:"sql",value:r.value,fontFamily:"monospace",lineNumbers:"on",minimap:{enabled:!1},scrollbar:{vertical:"hidden",horizontal:"visible"},fontSize:14,scrollBeyondLastLine:!1,lineHeight:20});o.onDidChangeModelContent(()=>{r.value=o.getValue()});const s=b.get("lastQuery");s&&(r.value=s,o.setValue(s))}),(o,s)=>(p(),g("div",U,[u(i(M),{gap:"large",class:"sql-container",align:"center"},{default:f(()=>[S("div",{ref_key:"sqlEditor",ref:n,class:"sql-editor"},null,512),u(i(D),{type:"primary",onClick:w},{icon:f(()=>[u(i(G))]),default:f(()=>[h(" Run ")]),_:1})]),_:1}),m.value.length?(p(),A(i(Q),{key:0,type:"error","show-icon":""},{message:f(()=>[(p(!0),g(R,null,j(m.value,d=>(p(),g("span",{key:d},[h(P(d)+" ",1),W]))),128))]),_:1})):B("",!0),u(i(V),{style:{width:"100%"},scroll:{x:100},"data-source":v.value,columns:y.value},null,8,["data-source","columns"])]))}});const ie=$(X,[["__scopeId","data-v-16ac5c6e"]]);export{ie as default};
//# sourceMappingURL=Sql.12f0c605.js.map
