import{d as _,r as m,J as r,b as D,c as I,w as s,aJ as l,eC as k,f as $,u as d,c4 as L,cI as x}from"./outputWidgets.5ced94d7.js";import{l as c}from"./DocsButton.vue_vue_type_script_setup_true_lang.b7605154.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},n=new Error().stack;n&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[n]="93802c99-3aae-4cc8-a1a8-417d19a8bf65",a._sentryDebugIdIdentifier="sentry-dbid-93802c99-3aae-4cc8-a1a8-417d19a8bf65")}catch{}})();const P=_({__name:"LaunchButton",props:{path:{}},setup(a){const n=a,e=m({state:"loading"}),i=r(()=>e.value.state!=="found"),p=r(()=>e.value.state==="loading"),f=r(()=>e.value.state==="found"?e.value.url:void 0),g=r(()=>{switch(e.value.state){case"error":return"Error";case"loading":return"Loading";case"not-deployed":return"No deploy";case"not-logged":return"Not logged";case"not-found":return"Page not found";case"found":return"Launch";default:throw new Error(`Invalid state ${e.value}`)}}),h=r(()=>{switch(e.value.state){case"error":return"Something went wrong when trying to get your deployed URL.";case"loading":return"Getting deployed url info...";case"not-deployed":return"You have no deployed url yet.";case"not-logged":return"You are not logged.";case"not-found":return"This page is not on the deployed application.";case"found":return"Launch the deployed version of this application in another tab.";default:throw new Error(`Invalid state ${e.value}`)}});async function y(o){const t=`https://${o}.abstra.app/_healthcheck`;return(await fetch(t)).ok}async function v(o){const t=`https://${o}.abstra.app/_pages/${n.path}`;return(await fetch(t)).ok}async function w(){if(!(await c.get()).logged){e.value={state:"not-logged"};return}const t=await c.getProjectInfo().catch(()=>null);if(!t){e.value={state:"error"};return}if(!await y(t.subdomain).catch(()=>null)){e.value={state:"not-deployed"};return}if(!await v(t.subdomain).catch(()=>null)){e.value={state:"not-found"};return}const b=`https://${t.subdomain}.abstra.app/${n.path}`;e.value={state:"found",url:b}}return w(),(o,t)=>(D(),I(d(x),{title:g.value},{content:s(()=>[l(k(h.value),1)]),default:s(()=>[$(d(L),{href:f.value,target:"_blank",disabled:i.value,loading:p.value},{default:s(()=>[l("Launch last deploy")]),_:1},8,["href","disabled","loading"])]),_:1},8,["title"]))}});export{P as _};
//# sourceMappingURL=LaunchButton.vue_vue_type_script_setup_true_lang.7fd38883.js.map
