import{a as F,j as I}from"./workspaceStore.1dfebc80.js";import{b as U,r as A,c as x,d as T}from"./FormRunner.1c0f3f4b.js";import{A as V}from"./api.5a5fe7cd.js";import{d as W,e7 as L,ek as N,D as B,e as w,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.97d0d8a6.js";import{a as Q}from"./asyncComputed.72143f3b.js";import{u as R}from"./uuid.159751e6.js";import{L as X}from"./CircularLoading.5245b03b.js";import"./url.6a6403b0.js";import"./Login.vue_vue_type_script_setup_true_lang.c906623c.js";import"./index.8765b89e.js";import"./WidgetsFrame.a8926a60.js";import"./Steps.5da1438f.js";import"./Watermark.49365ee3.js";import"./Card.d83ffd8b.js";import"./TabPane.1a05f343.js";import"./fetch.7ebcae96.js";import"./metadata.7dbff146.js";import"./PhBug.vue.3ea7349b.js";import"./PhCheckCircle.vue.2e3af5ba.js";import"./PhKanban.vue.949c555a.js";import"./PhWebhooksLogo.vue.10394676.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]="3eb6bdab-3803-45c1-b671-6ce8ea51d312",l._sentryDebugIdIdentifier="sentry-dbid-3eb6bdab-3803-45c1-b671-6ce8ea51d312")}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=w(null),v=w(!1);K(o,()=>{o.name==="form"&&C()});const{loading:m,result:r,error:b,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:g,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=!!b,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 g(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(b)&&!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:g,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 we=O(Z,[["__scopeId","data-v-d667e7b2"]]);export{we as default};
//# sourceMappingURL=Form.106982a3.js.map
