import{u as D}from"./userStore.d962fba4.js";import{b as E,c as C,d as R}from"./FormRunner.73650f9e.js";import{d as k,ei as S,ec as U,al as F,r as A,w as I,c as L,aR as W,U as V,R as x,u as o,ac as B,f as K,a as M,h as N,o as y,_ as T}from"./jwt-decode.esm.c9c37cdc.js";import{r as q}from"./redirect.42bf4f0a.js";import{a as G}from"./asyncComputed.7bc1692e.js";import{u as h}from"./uuid.8581bc03.js";import{L as P}from"./CircularLoading.217756fb.js";import{f as j}from"./workspaceStore.5a435520.js";import"./Login.vue_vue_type_script_setup_true_lang.ada1c6c9.js";import"./Logo.d77d5637.js";import"./string.8fab6b53.js";import"./index.b74c262c.js";import"./Steps.687763a5.js";import"./index.71eb83f3.js";import"./Watermark.5071a4b2.js";import"./constants.534f67bc.js";import"./url.9e033350.js";import"./colorHelpers.8ba18214.js";(function(){try{var u=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},n=new Error().stack;n&&(u._sentryDebugIds=u._sentryDebugIds||{},u._sentryDebugIds[n]="f8a59b5a-962a-4232-b8e0-5e68a76819a2",u._sentryDebugIdIdentifier="sentry-dbid-f8a59b5a-962a-4232-b8e0-5e68a76819a2")}catch{}})();const z={key:0,class:"loading"},H=k({__name:"Form",setup(u){const n=S(),c=U(),p=F({playerKey:h()}),g=D(),i=A(null);I(n,()=>{n.name==="form"&&w()});const{loading:d,result:t,error:f,refetch:w}=G(async()=>{p.playerKey=h();const r=n.path.slice(1),e=await j(r);if(!e){c.push({name:"error",params:{status:"404"}});return}const a=new C({formRunnerData:e,logService:null,connectionManager:new R(e.id,"player",n.query),onRedirect:_,onFormStart:()=>{},onFormEnd:()=>{},onStackTraceUpdate:null,onStateUpdate:l=>i.value=l}),s=a.getState();return i.value=s.formState,{runnerData:e,controller:a}}),b=L(()=>{const r=!d,e=!!f,a=!t||i.value===null;return r&&(e||a)});W(()=>{var r,e,a,s,l;b.value&&c.push({name:"error",params:{status:"500"}}),!!((r=t.value)!=null&&r.runnerData)&&(e=t.value)!=null&&e.runnerData&&(document.title=(l=(a=t.value)==null?void 0:a.runnerData.welcomeTitle)!=null?l:(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 a,s,l,v;return o(d)?(y(),B("div",z,[K(P)])):o(t)&&o(t).runnerData&&i.value&&!o(f)&&!o(d)?(y(),M(E,{key:p.playerKey,"form-runner-data":o(t).runnerData,"form-state":i.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:(l=o(t))==null?void 0:l.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 de=T(H,[["__scopeId","data-v-972fe12c"]]);export{de as default};
//# sourceMappingURL=Form.a4787001.js.map
