Skip to content

The only tool you need to know what is happening and how to fix it.

7.2 KB
Raw Blame
import{r as $e}from"../chunks/hp4PFHFv.js";import{a as S}from"../chunks/h7yRWCtK.js";import"../chunks/DsnmJJEf.js";import{p as Me,b as Ve,g as e,j as T,u as H,l as v,y as Ye,k as De,e as l,d as t,a as Je,h as $,r as x,c as B,f as o,m as i,n as z,t as F,o as te,q as re,v as Ze}from"../chunks/BKFspo1J.js";import{i as M}from"../chunks/COK9M2N0.js";import{k as qe}from"../chunks/R7BU62x2.js";import{e as xe}from"../chunks/DpeZtIXD.js";import{c as b}from"../chunks/CWm9VMfX.js";import{g as He}from"../chunks/Cv0CJCi1.js";import{r as Re}from"../chunks/UDuKBjKQ.js";import{E as Ue}from"../chunks/CGiec90h.js";import{a as ze,b as ye,c as be,S as we}from"../chunks/XUo-32-X.js";import{B as ae}from"../chunks/DY5VVhnr.js";import{I as We}from"../chunks/DGTs9ijT.js";import{L as pe}from"../chunks/CfoMaPyy.js";import{p as ge,a as Oe,t as Ge}from"../chunks/BrdmM8Kw.js";import{g as Ke}from"../chunks/CqMCVSVw.js";import{S as Qe}from"../chunks/c4qmhG1O.js";import{P as Pe}from"../chunks/MS5-RPlv.js";import{L as Xe}from"../chunks/CHGVBzd3.js";import{C as et}from"../chunks/Bpxj4ei_.js";const tt=()=>{if(!S.isAuthenticated)throw $e(302,"/login?returnTo=%2Fsetup");let k=[];try{k=JSON.parse(localStorage.getItem("PROJECTS_CACHE_V2")||"[]")}catch{k=[]}if(Array.isArray(k)&&k.length>0)throw $e(302,"/")},Bt=Object.freeze(Object.defineProperty({__proto__:null,load:tt},Symbol.toStringTag,{value:"Module"}));var rt=l("<!> New Organization",1),at=l("<!> Log out",1),ot=l(`<div><h1 class="text-2xl font-bold">You're not in an organization</h1> <p class="mt-1 text-sm text-muted-foreground">Looks like you are not part of any organizations. Would you like to register for one? If
					you were removed from one, an admin can also invite you back — logging out and returning
					once the invitation arrives keeps you in that organization rather than starting a second.</p></div> <div class="flex flex-wrap gap-2"><!> <!></div>`,1),st=l("<span> </span>"),nt=l("<span> </span> <!>",1),it=l("<!> <!>",1),lt=l("<!> New Organization",1),ct=l(`<div><h1 class="text-2xl font-bold">Create an Organization</h1> <p class="mt-1 text-sm text-muted-foreground">Name it and pick the timezone its on-call schedules should follow. You'll own it, and can
					invite the rest of your team afterwards.</p></div> <form class="space-y-4"><div class="flex max-w-sm flex-col space-y-1.5"><!> <!></div> <div class="flex max-w-sm flex-col space-y-1.5"><!> <!></div> <!> <div class="flex flex-wrap gap-2"><!> <!></div></form>`,1),dt=l('<p class="text-sm text-muted-foreground">You need an owner, admin, or user role in an organization to create projects.</p>'),ut=l("<!> <!>",1),vt=l('<div class="flex max-w-xs flex-col space-y-1.5"><!> <!></div>'),mt=l("<!> <!>",1),ft=l(`<div><h1 class="text-2xl font-bold">Set Up Projects</h1> <p class="mt-1 text-sm text-muted-foreground">Let your coding agent propose the project setup for your approval, or create projects
				manually.</p></div> <!>`,1),pt=l('<div class="mx-auto w-full max-w-2xl space-y-6"><!></div>');function Ft(k,Se){Me(Se,!0);const w=H(()=>S.organizations.filter(r=>r.role!=="readonly"));let m=T(null);Ve(()=>{if(e(m)!==null&&e(w).some(c=>c.id===e(m)))return;const r=ge.currentProject?.organizationId;v(m,e(w).some(c=>c.id===r)?r:e(w)[0]?.id??null,!0)});const ke=H(()=>e(w).find(r=>r.id===e(m))?.name??"");let _e=!1;Ye(async()=>{try{const r=await Oe.get("/me/login-bundle");if(_e)return;S.setOrganizations(r.organizations||[]),ge.setProjects(r.projects||[])}catch{}});const je=H(()=>S.organizations.length===0);let oe=T("choice"),R=T(""),U=T(De(Intl.DateTimeFormat().resolvedOptions().timeZone)),W=T(!1),se=T("");const Ie=Intl.supportedValuesOf("timeZone");async function Le(r){r.preventDefault(),v(W,!0),v(se,"");try{const c=await Oe.post("/organizations",{name:e(R),timezone:e(U)});_e=!0,S.setOrganizations([...S.organizations,c]),v(R,""),Ge.success("Successfully created the Organization",{position:"top-center"})}catch(c){v(se,Ke(c,"Failed to create the organization"),!0)}finally{v(W,!1)}}function Ne(){S.logout(),ge.clear(),He(Re("/login"))}var ne=pt(),Ce=$(ne);{var Ee=r=>{var c=B(),ie=o(c);{var le=d=>{var f=ot(),_=i(o(f),2),y=$(_);ae(y,{variant:"success",onclick:()=>v(oe,"organization"),children:(O,u)=>{var s=rt(),p=o(s);Pe(p,{class:"mr-2 size-4"}),z(),t(O,s)},$$slots:{default:!0}});var j=i(y,2);ae(j,{variant:"outline",onclick:Ne,children:(O,u)=>{var s=at(),p=o(s);Xe(p,{class:"mr-2 size-4"}),z(),t(O,s)},$$slots:{default:!0}}),x(_),t(d,f)},ce=d=>{var f=ct(),_=i(o(f),2),y=$(_),j=$(y);pe(j,{for:"organization-name",children:(a,N)=>{z();var n=F("Organization name");t(a,n)},$$slots:{default:!0}});var O=i(j,2);We(O,{id:"organization-name",placeholder:"Acme Inc.",autocomplete:"organization",get value(){return e(R)},set value(a){v(R,a,!0)}}),x(y);var u=i(y,2),s=$(u);pe(s,{for:"timezone",children:(a,N)=>{z();var n=F("Timezone");t(a,n)},$$slots:{default:!0}});var p=i(s,2);b(p,()=>we,(a,N)=>{N(a,{type:"single",get value(){return e(U)},set value(n){v(U,n,!0)},children:(n,D)=>{var G=it(),C=o(G);b(C,()=>ze,(P,Z)=>{Z(P,{id:"timezone",class:"w-full",children:(h,de)=>{var g=st(),E=$(g,!0);x(g),te(()=>re(E,e(U))),t(h,g)},$$slots:{default:!0}})});var J=i(C,2);b(J,()=>ye,(P,Z)=>{Z(P,{class:"max-h-60",children:(h,de)=>{var g=B(),E=o(g);xe(E,16,()=>Ie,A=>A,(A,K)=>{var Q=B(),ue=o(Q);{const ve=(q,X)=>{let ee=()=>X?.().selected;var he=nt(),me=o(he),Te=$(me,!0);x(me);var Be=i(me,2);{var Fe=fe=>{et(fe,{class:"absolute end-2 size-4"})};M(Be,fe=>{ee()&&fe(Fe)})}te(()=>re(Te,K)),t(q,he)};b(ue,()=>be,(q,X)=>{X(q,{get value(){return K},children:ve,$$slots:{default:!0}})})}t(A,Q)}),t(h,g)},$$slots:{default:!0}})}),t(n,G)},$$slots:{default:!0}})}),x(u);var I=i(u,2);Ue(I,{get error(){return e(se)}});var L=i(I,2),V=$(L);ae(V,{type:"submit",variant:"success",get disabled(){return e(W)},children:(a,N)=>{var n=lt(),D=o(n);Pe(D,{class:"mr-2 size-4"}),z(),t(a,n)},$$slots:{default:!0}});var Y=i(V,2);ae(Y,{type:"button",variant:"ghost",get disabled(){return e(W)},onclick:()=>v(oe,"choice"),children:(a,N)=>{z();var n=F("Back");t(a,n)},$$slots:{default:!0}}),x(L),x(_),Ze("submit",_,Le),t(d,f)};M(ie,d=>{e(oe)==="choice"?d(le):d(ce,!1)})}t(r,c)},Ae=r=>{var c=ft(),ie=i(o(c),2);{var le=d=>{var f=dt();t(d,f)},ce=d=>{var f=mt(),_=o(f);{var y=u=>{var s=vt(),p=$(s);pe(p,{children:(L,V)=>{z();var Y=F("Organization");t(L,Y)},$$slots:{default:!0}});var I=i(p,2);{let L=H(()=>e(m)!==null?String(e(m)):void 0);b(I,()=>we,(V,Y)=>{Y(V,{type:"single",get value(){return e(L)},onValueChange:a=>{a&&v(m,Number(a),!0)},children:(a,N)=>{var n=ut(),D=o(n);b(D,()=>ze,(C,J)=>{J(C,{class:"w-full",children:(P,Z)=>{z();var h=F();te(()=>re(h,e(ke)||"Select organization")),t(P,h)},$$slots:{default:!0}})});var G=i(D,2);b(G,()=>ye,(C,J)=>{J(C,{children:(P,Z)=>{var h=B(),de=o(h);xe(de,17,()=>e(w),g=>g.id,(g,E)=>{var A=B(),K=o(A);{let Q=H(()=>String(e(E).id));b(K,()=>be,(ue,ve)=>{ve(ue,{get value(){return e(Q)},children:(q,X)=>{z();var ee=F();te(()=>re(ee,e(E).name)),t(q,ee)},$$slots:{default:!0}})})}t(g,A)}),t(P,h)},$$slots:{default:!0}})}),t(a,n)},$$slots:{default:!0}})})}x(s),t(u,s)};M(_,u=>{e(w).length>1&&u(y)})}var j=i(_,2);{var O=u=>{var s=B(),p=o(s);qe(p,()=>e(m),I=>{Qe(I,{get organizationId(){return e(m)}})}),t(u,s)};M(j,u=>{e(m)!==null&&u(O)})}t(d,f)};M(ie,d=>{e(w).length===0?d(le):d(ce,!1)})}t(r,c)};M(Ce,r=>{e(je)?r(Ee):r(Ae,!1)})}x(ne),t(k,ne),Je()}export{Ft as component,Bt as universal};