import{u as F}from"./userStore-DbIwjNKy.js";import{P as R}from"./PageStageView-xhTSzzwr.js";import{F as L,a as W,b as A}from"./FormRunner-DigWBnDT.js";import{u as I,c as P,d as V,S as K}from"./workspaceStore-B9WQPxPo.js";import{e as M,J as x,r as p,K as B,b as N,aQ as q,Z as H,y as T,f as j,n as b,j as G,p as r,w as J,H as Q,U as Z,g as m,aq as z}from"./jwt-decode.esm-cMnpfgdw.js";import{r as O}from"./redirect-BWx9L-gj.js";import{a as X}from"./asyncComputed-CCHa7bTA.js";import{u as _}from"./uuid-D_nPNshk.js";import{L as Y}from"./CircularLoading-BM6NYRgA.js";import"./Watermark-BVtezSQa.js";import"./constants-2HINPs8G.js";import"./consoleCapture-CqJAVhTe.js";import"./Login.vue_vue_type_script_setup_true_lang-A61U9M-x.js";import"./OTPInput-Cg4mXNf-.js";import"./Logo-DJdEFC-4.js";import"./string-pgLwzgmr.js";import"./index-BbKS5vHb.js";import"./Steps-BJ0hIXfk.js";import"./index-C0olcWg6.js";import"./runnerData-B02TUtQ4.js";import"./url-vqNrw1OC.js";import"./colorHelpers-CPrTu2hh.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]="45d70ee3-9eab-450b-9810-ce261095b1f2",n._sentryDebugIdIdentifier="sentry-dbid-45d70ee3-9eab-450b-9810-ce261095b1f2")}catch{}})();const $={key:0,class:"loading"},ee=M({__name:"Form",setup(n){const o=Z(),u=Q(),f=x({playerKey:_()}),k=F(),S=I(),s=p(null),v=p(null),l=p(null);B(o,()=>{o.name==="form"&&(e.value?.controller?.stop(),E())});const{loading:c,result:e,error:g,refetch:E}=X(async()=>{f.playerKey=_();const a=o.path.slice(1),t=await P(a);if(!t){u.push({name:"error",params:{status:"404"}});return}if(l.value=t,S.state.currentPageType=t.type,t.type==="page")return document.title=t.data.title,{runnerData:null,controller:null};const i=t.data;v.value=await V();const h=new W({formRunnerData:i,logService:null,connectionManager:new A(i.id,"player",o.query,K.instance?.sessionMode??!1),onRedirect:y,onFormStart:()=>{},onFormEnd:()=>{},onStackTraceUpdate:null,onStateUpdate:U=>s.value=U}),D=h.getState();return s.value=D.formState,{runnerData:i,controller:h}}),C=N(()=>{if(l.value?.type==="page")return!1;const a=!c.value,t=!!g.value,i=!e.value||s.value===null;return a&&(t||i)});q(()=>{C.value&&u.push({name:"error",params:{status:"500"}}),e.value?.runnerData&&(document.title=e.value.runnerData.title)});function y(a,t){window.removeEventListener("beforeunload",d),O("player",u,a,t)}H(async()=>{window.addEventListener("beforeunload",d),window.addEventListener("pagehide",w)}),T(()=>{window.removeEventListener("beforeunload",d),window.removeEventListener("pagehide",w),e.value?.controller?.stop()});const d=a=>{if(e.value?.controller?.handleCloseAttempt())return a.preventDefault(),""},w=()=>{e.value?.controller?.closeSession()};return(a,t)=>r(c)?(m(),j("div",$,[J(Y)])):l.value&&l.value.type==="page"?(m(),b(R,{key:1,"ui-data":l.value.data},null,8,["ui-data"])):r(e)&&r(e).runnerData&&s.value&&!r(g)&&!r(c)?(m(),b(L,{key:f.playerKey,"form-runner-data":r(e).runnerData,"form-state":s.value,"is-preview":!1,"user-email":r(k).email,"worker-capacity":v.value,onRedirect:y,onActionClicked:r(e)?.controller.handleActionClick,onUpdateWidgetErrors:r(e)?.controller.updateWidgetFrontendErrors,onUpdateWidgetValue:r(e)?.controller.updateWidgetValue,onAuthComplete:r(e)?.controller.handleAuthComplete},null,8,["form-runner-data","form-state","user-email","worker-capacity","onActionClicked","onUpdateWidgetErrors","onUpdateWidgetValue","onAuthComplete"])):G("",!0)}}),Se=z(ee,[["__scopeId","data-v-0d259dfc"]]);export{Se as default};
//# sourceMappingURL=Form-CzMXF9yJ.js.map
