import{A as S}from"./api.c7e9dccb.js";import{b as I,j as U}from"./workspaceStore.5e86d4c2.js";import{b as A,r as T,c as x,d as W}from"./FormRunner.2d2a8584.js";import{d as L,ea as V,eo as K,D as N,e as w,g as B,f as M,aK as q,W as j,ag as G,u as t,o as p,X as P,b as y,c as D,w as _,R as X,aF as R,d9 as $,d5 as z,dd as H,$ as J}from"./vue-router.f3adf768.js";import{a as O}from"./asyncComputed.83d82971.js";import{u as k}from"./uuid.688298a4.js";import{L as Q}from"./CircularLoading.8e58ad1f.js";import"./fetch.3f8877b7.js";import"./metadata.330fba06.js";import"./PhBug.vue.2f731bdf.js";import"./PhCheckCircle.vue.e86b9dd7.js";import"./PhKanban.vue.dd808c16.js";import"./PhWebhooksLogo.vue.f610fe2c.js";import"./url.05ebda4d.js";import"./colorHelpers.850b4295.js";import"./Login.vue_vue_type_script_setup_true_lang.a51aa026.js";import"./Logo.68c86a36.js";import"./string.10d66498.js";import"./index.06531602.js";import"./Steps.b48ccc1b.js";import"./index.ff5213e8.js";import"./Watermark.b2002360.js";(function(){try{var l=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},o=new Error().stack;o&&(l._sentryDebugIds=l._sentryDebugIds||{},l._sentryDebugIds[o]="dedc4c40-f3f0-4b1f-a801-b7e6c05cfd7b",l._sentryDebugIdIdentifier="sentry-dbid-dedc4c40-f3f0-4b1f-a801-b7e6c05cfd7b")}catch{}})();const Y={key:0,class:"loading"},Z=L({__name:"Form",setup(l){const o=V(),c=K(),h=N({playerKey:k()}),E=I(),u=w(null),v=w(!1);B(o,()=>{o.name==="form"&&C()});const{loading:m,result:r,error:g,refetch:C}=O(async()=>{h.playerKey=k();const a=o.path.slice(1),e=await U(a);if(!e){c.push({name:"error",params:{status:"404"}});return}const n=o.query[S];if(!e.isInitial&&!n){v.value=!0;return}const s=new x({formRunnerData:e,logService:null,connectionManager:new W(e.id,"player",o.query),onRedirect:b,onFormStart:()=>{},onFormEnd:()=>{},onStackTraceUpdate:null,onStateUpdate:d=>u.value=d}),i=s.getState();return u.value=i.formState,{runnerData:e,controller:s}}),F=M(()=>{const a=!m,e=!!g,n=!r||u.value===null;return a&&(e||n)});q(()=>{var a,e,n,s,i;F.value&&c.push({name:"error",params:{status:"500"}}),!!((a=r.value)!=null&&a.runnerData)&&(e=r.value)!=null&&e.runnerData&&(document.title=(i=(n=r.value)==null?void 0:n.runnerData.welcomeTitle)!=null?i:(s=r.value)==null?void 0:s.runnerData.title)});function b(a,e){window.removeEventListener("beforeunload",f),T("player",c,a,e)}j(async()=>{window.addEventListener("beforeunload",f)}),G(()=>{window.removeEventListener("beforeunload",f)});const f=a=>{var e;if((e=r.value)!=null&&e.controller.handleCloseAttempt())return a.preventDefault(),""};return(a,e)=>{var n,s,i,d;return t(m)?(p(),P("div",Y,[y(Q)])):v.value?(p(),D(t(H),{key:1,class:"unset-thread-container",vertical:""},{default:_(()=>[y(t($),null,{default:_(()=>[R("Cannot open this link directly")]),_:1}),y(t(z),{class:"message"},{default:_(()=>[R(" 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)?(p(),D(A,{key:h.playerKey,"form-runner-data":t(r).runnerData,"form-state":u.value,"is-preview":!1,"user-email":(n=t(E).user)==null?void 0:n.claims.email,onRedirect:b,onActionClicked:(s=t(r))==null?void 0:s.controller.handleActionClick,onUpdateWidgetErrors:(i=t(r))==null?void 0:i.controller.updateWidgetFrontendErrors,onUpdateWidgetValue:(d=t(r))==null?void 0:d.controller.updateWidgetValue},null,8,["form-runner-data","form-state","user-email","onActionClicked","onUpdateWidgetErrors","onUpdateWidgetValue"])):X("",!0)}}});const De=J(Z,[["__scopeId","data-v-0e49e822"]]);export{De as default};
//# sourceMappingURL=Form.a57b3f11.js.map
