import{u as D}from"./userStore.247d5358.js";import{b as E,c as C,d as k}from"./FormRunner.754e8701.js";import{d as R,ea as S,e5 as F,ae as U,r as A,w as I,c as L,aK as W,k as V,j as x,u as o,a5 as K,f as B,a as M,h as N,o as y,_ as T}from"./jwt-decode.esm.c1356de1.js";import{r as j}from"./redirect.d9e193a1.js";import{a as q}from"./asyncComputed.c4333d47.js";import{u as h}from"./uuid.00fa9956.js";import{L as G}from"./CircularLoading.f125bcad.js";import{f as P}from"./workspaceStore.99340033.js";import"./Login.vue_vue_type_script_setup_true_lang.8e4e9b09.js";import"./Logo.df26cd08.js";import"./string.dbe1a2f4.js";import"./index.04b3ace7.js";import"./Steps.2a493034.js";import"./index.c27622fb.js";import"./Watermark.f40eace1.js";import"./constants.31a5b2c9.js";import"./url.99373f08.js";import"./runnerData.f4160ef6.js";import"./colorHelpers.49707a83.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]="d82e43b3-6d69-4822-ab27-4fff9732e5a8",i._sentryDebugIdIdentifier="sentry-dbid-d82e43b3-6d69-4822-ab27-4fff9732e5a8")}catch{}})();const z={key:0,class:"loading"},H=R({__name:"Form",setup(i){const a=S(),d=F(),f=U({playerKey:h()}),g=D(),l=A(null);I(a,()=>{a.name==="form"&&w()});const{loading:c,result:t,error:p,refetch:w}=q(async()=>{f.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=>l.value=u}),s=n.getState();return l.value=s.formState,{runnerData:e,controller:n}}),b=L(()=>{const r=!c,e=!!p,n=!t||l.value===null;return r&&(e||n)});W(()=>{var r,e,n,s,u;b.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),j("player",d,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(c)?(y(),K("div",z,[B(G)])):o(t)&&o(t).runnerData&&l.value&&!o(p)&&!o(c)?(y(),M(E,{key:f.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(H,[["__scopeId","data-v-9b9482e8"]]);export{me as default};
//# sourceMappingURL=Form.1ef409eb.js.map
