import{u as D}from"./userStore.e6231111.js";import{a as E,c as C,d as k}from"./FormRunner.77ae6b88.js";import{r as F}from"./redirect.e4ff411f.js";import{d as R,e4 as S,e3 as U,a6 as A,f as I,h as L,g as W,aE as V,J as x,a8 as K,u as o,K as B,b as M,c as N,F as T,o as y,Q as q}from"./index.e310aebb.js";import{a as G}from"./asyncComputed.6b1d4165.js";import{u as h}from"./uuid.ba72b934.js";import{L as J}from"./CircularLoading.f21c2905.js";import{f as P}from"./workspaceStore.9673015c.js";import"./Login.vue_vue_type_script_setup_true_lang.558db144.js";import"./Logo.afdc4154.js";import"./string.a01d17aa.js";import"./index.1acd89cf.js";import"./Steps.32c7dd17.js";import"./index.3752b014.js";import"./Watermark.8ab5e319.js";import"./url.fb968ca0.js";import"./colorHelpers.0fc16894.js";(function(){try{var l=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},a=new Error().stack;a&&(l._sentryDebugIds=l._sentryDebugIds||{},l._sentryDebugIds[a]="81d45690-2cca-4d89-99db-b14aa3d23f3b",l._sentryDebugIdIdentifier="sentry-dbid-81d45690-2cca-4d89-99db-b14aa3d23f3b")}catch{}})();const Q={key:0,class:"loading"},j=R({__name:"Form",setup(l){const a=S(),d=U(),p=A({playerKey:h()}),g=D(),i=I(null);L(a,()=>{a.name==="form"&&b()});const{loading:c,result:t,error:f,refetch:b}=G(async()=>{p.playerKey=h();const r=a.path.slice(1),e=await P(r);if(!e){d.push({name:"error",params:{status:"404"}});return}const n=new C({formRunnerData:e,logService:null,connectionManager:new k(e.id,"player",a.query),onRedirect:_,onFormStart:()=>{},onFormEnd:()=>{},onStackTraceUpdate:null,onStateUpdate:u=>i.value=u}),s=n.getState();return i.value=s.formState,{runnerData:e,controller:n}}),w=W(()=>{const r=!c,e=!!f,n=!t||i.value===null;return r&&(e||n)});V(()=>{var r,e,n,s,u;w.value&&d.push({name:"error",params:{status:"500"}}),!!((r=t.value)!=null&&r.runnerData)&&(e=t.value)!=null&&e.runnerData&&(document.title=(u=(n=t.value)==null?void 0:n.runnerData.welcomeTitle)!=null?u:(s=t.value)==null?void 0:s.runnerData.title)});function _(r,e){window.removeEventListener("beforeunload",m),F("player",d,r,e)}x(async()=>{window.addEventListener("beforeunload",m)}),K(()=>{window.removeEventListener("beforeunload",m)});const m=r=>{var e;if((e=t.value)!=null&&e.controller.handleCloseAttempt())return r.preventDefault(),""};return(r,e)=>{var n,s,u,v;return o(c)?(y(),B("div",Q,[M(J)])):o(t)&&o(t).runnerData&&i.value&&!o(f)&&!o(c)?(y(),N(E,{key:p.playerKey,"form-runner-data":o(t).runnerData,"form-state":i.value,"is-preview":!1,"user-email":o(g).email,onRedirect:_,onActionClicked:(n=o(t))==null?void 0:n.controller.handleActionClick,onUpdateWidgetErrors:(s=o(t))==null?void 0:s.controller.updateWidgetFrontendErrors,onUpdateWidgetValue:(u=o(t))==null?void 0:u.controller.updateWidgetValue,onAuthComplete:(v=o(t))==null?void 0:v.controller.handleAuthComplete},null,8,["form-runner-data","form-state","user-email","onActionClicked","onUpdateWidgetErrors","onUpdateWidgetValue","onAuthComplete"])):T("",!0)}}});const de=q(j,[["__scopeId","data-v-9b9482e8"]]);export{de as default};
//# sourceMappingURL=Form.8b4b3bc1.js.map
