import{u as F}from"./userStore-C3Z0vN5p.js";import{P as R}from"./PageStageView-CnyrhD6f.js";import{F as W,a as L,b as P}from"./FormRunner-NOflDnsh.js";import{u as A,c as I,d as V,S as M}from"./workspaceStore-QlTT1mu8.js";import{e as N,O as x,r as p,P as B,b as K,aU as q,n as T,l as j,f as G,q as k,j as H,s as r,v as O,N as z,W as J,g as m,ar as Q}from"./jwt-decode.esm-CX61wVx3.js";import{r as X}from"./redirect-t55MhdYq.js";import{a as Y}from"./asyncComputed-CygEe1bN.js";import{u as _}from"./uuid-DcrfRJI8.js";import{L as Z}from"./CircularLoading-CjXNFRbA.js";import"./Watermark-D2zHvRKy.js";import"./constants-B5rys1IL.js";import"./linkInterceptor-DeEo1UFM.js";import"./Login.vue_vue_type_script_setup_true_lang-n0L6Qcmz.js";import"./OTPInput-2Iwi2IQF.js";import"./Logo-Dr2w7cZG.js";import"./string-BfaOmKtt.js";import"./index-BOb0Rqlm.js";import"./Steps-DIKAUVhl.js";import"./index-Bzb3KREU.js";import"./runnerData-B4AKypWD.js";import"./url-D1jI6Lt8.js";import"./colorHelpers-Dde0Xcnl.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]="54fc0822-1673-4fb1-bcb7-9e6b1ccac689",n._sentryDebugIdIdentifier="sentry-dbid-54fc0822-1673-4fb1-bcb7-9e6b1ccac689")}catch{}})();const $={key:0,class:"loading"},ee=N({__name:"Form",setup(n){const o=J(),u=z(),f=x({playerKey:_()}),S=F(),v=A(),s=p(null),g=p(null),l=p(null);B(o,()=>{o.name==="form"&&(e.value?.controller?.stop(),E())});const{loading:c,result:e,error:y,refetch:E}=Y(async()=>{f.playerKey=_();const a=o.path.slice(1),t=await I(a);if(!t){u.push({name:"error",params:{status:"404"}});return}if(l.value=t,v.state.currentPageType=t.type,t.type==="page")return document.title=t.data.title,{runnerData:null,controller:null};v.actions.hydrate(t.workspace);const i=t.data;g.value=await V();const b=new L({formRunnerData:i,logService:null,connectionManager:new P(i.id,"player",o.query,M.instance?.sessionMode??!1),onRedirect:h,onFormStart:()=>{},onFormEnd:()=>{},onStackTraceUpdate:null,onStateUpdate:U=>s.value=U}),D=b.getState();return s.value=D.formState,{runnerData:i,controller:b}}),C=K(()=>{if(l.value?.type==="page")return!1;const a=!c.value,t=!!y.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 h(a,t){window.removeEventListener("beforeunload",d),X("player",u,a,t)}T(async()=>{window.addEventListener("beforeunload",d),window.addEventListener("pagehide",w)}),j(()=>{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(),G("div",$,[O(Z)])):l.value&&l.value.type==="page"?(m(),k(R,{key:1,"ui-data":l.value.data},null,8,["ui-data"])):r(e)&&r(e).runnerData&&s.value&&!r(y)&&!r(c)?(m(),k(W,{key:f.playerKey,"form-runner-data":r(e).runnerData,"form-state":s.value,"is-preview":!1,"user-email":r(S).email,"worker-capacity":g.value,onRedirect:h,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"])):H("",!0)}}),Se=Q(ee,[["__scopeId","data-v-278f4886"]]);export{Se as default};
//# sourceMappingURL=Form-C45CCnAb.js.map
