import{_ as A,a as K}from"./run.cf98bfe1.js";import{W as N,a as O,b as j,c as H}from"./ts.worker.921d436c.js";import{l as m,W as J,e as U}from"./toggleHighContrast.483b4227.js";import{f as G}from"./sqlFormatter.e0a34ad5.js";import{language as x}from"./sql.4f48b9c1.js";import{_ as Q}from"./json-studio.vue_vue_type_style_index_0_lang.ef678733.js";import{_ as X}from"./console-result.vue_vue_type_script_setup_true_lang.932f9a7d.js";import{e as Y}from"./apiConfig.09b7ec3b.js";import{d as Z,h as r,ab as ee,ag as te,L as oe,D as se,r as i,o as B,c as b,a as s,b as o,w as n,H as C,l as _,E as d,z as ne,A as ae,_ as le}from"./index.e3896b23.js";import"./readonly-studio.vue_vue_type_script_setup_true_lang.0062e564.js";const v=g=>(ne("data-v-22563186"),g=g(),ae(),g),re={class:"sqlBox"},ie={key:0,class:"sqlTopBox"},ue=v(()=>s("img",{src:A},null,-1)),de=v(()=>s("img",{src:K},null,-1)),ce={style:{margin:"auto"}},pe=_("trim"),fe=_("if"),me=_("where"),_e=_("foreach"),ve={class:"sqlMiddleBox"},ge=v(()=>s("div",{class:"sqlLeftBox"},[s("div",{id:"sqlCodeEditBox"})],-1)),he=v(()=>s("div",{class:"rightResize"},null,-1)),qe={class:"sqlRightBox"},xe={key:1,class:"sqlBottomBox"},we={class:"sqlCustomTabsLabel"},Ee=_("\xA0 "),Be=v(()=>s("span",null,"\u6267\u884C\u7ED3\u679C",-1)),be=Z({__name:"sql-studio",setup(g,{expose:S}){const T=r(""),D=r("sql"),V=r("vs-dark"),w=r(!1),c=r(!1),p=ee("apiSqlForm");te(()=>{a.dispose(),I.dispose(),console.log("editor dispose")}),oe(()=>{F(),console.log("editor init")});const I=m.registerCompletionItemProvider("sql",{provideCompletionItems:function(){let t=[];return x.keywords.forEach(e=>{t.push({label:e,kind:m.CompletionItemKind.Keyword,insertText:e})}),x.operators.forEach(e=>{t.push({label:e,kind:m.CompletionItemKind.Operator,insertText:e})}),x.builtinFunctions.forEach(e=>{t.push({label:e,kind:m.CompletionItemKind.Function,insertText:e})}),x.builtinVariables.forEach(e=>{t.push({label:e,kind:m.CompletionItemKind.Variable,insertText:e})}),{suggestions:t}}});self.MonacoEnvironment={getWorker(t,e){return e==="json"?new N:e==="css"||e==="scss"||e==="less"?new O:e==="html"||e==="handlebars"||e==="razor"?new j:["typescript","javascript"].includes(e)?new H:new J}};let a=null;const F=()=>{se(()=>{a?a.setValue(""):a=U.create(document.getElementById("sqlCodeEditBox"),{value:T.value,language:D.value,automaticLayout:!0,theme:V.value,foldingStrategy:"indentation",renderLineHighlight:"all",selectOnLineNumbers:!0,minimap:{enabled:!0},cursorStyle:"line",readOnly:!1,fontSize:16,autoIndent:!0,useTabStops:!1,quickSuggestionsDelay:100,scrollBeyondLastLine:!1,overviewRulerBorder:!1})})},h=t=>{let e=E();e=e?e+`
`:"",t=="trim"?f(e+'<trim prefix="" suffix="" suffixesToOverride="" prefixesToOverride=""></trim>'):t=="if"?f(e+'<if test="" ></if>'):t=="where"?f(e+"<where></where>"):t=="foreach"&&f(e+'<foreach open="(" close=")" collection="" separator="," item="item" index="index">#{item}</foreach>')},y=r(),q=r(),$=()=>{const t={};if(t.openTrans=p.openTrans,t.sqlDbType=p.sqlDbType,t.databaseId=p.databaseId,t.statement=E(),t.sqlSeparator=p.sqlSeparator,t.sqlMaxRow=p.sqlMaxRow,!t.sqlDbType){d.warning("\u8BF7\u9009\u62E9\u6570\u636E\u5E93\u7C7B\u522B");return}if(!t.sqlSeparator){d.warning("sql\u5206\u9694\u7B26\u4E0D\u80FD\u4E3A\u7A7A");return}if(!t.sqlDbType){d.warning("\u8BF7\u9009\u62E9\u6570\u636E\u5E93\u7C7B\u578B");return}if(!t.databaseId&&t.sqlDbType==1){d.warning("\u8BF7\u9009\u62E9\u6570\u636E\u5E93");return}if(!t.statement){d.warning("\u8BF7\u8F93\u5165sql\u8BED\u53E5");return}if(!t.sqlMaxRow){d.warning("\u8BF7\u8F93\u5165\u6700\u5927\u67E5\u8BE2\u6761\u6570");return}t.jsonParams=q.value.getEditorValue(),w.value=!0,Y(t).then(e=>{y.value.init(e.data,"1",!1)}).finally(()=>{w.value=!1})},k=()=>{a.setValue(G(a.getValue()))},f=t=>{a.setValue(t)},E=()=>a.getValue();return S({setEditorValue:f,getEditorValue:E,handleFormat:k,getSqlParam:()=>q.value.getEditorValue(),setSqlParam:t=>{q.value.setEditorValue(t)},closeDebug:()=>{c.value=!1}}),(t,e)=>{const W=i("el-switch"),u=i("el-button"),R=i("Postcard"),z=i("el-icon"),L=i("el-tab-pane"),P=i("el-tabs"),M=i("el-divider");return B(),b("div",re,[s("div",null,[o(W,{modelValue:c.value,"onUpdate:modelValue":e[0]||(e[0]=l=>c.value=l),"active-value":!0,"inactive-value":!1,"inline-prompt":"",style:{"--el-switch-on-color":"#8aa0ff","--el-switch-off-color":"#cec5be"},"active-text":"\u5173\u95ED\u8C03\u8BD5","inactive-text":"\u6253\u5F00\u8C03\u8BD5"},null,8,["modelValue"])]),c.value?(B(),b("div",ie,[s("div",null,[o(u,{text:"",onClick:e[1]||(e[1]=l=>k())},{default:n(()=>[ue]),_:1}),o(u,{loading:w.value,onClick:e[2]||(e[2]=l=>$()),text:""},{default:n(()=>[de]),_:1},8,["loading"])]),s("div",ce,[o(u,{size:"small",type:"warning",round:"",onClick:e[3]||(e[3]=l=>h("trim"))},{default:n(()=>[pe]),_:1}),o(u,{size:"small",type:"warning",round:"",onClick:e[4]||(e[4]=l=>h("if"))},{default:n(()=>[fe]),_:1}),o(u,{size:"small",type:"warning",round:"",onClick:e[5]||(e[5]=l=>h("where"))},{default:n(()=>[me]),_:1}),o(u,{size:"small",type:"warning",round:"",onClick:e[6]||(e[6]=l=>h("foreach"))},{default:n(()=>[_e]),_:1})])])):C("",!0),s("div",ve,[ge,he,s("div",qe,[o(Q,{ref_key:"JsonStudioRef",ref:q},null,512)])]),c.value?(B(),b("div",xe,[o(P,{class:"sqlBottomTabs"},{default:n(()=>[o(L,null,{label:n(()=>[s("span",we,[o(z,null,{default:n(()=>[o(R)]),_:1}),Ee,Be])]),default:n(()=>[o(X,{ref_key:"consoleResultRef",ref:y},null,512)]),_:1})]),_:1}),o(M)])):C("",!0)])}}});const Le=le(be,[["__scopeId","data-v-22563186"]]);export{Le as default};
