import{u as D}from"./userStore.8c20e3fa.js";import{b as E,c as C,d as k}from"./FormRunner.c8fde34c.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.23ceadb7.js";import{r as j}from"./redirect.0d5bad85.js";import{a as q}from"./asyncComputed.aa78e2c1.js";import{u as h}from"./uuid.541d028b.js";import{L as G}from"./CircularLoading.92168724.js";import{f as P}from"./workspaceStore.5a1444e4.js";import"./Login.vue_vue_type_script_setup_true_lang.b6548cc0.js";import"./Logo.05307b94.js";import"./string.ce2d885c.js";import"./index.2eaa9a2f.js";import"./Steps.2f8e4148.js";import"./index.f9894d42.js";import"./Watermark.5b3c33b7.js";import"./constants.f7f6f3bd.js";import"./url.e26dec77.js";import"./runnerData.73826bfe.js";import"./colorHelpers.e1f37246.js";(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},n=new Error().stack;n&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[n]="9feb8aaf-0678-4847-883e-70de8a5fef09",i._sentryDebugIdIdentifier="sentry-dbid-9feb8aaf-0678-4847-883e-70de8a5fef09")}catch{}})();const z={key:0,class:"loading"},H=R({__name:"Form",setup(i){const n=S(),d=F(),f=U({playerKey:h()}),g=D(),l=A(null);I(n,()=>{n.name==="form"&&w()});const{loading:c,result:t,error:p,refetch:w}=q(async()=>{f.playerKey=h();const r=n.path.slice(1),e=await P(r);if(!e){d.push({name:"error",params:{status:"404"}});return}const a=new C({formRunnerData:e,logService:null,connectionManager:new k(e.id,"player",n.query),onRedirect:_,onFormStart:()=>{},onFormEnd:()=>{},onStackTraceUpdate:null,onStateUpdate:u=>l.value=u}),s=a.getState();return l.value=s.formState,{runnerData:e,controller:a}}),b=L(()=>{const r=!c,e=!!p,a=!t||l.value===null;return r&&(e||a)});W(()=>{var r,e,a,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=(a=t.value)==null?void 0:a.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 a,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:(a=o(t))==null?void 0:a.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.c1a612e3.js.map
