import{A as S}from"./api.a9b631fd.js";import{b as F,i as I}from"./workspaceStore.61224c34.js";import{b as U,r as T,c as x,d as L}from"./FormRunner.6178a0b4.js";import{d as V,ea as W,eo as N,E as B,e as b,g as K,f as M,aL as q,X as G,ah as P,u as t,o as f,Y as X,b as h,c as D,w as y,S as Y,aG as C,dd as j,d9 as z,dh as H,a0 as J}from"./index.0f630b70.js";import{a as O}from"./asyncComputed.2bec113c.js";import{u as E}from"./uuid.035607ce.js";import{L as Q}from"./CircularLoading.b256c752.js";import"./fetch.04be8a9e.js";import"./metadata.cfd15460.js";import"./PhBug.vue.4c6c1483.js";import"./PhCheckCircle.vue.9b1e3e50.js";import"./PhKanban.vue.f3963316.js";import"./PhWebhooksLogo.vue.3edd7efd.js";import"./url.90c69b58.js";import"./colorHelpers.13000dc5.js";import"./Login.vue_vue_type_script_setup_true_lang.a1b5912b.js";import"./Logo.e9eed733.js";import"./string.532e13bb.js";import"./index.9404ab63.js";import"./index.6834cc58.js";import"./Steps.9b32d2c9.js";import"./index.19d08faa.js";import"./Watermark.2747e371.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]="0c01d25a-d24a-4282-892f-675a93b70f19",l._sentryDebugIdIdentifier="sentry-dbid-0c01d25a-d24a-4282-892f-675a93b70f19")}catch{}})();const Z={key:0,class:"loading"},$=V({__name:"Form",setup(l){const n=W(),d=N(),_=B({playerKey:E()}),k=F(),u=b(null),v=b(!1);K(n,()=>{n.name==="form"&&R()});const{loading:m,result:r,error:g,refetch:R}=O(async()=>{_.playerKey=E();const a=n.path.slice(1),e=await I(a);if(!e){d.push({name:"error",params:{status:"404"}});return}const o=n.query[S];if(!e.isInitial&&!o){v.value=!0;return}const s=new x({formRunnerData:e,logService:null,connectionManager:new L(e.id,"player",n.query),onRedirect:w,onFormStart:()=>{},onFormEnd:()=>{},onStackTraceUpdate:null,onStateUpdate:c=>u.value=c}),i=s.getState();return u.value=i.formState,{runnerData:e,controller:s}}),A=M(()=>{const a=!m,e=!!g,o=!r||u.value===null;return a&&(e||o)});q(()=>{var a,e,o,s,i;A.value&&d.push({name:"error",params:{status:"500"}}),!!((a=r.value)!=null&&a.runnerData)&&(e=r.value)!=null&&e.runnerData&&(document.title=(i=(o=r.value)==null?void 0:o.runnerData.welcomeTitle)!=null?i:(s=r.value)==null?void 0:s.runnerData.title)});function w(a,e){window.removeEventListener("beforeunload",p),T("player",d,a,e)}G(async()=>{window.addEventListener("beforeunload",p)}),P(()=>{window.removeEventListener("beforeunload",p)});const p=a=>{var e;if((e=r.value)!=null&&e.controller.handleCloseAttempt())return a.preventDefault(),""};return(a,e)=>{var o,s,i,c;return t(m)?(f(),X("div",Z,[h(Q)])):v.value?(f(),D(t(H),{key:1,class:"unset-thread-container",vertical:""},{default:y(()=>[h(t(j),null,{default:y(()=>[C("Cannot open this link directly")]),_:1}),h(t(z),{class:"message"},{default:y(()=>[C(" This form must be accessed within a thread, either by clicking on it by notification email or the Kanban board ")]),_:1})]),_:1})):t(r)&&t(r).runnerData&&u.value&&!t(g)&&!t(m)?(f(),D(U,{key:_.playerKey,"form-runner-data":t(r).runnerData,"form-state":u.value,"is-preview":!1,"user-email":t(k).email,onRedirect:w,onActionClicked:(o=t(r))==null?void 0:o.controller.handleActionClick,onUpdateWidgetErrors:(s=t(r))==null?void 0:s.controller.updateWidgetFrontendErrors,onUpdateWidgetValue:(i=t(r))==null?void 0:i.controller.updateWidgetValue,onAuthComplete:(c=t(r))==null?void 0:c.controller.handleAuthComplete},null,8,["form-runner-data","form-state","user-email","onActionClicked","onUpdateWidgetErrors","onUpdateWidgetValue","onAuthComplete"])):Y("",!0)}}});const Ce=J($,[["__scopeId","data-v-3aa2fe18"]]);export{Ce as default};
//# sourceMappingURL=Form.e4510b85.js.map
