import{u as D}from"./userStore.9178336d.js";import{b as E,c as C,d as R}from"./FormRunner.985a7701.js";import{d as k,al as S,r as U,w as F,c as A,aR as I,U as L,R as W,u as o,ac as V,f as x,a as B,h as K,eA as M,ec as N,o as y,_ as q}from"./jwt-decode.esm.7c9b757c.js";import{r as G}from"./redirect.eea1709f.js";import{a as P}from"./asyncComputed.29ba9357.js";import{u as h}from"./uuid.60efe701.js";import{L as T}from"./CircularLoading.19ad1ccf.js";import{f as j}from"./workspaceStore.7d445909.js";import"./Login.vue_vue_type_script_setup_true_lang.0f3cf312.js";import"./Logo.2bc39bab.js";import"./string.fea0919a.js";import"./index.94f4853b.js";import"./Steps.d5e9e2f9.js";import"./index.c68b675a.js";import"./Watermark.539f2cd5.js";import"./constants.6f371b22.js";import"./url.e6b61fa1.js";import"./colorHelpers.b8c57893.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},a=new Error().stack;a&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[a]="15f208b0-1c9a-4ffd-8800-ed7df1ef9ed3",s._sentryDebugIdIdentifier="sentry-dbid-15f208b0-1c9a-4ffd-8800-ed7df1ef9ed3")}catch{}})();const z={key:0,class:"loading"},H=k({__name:"Form",setup(s){const a=M(),i=N(),f=S({playerKey:h()}),g=D(),u=U(null);F(a,()=>{a.name==="form"&&w()});const{loading:c,result:t,error:p,refetch:w}=P(async()=>{f.playerKey=h();const r=a.path.slice(1),e=await j(r);if(!e){i.push({name:"error",params:{status:"404"}});return}const n=new C({formRunnerData:e,logService:null,connectionManager:new R(e.id,"player",a.query),onRedirect:_,onFormStart:()=>{},onFormEnd:()=>{},onStackTraceUpdate:null,onStateUpdate:d=>u.value=d}),l=n.getState();return u.value=l.formState,{runnerData:e,controller:n}}),b=A(()=>{const r=!c,e=!!p,n=!t||u.value===null;return r&&(e||n)});I(()=>{var r,e,n;b.value&&i.push({name:"error",params:{status:"500"}}),!!((r=t.value)!=null&&r.runnerData)&&(e=t.value)!=null&&e.runnerData&&(document.title=(n=t.value)==null?void 0:n.runnerData.title)});function _(r,e){window.removeEventListener("beforeunload",m),G("player",i,r,e)}L(async()=>{window.addEventListener("beforeunload",m)}),W(()=>{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,l,d,v;return o(c)?(y(),V("div",z,[x(T)])):o(t)&&o(t).runnerData&&u.value&&!o(p)&&!o(c)?(y(),B(E,{key:f.playerKey,"form-runner-data":o(t).runnerData,"form-state":u.value,"is-preview":!1,"user-email":o(g).email,onRedirect:_,onActionClicked:(n=o(t))==null?void 0:n.controller.handleActionClick,onUpdateWidgetErrors:(l=o(t))==null?void 0:l.controller.updateWidgetFrontendErrors,onUpdateWidgetValue:(d=o(t))==null?void 0:d.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"])):K("",!0)}}});const ce=q(H,[["__scopeId","data-v-1b2b3f4f"]]);export{ce as default};
//# sourceMappingURL=Form.f40604e6.js.map
