import{u as b}from"./userStore-DJ7XWmCi.js";import{F as D,a as E,b as R}from"./FormRunner-CP1MytoI.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-DRghvhGH.js";import{r as P}from"./redirect-CoqggwyF.js";import{a as q}from"./asyncComputed-DE90HLZh.js";import{u as h}from"./uuid-CkgDROLV.js";import{L as G}from"./CircularLoading-C7961vxu.js";import{f as T,c as Y}from"./workspaceStore-6xAxtabw.js";import"./Login.vue_vue_type_script_setup_true_lang-DmpRGvd2.js";import"./OTPInput-CZKT9bdY.js";import"./Logo-B9YkLTi0.js";import"./string-oqhohvBP.js";import"./index-DAL1Eh1-.js";import"./Steps-LzF26AxU.js";import"./index-BPB02-H4.js";import"./Watermark-d4B4um3U.js";import"./constants-jRdgy-I8.js";import"./url-b_OS5ik_.js";import"./runnerData-DyO4ndh_.js";import"./colorHelpers-BNJ_0v5x.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]="9514f389-1199-496c-8de6-346e95f32d35",n._sentryDebugIdIdentifier="sentry-dbid-9514f389-1199-496c-8de6-346e95f32d35")}catch{}})();const z={key:0,class:"loading"},H=S({__name:"Form",setup(n){const a=W(),i=A(),d=F({playerKey:h()}),g=b(),s=v(null),m=v(null);U(a,()=>{a.name==="form"&&w()});const{loading:u,result:e,error:p,refetch:w}=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:C=>s.value=C}),k=l.getState();return s.value=k.formState,{runnerData:r,controller:l}}),_=I(()=>{const o=!u,r=!!p,l=!e||s.value===null;return o&&(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(o,r){window.removeEventListener("beforeunload",c),P("player",i,o,r)}V(async()=>{window.addEventListener("beforeunload",c)}),x(()=>{window.removeEventListener("beforeunload",c),e.value?.controller.stop()});const c=o=>{if(e.value?.controller.handleCloseAttempt())return o.preventDefault(),""};return(o,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-9BD4YC4A.js.map
