import{u as b}from"./userStore.ce5d0de4.js";import{b as E,c as C,d as k}from"./FormRunner.b217127d.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.aa7cdf41.js";import{r as j}from"./redirect.fef06a1b.js";import{a as q}from"./asyncComputed.584e534b.js";import{u as h}from"./uuid.85cbee3f.js";import{L as G}from"./CircularLoading.7ed4de0e.js";import{f as P}from"./workspaceStore.616f71d7.js";import"./Login.vue_vue_type_script_setup_true_lang.62f8e382.js";import"./Logo.7c2afb14.js";import"./string.83af24ac.js";import"./index.17841a8f.js";import"./Steps.6760b238.js";import"./index.8b2bb03a.js";import"./Watermark.9168e586.js";import"./constants.903819dc.js";import"./url.33429ee0.js";import"./colorHelpers.2fcd0035.js";(function(){try{var l=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},n=new Error().stack;n&&(l._sentryDebugIds=l._sentryDebugIds||{},l._sentryDebugIds[n]="8309981f-8e0f-4152-aa69-64d0fa126a20",l._sentryDebugIdIdentifier="sentry-dbid-8309981f-8e0f-4152-aa69-64d0fa126a20")}catch{}})();const z={key:0,class:"loading"},H=R({__name:"Form",setup(l){const n=S(),d=F(),f=U({playerKey:h()}),g=b(),i=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=>i.value=u}),s=a.getState();return i.value=s.formState,{runnerData:e,controller:a}}),D=L(()=>{const r=!c,e=!!p,a=!t||i.value===null;return r&&(e||a)});W(()=>{var r,e,a,s,u;D.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&&i.value&&!o(p)&&!o(c)?(y(),M(E,{key:f.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:(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 ce=T(H,[["__scopeId","data-v-9b9482e8"]]);export{ce as default};
//# sourceMappingURL=Form.fa8042d7.js.map
