import{u as k}from"./index.6eea3de6.js";import{d as E,f1 as R,f7 as U,N as C,r as h,O as F,y as S,ar as A,o as I,R as L,u as n,b as g,eV as V,f as W,c as B,eX as x,E as M}from"./outputWidgets.bff33647.js";import{b as N,r as K,c as T,d as q}from"./FormRunner.d12a843a.js";import{a as G}from"./asyncComputed.ce6d6eed.js";import{u as b}from"./uuid.879868bc.js";import{L as O}from"./CircularLoading.1f94859f.js";import{f as P}from"./api.dd54e1b1.js";import"./fetch.ce6f0915.js";import"./pubsub.897f848f.js";import"./url.9e111d9b.js";import"./Login.vue_vue_type_script_setup_true_lang.e1cc7e51.js";import"./index.c2396270.js";import"./PhArrowClockwise.vue.fe31839f.js";import"./WidgetsFrame.830e3752.js";import"./Steps.76d6eef0.js";import"./Card.3943e645.js";import"./TabPane.0c295f83.js";import"./hasIn.edcda2a9.js";import"./PlusOutlined.cf52d035.js";import"./runnerData.e179cd6d.js";(function(){try{var l=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},u=new Error().stack;u&&(l._sentryDebugIds=l._sentryDebugIds||{},l._sentryDebugIds[u]="c0c6ea9d-9d8b-43c6-a9b6-1cb8fbaf3832",l._sentryDebugIdIdentifier="sentry-dbid-c0c6ea9d-9d8b-43c6-a9b6-1cb8fbaf3832")}catch{}})();const X={key:0,class:"loading"},j=E({__name:"Form",setup(l){const u=R(),c=U(),f=C({playerKey:b()}),i=h(null),d=h(null);F(u,()=>{u.name==="form"&&w()});const{loading:m,result:r,error:p,refetch:w}=G(async()=>{f.playerKey=b();const t=u.path.slice(1),e=await P(t);if(!e){c.push({name:"error",params:{status:"404"}});return}const a=new T({formRunnerData:e,userManager:k,logService:null,connectionManager:new q(e.id,"player",u.query),onRedirect:v,onFormStart:()=>{},onFormEnd:()=>{},onAuthUpdate:o=>d.value=o,onStackTraceUpdate:null,onStateUpdate:o=>i.value=o}),s=a.getState();return d.value=s.passwordlessUser,i.value=s.formState,{runnerData:e,controller:a}}),D=S(()=>{const t=!m,e=!!p,a=!r||i.value===null;return t&&(e||a)});A(()=>{var t,e,a,s,o;D.value&&c.push({name:"error",params:{status:"500"}}),!!((t=r.value)!=null&&t.runnerData)&&(e=r.value)!=null&&e.runnerData&&(document.title=(o=(a=r.value)==null?void 0:a.runnerData.welcomeTitle)!=null?o:(s=r.value)==null?void 0:s.runnerData.title)});function v(t,e){K("player",c,t,e)}I(async()=>{var e;!((e=window.should_ask_before_leave)==null||e)||window.addEventListener("beforeunload",_)}),L(()=>{window.removeEventListener("beforeunload",_)});const _=t=>{var e;if((e=r.value)!=null&&e.controller.handleCloseAttempt())return t.preventDefault(),""};return(t,e)=>{var a,s,o,y;return n(m)?(g(),V("div",X,[W(O)])):n(r)&&n(r).runnerData&&i.value&&!n(p)&&!n(m)?(g(),B(N,{key:f.playerKey,"form-runner-data":n(r).runnerData,"form-state":i.value,"is-preview":!1,"user-email":(a=d.value)==null?void 0:a.claims.email,onRedirect:v,onActionClicked:(s=n(r))==null?void 0:s.controller.handleActionClick,onUpdateWidgetErrors:(o=n(r))==null?void 0:o.controller.updateWidgetFrontendErrors,onUpdateWidgetValue:(y=n(r))==null?void 0:y.controller.updateWidgetValue},null,8,["form-runner-data","form-state","user-email","onActionClicked","onUpdateWidgetErrors","onUpdateWidgetValue"])):x("",!0)}}});const fe=M(j,[["__scopeId","data-v-445f692c"]]);export{fe as default};
//# sourceMappingURL=Form.86a9584e.js.map
