import{A as S}from"./api.e2091ab7.js";import{b as I,j as U}from"./workspaceStore.d7393ddd.js";import{b as A,r as T,c as x,d as W}from"./FormRunner.dab51a88.js";import{d as L,ea as V,eo as K,D as N,e as b,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.9fdef1c2.js";import{a as O}from"./asyncComputed.b83fe47e.js";import{u as k}from"./uuid.9da3532f.js";import{L as Q}from"./CircularLoading.e9b619e0.js";import"./fetch.37e528cd.js";import"./metadata.7a99eefc.js";import"./PhBug.vue.6c87d690.js";import"./PhCheckCircle.vue.af0e1704.js";import"./PhKanban.vue.2ddab4c5.js";import"./PhWebhooksLogo.vue.d6d363ca.js";import"./url.07fafc3a.js";import"./colorHelpers.ceab0a75.js";import"./Login.vue_vue_type_script_setup_true_lang.f4d29cbf.js";import"./Logo.df0c7b1a.js";import"./string.aab27b65.js";import"./index.12dad819.js";import"./index.612bc9e7.js";import"./Steps.7f61d286.js";import"./index.9aa7308e.js";import"./Watermark.dc7385c8.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]="63b50d4e-3e4a-40dc-8131-fd3cfaecdf3f",l._sentryDebugIdIdentifier="sentry-dbid-63b50d4e-3e4a-40dc-8131-fd3cfaecdf3f")}catch{}})();const Y={key:0,class:"loading"},Z=L({__name:"Form",setup(l){const o=V(),u=K(),h=N({playerKey:k()}),E=I(),d=b(null),v=b(!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){u.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:w,onFormStart:()=>{},onFormEnd:()=>{},onStackTraceUpdate:null,onStateUpdate:c=>d.value=c}),i=s.getState();return d.value=i.formState,{runnerData:e,controller:s}}),F=M(()=>{const a=!m,e=!!g,n=!r||d.value===null;return a&&(e||n)});q(()=>{var a,e,n,s,i;F.value&&u.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 w(a,e){window.removeEventListener("beforeunload",f),T("player",u,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,c;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&&d.value&&!t(g)&&!t(m)?(p(),D(A,{key:h.playerKey,"form-runner-data":t(r).runnerData,"form-state":d.value,"is-preview":!1,"user-email":(n=t(E).user)==null?void 0:n.claims.email,onRedirect:w,onActionClicked:(s=t(r))==null?void 0:s.controller.handleActionClick,onUpdateWidgetErrors:(i=t(r))==null?void 0:i.controller.updateWidgetFrontendErrors,onUpdateWidgetValue:(c=t(r))==null?void 0:c.controller.updateWidgetValue},null,8,["form-runner-data","form-state","user-email","onActionClicked","onUpdateWidgetErrors","onUpdateWidgetValue"])):X("",!0)}}});const Re=J(Z,[["__scopeId","data-v-22706e2c"]]);export{Re as default};
//# sourceMappingURL=Form.2c5b3586.js.map
