import{d as D,r as I,ez as A,ey as B,u as e,b as c,c as d,w as a,f as u,aI as n,c0 as s,cD as C,cp as j,v as x}from"./outputWidgets.a8447bcb.js";import{W as P}from"./workspaces.11e30eec.js";import{l as p}from"./DocsButton.vue_vue_type_script_setup_true_lang.e2056d48.js";import{p as R}from"./popupNotifcation.c5f94a79.js";import{a as U}from"./asyncComputed.6c2627ea.js";import"./index.8dd314e0.js";import{M as m}from"./transButton.26020e2e.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},l=new Error().stack;l&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[l]="f4424305-77a0-490c-9c98-3fd03f35d0b8",r._sentryDebugIdIdentifier="sentry-dbid-f4424305-77a0-490c-9c98-3fd03f35d0b8")}catch{}})();const M=D({__name:"LoginBlock",setup(r){const l="https://cloud.abstra.io/api-key?"+new URLSearchParams({redirect:location.href}),i=I(!1),{loading:f,result:t,refetch:y}=U(()=>p.get()),h=A(),b=B();function k(){const o=new URL(location.href);o.searchParams.delete("api-key"),b.replace(o.pathname+o.search)}function w(){var o;(o=t.value)!=null&&o.logged?m.success({title:"You're logged in!",content:"You can now deploy your project to Abstra Cloud."}):m.error({title:"Login failed",content:"Please try again. If the problem persists, contact help@abstra.io."})}const g=h.query["api-key"];typeof g=="string"&&p.create(g).then(y).then(k).then(w);async function v(){!t.value||(await p.delete(),y())}async function L(){if(!!t.value){i.value=!0;try{await P.deploy(),window.open(`https://cloud.abstra.io/projects/${t.value.logged&&t.value.project_id}/builds`,"_blank")}catch(o){R("Deploy failed",String(o))}i.value=!1}}return(o,E)=>{var _;return(_=e(t))!=null&&_.logged?(c(),d(e(j),{key:0},{default:a(()=>[u(e(s),{href:`https://cloud.abstra.io/projects/${e(t).project_id}`,target:"_blank"},{default:a(()=>[n(" Go to console ")]),_:1},8,["href"]),i.value?(c(),d(e(s),{key:1,loading:""},{default:a(()=>[n("Deploying")]),_:1})):(c(),d(e(C),{key:0,title:"Are you sure you want to deploy this project to Abstra Cloud?",onConfirm:L},{default:a(()=>[u(e(s),null,{default:a(()=>[n("Deploy")]),_:1})]),_:1})),u(e(s),{onClick:v},{default:a(()=>[n("Logout")]),_:1})]),_:1})):(c(),d(e(s),{key:1,href:l,loading:e(f),disabled:e(f)},{default:a(()=>[n(" Login to deploy ")]),_:1},8,["loading","disabled"]))}}});const $=x(M,[["__scopeId","data-v-a737d90d"]]);export{$ as L};
//# sourceMappingURL=LoginBlock.81ab4bf3.js.map
