import{b as D,i as E}from"./workspaceStore.2ea22595.js";import{a as C,r as S,c as k,d as R}from"./FormRunner.5f038519.js";import{d as F,ef as U,eH 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 a,o as y,Y as M,b as N,c as T,S as q,a0 as G}from"./index.a95f3dfe.js";import{a as H}from"./asyncComputed.cb5b1d6d.js";import{u as h}from"./uuid.ef3e0c9c.js";import{L as P}from"./CircularLoading.306b56d2.js";import"./url.a3a3492f.js";import"./colorHelpers.4faf9736.js";import"./Login.vue_vue_type_script_setup_true_lang.ae593ca7.js";import"./Logo.f019c7ef.js";import"./string.9fd91434.js";import"./index.12d555af.js";import"./Steps.3e1f2e98.js";import"./index.83f71fe4.js";import"./Watermark.c9be7b32.js";(function(){try{var u=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},n=new Error().stack;n&&(u._sentryDebugIds=u._sentryDebugIds||{},u._sentryDebugIds[n]="5958d3a4-eaf0-4a12-b0a0-aeda1e8f5567",u._sentryDebugIdIdentifier="sentry-dbid-5958d3a4-eaf0-4a12-b0a0-aeda1e8f5567")}catch{}})();const X={key:0,class:"loading"},Y=F({__name:"Form",setup(u){const n=U(),d=A(),f=I({playerKey:h()}),g=D(),i=L(null);W(n,()=>{n.name==="form"&&w()});const{loading:c,result:t,error:p,refetch:w}=H(async()=>{f.playerKey=h();const r=n.path.slice(1),e=await E(r);if(!e){d.push({name:"error",params:{status:"404"}});return}const o=new k({formRunnerData:e,logService:null,connectionManager:new R(e.id,"player",n.query),onRedirect:_,onFormStart:()=>{},onFormEnd:()=>{},onStackTraceUpdate:null,onStateUpdate:l=>i.value=l}),s=o.getState();return i.value=s.formState,{runnerData:e,controller:o}}),b=V(()=>{const r=!c,e=!!p,o=!t||i.value===null;return r&&(e||o)});x(()=>{var r,e,o,s,l;b.value&&d.push({name:"error",params:{status:"500"}}),!!((r=t.value)!=null&&r.runnerData)&&(e=t.value)!=null&&e.runnerData&&(document.title=(l=(o=t.value)==null?void 0:o.runnerData.welcomeTitle)!=null?l:(s=t.value)==null?void 0:s.runnerData.title)});function _(r,e){window.removeEventListener("beforeunload",m),S("player",d,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 o,s,l,v;return a(c)?(y(),M("div",X,[N(P)])):a(t)&&a(t).runnerData&&i.value&&!a(p)&&!a(c)?(y(),T(C,{key:f.playerKey,"form-runner-data":a(t).runnerData,"form-state":i.value,"is-preview":!1,"user-email":a(g).email,onRedirect:_,onActionClicked:(o=a(t))==null?void 0:o.controller.handleActionClick,onUpdateWidgetErrors:(s=a(t))==null?void 0:s.controller.updateWidgetFrontendErrors,onUpdateWidgetValue:(l=a(t))==null?void 0:l.controller.updateWidgetValue,onAuthComplete:(v=a(t))==null?void 0:v.controller.handleAuthComplete},null,8,["form-runner-data","form-state","user-email","onActionClicked","onUpdateWidgetErrors","onUpdateWidgetValue","onAuthComplete"])):q("",!0)}}});const ue=G(Y,[["__scopeId","data-v-c3fd8bc9"]]);export{ue as default};
//# sourceMappingURL=Form.08e8897f.js.map
