import{u as C}from"./router.1b9ffe64.js";import{b as F,r as I,c as U,d as x}from"./FormRunner.7a05f73f.js";import{A as T}from"./api.69f67839.js";import{d as B,eB as L,eM as W,D as V,e as b,g as N,f as K,ax as M,$ as q,a1 as G,u as t,o as f,eu as O,b as p,c as k,w as _,ew as P,as as D,cS as $,cO as j,cW as z,S as H}from"./vue-router.74c693f1.js";import{a as J}from"./asyncComputed.7b5c3427.js";import{u as R}from"./uuid.7ddedf43.js";import{L as Q}from"./CircularLoading.b9cd7656.js";import{f as X}from"./api.2418387e.js";import"./url.8b7ee03b.js";import"./Login.vue_vue_type_script_setup_true_lang.c085ac57.js";import"./index.e8eb3ab0.js";import"./WidgetsFrame.ff15d6d6.js";import"./Steps.fb5f5339.js";import"./Watermark.d47c9511.js";import"./Card.e642dff5.js";import"./TabPane.bfa47506.js";import"./fetch.aa87e7cf.js";import"./metadata.3e87581a.js";import"./PhCheckCircle.vue.970d6f97.js";import"./PhKanban.vue.b54530a2.js";import"./PhScroll.vue.9a674589.js";import"./PhWebhooksLogo.vue.ea04f3c9.js";import"./runnerData.91386489.js";(function(){try{var u=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},n=new Error().stack;n&&(u._sentryDebugIds=u._sentryDebugIds||{},u._sentryDebugIds[n]="ed9fa0e4-03d1-44cc-a20a-f3a7eac6604e",u._sentryDebugIdIdentifier="sentry-dbid-ed9fa0e4-03d1-44cc-a20a-f3a7eac6604e")}catch{}})();const Y={key:0,class:"loading"},Z=B({__name:"Form",setup(u){const n=L(),l=W(),h=V({playerKey:R()}),S=C(),c=b(null),y=b(!1);N(n,()=>{n.name==="form"&&E()});const{loading:m,result:r,error:v,refetch:E}=J(async()=>{h.playerKey=R();const a=n.path.slice(1),e=await X(a);if(!e){l.push({name:"error",params:{status:"404"}});return}const o=n.query[T];if(!e.isInitial&&!o){y.value=!0;return}const s=new U({formRunnerData:e,logService:null,connectionManager:new x(e.id,"player",n.query),onRedirect:g,onFormStart:()=>{},onFormEnd:()=>{},onStackTraceUpdate:null,onStateUpdate:d=>c.value=d}),i=s.getState();return c.value=i.formState,{runnerData:e,controller:s}}),A=K(()=>{const a=!m,e=!!v,o=!r||c.value===null;return a&&(e||o)});M(()=>{var a,e,o,s,i;A.value&&l.push({name:"error",params:{status:"500"}}),!!((a=r.value)!=null&&a.runnerData)&&(e=r.value)!=null&&e.runnerData&&(document.title=(i=(o=r.value)==null?void 0:o.runnerData.welcomeTitle)!=null?i:(s=r.value)==null?void 0:s.runnerData.title)});function g(a,e){I("player",l,a,e)}q(async()=>{var e;!((e=window.should_ask_before_leave)==null||e)||window.addEventListener("beforeunload",w)}),G(()=>{window.removeEventListener("beforeunload",w)});const w=a=>{var e;if((e=r.value)!=null&&e.controller.handleCloseAttempt())return a.preventDefault(),""};return(a,e)=>{var o,s,i,d;return t(m)?(f(),O("div",Y,[p(Q)])):y.value?(f(),k(t(z),{key:1,class:"unset-thread-container",vertical:""},{default:_(()=>[p(t($),null,{default:_(()=>[D("Cannot open this link directly")]),_:1}),p(t(j),{class:"message"},{default:_(()=>[D(" 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&&c.value&&!t(v)&&!t(m)?(f(),k(F,{key:h.playerKey,"form-runner-data":t(r).runnerData,"form-state":c.value,"is-preview":!1,"user-email":(o=t(S).user)==null?void 0:o.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:(d=t(r))==null?void 0:d.controller.updateWidgetValue},null,8,["form-runner-data","form-state","user-email","onActionClicked","onUpdateWidgetErrors","onUpdateWidgetValue"])):P("",!0)}}});const De=H(Z,[["__scopeId","data-v-7ca44c2f"]]);export{De as default};
//# sourceMappingURL=Form.75da9f80.js.map
