import{u as E}from"./userStore.c377c1d0.js";import{a as b,c as C,d as k}from"./FormRunner.c7475e5d.js";import{d as F,e4 as R,e3 as S,a6 as U,f as A,h as I,g as L,aE as W,J as V,a8 as x,u as o,K,b as B,c as M,F as N,o as y,Q as T}from"./index.dac48cf7.js";import{r as q}from"./redirect.d851d9ef.js";import{a as G}from"./asyncComputed.b070652a.js";import{u as h}from"./uuid.0411a228.js";import{L as J}from"./CircularLoading.d8c95c4b.js";import{f as P}from"./workspaceStore.cf197afe.js";import"./Login.vue_vue_type_script_setup_true_lang.1f8c3f40.js";import"./Logo.31124f9c.js";import"./string.9568178f.js";import"./index.e14e57d3.js";import"./Steps.da383f45.js";import"./index.75eff123.js";import"./Watermark.022cda6b.js";import"./constants.a095ad42.js";import"./url.1e47d6e4.js";import"./runnerData.ae189abc.js";import"./colorHelpers.5e2e7ccf.js";(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},a=new Error().stack;a&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[a]="68a71726-41d8-45cc-819a-ca2d0d143112",i._sentryDebugIdIdentifier="sentry-dbid-68a71726-41d8-45cc-819a-ca2d0d143112")}catch{}})();const Q={key:0,class:"loading"},j=F({__name:"Form",setup(i){const a=R(),c=S(),p=U({playerKey:h()}),g=E(),l=A(null);I(a,()=>{a.name==="form"&&w()});const{loading:d,result:t,error:f,refetch:w}=G(async()=>{p.playerKey=h();const r=a.path.slice(1),e=await P(r);if(!e){c.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=>l.value=u}),s=n.getState();return l.value=s.formState,{runnerData:e,controller:n}}),D=L(()=>{const r=!d,e=!!f,n=!t||l.value===null;return r&&(e||n)});W(()=>{var r,e,n,s,u;D.value&&c.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),q("player",c,r,e)}V(async()=>{window.addEventListener("beforeunload",m)}),x(()=>{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(d)?(y(),K("div",Q,[B(J)])):o(t)&&o(t).runnerData&&l.value&&!o(f)&&!o(d)?(y(),M(b,{key:p.playerKey,"form-runner-data":o(t).runnerData,"form-state":l.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"])):N("",!0)}}});const me=T(j,[["__scopeId","data-v-9b9482e8"]]);export{me as default};
//# sourceMappingURL=Form.df782098.js.map
