import{u as D}from"./userStore.1333dd7d.js";import{b as E,c as C,d as k}from"./FormRunner.1455d6d6.js";import{d as R,ec as S,e4 as F,ad as U,r as A,w as I,c as L,aJ as W,k as V,j as x,u as o,a4 as B,f as K,a as M,h as N,o as y,_ as T}from"./jwt-decode.esm.9a8c48e0.js";import{r as j}from"./redirect.deb4a683.js";import{a as q}from"./asyncComputed.2fb09f37.js";import{u as h}from"./uuid.c0731d36.js";import{L as G}from"./CircularLoading.f0cc8de9.js";import{f as J}from"./workspaceStore.b955b0a2.js";import"./Login.vue_vue_type_script_setup_true_lang.c7cd239e.js";import"./Logo.f1fdf1b2.js";import"./string.f4728f35.js";import"./index.1b6843a3.js";import"./Steps.d321b00e.js";import"./index.07b6a317.js";import"./Watermark.df69145e.js";import"./constants.4217f4ed.js";import"./url.143ffc6e.js";import"./runnerData.135ba9ac.js";import"./colorHelpers.cae3a29f.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]="ec27722c-4d64-4014-a0a8-032e526e3cbc",i._sentryDebugIdIdentifier="sentry-dbid-ec27722c-4d64-4014-a0a8-032e526e3cbc")}catch{}})();const P={key:0,class:"loading"},z=R({__name:"Form",setup(i){const a=S(),c=F(),p=U({playerKey:h()}),g=D(),l=A(null);I(a,()=>{a.name==="form"&&w()});const{loading:d,result:t,error:f,refetch:w}=q(async()=>{p.playerKey=h();const r=a.path.slice(1),e=await J(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}}),b=L(()=>{const r=!d,e=!!f,n=!t||l.value===null;return r&&(e||n)});W(()=>{var r,e,n,s,u;b.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),j("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(),B("div",P,[K(G)])):o(t)&&o(t).runnerData&&l.value&&!o(f)&&!o(d)?(y(),M(E,{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(z,[["__scopeId","data-v-9b9482e8"]]);export{me as default};
//# sourceMappingURL=Form.e1a2dfc8.js.map
