import{b as D,i as E}from"./workspaceStore.3e3a3ada.js";import{a as C,r as S,c as k,d as R}from"./FormRunner.d342fdbb.js";import{d as F,ea as U,eo as A,E as I,e as L,g as W,f as V,aL as x,X as B,ah as K,u as o,o as y,Y as M,b as N,c as T,S as q,a0 as G}from"./index.57388330.js";import{a as P}from"./asyncComputed.dea6d978.js";import{u as h}from"./uuid.da10c21a.js";import{L as X}from"./CircularLoading.b8405742.js";import"./url.40a6ac51.js";import"./colorHelpers.ae02acb9.js";import"./Login.vue_vue_type_script_setup_true_lang.c9c08e1c.js";import"./Logo.0a698e5e.js";import"./string.b6e197ca.js";import"./index.ee7e1ab7.js";import"./index.8cff4063.js";import"./Steps.95a3ebcb.js";import"./index.193e4f2e.js";import"./Watermark.63117252.js";(function(){try{var u=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},a=new Error().stack;a&&(u._sentryDebugIds=u._sentryDebugIds||{},u._sentryDebugIds[a]="69165c1f-ffe9-4919-a921-84e25bbe561b",u._sentryDebugIdIdentifier="sentry-dbid-69165c1f-ffe9-4919-a921-84e25bbe561b")}catch{}})();const Y={key:0,class:"loading"},j=F({__name:"Form",setup(u){const a=U(),c=A(),f=I({playerKey:h()}),g=D(),i=L(null);W(a,()=>{a.name==="form"&&b()});const{loading:d,result:t,error:p,refetch:b}=P(async()=>{f.playerKey=h();const r=a.path.slice(1),e=await E(r);if(!e){c.push({name:"error",params:{status:"404"}});return}const n=new k({formRunnerData:e,logService:null,connectionManager:new R(e.id,"player",a.query),onRedirect:_,onFormStart:()=>{},onFormEnd:()=>{},onStackTraceUpdate:null,onStateUpdate:l=>i.value=l}),s=n.getState();return i.value=s.formState,{runnerData:e,controller:n}}),w=V(()=>{const r=!d,e=!!p,n=!t||i.value===null;return r&&(e||n)});x(()=>{var r,e,n,s,l;w.value&&c.push({name:"error",params:{status:"500"}}),!!((r=t.value)!=null&&r.runnerData)&&(e=t.value)!=null&&e.runnerData&&(document.title=(l=(n=t.value)==null?void 0:n.runnerData.welcomeTitle)!=null?l:(s=t.value)==null?void 0:s.runnerData.title)});function _(r,e){window.removeEventListener("beforeunload",m),S("player",c,r,e)}B(async()=>{window.addEventListener("beforeunload",m)}),K(()=>{window.removeEventListener("beforeunload",m)});const m=r=>{var e;if((e=t.value)!=null&&e.controller.handleCloseAttempt())return r.preventDefault(),""};return(r,e)=>{var n,s,l,v;return o(d)?(y(),M("div",Y,[N(X)])):o(t)&&o(t).runnerData&&i.value&&!o(p)&&!o(d)?(y(),T(C,{key:f.playerKey,"form-runner-data":o(t).runnerData,"form-state":i.value,"is-preview":!1,"user-email":o(g).email,onRedirect:_,onActionClicked:(n=o(t))==null?void 0:n.controller.handleActionClick,onUpdateWidgetErrors:(s=o(t))==null?void 0:s.controller.updateWidgetFrontendErrors,onUpdateWidgetValue:(l=o(t))==null?void 0:l.controller.updateWidgetValue,onAuthComplete:(v=o(t))==null?void 0:v.controller.handleAuthComplete},null,8,["form-runner-data","form-state","user-email","onActionClicked","onUpdateWidgetErrors","onUpdateWidgetValue","onAuthComplete"])):q("",!0)}}});const ie=G(j,[["__scopeId","data-v-c3fd8bc9"]]);export{ie as default};
//# sourceMappingURL=Form.3150dda9.js.map
