import{b as D,i as E}from"./workspaceStore.dd86fabd.js";import{a as C,r as S,c as k,d as R}from"./FormRunner.5c4e8f28.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.b466b20d.js";import{a as P}from"./asyncComputed.4467697c.js";import{u as h}from"./uuid.36b47c8c.js";import{L as X}from"./CircularLoading.c0497912.js";import"./url.0fe255f2.js";import"./colorHelpers.26ff5df3.js";import"./Login.vue_vue_type_script_setup_true_lang.559b91f2.js";import"./Logo.19805c7a.js";import"./string.42378387.js";import"./index.849469be.js";import"./index.695b6622.js";import"./Steps.42f41182.js";import"./index.f3e3df19.js";import"./Watermark.ad544035.js";(function(){try{var l=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},n=new Error().stack;n&&(l._sentryDebugIds=l._sentryDebugIds||{},l._sentryDebugIds[n]="13a777c6-3ec2-417c-a800-b4f8aa3343c1",l._sentryDebugIdIdentifier="sentry-dbid-13a777c6-3ec2-417c-a800-b4f8aa3343c1")}catch{}})();const Y={key:0,class:"loading"},j=F({__name:"Form",setup(l){const n=U(),i=A(),p=I({playerKey:h()}),g=D(),u=L(null);W(n,()=>{n.name==="form"&&w()});const{loading:d,result:t,error:f,refetch:w}=P(async()=>{p.playerKey=h();const r=n.path.slice(1),e=await E(r);if(!e){i.push({name:"error",params:{status:"404"}});return}const a=new k({formRunnerData:e,logService:null,connectionManager:new R(e.id,"player",n.query),onRedirect:_,onFormStart:()=>{},onFormEnd:()=>{},onStackTraceUpdate:null,onStateUpdate:c=>u.value=c}),s=a.getState();return u.value=s.formState,{runnerData:e,controller:a}}),b=V(()=>{const r=!d,e=!!f,a=!t||u.value===null;return r&&(e||a)});x(()=>{var r,e,a,s,c;b.value&&i.push({name:"error",params:{status:"500"}}),!!((r=t.value)!=null&&r.runnerData)&&(e=t.value)!=null&&e.runnerData&&(document.title=(c=(a=t.value)==null?void 0:a.runnerData.welcomeTitle)!=null?c:(s=t.value)==null?void 0:s.runnerData.title)});function _(r,e){window.removeEventListener("beforeunload",m),S("player",i,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 a,s,c,v;return o(d)?(y(),M("div",Y,[N(X)])):o(t)&&o(t).runnerData&&u.value&&!o(f)&&!o(d)?(y(),T(C,{key:p.playerKey,"form-runner-data":o(t).runnerData,"form-state":u.value,"is-preview":!1,"user-email":o(g).email,onRedirect:_,onActionClicked:(a=o(t))==null?void 0:a.controller.handleActionClick,onUpdateWidgetErrors:(s=o(t))==null?void 0:s.controller.updateWidgetFrontendErrors,onUpdateWidgetValue:(c=o(t))==null?void 0:c.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 ue=G(j,[["__scopeId","data-v-c3fd8bc9"]]);export{ue as default};
//# sourceMappingURL=Form.ab9c5fc3.js.map
