import{u as V,_ as K}from"./Bzgyw6a8.js";import{g as z,r as g,h as S,bd as F,bz as T,i as f,aJ as $,b8 as j,c as E,o as D,B as A,l as J,M as q,s as G,v as I,x as P,O as Q,bA as X,b as p,d as l,w as u,D as h,K as B,F as Y,a0 as L,bB as Z,aW as ee,t as te,q as oe,e as b,bC as ae,E as se,a8 as ne}from"./Bq-XgLEJ.js";import{u as le}from"./CI3sxcT_.js";const ie=z({__name:"MonacoEditor.client",props:{lang:{default:()=>"plaintext"},options:{default:()=>({})},modelValue:{default:()=>""}},emits:["update:modelValue","load"],setup(w,{expose:c,emit:i}){const t=w,m=i,k=g(!0),v=S(()=>t.lang||t.options.language),r=F(),d=g(),s=T(),C={automaticLayout:!0};let e,n;return f(()=>t.modelValue,()=>{(e==null?void 0:e.getValue())!==t.modelValue&&(e==null||e.setValue(t.modelValue))}),f(()=>t.lang,()=>{n&&n.dispose(),n=s.editor.createModel(t.modelValue,v.value),e==null||e.setModel(n)}),f(()=>t.options,()=>{e==null||e.updateOptions($(t.options,C))}),f(d,(x,y)=>{!d.value||y||(e=s.editor.create(d.value,$(t.options,C)),n=s.editor.createModel(t.modelValue,v.value),r.value=e,e.layout(),e.setModel(n),e.onDidChangeModelContent(()=>{m("update:modelValue",e.getValue())}),k.value=!1,m("load",e))}),c({$editor:r}),j(()=>{e==null||e.dispose(),n==null||n.dispose()}),(x,y)=>(D(),E("div",{ref_key:"editorElement",ref:d},[k.value?A(x.$slots,"default",{key:0}):J("",!0)],512))}}),re=ae(ie),de={class:"grid items-start lg:grid-cols-5"},ue={class:"grid grid-cols-1 lg:col-span-4 bg-backdrop dark:bg-backdrop-dark"},ce={class:"h-10 flex items-center justify-between px-4"},me={class:"font-semibold"},pe={class:"flex items-center select-none"},ge={class:"overflow-hidden border-l border-t dark:border-gray-600"},_e=z({__name:"[name]",setup(w){const c=g(!1),i=S(()=>q().params.name),t=g(""),m=g(""),k=G(),v=S(()=>k.value==="light"?"vs-light":"vs-dark"),r=g();le({title:`${i.value} - Jesse`}),f(v,a=>{r.value.$editor.updateOptions({theme:a})}),I(async()=>{setTimeout(async()=>{t.value=await V().getStrategy(i.value),m.value=t.value,r.value.$editor.updateOptions({theme:v.value})},200),window.addEventListener("keydown",y)}),P(()=>{window.removeEventListener("keydown",y)});const d=S(()=>t.value!==m.value),s=S(()=>Q().settings.editor),C={automaticLayout:!0,minimap:{enabled:s.value.minimap},fontSize:s.value.fontSize,padding:{top:16,bottom:16},cursorStyle:s.value.cursorStyle,cursorWidth:s.value.cursorWidth,lineHeight:s.value.lineHeight,cursorBlinking:s.value.cursorBlinking,renderLineHighlight:s.value.renderLineHighlight};f(s,a=>{r.value.$editor.updateOptions({minimap:{enabled:a.minimap},fontSize:a.fontSize,cursorStyle:a.cursorStyle,cursorWidth:a.cursorWidth,lineHeight:a.lineHeight,cursorBlinking:a.cursorBlinking,renderLineHighlight:a.renderLineHighlight})},{deep:!0});function e(){se.copyToClipboard(t.value),L("success","Code copied to clipboard")}async function n(){if(d.value){if(t.value===""){L("error","Code cannot be empty");return}await V().saveStrategy(i.value,t.value),m.value=t.value}}const x=X.debounce(async()=>{await n()},300);function y(a){a.key==="s"&&(navigator.platform.match("Mac")?a.metaKey:a.ctrlKey)&&(a.preventDefault(),x())}function H(){r.value.$editor.trigger("source","actions.find",{})}function O(){V().deleteStrategy(i.value),ne().push("/strategies")}return(a,o)=>{const R=K,_=oe,N=re,U=Z,W=ee;return D(),E(Y,null,[p("section",de,[l(R),p("div",ue,[l(U,null,{default:u(()=>[p("div",ce,[p("h2",me,te(h(i)),1),p("div",pe,[l(_,{size:"xs",icon:"i-heroicons-trash",color:"gray",variant:"ghost",class:"ml-2",onClick:o[0]||(o[0]=M=>c.value=!0)},{default:u(()=>o[3]||(o[3]=[b(" Delete ")])),_:1}),l(_,{size:"xs",icon:"i-heroicons-clipboard",color:"gray",variant:"ghost",class:"ml-2",onClick:e},{default:u(()=>o[4]||(o[4]=[b(" Copy ")])),_:1}),l(_,{size:"xs",icon:"i-heroicons-magnifying-glass",class:"ml-2",color:"gray",variant:"ghost",onClick:H},{default:u(()=>o[5]||(o[5]=[b(" Find ")])),_:1}),l(_,{size:"xs",icon:"i-heroicons-check",class:"ml-2",color:"teal",variant:"ghost",disabled:!h(d),onClick:n},{default:u(()=>o[6]||(o[6]=[b(" Save ")])),_:1},8,["disabled"])])]),p("div",ge,[l(N,{ref_key:"editorRef",ref:r,modelValue:h(t),"onUpdate:modelValue":o[1]||(o[1]=M=>B(t)?t.value=M:null),lang:"python",options:C,style:{height:"calc(100vh - 4rem - 4px - 2.5rem)"}},{default:u(()=>o[7]||(o[7]=[b(" Loading editor... ")])),_:1},8,["modelValue"])])]),_:1})])]),l(W,{modelValue:h(c),"onUpdate:modelValue":o[2]||(o[2]=M=>B(c)?c.value=M:null),title:"Delete strategy",description:`Are you sure you want to delete the strategy '${h(i)}'?`,type:"info"},{default:u(()=>[l(_,{variant:"solid",color:"red",class:"flex justify-center",label:"Delete",onClick:O})]),_:1},8,["modelValue","description"])],64)}}});export{_e as default};
