import{u as U}from"./userStore-DX_yqXyz.js";import{P as F}from"./PageStageView-_Cx8Y7jn.js";import{F as L,a as W,b as A}from"./FormRunner-Bp_gPUKd.js";import{u as I,c as P,d as V,S as K}from"./workspaceStore-C0F9gl0n.js";import{e as M,K as N,r as p,N as x,b as B,aR as T,Z as j,D as q,f as G,l as b,j as H,n as r,p as J,J as Z,U as z,g as m,ar as O}from"./jwt-decode.esm-BPi7UGps.js";import{r as Q}from"./redirect-ByzQbemv.js";import{a as X}from"./asyncComputed-Bgqf7g2H.js";import{u as _}from"./uuid-DY-RQD4p.js";import{L as Y}from"./CircularLoading-ZA74WI6Y.js";import"./Watermark-Dg0LFP37.js";import"./constants-BsVzWrXw.js";import"./consoleCapture-B_VXYVZg.js";import"./Login.vue_vue_type_script_setup_true_lang-BrIpKEBC.js";import"./OTPInput-CsSGsCLg.js";import"./Logo-BjkHFdxE.js";import"./string-IVdpZYL8.js";import"./index-B46w1qrG.js";import"./Steps-BcCgD_ny.js";import"./index-BlxwwF8y.js";import"./runnerData-CVdM876v.js";import"./url-pqXfY2Q9.js";import"./colorHelpers-2--HXixt.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]="4d3bd360-e4db-4660-9e02-ea7af6bd92c0",n._sentryDebugIdIdentifier="sentry-dbid-4d3bd360-e4db-4660-9e02-ea7af6bd92c0")}catch{}})();const $={key:0,class:"loading"},ee=M({__name:"Form",setup(n){const o=z(),u=Z(),f=N({playerKey:_()}),k=U(),S=I(),s=p(null),v=p(null),l=p(null);x(o,()=>{o.name==="form"&&(e.value?.controller?.stop(),D())});const{loading:d,result:e,error:g,refetch:D}=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 w=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:R=>s.value=R}),C=w.getState();return s.value=C.formState,{runnerData:i,controller:w}}),E=B(()=>{if(l.value?.type==="page")return!1;const a=!d.value,t=!!g.value,i=!e.value||s.value===null;return a&&(t||i)});T(()=>{E.value&&u.push({name:"error",params:{status:"500"}}),e.value?.runnerData&&(document.title=e.value.runnerData.title)});function y(a,t){window.removeEventListener("beforeunload",c),Q("player",u,a,t)}j(async()=>{window.addEventListener("beforeunload",c),window.addEventListener("pagehide",h)}),q(()=>{window.removeEventListener("beforeunload",c),window.removeEventListener("pagehide",h),e.value?.controller?.stop()});const c=a=>{if(e.value?.controller?.handleCloseAttempt())return a.preventDefault(),""},h=()=>{e.value?.controller?.closeSession()};return(a,t)=>r(d)?(m(),G("div",$,[J(Y)])):l.value&&l.value.type==="page"?(m(),b(F,{key:1,"ui-data":l.value.data},null,8,["ui-data"])):r(e)&&r(e).runnerData&&s.value&&!r(g)&&!r(d)?(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"])):H("",!0)}}),Se=O(ee,[["__scopeId","data-v-0d259dfc"]]);export{Se as default};
//# sourceMappingURL=Form-CuAc3VQX.js.map
