import{f as d,eI as C,d as x,eE as k,L as q,z as A,r as i,o as B,b as p,ew as y,w as m,u,c as D,ey as E,e as O,bG as P,as as h,aE as R,eF as V,eH as j,cE as L,eC as N,eD as z,x as F}from"./outputWidgets.6e1c5425.js";import{e as M}from"./toggleHighContrast.5ee3c63e.js";import"./router.4a0ba06b.js";import"./index.76daa7f6.js";import{P as Q}from"./project.ba2bfaa1.js";import{A as $}from"./index.c12e1c2f.js";import{A as T}from"./index.0b7245cc.js";import"./Form.b82a2cec.js";import"./hasIn.bf07751b.js";import"./popupNotifcation.76f4dd63.js";import"./record.c7d63161.js";import"./pubsub.4f3043c8.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]="0f4e952c-2df0-4ef4-a9f5-ffc8fe8d1c4f",e._sentryDebugIdIdentifier="sentry-dbid-0f4e952c-2df0-4ef4-a9f5-ffc8fe8d1c4f")}catch{}})();var H={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=H;function w(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){J(e,r,a[r])})}return e}function J(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=w({},t,a.attrs);return d(C,w({},n,{icon:G}),null)};_.displayName="CaretRightOutlined";_.inheritAttrs=!1;const U=_;function W(e){const t={};for(const a in e)e.hasOwnProperty(a)&&(t[a]=String(e[a]));return t}const X=e=>(N("data-v-1a40f6be"),e=e(),z(),e),Y={class:"container"},Z=X(()=>O("br",null,null,-1)),K=x({__name:"Sql",setup(e){const a=k().params.projectId,n=new q(A.string(),"lastQuery"),r=i(null),l=i(""),v=i([]),b=i([]),g=i([]),S=async()=>{const o=await Q.executeQuery(a,l.value,[]);if(n.set(l.value),!o)return;const{returns:s,errors:f}=o;g.value=f,b.value=s.fields.map(c=>({title:c.name,key:c.name,dataIndex:c.name})),v.value=s.result.map((c,I)=>W({key:`${I+1}`,...c}))};return B(()=>{const o=M.create(r.value,{language:"sql",value:l.value,fontFamily:"monospace",lineNumbers:"on",minimap:{enabled:!1},scrollbar:{vertical:"hidden",horizontal:"visible"},fontSize:14,scrollBeyondLastLine:!1,lineHeight:20});o.onDidChangeModelContent(()=>{l.value=o.getValue()});const s=n.get();s&&(l.value=s,o.setValue(s))}),(o,s)=>(p(),y("div",Y,[d(u($),{gap:"large",class:"sql-container",align:"center"},{default:m(()=>[O("div",{ref_key:"sqlEditor",ref:r,class:"sql-editor"},null,512),d(u(P),{type:"primary",onClick:S},{icon:m(()=>[d(u(U))]),default:m(()=>[h(" Run ")]),_:1})]),_:1}),g.value.length?(p(),D(u(T),{key:0,type:"error","show-icon":""},{message:m(()=>[(p(!0),y(R,null,V(g.value,f=>(p(),y("span",{key:f},[h(j(f)+" ",1),Z]))),128))]),_:1})):E("",!0),d(u(L),{style:{width:"100%"},scroll:{x:100},"data-source":v.value,columns:b.value},null,8,["data-source","columns"])]))}});const fe=F(K,[["__scopeId","data-v-1a40f6be"]]);export{fe as default};
//# sourceMappingURL=Sql.13873d7e.js.map
