import{u as P}from"./index.294557b8.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 q,eA as M,eB as V,r as w,c as L,eK as N}from"./outputWidgets.83ad65aa.js";import{b as T,c as H,d as O,r as j}from"./FormRunner.aa9f16ae.js";import{a as J}from"./asyncComputed.eebec89e.js";import{L as K}from"./CircularLoading.05e42a56.js";import{F as z}from"./forms.80cfb984.js";import{W as E}from"./workspaces.a03a836c.js";import"./envVars.f18fb294.js";import{J as G}from"./icons.ec92f7f9.js";import"./pubsub.6c6cbc8d.js";import"./url.27ce9387.js";import"./Passwordless.1616ae72.js";import"./PlayerNavbar.e416200d.js";import"./WidgetsFrame.8301aa17.js";import"./Steps.f845ba67.js";import"./Card.e59afab4.js";import"./TabPane.b3ba7cb7.js";import"./hasIn.597d0078.js";import"./Typography.fea800b8.js";import"./record.df4e3ae7.js";import"./runnerData.83b2a9f7.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]="426139c2-94c6-48c2-be88-379f25b5d279",e._sentryDebugIdIdentifier="sentry-dbid-426139c2-94c6-48c2-be88-379f25b5d279")}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 c(){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:c},te)])])]))}});const ae=k(oe,[["__scopeId","data-v-3e46b76c"]]),ne=b({__name:"BackButton",emits:["exitFullscreenPreview"],setup(e,{emit:r}){return(s,o)=>{const c=$("icon");return d(),m("button",{class:"back-btn",onClick:o[0]||(o[0]=h=>r("exitFullscreenPreview"))},[g(c,{class:"icon",path:a(G),width:"20",height:"20",fill:"#5A677A"},null,8,["path"]),q(" Editor ")])}}});const se=k(ne,[["__scopeId","data-v-a3f31716"]]),ce={class:"page"},ie={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=M(),s=V(),o=w(null),c=w(null),h=s.query,_=w(null);function S(t,i){j("preview",r,t,i)}const{result:f,loading:B,refetch:x,error:F}=J(async()=>{const[t,i,v]=await Promise.all([z.get(s.params.id),E.get(),E.readTestData()]),u=new H({formRunnerData:t.makeRunnerData(i),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),c.value=t.makeRunnerData(i);const p=u.getState();return o.value=p.formState,_.value=p.passwordlessUser,N({form:t,workspace:i,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,i)=>{var v,u,p,l,R;return d(),m("div",ce,[a(B)||!o.value||!c.value?(d(),L(K,{key:0})):a(F)?(d(),m("div",ie,[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":c.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.00b83b68.js.map
