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