import{a as F,j as I}from"./workspaceStore.d0364043.js";import{b as U,r as A,c as x,d as T}from"./FormRunner.44462dfa.js";import{A as V}from"./api.1f95d268.js";import{d as W,e7 as L,ek as N,D as B,e as b,g as K,f as M,aC as q,V as j,a7 as G,u as t,W as P,b as p,c as D,w as y,R as $,o as _,ax as k,d5 as z,d1 as H,d9 as J,$ as O}from"./vue-router.2175af64.js";import{a as Q}from"./asyncComputed.bdf01236.js";import{u as R}from"./uuid.84c098a7.js";import{L as X}from"./CircularLoading.513bcb84.js";import"./url.bfee0c48.js";import"./Login.vue_vue_type_script_setup_true_lang.c4c57154.js";import"./index.db580684.js";import"./WidgetsFrame.e9ea1619.js";import"./Steps.235e1440.js";import"./Watermark.ef8364ea.js";import"./Card.e8e29a1c.js";import"./TabPane.ecb5d5c2.js";import"./fetch.332d7953.js";import"./metadata.8dc4f573.js";import"./PhBug.vue.03b8d41c.js";import"./PhCheckCircle.vue.5f84018f.js";import"./PhKanban.vue.2e9223b7.js";import"./PhWebhooksLogo.vue.39736b9f.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]="02faa13d-efc5-4a72-8a46-72c582d12144",l._sentryDebugIdIdentifier="sentry-dbid-02faa13d-efc5-4a72-8a46-72c582d12144")}catch{}})();const Y={key:0,class:"loading"},Z=W({__name:"Form",setup(l){const o=L(),d=N(),h=B({playerKey:R()}),E=F(),u=b(null),v=b(!1);K(o,()=>{o.name==="form"&&C()});const{loading:m,result:r,error:g,refetch:C}=Q(async()=>{h.playerKey=R();const a=o.path.slice(1),e=await I(a);if(!e){d.push({name:"error",params:{status:"404"}});return}const n=o.query[V];if(!e.isInitial&&!n){v.value=!0;return}const s=new x({formRunnerData:e,logService:null,connectionManager:new T(e.id,"player",o.query),onRedirect:w,onFormStart:()=>{},onFormEnd:()=>{},onStackTraceUpdate:null,onStateUpdate:c=>u.value=c}),i=s.getState();return u.value=i.formState,{runnerData:e,controller:s}}),S=M(()=>{const a=!m,e=!!g,n=!r||u.value===null;return a&&(e||n)});q(()=>{var a,e,n,s,i;S.value&&d.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),A("player",d,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("div",Y,[p(X)])):v.value?(_(),D(t(J),{key:1,class:"unset-thread-container",vertical:""},{default:y(()=>[p(t(z),null,{default:y(()=>[k("Cannot open this link directly")]),_:1}),p(t(H),{class:"message"},{default:y(()=>[k(" 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)?(_(),D(U,{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: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"])):$("",!0)}}});const be=O(Z,[["__scopeId","data-v-d667e7b2"]]);export{be as default};
//# sourceMappingURL=Form.49ed429b.js.map
