import{d as q,ex as A,ey as j,G as z,r as _,H as J,b as n,d2 as I,e as O,u as r,c as p,f as t,w as l,eu as P,bu as Q,cy as U,eD as X,v as Y}from"./registerWidgets.e46eca28.js";import{L as Z}from"./CircularLoading.484aa2f6.js";import{E as ee}from"./Error.871366c2.js";import{R as re,F as oe}from"./broker.59f9a113.js";import{_ as te}from"./FormSettings.vue_vue_type_script_setup_true_lang.92ffe82c.js";import{T as ae,_ as se,a as L}from"./UnsavedChangesHandler.vue_vue_type_script_setup_true_lang.27db324e.js";import{S as ne,L as le}from"./SmartConsole.13554642.js";import{a as me}from"./asyncComputed.15fd30e0.js";import{F as ie}from"./forms.e1efaa71.js";import{W as fe}from"./workspaces.5c5c851b.js";import{B as ce}from"./BackButton.ff29c188.js";import{_ as ue}from"./SaveButton.vue_vue_type_script_setup_true_lang.0cecc98a.js";import{_ as de}from"./DocsButton.vue_vue_type_script_setup_true_lang.b60f35ac.js";import{_ as pe}from"./PreviewButton.vue_vue_type_script_setup_true_lang.d6d9b5b1.js";import{r as S}from"./index.2ced575c.js";import"./lottie.2b81658b.js";import"./passwordlessManager.f4cc4f94.js";import"./pubsub.8f2ecd1e.js";import"./storage.f303ee10.js";import"./Passwordless.5a77ee63.js";import"./icons.db549bc5.js";import"./executeJs.a5a141fd.js";import"./PlayerNavbar.6a57e760.js";import"./Steps.deb305bb.js";import"./Modal.47e24ea4.js";import"./WidgetsFrame.71d81391.js";import"./ActionButton.vue_vue_type_script_setup_true_lang.114e5eb7.js";import"./Title.6ee361e2.js";import"./transButton.6834f8a3.js";import"./Form.6fcc3ee8.js";import"./dashes.668993c6.js";import"./activeRecord.d83b1b14.js";import"./hooks.a12c1aa6.js";import"./jobs.08d5f9ac.js";import"./index.00020abd.js";import"./uuid.241470e3.js";(function(){try{var m=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},i=new Error().stack;i&&(m._sentryDebugIds=m._sentryDebugIds||{},m._sentryDebugIds[i]="a113c8f2-ce18-4966-854a-4ca4fa3c2bc7",m._sentryDebugIdIdentifier="sentry-dbid-a113c8f2-ce18-4966-854a-4ca4fa3c2bc7")}catch{}})();const _e={class:"page"},ge={key:1,class:"error"},ye=q({__name:"FormEditor",setup(m){var b,w,C,R;const i=A(),u=j(),g=z({fullscreen:!1,rightPanelCollapsed:!1,hasChanges:!1,started:!1});function $(e,d){S("editor",i,e,d)}addEventListener("keydown",e=>{(e.ctrlKey||e.metaKey)&&e.key==="s"&&(e.preventDefault(),V())});const N=_(null),y=_(null),{loading:T,result:o,error:v,refetch:M}=me(()=>Promise.all([fe.get(),ie.get(u.params.formPath)]).then(([e,d])=>X({workspace:e,form:d}))),h=_(!1);async function V(){var e;h.value=!0;try{await((e=o.value)==null?void 0:e.form.save())}finally{h.value=!1}}const s=le.create(),f=J(()=>re.create({formPath:u.params.formPath}));(b=f.value)==null||b.on("stdout",e=>{s.log({type:"stdout",log:e.log})}),(w=f.value)==null||w.on("stderr",e=>{s.log({type:"stderr",log:e.log})}),(C=f.value)==null||C.onClose(()=>{s.log({type:"stderr",log:"Program closed"})}),(R=f.value)==null||R.on("files:changed",()=>{s.log({type:"files-changed",log:"Files changed"})});const G=()=>{s.clear()},k=async()=>{var e;return s.log({type:"restart"}),(e=y.value)==null?void 0:e.run()},H=({path:e})=>{S("editor",i,e)},K=()=>{g.started=!0},W=()=>{g.started=!1};return(e,d)=>{var F,x,B,E,D;return n(),I(Q,null,[O("div",_e,[r(T)||!((F=r(o))!=null&&F.form)||!((x=r(o))!=null&&x.workspace)?(n(),p(Z,{key:0})):r(v)?(n(),I("div",ge,[t(ee,{error:r(v),onReload:r(M)},null,8,["error","onReload"])])):(n(),p(ae,{key:2},{left:l(()=>[t(ce,{link:"/_editor/forms"})]),right:l(()=>[t(r(U),null,{default:l(()=>{var a,c;return[t(de),t(pe,{model:(a=r(o))==null?void 0:a.form},null,8,["model"]),t(ue,{model:(c=r(o))==null?void 0:c.form},null,8,["model"])]}),_:1})]),default:l(()=>[t(L,{title:"Preview"},{default:l(()=>{var a,c;return[t(oe,{ref_key:"runner",ref:y,form:(c=r(o))==null?void 0:c.form.makeRunnerData((a=r(o))==null?void 0:a.workspace),params:r(u).query,"is-preview":!0,"enable-auto-focus":!1,broker:f.value,style:{height:"unset",flex:1,overflow:"hidden"},onNavigate:H,onLogout:k,onExit:W,onStart:K,onRedirect:$},null,8,["form","params","broker"])]}),_:1}),t(L,{title:"Settings"},{default:l(()=>{var a;return[(a=r(o))!=null&&a.form?(n(),p(te,{key:0,class:"settings",form:r(o).form},null,8,["form"])):P("",!0)]}),_:1})]),_:1})),(B=r(o))!=null&&B.form?(n(),p(ne,{key:3,ref_key:"smartConsole",ref:N,runtime:"forms","log-service":r(s),onRestart:k,onClearTerminal:G},null,8,["log-service"])):P("",!0)]),t(se,{"has-changes":(D=(E=r(o))==null?void 0:E.form)==null?void 0:D.hasChanges()},null,8,["has-changes"])],64)}}});const er=Y(ye,[["__scopeId","data-v-a0fb63f1"]]);export{er as default};
//# sourceMappingURL=FormEditor.a89bee4c.js.map
