import{u as F}from"./userStore-bm3GzS2y.js";import{F as R,a as U,b as W}from"./FormRunner-BIwKVhea.js";import{P as A}from"./PageStageView-DnPsEHJr.js";import{u as I,c as V,d as L,S as P}from"./workspaceStore-Dn9srdAl.js";import{e as x,V as M,r as p,H as B,ak as K,ag as N,b as T,b9 as j,S as q,x as G,f as H,n as w,j as O,p as a,v as z,g as m,aO as J}from"./jwt-decode.esm-ChM3M22o.js";import{r as Q}from"./redirect-B-KiSHNT.js";import{a as X}from"./asyncComputed-x-5HqNbZ.js";import{u as k}from"./uuid-BbT-vu21.js";import{L as Y}from"./CircularLoading-CmCyhWrG.js";import"./Login.vue_vue_type_script_setup_true_lang-pneGz7rM.js";import"./OTPInput-BitBijAj.js";import"./Logo-7FCebu-v.js";import"./string-Dy2mpz43.js";import"./index-Bqr3mRN_.js";import"./Steps-nGqQtse3.js";import"./index-BYG_sTWw.js";import"./Watermark-Ckqq0m8r.js";import"./constants-D_Yr6O9R.js";import"./runnerData-Ddr8QC8K.js";import"./url-Crd93M85.js";import"./colorHelpers-B7xTgS8f.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]="79160bc6-cda8-4acf-a688-76867238fc16",n._sentryDebugIdIdentifier="sentry-dbid-79160bc6-cda8-4acf-a688-76867238fc16")}catch{}})();const Z={key:0,class:"loading"},$=x({__name:"Form",setup(n){const o=K(),i=N(),f=M({playerKey:k()}),_=F(),b=I(),s=p(null),v=p(null),l=p(null);B(o,()=>{o.name==="form"&&(e.value?.controller?.stop(),S())});const{loading:c,result:e,error:y,refetch:S}=X(async()=>{f.playerKey=k();const r=o.path.slice(1),t=await V(r);if(!t){i.push({name:"error",params:{status:"404"}});return}if(l.value=t,b.state.currentPageType=t.type,t.type==="page")return document.title=t.data.title,{runnerData:null,controller:null};const u=t.data;v.value=await L();const h=new R({formRunnerData:u,logService:null,connectionManager:new U(u.id,"player",o.query,P.instance?.sessionMode??!1),onRedirect:g,onFormStart:()=>{},onFormEnd:()=>{},onStackTraceUpdate:null,onStateUpdate:E=>s.value=E}),D=h.getState();return s.value=D.formState,{runnerData:u,controller:h}}),C=T(()=>{if(l.value?.type==="page")return!1;const r=!c.value,t=!!y.value,u=!e.value||s.value===null;return r&&(t||u)});j(()=>{C.value&&i.push({name:"error",params:{status:"500"}}),e.value?.runnerData&&(document.title=e.value.runnerData.title)});function g(r,t){window.removeEventListener("beforeunload",d),Q("player",i,r,t)}q(async()=>{window.addEventListener("beforeunload",d)}),G(()=>{window.removeEventListener("beforeunload",d),e.value?.controller?.stop()});const d=r=>{if(e.value?.controller?.handleCloseAttempt())return r.preventDefault(),""};return(r,t)=>a(c)?(m(),H("div",Z,[z(Y)])):l.value&&l.value.type==="page"?(m(),w(A,{key:1,"ui-data":l.value.data},null,8,["ui-data"])):a(e)&&a(e).runnerData&&s.value&&!a(y)&&!a(c)?(m(),w(W,{key:f.playerKey,"form-runner-data":a(e).runnerData,"form-state":s.value,"is-preview":!1,"user-email":a(_).email,"worker-capacity":v.value,onRedirect:g,onActionClicked:a(e)?.controller.handleActionClick,onUpdateWidgetErrors:a(e)?.controller.updateWidgetFrontendErrors,onUpdateWidgetValue:a(e)?.controller.updateWidgetValue,onAuthComplete:a(e)?.controller.handleAuthComplete},null,8,["form-runner-data","form-state","user-email","worker-capacity","onActionClicked","onUpdateWidgetErrors","onUpdateWidgetValue","onAuthComplete"])):O("",!0)}}),_e=J($,[["__scopeId","data-v-7fbd9306"]]);export{_e as default};
//# sourceMappingURL=Form-Dui72_Ye.js.map
