import{g as M,r as m,h as _,bh as h,bD as k,i as l,aQ as f,bc as y,c as B,o as C,B as E,l as b}from"./DClyChXX.js";const x=M({__name:"MonacoEditor.client",props:{lang:{default:()=>"plaintext"},options:{default:()=>({})},modelValue:{default:()=>""}},emits:["update:modelValue","load"],setup(V,{expose:g,emit:v}){const a=V,n=v,u=m(!0),d=_(()=>a.lang||a.options.language),c=h(),t=m(),s=k(),i={automaticLayout:!0};let e,o;return l(()=>a.modelValue,()=>{(e==null?void 0:e.getValue())!==a.modelValue&&(e==null||e.setValue(a.modelValue))}),l(()=>a.lang,()=>{o&&o.dispose(),o=s.editor.createModel(a.modelValue,d.value),e==null||e.setModel(o)}),l(()=>a.options,()=>{e==null||e.updateOptions(f(a.options,i))}),l(t,(p,r)=>{!t.value||r||(e=s.editor.create(t.value,f(a.options,i)),o=s.editor.createModel(a.modelValue,d.value),c.value=e,e.layout(),e.setModel(o),e.onDidChangeModelContent(()=>{n("update:modelValue",e.getValue())}),u.value=!1,n("load",e))}),g({$editor:c}),y(()=>{e==null||e.dispose(),o==null||o.dispose()}),(p,r)=>(C(),B("div",{ref_key:"editorElement",ref:t},[u.value?E(p.$slots,"default",{key:0}):b("",!0)],512))}});export{x as _};
