import{C as e,Dt as t,I as n,It as r,Q as i,S as a,T as o,Wt as s,Y as c,an as l,bt as u,cn as d,j as f,k as p,lt as m,w as h,x as g}from"./_plugin-vue_export-helper-BVhEvvHC.js";import{n as _}from"./events-Bc6cZn5G.js";import{Dn as v,Ln as y,P as b,an as x,pn as S}from"./src-CD6Jsigc.js";import{E as C,M as w,i as T,j as E,y as D}from"./src-C_qKxWab.js";import{r as O,t as k}from"./axios-DSyjHw-i.js";import{n as A}from"./runtimeModeStore-Db3SY58j.js";n(),u(),s();var j={class:`h-screen w-screen bg-background text-foreground flex flex-col overflow-hidden`},M={class:`text-xs font-medium text-muted-foreground`},N={key:0,class:`ml-2 rounded-sm border border-red-400/40 bg-red-400/10 px-1.5 py-0.5 text-[9px] font-bold uppercase tracking-wider text-red-300`},P={key:1,class:`ml-2 rounded-sm border border-amber-400/40 bg-amber-400/10 px-1.5 py-0.5 text-[9px] font-bold uppercase tracking-wider text-amber-300`},ee={key:0,class:`flex-1 flex items-center justify-center text-muted-foreground`},F={key:1,class:`flex-1 flex items-center justify-center text-muted-foreground`},I=5,L=f({__name:`ScriptEditorWindow`,setup(n){let{dragRegionStyle:s,noDragStyle:u}=b(),{t:f}=O({useScope:`global`}),L=w(),R=A(),z=g(()=>!!L.rpc),B=null;m([()=>L.activeSceneName,()=>L.rpc],([e,t])=>{B&&=(B.disconnect(),null),e&&t&&(B=E({rpc:t,sceneName:e}),D(B))},{immediate:!0});let{selectedId:V,isSaving:H,loading:U,activeErrors:W,scripts:G,handleSelect:K,handleUpdateName:q,handleUpdateContent:J,handleSave:Y,handleCreate:X,handleDelete:Z}=C({events:_});c(()=>{document.title=f(`sceneEditor.openScriptEditor`),R.refresh().catch(e=>console.warn(`Could not load runtime mode`,e))});function Q(e){return f(`scriptAi.${e}`)}let $=t(!1);function te(){k.post(`/status/minimize`,{windowType:I})}function ne(){k.post(`/status/maximize`,{windowType:I}).then(e=>{$.value=e.data})}function re(){k.post(`/status/close`,{windowType:I})}return(t,n)=>(i(),o(`div`,j,[a(`div`,{class:`h-8 shrink-0 flex items-center px-3 bg-card border-b border-border select-none`,style:l(r(s))},[a(`span`,M,d(r(f)(`sceneEditor.openScriptEditor`)),1),r(R).loadFailed?(i(),o(`span`,N,d(r(f)(`runtimeMode.unavailable`)),1)):r(R).isNonProduction?(i(),o(`span`,P,d(r(f)(`runtimeMode.${r(R).mode.toLowerCase()}`)),1)):h(``,!0),a(`div`,{class:`ml-auto flex items-center`,style:l(r(u))},[a(`button`,{class:`h-8 w-10 inline-flex items-center justify-center hover:bg-muted transition-colors`,onClick:te},[p(r(v),{class:`h-3.5 w-3.5`})]),a(`button`,{class:`h-8 w-10 inline-flex items-center justify-center hover:bg-muted transition-colors`,onClick:ne},[$.value?(i(),e(r(y),{key:0,class:`h-3.5 w-3.5 rotate-0 scale-x-[-1]`})):(i(),e(r(S),{key:1,class:`h-3.5 w-3.5`}))]),a(`button`,{class:`h-8 w-10 inline-flex items-center justify-center hover:bg-destructive hover:text-destructive-foreground transition-colors`,onClick:re},[p(r(x),{class:`h-3.5 w-3.5`})])],4)],4),z.value?r(U)?(i(),o(`div`,F,d(r(f)(`sceneEditor.loading`)),1)):(i(),e(r(T),{key:2,class:`min-h-0 flex-1`,scripts:r(G),"selected-id":r(V),errors:r(W),"script-errors":r(L).scriptErrors,"is-saving":r(H),dark:!0,rpc:r(L).rpc,"scene-name":r(L).activeSceneName,translate:Q,onSelect:r(K),"onUpdate:name":r(q),"onUpdate:content":r(J),onSave:r(Y),onCreate:r(X),onDelete:r(Z)},null,8,[`scripts`,`selected-id`,`errors`,`script-errors`,`is-saving`,`rpc`,`scene-name`,`onSelect`,`onUpdate:name`,`onUpdate:content`,`onSave`,`onCreate`,`onDelete`])):(i(),o(`div`,ee,d(r(f)(`sceneEditor.connecting`)),1))]))}});export{L as default};