import{u as S}from"./router.94ccd1ff.js";import{b as F,r as I,c as U,d as x}from"./FormRunner.ae5b128b.js";import{A as T}from"./api.821769a1.js";import{d as L,eC as V,eJ as B,y as N,q as b,x as W,J as K,aw as q,Z as M,a0 as J,u as t,o as f,eu as G,b as p,c as k,w as _,ew as P,ar as D,cR as Z,cN as j,cV as z,R as H}from"./vue-router.6b399b0b.js";import{a as O}from"./asyncComputed.c7982027.js";import{u as R}from"./uuid.2cda8c4d.js";import{L as Q}from"./CircularLoading.4ef662fa.js";import{f as X}from"./api.84842e32.js";import"./url.2f4a4260.js";import"./Login.vue_vue_type_script_setup_true_lang.79c1592e.js";import"./index.80a69b0e.js";import"./WidgetsFrame.b6d30f3d.js";import"./Steps.14c36c38.js";import"./Watermark.9380ed47.js";import"./Card.ddda3ab5.js";import"./TabPane.dfa9c37c.js";import"./fetch.2c48c3fe.js";import"./metadata.961ac5fc.js";import"./PhCheckCircle.vue.a5f11655.js";import"./PhKanban.vue.3064199b.js";import"./PhScroll.vue.094a2d8c.js";import"./PhWebhooksLogo.vue.30aa7d79.js";import"./runnerData.3191407d.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]="d91172d9-b944-4eed-845c-090ca7d9466e",u._sentryDebugIdIdentifier="sentry-dbid-d91172d9-b944-4eed-845c-090ca7d9466e")}catch{}})();const Y={key:0,class:"loading"},$=L({__name:"Form",setup(u){const n=V(),c=B(),y=N({playerKey:R()}),C=S(),l=b(null),h=b(!1);W(n,()=>{n.name==="form"&&E()});const{loading:m,result:r,error:v,refetch:E}=O(async()=>{y.playerKey=R();const a=n.path.slice(1),e=await X(a);if(!e){c.push({name:"error",params:{status:"404"}});return}const o=n.query[T];if(!e.isInitial&&!o){h.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=>l.value=d}),i=s.getState();return l.value=i.formState,{runnerData:e,controller:s}}),A=K(()=>{const a=!m,e=!!v,o=!r||l.value===null;return a&&(e||o)});q(()=>{var a,e,o,s,i;A.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)}M(async()=>{var e;!((e=window.should_ask_before_leave)==null||e)||window.addEventListener("beforeunload",w)}),J(()=>{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",Y,[p(Q)])):h.value?(f(),k(t(z),{key:1,class:"unset-thread-container",vertical:""},{default:_(()=>[p(t(Z),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"])):P("",!0)}}});const De=H($,[["__scopeId","data-v-7ca44c2f"]]);export{De as default};
//# sourceMappingURL=Form.5e53bdf0.js.map
