import{u as C}from"./userStore-gUmjnlUt.js";import{F as D,a as E,b as R}from"./FormRunner-CsccYVBP.js";import{e as S,Y as F,r as v,M as U,an as W,aj as A,b as I,b5 as L,W as V,x,f as M,n as B,j as K,p as t,v as N,g as y,aP as j}from"./jwt-decode.esm-CuqABuF0.js";import{r as P}from"./redirect-E-d4puVN.js";import{a as q}from"./asyncComputed-Ba-hGgzE.js";import{u as h}from"./uuid-BEs58qNE.js";import{L as G}from"./CircularLoading-yzaaHzVQ.js";import{f as T,c as Y}from"./workspaceStore-Ba1E_U_-.js";import"./Login.vue_vue_type_script_setup_true_lang-DAzItxh6.js";import"./OTPInput-C0pHFTkX.js";import"./Logo-a_c-G9th.js";import"./string-CcKlk4eJ.js";import"./index-DyxOBHke.js";import"./Steps-B8CWfzxA.js";import"./index-BuNHV0sx.js";import"./Watermark-C71KUByt.js";import"./constants-BofaUPsW.js";import"./url-Cjn6hAfg.js";import"./runnerData-DQ3Ht7os.js";import"./colorHelpers-CyiO3ixI.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},o=new Error().stack;o&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[o]="e53dcb65-ca80-4e36-aaf9-a6312e9522fd",n._sentryDebugIdIdentifier="sentry-dbid-e53dcb65-ca80-4e36-aaf9-a6312e9522fd")}catch{}})();const z={key:0,class:"loading"},H=S({__name:"Form",setup(n){const o=W(),i=A(),d=F({playerKey:h()}),g=C(),s=v(null),m=v(null);U(o,()=>{o.name==="form"&&w()});const{loading:u,result:e,error:p,refetch:w}=q(async()=>{d.playerKey=h();const a=o.path.slice(1),r=await T(a);if(m.value=await Y(),!r){i.push({name:"error",params:{status:"404"}});return}const l=new D({formRunnerData:r,logService:null,connectionManager:new E(r.id,"player",o.query),onRedirect:f,onFormStart:()=>{},onFormEnd:()=>{},onStackTraceUpdate:null,onStateUpdate:k=>s.value=k}),b=l.getState();return s.value=b.formState,{runnerData:r,controller:l}}),_=I(()=>{const a=!u,r=!!p,l=!e||s.value===null;return a&&(r||l)});L(()=>{_.value&&i.push({name:"error",params:{status:"500"}}),e.value?.runnerData&&e.value?.runnerData&&(document.title=e.value?.runnerData.title)});function f(a,r){window.removeEventListener("beforeunload",c),P("player",i,a,r)}V(async()=>{window.addEventListener("beforeunload",c)}),x(()=>{window.removeEventListener("beforeunload",c),e.value?.controller.stop()});const c=a=>{if(e.value?.controller.handleCloseAttempt())return a.preventDefault(),""};return(a,r)=>t(u)?(y(),M("div",z,[N(G)])):t(e)&&t(e).runnerData&&s.value&&!t(p)&&!t(u)?(y(),B(R,{key:d.playerKey,"form-runner-data":t(e).runnerData,"form-state":s.value,"is-preview":!1,"user-email":t(g).email,"worker-capacity":m.value,onRedirect:f,onActionClicked:t(e)?.controller.handleActionClick,onUpdateWidgetErrors:t(e)?.controller.updateWidgetFrontendErrors,onUpdateWidgetValue:t(e)?.controller.updateWidgetValue,onAuthComplete:t(e)?.controller.handleAuthComplete},null,8,["form-runner-data","form-state","user-email","worker-capacity","onActionClicked","onUpdateWidgetErrors","onUpdateWidgetValue","onAuthComplete"])):K("",!0)}}),fe=j(H,[["__scopeId","data-v-22488e59"]]);export{fe as default};
//# sourceMappingURL=Form-D65PUTKT.js.map
