1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._posthogChunkIds=e._posthogChunkIds||{},e._posthogChunkIds[n]="01a086e7-d7f8-7643-b3d4-3d21a9287baf")}catch(e){}}(); 2!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="d3ceeaee-adaa-5131-95c6-944a5cf09cd5")}catch(e){}}(); 3import{u as m,j as e}from"./query-vendor-Bpmm07UM.js";import{a as p}from"./index-B4qsZXfP.js";import"./router-vendor-PdvXAmya.js";const c={active_sub_in_window:{label:"Active subscription, in window",tone:"ok"},cycle_linked_active:{label:"Cycle-linked, on cadence",tone:"ok"},manual_review:{label:"Manual review pending",tone:"warn"},old_over_30d:{label:"Older than 30 days",tone:"warn"},cancelled_sub_leak:{label:"CANCELLED subscription â leak",tone:"leak"},paused_sub_leak:{label:"PAUSED subscription â leak",tone:"leak"},no_subscription:{label:"No subscription (orphan)",tone:"leak"}},d=["cancelled_sub_leak","paused_sub_leak","no_subscription","manual_review","old_over_30d","active_sub_in_window","cycle_linked_active"];function _(){const{data:s,isLoading:i,error:x,refetch:o}=m({queryKey:["admin","drafts","health"],queryFn:()=>p.get("/api/owner/drafts/health"),staleTime:1e4});if(i)return e.jsx("div",{className:"p-8 text-neutral-400",children:"Loadingâ¦"});if(x)return e.jsxs("div",{className:"p-8",children:[e.jsx("p",{className:"text-red-400",children:"Failed to load."}),e.jsx("button",{onClick:()=>o(),className:"mt-2 rounded-xl border border-surface-border px-3 py-2 text-sm text-neutral-300 hover:border-brand",children:"Reload"})]});const n=(s==null?void 0:s.counts.total)??0;return e.jsxs("div",{className:"mx-auto w-full max-w-6xl px-4 sm:px-6 py-8",children:[e.jsxs("header",{className:"mb-6",children:[e.jsx("h1",{className:"text-2xl font-semibold text-white",children:"DRAFT plan health"}),e.jsxs("p",{className:"mt-2 text-sm text-neutral-400",children:[n," DRAFT plan",n===1?"":"s"," across all athletes. Leak buckets (red) should be empty in steady state â if they're not, the daily watchdog will email admin and one of the cleanup crons will eventually catch them. See ",e.jsx("code",{className:"text-brand",children:"docs/plans/draft-lifecycle.md"}),"."]})]}),e.jsx("section",{className:"mb-8 grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-4",children:d.map(a=>{const l=c[a],r=(s==null?void 0:s.counts[a])??0,t=l.tone;return e.jsxs("div",{className:"rounded-xl border p-4 "+(t==="leak"?"border-red-700 bg-red-950/30":t==="warn"?"border-amber-700 bg-amber-950/20":"border-surface-border bg-surface-raised"),children:[e.jsx("div",{className:"text-xs uppercase tracking-wide text-neutral-400",children:l.label}),e.jsx("div",{className:"mt-1 text-2xl font-semibold "+(t==="leak"?"text-red-300":t==="warn"?"text-amber-300":"text-white"),children:r})]},a)})}),d.map(a=>{const l=(s==null?void 0:s.buckets[a])??[];if(l.length===0)return null;const r=c[a];return e.jsxs("section",{className:"mb-8",children:[e.jsxs("h2",{className:"mb-3 text-sm font-medium uppercase tracking-wide text-neutral-400",children:[r.label," ",e.jsxs("span",{className:"text-neutral-500",children:["(",l.length,")"]})]}),e.jsx("div",{className:"overflow-x-auto rounded-xl border border-surface-border",children:e.jsxs("table",{className:"w-full min-w-[640px] text-sm",children:[e.jsx("thead",{className:"bg-surface-raised text-xs uppercase tracking-wide text-neutral-400",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2 text-left",children:"Plan"}),e.jsx("th",{className:"px-3 py-2 text-left",children:"Athlete"}),e.jsx("th",{className:"px-3 py-2 text-left",children:"Type"}),e.jsx("th",{className:"px-3 py-2 text-left",children:"Period"}),e.jsx("th",{className:"px-3 py-2 text-left",children:"Age (d)"}),e.jsx("th",{className:"px-3 py-2 text-left",children:"Sub"}),e.jsx("th",{className:"px-3 py-2 text-left",children:"Cycle"}),e.jsx("th",{className:"px-3 py-2 text-left",children:"Last edit"})]})}),e.jsx("tbody",{children:l.map(t=>e.jsxs("tr",{className:"border-t border-surface-border text-neutral-300",children:[e.jsx("td",{className:"px-3 py-2 font-mono",children:t.plan_id}),e.jsx("td",{className:"px-3 py-2",children:e.jsxs("a",{href:`/admin/athletes/${t.athlete_id}`,className:"text-brand hover:underline",children:["#",t.athlete_id]})}),e.jsx("td",{className:"px-3 py-2",children:t.plan_type}),e.jsx("td",{className:"px-3 py-2 text-xs text-neutral-400",children:t.period_month}),e.jsx("td",{className:"px-3 py-2",children:t.age_days}),e.jsx("td",{className:"px-3 py-2 text-xs text-neutral-400",children:t.sub_status??"â"}),e.jsx("td",{className:"px-3 py-2 text-xs text-neutral-400",children:t.cycle_linked?t.cycle_status:"no cycle"}),e.jsx("td",{className:"px-3 py-2 text-xs text-neutral-400",children:t.last_user_interaction_at?new Date(t.last_user_interaction_at).toLocaleStr
3ing():"â"})]},t.plan_id))})]})})]},a)})]})}export{_ as default}; 4 5//# debugId=d3ceeaee-adaa-5131-95c6-944a5cf09cd5 6 7//# chunkId=01a086e7-d7f8-7643-b3d4-3d21a9287baf
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.