import{e as m,Q as _,x as v,n as l,g as c,w as n,v as s,p as i,D as u,bx as w,am as y,q as d,t as p,l as h,T as f,aO as b,r as I,ak as P}from"./jwt-decode.esm-BYfS37aG.js";import{_ as x}from"./AbstraLogo.vue_vue_type_script_setup_true_lang-CSc1qEVg.js";import{B as j}from"./BaseLayout-DElsrb1B.js";import{l as g}from"./fetch-DQISYrhY.js";import"./router-D53qV9Zg.js";import{a as T}from"./project-C7QI6pXl.js";import"./tables-nYEEmE6H.js";import{u as W}from"./projectStore-6bDmkbW0.js";import"./logo-BiWG9_W5.js";import"./Logo-DKvJNxAR.js";import"./ts.worker-Biy-7fEJ.js";import"./string-IQGGUV40.js";import"./organizationSwitcher-DapMvF_6.js";import"./organization-BI2IWMw4.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},t=new Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="900dbdf2-5d35-4fa2-911f-33a2affb296a",e._sentryDebugIdIdentifier="sentry-dbid-900dbdf2-5d35-4fa2-911f-33a2affb296a")}catch{}})();const k=m({__name:"View",props:{controller:{}},setup(e){const t=e,r=t.controller.loadingPercentage();return _(()=>{t.controller.start()}),v(()=>{t.controller.cleanUp()}),(a,o)=>(c(),l(j,null,{content:n(()=>[s(i(u),{align:"center",justify:"center",style:{width:"100vw",height:"100dvh"}},{default:n(()=>[s(i(u),{gap:"large",align:"center",justify:"space-evenly",vertical:"",style:{width:"45%","min-width":"600px",height:"100%"}},{default:n(()=>[s(x,{size:"large"}),s(i(w),{size:[10,10],"show-info":!1,percent:i(r),"stroke-color":"var(--ac-brand-primary)"},null,8,["percent"]),s(i(y),{level:3},{default:n(()=>[d(p(i(h).translate("i18n_webeditorview_preparing_environment")),1)]),_:1}),i(r)<100?(c(),l(i(f),{key:0},{default:n(()=>[d(p(i(h).translate("i18n_webeditorview_setting_up")),1)]),_:1})):(c(),l(i(f),{key:1},{default:n(()=>[d(p(i(h).translate("i18n_webeditorview_redirecting_soon")),1)]),_:1}))]),_:1})]),_:1})]),_:1}))}}),E=b(k,[["__scopeId","data-v-b6b25da5"]]);function R(e,t){if(!e)return"";const r=t.toString();if(!r)return e;const o=e.includes("?")?"&":"?";return`${e}${o}${r}`}class S{projectId;loading;fetch=g;interval=null;urls=null;totalWaitTime;poolingInterval;pingResponded=!1;redirectPath;constructor(t,r,a=g){this.projectId=t,this.loading=I(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);const r=R(this.urls.redirect,t);window.location.replace(r)}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 T.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 H=m({__name:"WebEditor",setup(e){const t=P(),r=W(),a=t.query.redirect,o=new S(r.projectId,a);return(D,U)=>(c(),l(E,{controller:i(o)},null,8,["controller"]))}});export{H as default};
//# sourceMappingURL=WebEditor-D0VSUkNV.js.map
