import{u as P}from"./index.d59ef797.js";import{d as b,H as U,b as d,ev as m,e as n,eD as y,eE as A,eF as W,v as k,a as $,f as g,u as a,ar as M,eA as q,eB as V,r as w,c as L,eM as N}from"./outputWidgets.6bfc0239.js";import{b as T,c as H,d as O,r as j}from"./FormRunner.dc1c5b09.js";import{a as K}from"./asyncComputed.21831dee.js";import{L as z}from"./CircularLoading.c1d47ee0.js";import{F as G}from"./forms.9e600492.js";import{W as E}from"./workspaces.aee677ed.js";import"./envVars.75d5e3af.js";import{K as J}from"./icons.5f4f8713.js";import"./pubsub.56f48661.js";import"./url.c2408bab.js";import"./Passwordless.43cdb0c3.js";import"./PlayerNavbar.b0828f3f.js";import"./WidgetsFrame.f3e18a8a.js";import"./Steps.cdfeb83b.js";import"./Card.77a4a6f5.js";import"./TabPane.e27b42bc.js";import"./hasIn.42df2c7d.js";import"./Typography.7fe49268.js";import"./record.dbb754fe.js";import"./runnerData.218d57bf.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},r=new Error().stack;r&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[r]="4fd49ab0-2006-4748-a118-a2cdcf90664b",e._sentryDebugIdIdentifier="sentry-dbid-4fd49ab0-2006-4748-a118-a2cdcf90664b")}catch{}})();const I=e=>(A("data-v-3e46b76c"),e=e(),W(),e),Q={class:"error"},X=I(()=>n("h1",{class:"error-header"},"Error",-1)),Y={class:"error-body"},Z={class:"error-message"},ee={class:"error-details"},re=I(()=>n("span",null,"Reload",-1)),te=[re],oe=b({__name:"Error",props:{error:{type:Object,required:!0},repeated:{type:Boolean,required:!1}},emits:["reload"],setup(e,{emit:r}){const s=e,o=U(()=>s.repeated?"Ooops. The same error occured, please try again later.":"An error occurred while loading.");function i(){r("reload")}return(h,_)=>(d(),m("div",Q,[X,n("div",Y,[n("div",Z,[n("p",null,y(o.value),1),n("p",ee,y(e.error.name)+": "+y(e.error.message),1)]),n("div",{class:"error-actions"},[n("button",{class:"btn btn-primary",onClick:i},te)])])]))}});const ae=k(oe,[["__scopeId","data-v-3e46b76c"]]),ne=b({__name:"BackButton",emits:["exitFullscreenPreview"],setup(e,{emit:r}){return(s,o)=>{const i=$("icon");return d(),m("button",{class:"back-btn",onClick:o[0]||(o[0]=h=>r("exitFullscreenPreview"))},[g(i,{class:"icon",path:a(J),width:"20",height:"20",fill:"#5A677A"},null,8,["path"]),M(" Editor ")])}}});const se=k(ne,[["__scopeId","data-v-a3f31716"]]),ie={class:"page"},ce={key:1,class:"error"},le={key:2,style:{width:"100%",height:"100%",display:"flex"}},de={style:{width:"100%",height:"100%",display:"flex"}},ue=b({__name:"FormPreview",setup(e){const r=q(),s=V(),o=w(null),i=w(null),h=s.query,_=w(null);function S(t,c){j("preview",r,t,c)}const{result:f,loading:B,refetch:x,error:F}=K(async()=>{const[t,c,v]=await Promise.all([G.get(s.params.id),E.get(),E.readTestData()]),u=new H({formRunnerData:t.makeRunnerData(c),queryParams:h,userManager:P,connectionManager:new O(t.id),onFormStart:()=>{},onFormEnd:()=>{},onRedirect:S,onAuthUpdate:l=>_.value=l,onStateUpdate:l=>o.value=l,logService:null,onStackTraceUpdate:null});t.updateInitialState("test_data",v),i.value=t.makeRunnerData(c);const p=u.getState();return o.value=p.formState,_.value=p.passwordlessUser,N({form:t,workspace:c,controller:u})}),D=async({id:t})=>{await r.push({params:{id:t},name:"formPreview",query:s.query}),x()},C=()=>{r.push(`/_editor/form/${encodeURIComponent(s.params.id)}`)};return(t,c)=>{var v,u,p,l,R;return d(),m("div",ie,[a(B)||!o.value||!i.value?(d(),L(z,{key:0})):a(F)?(d(),m("div",ce,[g(ae,{error:a(F),onReload:a(x)},null,8,["error","onReload"])])):(d(),m("main",le,[n("div",de,[g(T,{style:{height:"unset",flex:1,overflow:"hidden"},"is-preview":!1,"form-runner-data":i.value,"form-state":o.value,"user-email":(v=_.value)==null?void 0:v.claims.email,onUpdateWidgetErrors:(u=a(f))==null?void 0:u.controller.updateWidgetFrontendErrors,onUpdateWidgetValue:(p=a(f))==null?void 0:p.controller.updateWidgetValue,onActionClicked:(l=a(f))==null?void 0:l.controller.handleActionClick,onNavigate:D,onLogout:(R=a(f))==null?void 0:R.controller.logout},null,8,["form-runner-data","form-state","user-email","onUpdateWidgetErrors","onUpdateWidgetValue","onActionClicked","onLogout"]),g(se,{onExitFullscreenPreview:C})])]))])}}});const Ue=k(ue,[["__scopeId","data-v-c5c2a66b"]]);export{Ue as default};
//# sourceMappingURL=FormPreview.4a250891.js.map
