import{u as A}from"./router.142fcc1c.js";import{b as F,r as I,c as U,d as T}from"./FormRunner.ab4827e7.js";import{A as x}from"./api.5db3b5f8.js";import{d as L,eC as V,eJ as B,z as N,r as b,y as W,K,aw as M,o as q,a0 as z,u as t,b as f,eu as G,f as p,c as k,w as _,ew as J,ar as D,cR as P,cN as j,cV as H,S as O}from"./vue-router.67809441.js";import{a as Q}from"./asyncComputed.c6a51599.js";import{u as R}from"./uuid.eef07528.js";import{L as X}from"./CircularLoading.b824a8db.js";import{f as Y}from"./api.fed40c5d.js";import"./url.bf0f022f.js";import"./Login.vue_vue_type_script_setup_true_lang.947f6490.js";import"./index.35943144.js";import"./WidgetsFrame.002b9951.js";import"./Steps.a1a0fd44.js";import"./Watermark.f55a225f.js";import"./Card.722a13de.js";import"./TabPane.f0c2dc5c.js";import"./fetch.df469531.js";import"./metadata.e61929fd.js";import"./PhCheckCircle.vue.cf3f2492.js";import"./PhKanban.vue.d680969f.js";import"./PhScroll.vue.505180b1.js";import"./PhWebhooksLogo.vue.bae5126c.js";import"./runnerData.5c6d9896.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]="8bae0384-dfeb-41fd-908e-82035015f398",u._sentryDebugIdIdentifier="sentry-dbid-8bae0384-dfeb-41fd-908e-82035015f398")}catch{}})();const Z={key:0,class:"loading"},$=L({__name:"Form",setup(u){const n=V(),c=B(),y=N({playerKey:R()}),C=A(),l=b(null),h=b(!1);W(n,()=>{n.name==="form"&&E()});const{loading:m,result:r,error:v,refetch:E}=Q(async()=>{y.playerKey=R();const a=n.path.slice(1),e=await Y(a);if(!e){c.push({name:"error",params:{status:"404"}});return}const o=n.query[x];if(!e.isInitial&&!o){h.value=!0;return}const s=new U({formRunnerData:e,logService:null,connectionManager:new T(e.id,"player",n.query),onRedirect:g,onFormStart:()=>{},onFormEnd:()=>{},onStackTraceUpdate:null,onStateUpdate:d=>l.value=d}),i=s.getState();return l.value=i.formState,{runnerData:e,controller:s}}),S=K(()=>{const a=!m,e=!!v,o=!r||l.value===null;return a&&(e||o)});M(()=>{var a,e,o,s,i;S.value&&c.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",c,a,e)}q(async()=>{var e;!((e=window.should_ask_before_leave)==null||e)||window.addEventListener("beforeunload",w)}),z(()=>{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(),G("div",Z,[p(X)])):h.value?(f(),k(t(H),{key:1,class:"unset-thread-container",vertical:""},{default:_(()=>[p(t(P),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&&l.value&&!t(v)&&!t(m)?(f(),k(F,{key:y.playerKey,"form-runner-data":t(r).runnerData,"form-state":l.value,"is-preview":!1,"user-email":(o=t(C).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"])):J("",!0)}}});const De=O($,[["__scopeId","data-v-7ca44c2f"]]);export{De as default};
//# sourceMappingURL=Form.25837672.js.map
