import{d as f,X as g,aM as m,B as o,m as l,G as n,g as s,D as e,M as p,by as v,Y as _,$ as c,Z as h,ap as y,r as w,S as I}from"./jwt-decode.esm-Dca5fHH5.js";import{_ as b}from"./AbstraLogo.vue_vue_type_script_setup_true_lang-VbWqKJaf.js";import{B as P}from"./BaseLayout-CAFdFQyK.js";import{l as u}from"./fetch-CmLIxYFV.js";import"./router-D5wfdag3.js";import{P as x}from"./project-BZzoNeQM.js";import"./tables-BsqTY_wE.js";import"./Logo-DAfI0pPB.js";import"./index-Cyx2lZTa.js";import"./record-BZIfMWML.js";import"./string-BYR4BIXr.js";(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},t=new Error().stack;t&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[t]="cf504233-84b6-4391-b861-edb04871d5df",i._sentryDebugIdIdentifier="sentry-dbid-cf504233-84b6-4391-b861-edb04871d5df")}catch{}})();const W=f({__name:"View",props:{controller:{}},setup(i){const t=i,r=t.controller.loadingPercentage();return g(()=>{t.controller.start()}),m(()=>{t.controller.cleanUp()}),(a,d)=>(l(),o(P,null,{content:n(()=>[s(e(p),{align:"center",justify:"center",style:{width:"100vw",height:"100dvh"}},{default:n(()=>[s(e(p),{gap:"large",align:"center",justify:"space-evenly",vertical:"",style:{width:"45%","min-width":"600px",height:"100%"}},{default:n(()=>[s(b,{size:"large"}),s(e(v),{size:[10,10],"show-info":!1,percent:e(r),"stroke-color":"#EA576A"},null,8,["percent"]),s(e(_),{level:3},{default:n(()=>[c("Preparing your environment")]),_:1}),e(r)<100?(l(),o(e(h),{key:0},{default:n(()=>[c("We are setting things up... This may take up to 1 minute.")]),_:1})):(l(),o(e(h),{key:1},{default:n(()=>[c("You will be redirected soon")]),_:1}))]),_:1})]),_:1})]),_:1}))}}),j=y(W,[["__scopeId","data-v-0794e790"]]);class T{projectId;loading;fetch=u;interval=null;urls=null;totalWaitTime;poolingInterval;pingResponded=!1;redirectPath;constructor(t,r,a=u){this.projectId=t,this.loading=w(0),this.fetch=a,this.totalWaitTime=6e4,this.poolingInterval=2500,this.redirectPath=r}increment(){this.loading.value+=100/(this.totalWaitTime/this.poolingInterval)}speedUp(){this.totalWaitTime=5e3,this.poolingInterval=500,this.interval&&clearInterval(this.interval),this.interval=setInterval(async()=>{this.increment(),this.loading.value>=100&&this.navigate()},this.poolingInterval)}navigate(){if(this.urls){const t=new URLSearchParams;this.redirectPath&&t.set("redirect",this.redirectPath),window.location.replace(this.urls.redirect+"?"+t.toString())}this.cleanUp()}async ping(){if(!this.urls)return!1;if(this.pingResponded)return!0;const t=await this.fetch(this.urls.ping,{signal:AbortSignal.timeout(500)});return this.pingResponded=t.status===200,this.pingResponded}async start(){const t=await x.startWebEditor(this.projectId);this.urls=t,this.interval=setInterval(async()=>{this.increment(),this.pingResponded||await this.ping()&&this.speedUp(),this.loading.value>=100&&this.navigate()},this.poolingInterval)}cleanUp(){this.interval&&clearInterval(this.interval)}loadingPercentage(){return this.loading}}const z=f({__name:"WebEditor",setup(i){const t=I(),r=t.params.projectId,a=t.query.redirect,d=new T(r,a);return(k,R)=>(l(),o(j,{controller:e(d)},null,8,["controller"]))}});export{z as default};
//# sourceMappingURL=WebEditor-DF5_xAnv.js.map
