PageSourceSearch

https://xterns.ai/assets/TechLeadSprintBoard-fOAq91yr.js

js xterns.ai collected 2026-10-05 13:24:52 UTC 45,799 bytes, 17 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DLd_kDlx.js","assets/index-Dv1CEmDN.css"])))=>i.map(i=>d[i]);
2import{c as ae,r as _,M as rt,s as M,w as re,j as e,B as N,J as k,H as Ce,x as z,U as ke,T as ne,X as nt,ae as H,q as lt,P as U,h as W,i as De,l as it,m as le,e as ot,bp as ct,g as R,N as Pe,O as Me,Q as Ee,V as Te,A as dt,Y as Ae,n as mt,bq as $e,u as Le,aj as xt,F as ee,a4 as ht,k as pt,f as ut,o as gt,aK as X,bK as Q,bu as V,bM as J}from"./index-DLd_kDlx.js";import{T as Y}from"./TechLeadHeader-eLOg3V3h.js";import{u as ft}from"./usePodDetails-C9Suehy1.js";import{u as bt}from"./usePodMembers-8OtOtFCP.js";import{u as jt}from"./useSprintManagement-C4IIF8L2.js";import{C as vt}from"./CreateRepoDialog-CS0zHZ02.js";import{A as wt}from"./arrow-left-BXtn7MCa.js";import{G as Ne}from"./git-branch-C-twpC7K.js";import{T as ie}from"./triangle-alert-Chqk_WK7.js";import{C as Nt,a as yt,b as _t}from"./collapsible-i67bJVO7.js";import{L as te}from"./label-D4-ENrYn.js";import{S as Re,a as Oe,b as Fe,c as Ie,d as We}from"./select-RSrodAEw.js";import{A as St,a as Ct}from"./alert-CyfKy7ls.js";import{S as kt}from"./scroll-area-BXTuUF24.js";import{L as se}from"./loader-circle-D2miE2xB.js";import{C as Dt}from"./clock-3-De2r9tJK.js";import{C as Pt}from"./chevron-down-DpJJsCer.js";import{P as Mt}from"./play-rljZUdXx.js";import{A as Et}from"./arrow-right-left-C4CM-5rU.js";import{P as ye}from"./plus-0WhrdjYO.js";import{R as oe}from"./refresh-cw-CoPjtj5-.js";import{E as Tt}from"./ellipsis-BUCYa95L.js";import{d as At,f as B}from"./format-BTXglRCX.js";import{P as $t}from"./PodTechLeadCollaborationPanel-DOXEgUVe.js";import"./dropdown-menu-DSd1c3Vk.js";import"./index-Deh-4PO1.js";import"./index-lTaZyIGy.js";import"./chevron-right-CD1gvy-q.js";import"./NotificationIcon-C1wwYnH5.js";import"./popover-BMD5FOmU.js";import"./NotificationItem-Dc2WXW-y.js";import"./formatDistanceToNow-57P64IbE.js";import"./en-US-9SRVm7yB.js";import"./differenceInCalendarMonths-BA0TPVs2.js";import"./endOfDay-DkR3ZXc8.js";import"./endOfMonth-CYn6pTOm.js";import"./message-square-CtxeCfRz.js";import"./trophy-DBX-jNOC.js";import"./rotate-ccw-Bx1C64Ur.js";import"./useRoadmapData-uoMx8Hqe.js";import"./switch-7Twrb7Os.js";import"./useGitHubIdentity-DDmb0Jwt.js";import"./external-link-D0CFvOTk.js";import"./index-D7uKcQzO.js";import"./index-BdQq_4o_.js";import"./chevron-up-M4SAwIjf.js";import"./useMultilateralTechLeadInvitations-CzvKFiLJ.js";import"./useTechLeads-Cmw-XrPs.js";import"./TechLeadPicker-DENSUSgV.js";import"./command-BReSBG4f.js";import"./search-DFH5eAlA.js";import"./star-BH1OFEcs.js";import"./textarea-C6X-I43k.js";import"./alert-dialog-Ct5JsrY0.js";import"./user-cog-BjzUwQIe.js";import"./shield-alert-CVqPbwtZ.js";import"./mail-plus-CkuPXPSq.js";/**
3 * @license lucide-react v0.462.0 - ISC
4 *
5 * This source code is licensed under the ISC license.
6 * See the LICENSE file in the root directory of this source tree.
7 */const Z=ae("CalendarPlus",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 13V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8",key:"3spt84"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M16 19h6",key:"xwg31i"}],["path",{d:"M19 16v6",key:"tddt3s"}]]);/**
8 * @license lucide-react v0.462.0 - ISC
9 *
10 * This source code is licensed under the ISC license.
11 * See the LICENSE file in the root directory of this source tree.
12 */const Lt=ae("CircleGauge",[["path",{d:"M15.6 2.7a10 10 0 1 0 5.7 5.7",key:"1e0p6d"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M13.4 10.6 19 5",key:"1kr7tw"}]]);/**
13 * @license lucide-react v0.462.0 - ISC
14 *
15 * This source code is licensed under the ISC license.
16 * See the LICENSE file in the root directory of this source tree.
17 */const Rt=ae("Kanban",[["path",{d:"M6 5v11",key:"mdvv1e"}],["path",{d:"M12 5v6",key:"14ar3b"}],["path",{d:"M18 5v14",key:"7ji314"}]]),Ot=(t,o,c,l=!1,d=!1)=>{const i=_.useMemo(()=>{if(d)return"loading";if(l)return"error";const r=t.length>0,m=o.length>0,n=c.length>0;return r?r&&!m?"incomplete":r&&m&&!n?"needs_sprints":"complete":"none"},[t.length,o.length,c.length,l,d]);return{status:i,hasDeliveryPlan:i!=="none"&&i!=="error"&&i!=="loading"}};function Ft(t){const{data:o,isLoading:c,refetch:l}=rt({queryKey:["github-pod-repo",t],enabled:!!t,queryFn:async()=>{const{data:d,error:i}=await M.from("github_pod_repos").select("id, repo_full_name, repo_id, installation_id").eq("pod_id",t).limit(1).maybeSingle();if(i)throw console.error("useGitHubPodRepo: Error fetching repo:",i),i;return d}});return{linkedRepo:o??null,hasRepo:!!o,isLoading:c,refetch:l}}function It(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,"")}function Wt({podDetails:t,activeSprint:o,onBackToPods:c,podMembers:l=[],hasRepo:d=!0,podId:i,onRepoLinked:a,isNewPod:r=!1,requiresRepo:m=!1,canLinkRepository:n=!1}){var y,p,u,x;const[f,h]=re.useState(!0),S=l.filter(v=>v.role!=="tech_lead").length,b=t.max_members-1,j=async v=>{if(i)try{const{data:{user:g}}=await M.auth.getUser();if(!g)throw new Error("Not authenticated");const{error:w}=await M.from("github_pod_repos").insert({pod_id:i,repo_full_name:v,linked_by:g.id,installation_id:0});if(w)if(w.code==="23505")H({title:"Repository already linked",description:v});else throw w;else H({title:"Repository Linked",description:`${v} has been linked to this pod.`});await M.from("pods").update({github_repo_url:`https://github.com/${v}`,github_connected_at:new Date().toISOString()}).eq("id",i),a==null||a()}catch(g){console.error("Failed to link repo:",g),H({title:"Link Failed",description:g.message,variant:"destructive"})}};return e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"rounded-2xl border border-slate-200/80 bg-white p-4 shadow-[0_12px_35
17px_rgba(15,23,42,0.04)] sm:p-5",children:e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(N,{variant:"outline",size:"icon",onClick:c,className:"h-9 w-9 shrink-0 rounded-full border-slate-200",children:e.jsx(wt,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h1",{className:"text-2xl font-semibold tracking-tight text-slate-950",children:"Sprint Board"}),o&&e.jsxs(k,{className:"rounded-full bg-blue-50 px-2.5 py-1 text-blue-700 hover:bg-blue-50",children:[e.jsx(Ce,{className:"mr-1.5 h-3.5 w-3.5"}),o.name]})]}),e.jsx("p",{className:"mt-1 text-sm font-medium text-slate-700",children:((y=t.projects)==null?void 0:y.title)||"Delivery workspace"}),e.jsxs("p",{className:"mt-0.5 text-xs text-slate-500",children:["Pod: ",t.pod_name]})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(k,{className:`rounded-full px-3 py-1.5 ${d?"bg-emerald-50 text-emerald-700 hover:bg-emerald-50":"bg-amber-50 text-amber-700 hover:bg-amber-50"}`,children:[d?e.jsx(z,{className:"mr-1.5 h-3.5 w-3.5"}):e.jsx(Ne,{className:"mr-1.5 h-3.5 w-3.5"}),d?"Repository Linked":"Repository Needed"]}),e.jsxs(k,{className:"rounded-full bg-slate-100 px-3 py-1.5 text-slate-700 hover:bg-slate-100",children:[e.jsx(ke,{className:"mr-1.5 h-3.5 w-3.5"}),S," / ",b," Xterns"]}),e.jsxs(k,{className:"rounded-full bg-blue-50 px-3 py-1.5 text-blue-700 hover:bg-blue-50",children:[e.jsx(ne,{className:"mr-1.5 h-3.5 w-3.5"}),((p=t.recruiting_phase)==null?void 0:p.replace(/_/g," "))||"Waiting Minimum"]})]})]})}),!d&&f&&e.jsxs("div",{className:"flex flex-col gap-3 rounded-2xl border border-amber-200/80 bg-amber-50/90 px-4 py-3 text-amber-900 shadow-sm sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[e.jsx(ie,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold",children:"GitHub repository not linked."}),e.jsx("p",{className:"text-xs text-amber-800",children:n?r&&m?"Link a repository to generate delivery plans, commits, PR tracking, and deployment insights.":"Link a repository to enable commits, PR tracking, and deployment insights.":"The assigned pod owner must create or link the GitHub repository."})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[n&&e.jsx(vt,{defaultRepoName:It(((u=t.projects)==null?void 0:u.title)||t.pod_name),defaultDescription:((x=t.projects)==null?void 0:x.description)||"",podName:t.pod_name,onCreated:j,trigger:e.jsxs(N,{size:"sm",className:"rounded-full bg-amber-600 text-white hover:bg-amber-700",children:[e.jsx(Ne,{className:"mr-2 h-4 w-4"}),"Link Repository"]})}),e.jsx(N,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-full text-amber-700 hover:bg-amber-100",onClick:()=>h(!1),children:e.jsx(nt,{className:"h-4 w-4"})})]})]})]})}const Ut=["from-blue-50 to-white text-blue-700","from-emerald-50 to-white text-emerald-700","from-slate-50 to-white text-xterns-navy","from-orange-50 to-white text-orange-700"];function qt({sprints:t,activeSprint:o}){var m;const c=t.flatMap(n=>n.stories||[]),l=c.filter(n=>n.status==="done").length,d=c.length,i=t.filter(n=>n.status==="completed").length,a=d?Math.round(l/d*100):0,r=[{icon:lt,label:"Total Sprints",value:t.length,detail:`${i} completed`,progress:t.length?Math.round(i/t.length*100):0},{icon:ne,label:"Active Sprint",value:o?o.sprint_number||((m=o.name)==null?void 0:m.replace(/\D/g,""))||1:0,detail:o?o.name:"No active sprint",progress:o?62:0},{icon:z,label:"Stories Completed",value:l,detail:`${d-l} remaining`,progress:a},{icon:Lt,label:"Overall Progress",value:`${a}%`,detail:d?`${l} / ${d} stories`:"No stories yet",progress:a}];return e.jsx("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:r.map((n,f)=>{const h=n.icon;return e.jsxs("div",{className:`group overflow-hidden rounded-2xl border border-slate-200/80 bg-gradient-to-br ${Ut[f]} p-4 shadow-[0_10px_28px_rgba(15,23,42,0.04)] transition-all duration-200 hover:-translate-y-0.5 hover:shadow-[0_16px_38px_rgba(15,23,42,0.08)]`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("div",{className:"rounded-2xl bg-white/80 p-2.5 shadow-sm",children:e.jsx(h,{className:"h-5 w-5"})}),e.jsx("span",{className:"rounded-full bg-white/80 px-2 py-1 text-[11px] font-semibold text-slate-500",children:n.progress>0?`+${Math.min(12,Math.max(1,Math.round(n.progress/10)))}% trend`:"ready"})]}),e.jsxs("div",{className:"mt-4",children:[e.jsx("p",{className:"text-3xl font-semibold tracking-tight text-slate-950",children:n.value}),e.jsx("p",{className:"mt-1 text-sm font-medium text-slate-700",children:n.label}),e.jsx("p",{className:"mt-0.5 text-xs text-slate-500",children:n.detail})]}),e.jsx(U,{value:n.progress,className:"mt-4 h-1.5 bg-white/70"})]},n.label)})})}function Bt({status:t,onGenerateDeliveryPlan:o,onCompleteDeliveryPlan:c,onRegenerateDeliveryPlan:l}){const i=(()=>{switch(t){case"none":return{icon:ne,iconColor:"text-blue-700",title:"No Delivery Plan Found",description:"No delivery plan has been generated for this pod yet. Generate one to create sprints and manage the delivery timeline.",message:"The sprint board requires a delivery plan with epics and stories to organize work into sprints.",buttonText:"Generate Delivery Plan",action:o};case"incomplete":return{icon:ie,iconColor:"text-yellow-600",title:"Incomplete Delivery Plan",description:"The delivery plan has epics but no stories. Stories are needed to create detailed sprint plans.",message:"Complete the delivery plan by generating stories for the existing epics, or start fresh with a new plan.",buttonText:"Complete Delivery Plan",action:c,secondaryButtonText:"Regenerate Plan",secondaryAction:l};case"needs_sprints":return{icon:ot,iconColor:"text-green-600",title:"Delivery Plan Complete",description:"The delivery plan has epics and stories, but sprints haven't been generated yet.",message:"The delivery plan is ready. Sprints will be automatically generated from the stories.",buttonText:"Regenerate Plan",action:l};default:return null}})();if(!i)return null;const a=i.icon,r=n=>{n.preventDefault(),n.stopPropagation(),console.log("DeliveryPlanStatus: Primary action clicked for status:",t),console.log("DeliveryPlanStatus: Calling action function...");try{i.action(),console.log("DeliveryPlanStatus: Action function called successfully")}catch(f){console.error("DeliveryPlanStatus: Error calling action function:",f)}},m=n=>{var f;n.preventDefault(),n.stopPropagation(),console.log("DeliveryPlanStatus: Secondary action clicked for status:",t),console.log("DeliveryPlanStatus: Calling secondary action function...");try{(f=i.secondaryAction)==null||f.call(i),console.log("DeliveryPlanStatus: Secondary action function called successfully")}catch(h){console.error("DeliveryPlanStatus: Error calling secondary action function:",h)}};return e.jsxs(W,{className:"rounded-[20px] border-slate-200/70 shadow-[0_18px_45px_rgba(15,23,42,0.06)]",children:[e.jsx(De,{className:"p-5 pb-3",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-2xl bg-slate-100 ${i.iconColor}`,children:e.jsx(a,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("span",{className:"text-base font-semibold text-slate-950",children:i.title}),e.jsx(it,{className:"mt-1 text-sm leading-5 text-slate-500",children:i.description})]})]})}),e.jsxs(le,{className:"px-5 pb-5",children:[e.jsx("div",{className:"mb-4 rounded-2xl bg-slate-50 p-4 text-sm leading-6 text-slate-600",children:i.message}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx(N,{type:"button",onClick:r,className:"rounded-xl bg-blue-600 text-white hover:bg-blue-700",children:i.buttonText}),i.secondaryAction&&i.secondaryButtonText&&e.jsx(N,{type:"button",variant:"outline",onClick:m,className:"rounded-xl border-slate-200 hover:bg-slate-50",children:i.secondaryButtonText})]})]})]})}const zt=({podId:t,onSuccess:o})=>{const[c,l]=_.useState([]),[d,i]=_.useState(!1),[a,r]=_.useState(!1),{queueEvent:m}=ct(),n=async()=>
17{if(t){i(!0);try{const{data:b,error:j}=await M.from("sprints").select("id, name, sprint_number, status, start_date, end_date").eq("pod_id",t).in("status",["not_started","active"]).order("sprint_number",{ascending:!0});if(j)throw j;const y=(b||[]).map(p=>({...p,status:p.status}));l(y)}catch(b){console.error("Error fetching available sprints:",b),R.error("Failed to load available sprints")}finally{i(!1)}}},f=async(b,j,y)=>{try{console.log("[Story Transfer] Applying -1 collaboration score to all pod members");const{data:p,error:u}=await M.from("pod_members").select("user_id").eq("pod_id",b).eq("status","active");if(u)throw u;if(!p||p.length===0)return;const x=p.map(async w=>{const{data:s}=await M.from("xterns_profiles").select("email").eq("user_id",w.user_id).single();if(!(s!=null&&s.email))return null;const C=crypto.randomUUID(),E=new Date().toISOString(),A={source_sprint_id:j,pod_id:b,stories_moved:y,reason:"Incomplete stories moved to another sprint"},{error:T}=await M.from("ei_metrics").insert({user_id:w.user_id,metric_type:"pod_incomplete_sprint",metric_value:1,metadata:A});
17return T&&console.error("[Story Transfer] Failed to insert ei_metric for user:",w.user_id,T),m("pod_incomplete_sprint",{email:s.email.toLowerCase(),event_id:C,occurred_at:E,platform:"xterns",platform_user_id:w.user_id,event_type:"pod_incomplete_sprint",payload:A,points_local:-1,rules_version:"xterns_v1.0"})}),g=(await Promise.all(x)).filter(w=>w!==null).length;console.log(`✅ Queued pod_incomplete_sprint events for ${g} xterns (-1 collaboration each)`)}catch(p){console.error("[Story Transfer] Error queuing deduction events:",p)}};return{availableSprints:c,isLoadingSprints:d,isTransferring:a,fetchAvailableSprints:n,transferStories:async(b,j,y)=>{if(!b.length||!j)return R.error("Please select stories and a target sprint"),!1;r(!0);try{const{error:p}=await M.from("roadmap_stories").update({sprint_id:j,status:"todo"}).in("id",b);if(p)throw p;y&&await f(t,y,b.length);const u=c.find(x=>x.id===j);return R.success("Stories Moved Successfully",{description:`${b.length} ${b.length===1?"story":"stories"} moved to ${(u==null?void 0:u.name)||"target sprint"}`}),o==null||o(),!0}catch(p){return console.error("Error transferring stories:",p),R.error("Failed to move stories",{description:p instanceof Error?p.message:"An error occurred"}),!1}finally{r(!1)}},getIncompleteStories:b=>b.filter(j=>j.status!=="done")}},Gt=({open:t,onOpenChange:o,incompleteStories:c,currentSprintId:l,currentSprintName:d,podId:i,onSuccess:a})=>{const[r,m]=_.useState([]),[n,f]=_.useState(""),{availableSprints:h,isLoadingSprints:S,isTransferring:b,fetchAvailableSprints:j,transferStories:y}=zt({podId:i,onSuccess:()=>{a(),o(!1)}});_.useEffect(()=>{t&&(j(),m(c.map(s=>s.id)),f(""))},[t]);const p=h.filter(s=>s.id!==l),u=s=>{m(C=>C.includes(s)?C.filter(E=>E!==s):[...C,s])},x=()=>{r.length===c.length?m([]):m(c.map(s=>s.id))},v=async()=>{await y(r,n,l)&&(m([]),f(""))},g=s=>{switch(s){case"high":return"bg-red-100 text-red-800";case"medium":return"bg-yellow-100 text-yellow-800";case"low":return"bg-green-100 text-green-800";default:return"bg-gray-100 text-gray-800"}},w=s=>{switch(s){case"to_do":return"bg-gray-100 text-gray-700";case"in_progress":return"bg-blue-100 text-blue-700";case"in_review":return"bg-purple-100 text-purple-700";default:return"bg-gray-100 text-gray-700"}};return e.jsx(Pe,{open:t,onOpenChange:o,children:e.jsxs(Me,{className:"sm:max-w-[600px]",children:[e.jsxs(Ee,{children:[e.jsxs(Te,{className:"flex items-center gap-2",children:["Move Incomplete Stories",e.jsx(dt,{className:"w-4 h-4 text-muted-foreground"})]}),e.jsxs(Ae,{children:["Move unfinished stories from ",d," to another sprint."]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs(St,{variant:"destructive",className:"bg-orange-50 border-orange-200",children:[e.jsx(ie,{className:"h-4 w-4 text-orange-600"}),e.jsxs(Ct,{className:"text-orange-800 text-sm",children:[e.jsx("strong",{children:"Scoring Impact:"})," When this sprint is completed with incomplete stories, all pod members will receive a ",e.jsx("strong",{children:"-1 collaboration score deduction"})," for team accountability."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(te,{htmlFor:"target-sprint",children:"Move to Sprint"}),S?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-2",children:[e.jsx(se,{className:"w-4 h-4 animate-spin"}),"Loading sprints..."]}):e.jsxs(Re,{value:n,onValueChange:f,children:[e.jsx(Oe,{id:"target-sprint",children:e.jsx(Fe,{placeholder:"Select target sprint"})}),e.jsx(Ie,{children:p.length===0?e.jsx("div",{className:"p-2 text-sm text-muted-foreground",children:"No available sprints"}):p.map(s=>e.jsx(We,{value:s.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:s.name}),e.jsx(k,{variant:"outline",className:"text-xs",children:s.status==="active"?"Active":"Not Started"})]})},s.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(te,{children:["Select Stories to Move (",r.length,"/",c.length,")"]}),e.jsx(N,{variant:"ghost",size:"sm",onClick:x,className:"text-xs",children:r.length===c.length?"Deselect All":"Select All"})]}),e.jsx(kt,{className:"h-[240px] border rounded-md p-3",children:e.jsxs("div",{className:"space-y-2",children:[c.map(s=>e.jsxs("div",{className:`flex items-start gap-3 p-3 rounded-lg border transition-colors ${r.includes(s.id
17)?"bg-primary/5 border-primary/30":"bg-background hover:bg-muted/50"}`,children:[e.jsx(mt,{id:s.id,checked:r.includes(s.id),onCheckedChange:()=>u(s.id),className:"mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(k,{variant:"outline",className:"text-xs font-mono",children:s.ticket_number}),e.jsx(k,{className:`text-xs ${g(s.priority)}`,children:s.priority}),e.jsx(k,{className:`text-xs ${w(s.status)}`,children:s.status.replace("_"," ")})]}),e.jsx("label",{htmlFor:s.id,className:"text-sm font-medium cursor-pointer line-clamp-1",children:s.title}),s.story_points&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[s.story_points," story points"]})]})]},s.id)),c.length===0&&e.jsx("div",{className:"text-center py-8 text-muted-foreground text-sm",children:"No incomplete stories in this sprint"})]})})]})]}),e.jsxs($e,{children:[e.jsx(N,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(N,{onClick:v,disabled:r.length===0||!n||b,children:b?e.jsxs(e.Fragment,{children:[e.jsx(se,{className:"w-4 h-4 mr-2 animate-spin"}),"Moving..."]}):e.jsxs(e.Fragment,{children:["Move ",r.length," ",r.length===1?"Story":"Stories"]})})]})]})})},_e={not_started:{label:"Not Started",className:"bg-slate-100 text-slate-700 hover:bg-slate-100",icon:xt},active:{label:"Active",className:"bg-blue-50 text-blue-700 hover:bg-blue-50",icon:Dt},completed:{label:"Completed",className:"bg-emerald-50 text-emerald-700 hover:bg-emerald-50",icon:z}},Kt={todo:"bg-blue-50 text-blue-700 hover:bg-blue-50",in_progress:"bg-orange-50 text-orange-700 hover:bg-orange-50",in_review:"bg-violet-50 text-violet-700 hover:bg-violet-50",done:"bg-emerald-50 text-emerald-700 hover:bg-emerald-50"},Ht={low:"bg-slate-100 text-slate-600 hover:bg-slate-100",medium:"bg-amber-50 text-amber-700 hover:bg-amber-50",high:"bg-red-50 text-red-700 hover:bg-red-50",critical:"bg-red-600 text-white hover:bg-red-600"};function Xt(t){return t.replace(/_/g," ").replace(/\b\w/g,o=>o.toUpperCase())}
17const Qt=({sprint:t,onStartSprint:o,onCompleteSprint:c,canStart:l,podId:d,canCompleteSprint:i,onRefresh:a})=>{const[r,m]=_.useState(t.status==="active"),[n,f]=_.useState(!1),[h,S]=_.useState(!1),b=Le(),j=t.stories.filter(s=>s.status!=="done"),y=t.stories.length-j.length,p=t.stories.length?Math.round(y/t.stories.length*100):0,u=Math.max(0,At(new Date(t.end_date),new Date)),x=_e[t.status]||_e.not_started,v=x.icon,g=()=>{b(`/tech-lead/sprint-board-swimlanes?pod=${d}&sprint=${t.id}`)},w=async()=>{f(!0);try{const{canComplete:s,reason:C}=await i(t.id);if(!s){R.error("Cannot Complete Sprint",{description:C||"Sprint cannot be completed at this time"});return}await c(t.id),R.success("Sprint Completed",{description:`${t.name} has been completed successfully!`})}catch(s){R.error("Error",{description:s instanceof Error?s.message:"Failed to complete sprint"})}finally{f(!1)}};return e.jsxs("div",{className:"overflow-hidden rounded-2xl border border-slate-200/80 bg-white shadow-[0_10px_30px_rgba(15,23,42,0.04)] transition-all duration-200 hover:-translate-y-0.5 hover:shadow-[0_18px_42px_rgba(15,23,42,0.08)]",children:[e.jsxs(Nt,{open:r,onOpenChange:m,children:[e.jsx(yt,{asChild:!0,children:e.jsx("button",{type:"button",className:"w-full p-4 text-left transition-colors hover:bg-slate-50/80 sm:p-5",children:e.jsxs("div",{className:"flex flex-col gap-4 xl:flex-row xl:items-center xl:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Pt,{className:`h-4 w-4 text-slate-400 transition-transform duration-200 ${r?"":"-rotate-90"}`}),e.jsx("h3",{className:"text-lg font-semibold tracking-tight text-slate-950",children:t.name}),e.jsxs(k,{className:`rounded-full px-2.5 py-1 ${x.className}`,children:[e.jsx(v,{className:"mr-1.5 h-3.5 w-3.5"}),x.label]})]}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-slate-500",children:[e.jsxs("span",{children:[B(new Date(t.start_date),"MMM d")," - ",B(new Date(t.end_date),"MMM d, yyyy")]}),e.jsxs("span",{children:[t.stories.length," ",t.stories.length===1?"Story":"Stories"]}),e.jsxs("span",{children:[y," completed"]}),e.jsxs("span",{children:[u," days left"]})]})]}),e.jsxs("div",{className:"grid min-w-[260px] gap-2 sm:min-w-[360px]",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Progress"}),e.jsxs("span",{className:"font-semibold text-slate-950",children:[p,"%"]})]}),e.jsx(U,{value:p,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-[11px] text-slate-500",children:[e.jsxs("span",{children:[y," / ",t.stories.length||0," stories"]}),e.jsxs("span",{children:[j.length," remaining"]})]})]})]})})}),e.jsx(_t,{className:"border-t border-slate-100 data-[state=open]:animate-accordion-down data-[state=closed]:animate-accordion-up",children:e.jsxs("div",{className:"space-y-4 p-4 sm:p-5",children:[e.jsxs("div",{className:"flex flex-wrap gap-2 rounded-2xl border border-slate-200/70 bg-slate-50/80 p-2",children:[e.jsxs(N,{size:"sm",className:"rounded-xl bg-blue-600 hover:bg-blue-700",onClick:g,children:[e.jsx(Rt,{className:"mr-2 h-4 w-4"}),"Open Board"]}),t.status==="not_started"&&l&&e.jsxs(N,{size:"sm",variant:"outline",className:"rounded-xl bg-white",onClick:()=>o(t.id),children:[e.jsx(Mt,{className:"mr-2 h-4 w-4"}),"Start Sprint"]}),t.status==="active"&&e.jsxs(N,{size:"sm",variant:"outline",className:"rounded-xl bg-white",onClick:w,disabled:n,children:[e.jsx(z,{className:"mr-2 h-4 w-4"}),n?"Checking...":"Complete Sprint"]}),t.status!=="completed"&&j.length>0&&e.jsxs(N,{size:"sm",variant:"outline",className:"rounded-xl bg-white",onClick:()=>S(!0),children:[e.jsx(Et,{className:"mr-2 h-4 w-4"}),"Move Stories"]}),e.jsxs(N,{size:"sm",variant:"outline",className:"rounded-xl bg-white",onClick:g,children:[e.jsx(ye,{className:"mr-2 h-4 w-4"}),"Create Story"]}),e.jsxs(N,{size:"sm",variant:"ghost",className:"rounded-xl text-slate-500",onClick:a,children:[e.jsx(oe,{className:"mr-2 h-4 w-4"}),"Refresh"]}),e.jsx(N,{size:"icon",variant:"ghost",className:"ml-auto h-9 w-9 rounded-xl text-slate-400",children:e.jsx(Tt,{className:"h-4 w-4"})})]}),t.status==="not_started"&&!l&&e.jsx("div",{className:"rounded-2xl bg-slate-50 px-4 py-3 text-xs text-slate-500",children:"Complete the current sprint before starting this one."}),t.stories.length===0?e.jsxs("div",{className:"rounded-2xl border border-dashed border-slate-200 bg-slate-50 p-8 text-center",children:[e.jsx("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-2xl bg-blue-50 text-blue-700",children:e.jsx(ye,{className:"h-5 w-5"})}),e.jsx("h4",{className:"mt-3 font-semibold text-slate-950",children:"No stories in this sprint yet"}),e.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"Create your first story or move backlog stories into this sprint."}),e.jsx(N,{className:"mt-4 rounded-full bg-blue-600 hover:bg-blue-700",onClick:g,children:"Create Story"})]}):e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:t.stories.map(s=>e.jsxs("article",{className:"rounded-2xl border border-slate-200/80 bg-white p-4 shadow-sm transition-all duration-200 hover:-translate-y-0.5 hover:shadow-md",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("h4",{className:"line-clamp-2 text-sm font-semibold leading-5 text-slate-950",children:s.title}),e.jsx(k,{className:`shrink-0 rounded-full px-2 py-0.5 text-[10px] ${Ht[s.priority]}`,children:s.priority.toUpperCase()})]}),s.description&&e.jsx("p",{className:"mt-2 line-clamp-2 text-xs leading-5 text-slate-500",children:s.description}),e.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2",children:[e.jsx(k,{className:`rounded-full px-2.5 py-1 text-xs ${Kt[s.status]}`,children:Xt(s.status)}),e.jsxs(k,{variant:"outline",className:"rounded-full border-slate-200 px-2.5 py-1 text-xs text-slate-600",children:[s.story_points||1," Points"]}),s.ticket_number&&e.jsx(k,{variant:"outline",className:"rounded-full border-slate-200 px-2.5 py-1 text-xs text-slate-500",children:s.ticket_number})]})]},s.id))})]})})]}),d&&e.jsx(Gt,{open:h,onOpenChange:S,incompleteStories:j,currentSprintId:t.id,currentSprintName:t.name,podId:d,onSuccess:()=>{a==null||a()}})]})},Se={completed:{label:"Completed",dot:"bg-emerald-500",text:"text-emerald-700"},active:{label:"Active",dot:"bg-blue-500",text:"text-blue-700"},not_started:{label:"Upcoming",dot:"bg-slate-300",text:"text-slate-500"}};function Vt({sprints:t,metadata:o,error:c,canStartNewSprint:l,canCompleteSprint:d,podId:i,startSprint:a,completeSprint:r,refetch:m,onCreateNewSprint:n,canCreateMoreSprints:f,podStatus:h}){const b=t.reduce((x,v)=>{const g=new Date(v.start_date),w=new Date(v.end_date),s=Math.ceil((w.getTime()-g.getTime())/(1440*60*1e3))+1;return x+Math.ceil(s/7)},0),j=Math.max(0,20-b),y=t.flatMap(x=>x.stories||[]).filter(x=>x.status==="done").length,p=o.totalStories||t.flatMap(x=>x.stories||[]).length,u=p?Math.round(y/p*100):0;return e.jsxs("section",{className:"rounded-2xl border border-slate-200/80 bg-white p-4 shadow-[0_12px_35
17px_rgba(15,23,42,0.04)] sm:p-5",children:[e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold tracking-tight text-slate-950",children:"Sprint Timeline"}),e.jsxs("p",{className:"mt-1 text-sm text-slate-500",children:[b," of ",20," weeks used / ",p," ",p===1?"story":"stories"," planned / ",j," ",j===1?"week":"weeks"," remaining."]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 rounded-2xl border border-slate-200/70 bg-white/85 p-1.5 shadow-sm backdrop-blur",children:[e.jsxs(N,{variant:"ghost",size:"sm",className:"rounded-xl text-slate-600",onClick:m,children:[e.jsx(oe,{className:"mr-2 h-4 w-4"}),"Refresh"]}),e.jsxs(N,{size:"sm",variant:"outline",className:"rounded-xl border-slate-200",onClick:n,disabled:!f||h==="completed",children:[e.jsx(Z,{className:"mr-2 h-4 w-4"}),"Create Sprint"]})]})]}),e.jsxs("div",{className:"mt-5 rounded-2xl bg-slate-50 p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-slate-800",children:"Delivery Progress"}),e.jsxs("p",{className:"mt-0.5 text-xs text-slate-500",children:[y," / ",p," stories completed"]})]}),e.jsxs("span",{className:"text-2xl font-semibold text-slate-950",children:[u,"%"]})]}),e.jsx(U,{value:u,className:"mt-3 h-2"})]}),t.length>0&&e.jsx("div",{className:"mt-5 overflow-x-auto pb-2",children:e.jsx("div",{className:"flex min-w-max items-center gap-3",children:t.map((x,v)=>{var s;const g=Se[x.status]||Se.not_started,w=(s=x.stories)!=null&&s.length?Math.round(x.stories.filter(C=>C.status==="done").length/x.stories.length*100):0;return e.jsxs(re.Fragment,{children:[e.jsxs("div",{className:"min-w-[170px] rounded-2xl border border-slate-200 bg-white p-3 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${g.dot}`}),e.jsx("span",{className:"text-sm font-semibold text-slate-950",children:x.name})]}),e.jsx("p",{className:`mt-1 text-xs font-medium ${g.text}`,children:g.label}),e.jsx(U,{value:w,className:"mt-3 h-1.5"})]}),v<t.length-1&&e.jsx("div",{className:"h-px w-10 bg-slate-200"})]},x.id)})})}),c?e.jsxs("div",{className:"mt-5 rounded-2xl border border-red-100 bg-red-50 p-8 text-center",children:[e.jsx(ee,{className:"mx-auto h-10 w-10 text-red-500"}),e.jsx("p",{className:"mt-3 font-semibold text-red-700",children:"Error loading sprint data"}),e.jsx("p",{className:"mt-1 text-sm text-red-600",children:c}),e.jsx(N,{onClick:m,className:"mt-4 rounded-full",children:"Try Again"})]}):t.length===0?e.jsxs("div",{className:"mt-5 rounded-2xl border border-dashed border-slate-200 bg-slate-50 p-10 text-center",children:[e.jsx(Z,{className:"mx-auto h-10 w-10 text-blue-500"}),e.jsx("h3",{className:"mt-3 text-lg font-semibold text-slate-950",children:"No sprints yet"}),e.jsx("p",{className:"mx-auto mt-1 max-w-md text-sm text-slate-500",children:"Create your first sprint to organize stories and start delivery tracking."}),e.jsx(N,{onClick:n,disabled:!f||h==="completed",className:"mt-5 rounded-full bg-blue-600 hover:bg-blue-700",children:"Create Sprint"})]}):e.jsx("div",{className:"mt-5 space-y-4",children:t.map((x,v)=>e.jsx(Qt,{sprint:x,onStartSprint:a,onCompleteSprint:r,canStart:l&&v===t.findIndex(g=>g.status==="not_started"),podId:i,canCompleteSprint:d,onRefresh:m},x.id))}),t.length>0&&e.jsxs("div",{className:"mt-5 flex flex-col items-center gap-2 border-t border-slate-100 pt-4",children:[e.jsxs(N,{onClick:n,disabled:j===0||h==="completed",className:"rounded-full bg-slate-950 px-5 hover:bg-slate-800",children:[e.jsx(Z,{className:"mr-2 h-4 w-4"}),"Create New Sprint"]}),e.jsx("p",{className:"text-xs text-slate-500",children:h==="completed"?"Pod has been completed":j>0?`Remaining: ${j} ${j===1?"week":"weeks"} (max 20 weeks)`:"Pod has reached the 20-week maximum"})]})]})}function Jt({open:t,onOpenChange:o,onCreateSprint:c,podDurationWeeks:l,sprints:d,projectStartDate:i}){const[a,r]=_.useState(1),[m,n]=_.useState(!1),{totalWeeksUsed:f,remainingWeeks:h,maxSprintDuration:S,durationOptions:b}=_.useMemo(()=>{const u=d.reduce((w,s)=>{const C=new Date(s.start_date),E=new Date(s.end_date),A=Math.ceil((E.getTime()-C.getTime())/(1440*60*1e3))+1,T=Math.ceil(A/7);return w+T},0),x=l-u,v=Math.min(4,x),g=Array.from({length:v},(w,s)=>s+1);return{totalWeeksUsed:u,remainingWeeks:x,maxSprintDuration:v,durationOptions:g}},[d,l]),{sprintStartDate:j,sprintEndDate:y}=_.useMemo(()=>
17{if(d.length===0){const w=new Date(i),s=new Date(w);return s.setDate(w.getDate()+a*7-1),{sprintStartDate:w,sprintEndDate:s}}const u=d[d.length-1],x=new Date(u.end_date),v=new Date(x);v.setDate(x.getDate()+1);const g=new Date(v);return g.setDate(v.getDate()+a*7-1),{sprintStartDate:v,sprintEndDate:g}},[d,i,a]),p=async()=>{n(!0);try{await c(a),o(!1),r(1)}catch(u){console.error("Error creating sprint:",u)}finally{n(!1)}};return e.jsx(Pe,{open:t,onOpenChange:o,children:e.jsxs(Me,{className:"sm:max-w-[500px]",children:[e.jsxs(Ee,{children:[e.jsx(Te,{children:"Create New Sprint"}),e.jsx(Ae,{children:"Configure your new sprint duration. The system will automatically calculate dates based on your pod timeline."})]}),e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs("div",{className:"rounded-lg bg-muted p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(ht,{className:"h-4 w-4"}),"Pod Timeline Overview"]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-sm",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-muted-foreground",children:"Total"}),e.jsxs("div",{className:"font-semibold",children:[l," weeks"]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-muted-foreground",children:"Used"}),e.jsxs("div",{className:"font-semibold",children:[f," weeks"]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-muted-foreground",children:"Remaining"}),e.jsxs("div",{className:"font-semibold text-primary",children:[h," weeks"]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(te,{htmlFor:"sprint-duration",children:"Sprint Duration"}),e.jsxs(Re,{value:a.toString(),onValueChange:u=>r(parseInt(u)),children:[e.jsx(Oe,{id:"sprint-duration",children:e.jsx(Fe,{placeholder:"Select sprint duration"})}),e.jsx(Ie,{children:b.map(u=>e.jsxs(We,{value:u.toString(),children:[u," ",u===1?"week":"weeks"]},u))})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Maximum duration: ",S," ",S===1?"week":"weeks"," (based on remaining pod time)"]})]}),e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Ce,{className:"h-4 w-4"}),"Sprint Dates Preview"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-muted-foreground",children:"Start Date"}),e.jsx("div",{className:"font-medium",children:B(j,"MMM dd, yyyy")})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-muted-foreground",children:"End Date"}),e.jsx("div",{className:"font-medium",children:B(y,"MMM dd, yyyy")})]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Sprint ",d.length+1," • ",a," ",a===1?"week":"weeks"," duration"]})]})]}),e.jsxs($e,{children:[e.jsx(N,{variant:"outline",onClick:()=>o(!1),disabled:m,children:"Cancel"}),e.jsxs(N,{onClick:p,disabled:m||b.length===0,children:[m&&e.jsx(se,{className:"mr-2 h-4 w-4 animate-spin"}),"Create Sprint"]})]})]})})}function Yt({podId:t,allocations:o,members:c}){const[l,d]=_.useState({});_.useEffect(()=>{let r=!0;return M.from("project_applications").select("pathway_role").eq("pod_id",t).eq("status","accepted").then(({data:m})=>{if(!r)return;const n={};(m||[]).forEach(({pathway_role:f})=>{if(!f)return;const h=f.toLowerCase();n[h]=(n[h]||0)+1}),d(n)}),()=>{r=!1}},[t,c]);const i=_.useMemo(()=>o.map(r=>{const m=r.pathway.toLowerCase(),n=c.filter(h=>{var S;return h.status==="active"&&h.role!=="tech_lead"&&((S=h.pathway_role)==null?void 0:S.toLowerCase())===m}).length,f=l[m]||0;return{...r,accepted:f,joined:n,remaining:Math.max(0,r.seats-Math.max(f,n))}}),[o,c,l]),a=r=>r.split("-").map(m=>m.charAt(0).toUpperCase()+m.slice(1)).join(" ");return e.jsxs(W,{className:"rounded-[20px] border-slate-200/70 shadow-[0_18px_45px_rgba(15,23,42,0.05)]",children:[e.jsx(De,{className:"pb-3",children:e.jsxs(pt,{className:"flex items-center gap-2 text-base",children:[e.jsx(ke,{className:"h-5 w-5 text-blue-600"}),"Pathway capacity"]})}),e.jsx(le,{children:i.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No pathway seat allocations are configured."}):e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:i.map(r=>e.jsxs("div",{className:"rounded-2xl border border-slate-200 p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("p",{className:"font-medium text-slate-950",children:a(r.pathway)}),e.jsxs("span",{className:"text-sm font-semibold",children:[r.joined,"/",r.seats," joined"]})]}),e.jsx(U,{className:"my-3 h-2",value:r.seats?Math.min(100,r.joined/r.seats*100):0}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsxs("span",{children:[r.seats," needed"]}),e.jsxs("span",{children:[r.accepted," accepted"]}),e.jsxs("span",{children:[r.remaining," remaining"]})]})]},r.pathway))})})]})}function ra(){var fe,be;const{user:t}=ut(),[o]=gt(),c=Le(),l=o.get("pod"),[d,i]=_.useState(!1),{podDetails:a,isLoading:r}=ft(l),{podMembers:m,isLoading:n}=bt(l),f=r||n,{sprints:h,metadata:S,isLoading:b,error:j,activeSprint:y,canStartNewSprint:p,startSprint:u,completeSprint:x,canCompleteSprint:v,refetch:g,createSprintsFromDeliveryPlan:w,roadmapData:s,roadmapLoading:C,roadmapError:E,isTimeout:A}=jt(l),{status:T,hasDeliveryPlan:ce}=Ot(s.epics,s.stories,h,E!==null||A,f||b||C),{hasRepo:Ue,refetch:qe}=Ft(l);
17if(re.useEffect(()=>{l||c("/tech-lead/sprint-board-pods")},[c,l]),!l)return null;const Be="2026-03-18",ze=["devops-engineering","fullstack-engineering"],de=a?a.created_at>Be:!1,me=Array.isArray((fe=a==null?void 0:a.projects)==null?void 0:fe.career_paths)?a.projects.career_paths:[],xe=me.some(D=>ze.includes(D)),he=Ue||!!(a!=null&&a.github_repo_url)||!!(a!=null&&a.github_connected_at),Ge=de&&!he&&xe,pe=(a==null?void 0:a.pod_type)==="multilateral",Ke=!!(t!=null&&t.id)&&((be=a==null?void 0:a.tech_leads)==null?void 0:be.user_id)===t.id,ue=()=>{c("/tech-lead/sprint-board-pods")},He=()=>{c(`/tech-lead/delivery-plan-creation?pod=${l}`)},Xe=()=>{c(`/tech-lead/delivery-plan-creation?pod=${l}&mode=complete`)},ge=()=>{c(`/tech-lead/delivery-plan-creation?pod=${l}&mode=regenerate`)},Qe=async()=>{try{await w(),await g()}catch(D){console.error("Error creating sprints:",D)}},Ve=async D=>{if(!(!a||!l))try{const{supabase:P}=await J(async()=>{const{supabase:L}=await import("./index-DLd_kDlx.js").then(I=>I.bR);return{supabase:L}},__vite__mapDeps([0,1])),{toast:O}=await J(async()=>{const{toast:L}=await import("./index-DLd_kDlx.js").then(I=>I.bQ);return{toast:L}},__vite__mapDeps([0,1])),{data:F}=await P.from("pods").select("project_start_date, pod_duration_weeks").eq("id",l).single();if(!F)throw new Error("Pod configuration not found");const G=20-h.reduce((L,I)=>{const et=new Date(I.start_date),tt=new Date(I.end_date),st=Math.ceil((tt.getTime()-et.getTime())/(1440*60*1e3))+1,at=Math.ceil(st/7);return L+at},0);if(D>G){O({title:"Cannot Create Sprint",description:`Only ${G} ${G===1?"week":"weeks"} remaining in the 20-week maximum.`,variant:"destructive"});return}const K=h.length+1;let $;if(h.length>0){const L=h[h.length-1];$=new Date(L.end_date),$.setDate($.getDate()+1)}else $=new Date(F.project_start_date);const ve=new Date($);ve.setDate($.getDate()+D*7-1);const{error:we}=await P.from("sprints").insert({pod_id:l,name:`Sprint ${K}`,sprint_number:K,start_date:$.toISOString().split("T")[0],end_date:ve.toISOString().split("T")[0],status:"not_started"});if(we)throw we;O({title:"Sprint Created",description:`Sprint ${K} (${D} ${D===1?"week":"weeks"}) has been created successfully.`}),await g()}catch(P){console.error("Error creating new sprint:",P);const{toast:O}=await J(async()=>{const{toast:F}=await import("./index-DLd_kDlx.js").then(q=>q.bQ);return{toast:F}},__vite__mapDeps([0,1]));O({title:"Sprint Creation Failed",description:P.message,variant:"destructive"})}},Je=20,Ye=h.reduce((D,P)=>{const O=new Date(P.start_date),F=new Date(P.end_date),q=Math.ceil((F.getTime()-O.getTime())/(1440*60*1e3))+1,je=Math.ceil(q/7);return D+je},0),Ze=Math.max(0,Je-Ye)>0;return r&&!a||b&&!h.length||C&&s.epics.length===0?e.jsx(X,{children:e.jsxs("div",{className:"min-h-screen flex w-full bg-[#F8FAFC]",children:[e.jsx(Q,{}),e.jsxs(V,{className:"flex-1",children:[e.jsx(Y,{title:"Sprint Board"}),e.jsxs("main",{className:"mx-auto w-full max-w-[1500px] space-y-4 px-4 py-5 sm:px-6 lg:px-8",children:[e.jsx("div",{className:"h-24 w-full animate-pulse rounded-2xl bg-white"}),e.jsx("div",{className:"grid gap-3 md:grid-cols-4",children:Array.from({length:4}).map((D,P)=>e.jsx("div",{className:"h-28 animate-pulse rounded-2xl bg-white"},P))}),e.jsx("div",{className:"h-72 w-full animate-pulse rounded-2xl bg-white"})]})]})]})}):a?e.jsx(X,{children:e.jsxs("div",{className:"min-h-screen flex w-full bg-[#F8FAFC]",children:[e.jsx(Q,{}),e.jsxs(V,{className:"flex-1",children:[e.jsx(Y,{title:"Sprint Board"}),e.jsxs("main",{className:"mx-auto w-full max-w-[1500px] space-y-5 px-4 py-5 sm:px-6 lg:px-8",children:[e.jsx(Wt,{podDetails:a,activeSprint:y,onBackToPods:ue,podMembers:m,hasRepo:he,podId:l,onRepoLinked:()=>qe(),isNewPod:de,requiresRepo:xe,canLinkRepository:Ke}),e.jsx($t,{podId:l,isMultilateral:pe,pathways:me}),pe&&e.jsx(Yt,{podId:l,allocations:Array.isArray(a.pathway_allocations)?a.pathway_allocations:[],members:m}),Ge?null:T==="error"?e.jsx(W,{className:"rounded-[20px] border-slate-200/70 p-6 shadow-[0_18px_45px_rgba(15,23,42,0.06)]",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("div",{className:"mx-auto flex h-14 w-14 items-center justify-center rounded-2xl bg-amber-50 text-amber-600",children:e.jsx(ee,{className:"h-6 w-6"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"mb-2 text-lg font-semibold tracking-tight text-slate-950",children:"Unable to Load Sprint Data"}),e.jsx("p",{className:"text-muted-foreground mb-2",children:A?"The database query timed out. This usually happens with large datasets or heavy server load.":"An error occurred while loading your sprint data."}),E&&e.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:["Error: ",E]})]}),e.jsxs(N,{onClick:()=>g(),variant:"outline",className:"rounded-xl border-slate-200",children:[e.jsx(oe,{className:"mr-2 h-4 w-4"}),"Retry Loading Data"]})]})}):!ce||T!=="complete"?e.jsxs(e.Fragment,{children:[e.jsx(Bt,{status:T,onGenerateDeliveryPlan:He,onCompleteDeliveryPlan:Xe,onRegenerateDeliveryPlan:ge}),T==="needs_sprints"&&ce&&e.jsx(W,{className:"rounded-[20px] border-slate-200/70 p-6 shadow-[0_18px_45px_rgba(15,23,42,0.06)]",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold tracking-tight text-slate-950",children:"Manual Sprint Creation"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"If regenerating isn't working, try creating sprints manually from your existing delivery plan."}),e.jsx(N,{onClick:Qe,variant:"outline",className:"rounded-xl border-slate-200",children:"Create Sprints Manually"})]})})]}):e.jsxs(e.Fragment,{children:[e.jsx(qt,{sprints:h,activeSprint:y}),e.jsx(Vt,{sprints:h,metadata:S,error:j,canStartNewSprint:p,canCompleteSprint:v,podId:l,startSprint:u,completeSprint:x,refetch:g,onCreateNewSprint:()=>i(!0),onGenerateSprintPlan:ge,canCreateMoreSprints:Ze,podDurationWeeks:(a==null?void 0:a.pod_duration_weeks)||12,sprintDurationWeeks:(a==null?void 0:a.sprint_duration_weeks)||2,podStatus:a==null?void 0:a.status}),e.jsx(Jt,{open:d,onOpenChange:i,onCreateSprint:Ve,podDurationWeeks:20,sprints:h,projectStartDate:(a==null?void 0:a.project_start_date)||new Date().toISOString()})]})]})]})]})}):e.jsx(X,{children:e.jsxs("div",{className:"min-h-screen flex w-full bg-[#F8FAFC]",children:[e.jsx(Q,{}),e.jsxs(V,{className:"flex-1",children:[e.jsx(Y,{title:"Sprint Board"}),e.jsx("main",{className:"mx-auto w-full max-w-[1500px] px-4 py-5 sm:px-6 lg:px-8",children:e.jsx(W,{className:"rounded-[20px] border-slate-200/70 shadow-[0_18px_45px_rgba(15,23,42,0.06)]",children:e.jsx(le,{className:"p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(ee,{className:"h-12 w-12 text-red-500 mx-auto mb-4"}),e.jsx("p",{className:"text-red-600 mb-4",children:"Pod not found. Please check the URL."}),e.jsx(N,{onClick:ue,children:"Back to Pod List"})]})})})})]})]})})}export{ra as default};

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.