import{u as C}from"./userStore-SgpjV08H.js";import{F as D,a as E,b as R}from"./FormRunner-CGJ66SRS.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-CcJLQF7t.js";import{r as P}from"./redirect-BnyX1nzW.js";import{a as q}from"./asyncComputed-Drro_Pqi.js";import{u as h}from"./uuid-ClTYWVAh.js";import{L as G}from"./CircularLoading-D3iBqEu8.js";import{f as T,c as Y}from"./workspaceStore-9C3R-gE4.js";import"./Login.vue_vue_type_script_setup_true_lang-Dpi7E6IH.js";import"./OTPInput-COiAzcnd.js";import"./Logo-DhZ5XNo1.js";import"./string-C84WbZZV.js";import"./index-9Olx2Wl7.js";import"./Steps-B2YKm7q4.js";import"./index-BM4OvsOY.js";import"./Watermark-DZzAl6kd.js";import"./constants-rOn-kt-k.js";import"./url-Dm-l1SL8.js";import"./runnerData-BH8BB-8q.js";import"./colorHelpers-CEpvYiFq.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},a=new Error().stack;a&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[a]="933dd72a-3bbf-438f-9ec2-b9c16804c4db",n._sentryDebugIdIdentifier="sentry-dbid-933dd72a-3bbf-438f-9ec2-b9c16804c4db")}catch{}})();const z={key:0,class:"loading"},H=S({__name:"Form",setup(n){const a=W(),i=A(),d=F({playerKey:h()}),b=C(),s=v(null),m=v(null);U(a,()=>{a.name==="form"&&g()});const{loading:c,result:e,error:p,refetch:g}=q(async()=>{d.playerKey=h();const o=a.path.slice(1),r=await T(o);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",a.query),onRedirect:f,onFormStart:()=>{},onFormEnd:()=>{},onStackTraceUpdate:null,onStateUpdate:k=>s.value=k}),_=l.getState();return s.value=_.formState,{runnerData:r,controller:l}}),w=I(()=>{const o=!c,r=!!p,l=!e||s.value===null;return o&&(r||l)});L(()=>{w.value&&i.push({name:"error",params:{status:"500"}}),e.value?.runnerData&&e.value?.runnerData&&(document.title=e.value?.runnerData.title)});function f(o,r){window.removeEventListener("beforeunload",u),P("player",i,o,r)}V(async()=>{window.addEventListener("beforeunload",u)}),x(()=>{window.removeEventListener("beforeunload",u),e.value?.controller.stop()});const u=o=>{if(e.value?.controller.handleCloseAttempt())return o.preventDefault(),""};return(o,r)=>t(c)?(y(),M("div",z,[N(G)])):t(e)&&t(e).runnerData&&s.value&&!t(p)&&!t(c)?(y(),B(R,{key:d.playerKey,"form-runner-data":t(e).runnerData,"form-state":s.value,"is-preview":!1,"user-email":t(b).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-CAR1RLGL.js.map
