import{f as u,eG as I,d as x,eB as q,r as i,o as k,S as y,b as f,ev as g,w as p,u as c,c as D,ex as A,e as O,bG as B,ar as h,aD as P,eC as R,eD as V,cG as j,eE as E,eF as N,v as F}from"./outputWidgets.3c3deba7.js";import"./router.2687a12c.js";import"./index.79fda194.js";import{P as L}from"./project.a7f8dc6e.js";import{e as M}from"./toggleHighContrast.2076150f.js";import{A as Q}from"./index.c3c37865.js";import{A as $}from"./index.288cdbc6.js";import"./Form.21b032af.js";import"./hasIn.26cab181.js";import"./index.cf4c23b9.js";import"./record.e2163ce9.js";import"./pubsub.59f66cb7.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]="ff530af3-81b7-4b34-ae56-645210946a22",e._sentryDebugIdIdentifier="sentry-dbid-ff530af3-81b7-4b34-ae56-645210946a22")}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 G=z;function S(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=S({},t,a.attrs);return u(I,S({},n,{icon:G}),null)};_.displayName="CaretRightOutlined";_.inheritAttrs=!1;const H=_;function J(e){const t={};for(const a in e)e.hasOwnProperty(a)&&(t[a]=String(e[a]));return t}const U=e=>(E("data-v-29bbdaa2"),e=e(),N(),e),W={class:"container"},X=U(()=>O("br",null,null,-1)),Y=x({__name:"Sql",setup(e){const a=q().params.projectId,n=i(null),r=i(""),b=i([]),v=i([]),m=i([]),w=async()=>{const o=await L.executeQuery(a,r.value,[]);if(y.set("lastQuery",r.value),!o)return;const{returns:s,errors:d}=o;m.value=d,v.value=s.fields.map(l=>({title:l.name,key:l.name,dataIndex:l.name})),b.value=s.result.map((l,C)=>J({key:`${C+1}`,...l}))};return k(()=>{const o=M.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=y.get("lastQuery");s&&(r.value=s,o.setValue(s))}),(o,s)=>(f(),g("div",W,[u(c(Q),{gap:"large",class:"sql-container",align:"center"},{default:p(()=>[O("div",{ref_key:"sqlEditor",ref:n,class:"sql-editor"},null,512),u(c(B),{type:"primary",onClick:w},{icon:p(()=>[u(c(H))]),default:p(()=>[h(" Run ")]),_:1})]),_:1}),m.value.length?(f(),D(c($),{key:0,type:"error","show-icon":""},{message:p(()=>[(f(!0),g(P,null,R(m.value,d=>(f(),g("span",{key:d},[h(V(d)+" ",1),X]))),128))]),_:1})):A("",!0),u(c(j),{style:{width:"100%"},scroll:{x:100},"data-source":b.value,columns:v.value},null,8,["data-source","columns"])]))}});const ue=F(Y,[["__scopeId","data-v-29bbdaa2"]]);export{ue as default};
//# sourceMappingURL=Sql.b682374c.js.map
