import{a as F,j as I}from"./workspaceStore.85cfb2dd.js";import{b as U,r as A,c as x,d as T}from"./FormRunner.02b18d40.js";import{A as V}from"./api.cd4d7211.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 f,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.c536fc2b.js";import{a as Q}from"./asyncComputed.5fa11bed.js";import{u as R}from"./uuid.43c495fc.js";import{L as X}from"./CircularLoading.8a685a21.js";import"./url.4c149b5f.js";import"./Login.vue_vue_type_script_setup_true_lang.b5e4a260.js";import"./index.b2537806.js";import"./WidgetsFrame.8708f72e.js";import"./Steps.d0f2194c.js";import"./Watermark.79f754d4.js";import"./Card.7a2cefaf.js";import"./TabPane.373d8ad5.js";import"./fetch.f9fa5060.js";import"./metadata.31121f20.js";import"./PhBug.vue.96f8bd7a.js";import"./PhCheckCircle.vue.f717448d.js";import"./PhKanban.vue.718d6f52.js";import"./PhWebhooksLogo.vue.f166a38b.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]="96a11047-a455-48e0-9cee-c861d962dd75",l._sentryDebugIdIdentifier="sentry-dbid-96a11047-a455-48e0-9cee-c861d962dd75")}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",p),A("player",d,a,e)}j(async()=>{window.addEventListener("beforeunload",p)}),G(()=>{window.removeEventListener("beforeunload",p)});const p=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,[f(X)])):v.value?(_(),D(t(J),{key:1,class:"unset-thread-container",vertical:""},{default:y(()=>[f(t(z),null,{default:y(()=>[k("Cannot open this link directly")]),_:1}),f(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.bd7cca2d.js.map
