1import{r as n,j as e,k as R,ay as H,az as V,B as r,f as g,l as F,i as j,a6 as y,aa as f,ab as N,ac as w,X as se,T as u,af as M,R as v,a1 as C}from"./index-CWOAIT0E.js";import{S,a as k,b as A,c as O,d as m}from"./select-CUr213xY.js";import{u as ae,a as te,s as ie,b as P,c as re,d as I}from"./ai-labs.functions-Tl-Uv9cd.js";import{B as le}from"./beaker-Cqpskpra.js";import{S as ne}from"./sparkles-BHE9jnzE.js";import{P as $}from"./plus-CdiRcbxn.js";import{E as de}from"./eye-Db0t_ngJ.js";import{A as ce}from"./archive-DZ-o7cKX.js";import{W as oe}from"./wand-sparkles-eBQgMTOT.js";import{C as ue}from"./circle-check-DZL9_4hc.js";import"./chevron-up-BobSmDnT.js";const me={draft:"bg-muted text-muted-foreground",open:"bg-primary text-on-jade",filled:"bg-secondary text-foreground",archived:"bg-muted text-muted-foreground",cancelled:"bg-destructive/15 text-destructive"},pe=["applied","shortlisted","selected","rejected"];async function h(){const{data:x}=await v.auth.getSession();return{Authorization:`Bearer ${x.session?.access_token??""}`}}function Ce(){const[x,U]=n.useState([]),[q,W]=n.useState([]),[c,L]=n.useState(null),[o,z]=n.useState(null),[E,K]=n.useState([]),[Q,b]=n.useState(!1),[X,_]=n.useState(!1),[i,p]=n.useState(null),[a,l]=n.useState(null),D=async()=>{const[{data:s},{data:t}]=await Promise.all([v.from("ai_labs").select("id,name,slug,website,hq_country,description,is_seeded").order("name"),v.from("ai_opportunities").select("id,ai_lab_id,title,summary,status,visibility,hourly_rate_eur,lab_hourly_rate_eur,seats,seats_filled,domains,required_trust_tier").order("created_at",{ascending:!1})]);U(s??[]),W(t??[])};n.useEffect(()=>{D()},[]);const B=async s=>{z(s);const{data:t}=await v.from("ai_opportunity_applications").select("id,coach_id,status,cover_note,ai_fit_score,ai_fit_reasoning,weekly_hours_available,coach:coach_profiles(headline,trust_tier,slug)").eq("opportunity_id",s.id).order("ai_fit_score",{ascending:!1,nullsFirst:!1});K(t??[])},d=async(s,t,ee=!1)=>{L(s);try{await t(),C.success(s),await D(),ee&&o&&await B(o)}catch(T){C.error(String(T?.message??T))}finally{L(null)}},G=()=>d("Seeded labs",async()=>{const s=await ie({headers:await h()});C.success(`Inserted ${s.inserted}, skipped ${s.skipped}`)}),J=()=>d("Saved lab",async()=>{if(!i?.name)throw new Error("Name required");await ae({data:{labId:i.id,name:i.name,website:i.website??"",description:i.description??void 0,hq_country:i.hq_country??void 0},headers:await h()}),b(!1),p(null)}),Y=()=>d("Saved opportunity",async()=>{if(!a?.title||!a.ai_lab_id||!a.summary||!a.hourly_rate_eur)throw new Error("Title, lab, summary, and rate required");await te({data:{opportunityId:a.id,ai_lab_id:a.ai_lab_id,title:a.title,summary:a.summary,hourly_rate_eur:Number(a.hourly_rate_eur),lab_hourly_rate_eur:a.lab_hourly_rate_eur?Number(a.lab_hourly_rate_eur):void 0,domains:a.domains??[],seats:a.seats??1,visibility:a.visibility??"matched_speciality",required_trust_tier:a.required_trust_tier||void 0,status:a.status??"draft"},headers:await h()}),_(!1),l(null)}),Z=new Map(x.map(s=>[s.id,s]));return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(R,{children:[e.jsxs(H,{
1className:"flex flex-row items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs(V,{className:"flex items-center gap-2",children:[e.jsx(le,{className:"h-4 w-4"})," AI Labs"]}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Frontier labs and annotation companies that hire Codex coaches for RLHF, evals, and domain-expert tasks."})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(r,{variant:"outline",size:"sm",onClick:G,disabled:c!==null,children:[c==="Seeded labs"?e.jsx(g,{className:"h-4 w-4 animate-spin"}):e.jsx(ne,{className:"h-4 w-4"}),e.jsx("span",{className:"ml-2",children:"Seed 30 labs"})]}),e.jsxs(r,{size:"sm",onClick:()=>{p({}),b(!0)},children:[e.jsx($,{className:"h-4 w-4"}),e.jsx("span",{className:"ml-2",children:"New lab"})]})]})]}),e.jsx(F,{children:e.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:x.map(s=>e.jsxs("button",{onClick:()=>{p(s),b(!0)},className:"flex items-start justify-between gap-2 rounded-xl border border-border bg-card p-3 text-left transition-colors hover:bg-muted/40",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate font-medium",children:s.name}),e.jsxs("p",{className:"truncate text-xs text-muted-foreground",children:[s.hq_country??"â"," · ",s.website??"no website"]})]}),s.is_seeded&&e.jsx(j,{variant:"outline",className:"text-[10px]",children:"seed"})]},s.id))})})]}
1),e.jsxs(R,{children:[e.jsxs(H,{className:"flex flex-row items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(V,{children:"Opportunities"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Roles labs hire Codex coaches for. Set visibility per opportunity."})]}),e.jsxs(r,{size:"sm",onClick:()=>{l({visibility:"matched_speciality",seats:1,status:"draft"}),_(!0)},children:[e.jsx($,{className:"h-4 w-4"}),e.jsx("span",{className:"ml-2",children:"New opportunity"})]})]}),e.jsxs(F,{className:"space-y-2",children:[q.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"No opportunities yet."}),q.map(s=>{const t=Z.get(s.ai_lab_id);return e.jsx("div",{className:"rounded-xl border border-border bg-card p-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"truncate font-medium",children:s.title}),e.jsx(j,{className:me[s.status],children:s.status}),e.jsx(j,{variant:"outline",className:"text-[10px]",children:s.visibility}),e.jsxs(j,{variant:"outline",className:"text-[10px]",children:[s.seats_filled,"/",s.seats," seats"]})]}),e.jsx("p",{className:"mt-1 line-clamp-2 text-sm text-muted-foreground",children:s.summary}),e.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:[t?.name??"â"," · â¬",s.hourly_rate_eur,"/h coach",s.lab_hourly_rate_eur?` · â¬${s.lab_hourly_rate_eur}/h lab`:""]})]}),e.jsxs("div",{className:"flex shrink-0 flex-col gap-1.5",children:[e.jsxs(r,{size:"sm",variant:"outline",onClick:()=>B(s),children:[e.jsx(de,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"ml-1.5",children:"Applicants"})]}),e.jsx(r,{size:"sm",variant:"outline",onClick:()=>{l(s),_(!0)},children:"Edit"}),s.status==="draft"&&e.jsx(r,{size:"sm",onClick:()=>d("Opened",()=>P({data:{opportunityId:s.id,status:"open"}})),children:"Publish"}),s.status==="open"&&e.jsx(r,{size:"sm",variant:"outline",onClick:()=>d("Archived",()=>P({data:{opportunityId:s.id,status:"archived"}})),children:e.jsx(ce,{className:"h-3.5 w-3.5"})})]})]})},s.id)})]})]}),e.jsx(y,{open:o!==null,onOpenChange:s=>!s&&z(null),children:e.jsxs(f,{className:"max-w-6xl",children:[e.jsx(N,{children:e.jsxs(w,{children:[o?.title," â applicants"]})}),o&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[E.length," applicants · ",o.seats_filled,"/",o.seats," seats filled"]}),e.jsxs(r,{size:"sm",onClick:()=>d("AI ranked",async()=>{await re({data:{opportunityId:o.id},headers:await h()})},!0),disabled:c!==null,children:[c==="AI ranked"?e.jsx(g,{className:"h-4 w-4 animate-spin"}):e.jsx(oe,{className:"h-4 w-4"}),e.jsx("span",{className:"ml-2",children:"AI rank all"})]})]}),e.jsx("div",{className:"grid gap-3 lg:grid-cols-4",children:pe.map(s=>e.jsxs("div",{className:"rounded-xl border border-border bg-muted/20 p-2",children:[e.jsx("p",{className:"mb-2 px-1 text-xs font-semibold uppercase text-muted-foreground",children:s}),e.jsx("div",{className:"space-y-2",children:E.filter(t=>t.status===s).map(t=>e.jsxs("div",{className:"rounded-lg border border-border bg-card p-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:t.coach?.headline??"Coach"}),t.ai_fit_score!=null&&e.jsx(j,{className:"bg-primary text-on-jade text-[10px]",children:t.ai_fit_score})]}),e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[t.coach?.trust_tier," · ",t.weekly_hours_available??"?","h/wk"]}),t.cover_note&&e.jsx("p",{className:"mt-1 line-clamp-3 text-xs",children:t.cover_note}),t.ai_fit_reasoning&&e.jsx("p",{className:"mt-1 line-clamp-2 text-[11px] text-muted-foreground italic",children:t.ai_fit_reasoning}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-1",children:[s!=="shortlisted"&&s!=="selected"&&e.jsx(r,{size:"sm",variant:"outline",className:"h-6 px-2 text-[10px]",onClick:()=>d("Updated",async()=>I({data:{applicationId:t.id,status:"shortlisted"},headers:await h()}),!0),children:"Shortlist"}),s!=="selected"&&e.jsx(r,{size:"sm",className:"h-6 px-2 text-[10px]",onClick:()=>d("Selected",async()=>I({data:{applicationId:t.id,status:"selected"},headers:await h()}),!0),children:e.jsx(ue,{className:"h-3 w-3"})}),s!=="rejected"&&e.jsx(r,{size:"sm",variant:"outline",className:"h-6 px-2 text-[10px]",onClick:()=>d("Rejected",async()=>I({data:{applicationId:t.id,status:"rejected"},headers:await h()}),!0),children:e.jsx(se,{className:"h-3 w-3"})})]})]},t.id))})]},s))})]})]})}
1),e.jsx(y,{open:Q,onOpenChange:b,children:e.jsxs(f,{children:[e.jsx(N,{children:e.jsx(w,{children:i?.id?"Edit lab":"New AI lab"})}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(u,{placeholder:"Name",value:i?.name??"",onChange:s=>p({...i,name:s.target.value})}),e.jsx(u,{placeholder:"Website (https://...)",value:i?.website??"",onChange:s=>p({...i,website:s.target.value})}),e.jsx(u,{placeholder:"HQ country (e.g. US)",value:i?.hq_country??"",onChange:s=>p({...i,hq_country:s.target.value})}),e.jsx(M,{placeholder:"Description",rows:3,value:i?.description??"",onChange:s=>p({...i,description:s.target.value})}),e.jsx(r,{onClick:J,disabled:c!==null,className:"w-full",children:c==="Saved lab"?e.jsx(g,{className:"h-4 w-4 animate-spin"}):"Save"})]})]})}),e.jsx(y,{open:X,onOpenChange:_,children:e.jsxs(f,{className:"max-w-2xl",children:[e.jsx(N,{children:e.jsx(w,{children:a?.id?"Edit opportunity":"New opportunity"})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs(S,{value:a?.ai_lab_id??"",onValueChange:s=>l({...a,ai_lab_id:s}),children:[e.jsx(k,{children:e.jsx(A,{placeholder:"Select lab"})}),e.jsx(O,{children:x.map(s=>e.jsx(m,{value:s.id,children:s.name},s.id))})]}),e.jsx(u,{placeholder:"Title (e.g. RLHF expert annotators â yoga & breathwork)",value:a?.title??"",onChange:s=>l({...a,title:s.target.value})}),e.jsx(M,{placeholder:"Short summary (shown in coach dashboard)",rows:3,value:a?.summary??"",onChange:s=>l({...a,summary:s.target.value})}),e.jsx(u,{placeholder:"Domains comma-separated (yoga,breathwork,nutrition)",value:a?.domains?.join(",")??"",onChange:s=>l({...a,domains:s.target.value.split(",").map(t=>t.trim()).filter(Boolean)})}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsx(u,{placeholder:"â¬/h coach",type:"number",value:a?.hourly_rate_eur??"",onChange:s=>l({...a,hourly_rate_eur:Number(s.target.value)})}),e.jsx(u,{placeholder:"â¬/h lab",type:"number",value:a?.lab_hourly_rate_eur??"",onChange:s=>l({...a,lab_hourly_rate_eur:Number(s.target.value)})}),e.jsx(u,{placeholder:"Seats",type:"number",value:a?.seats??1,onChange:s=>l({...a,seats:Number(s.target.value)})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs(S,{value:a?.visibility??"matched_speciality",onValueChange:s=>l({...a,visibility:s}),children:[e.jsx(k,{children:e.jsx(A,{})}),e.jsxs(O,{children:[e.jsx(m,{value:"all_active",children:"All active coaches"}),e.jsx(m,{value:"matched_speciality",children:"Matched by speciality"}),e.jsx(m,{value:"verified_only",children:"Verified only"}),e.jsx(m,{value:"matched_and_verified",children:"Matched + verified"})]})]}),e.jsxs(S,{value:a?.required_trust_tier??"",onValueChange:s=>l({...a,required_trust_tier:s||null}),children:[e.jsx(k,{children:e.jsx(A,{placeholder:"No tier requirement"})}),e.jsxs(O,{children:[e.jsx(m,{value:"crawled",children:"crawled+"}),e.jsx(m,{value:"claimed",children:"claimed+"}),e.jsx(m,{value:"verified",children:"verified only"})]})]})]}),e.jsx(r,{onClick:Y,disabled:c!==null,className:"w-full",children:c==="Saved opportunity"?e.jsx(g,{className:"h-4 w-4 animate-spin"}):"Save"})]})]})})]})}export{Ce as component};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.