PageSourceSearch

https://mycurriculummate.com.au/static/js/9461.5ad4f4a4.chunk.js

js mycurriculummate.com.au collected 2026-09-24 14:09:47 UTC 24,844 bytes, 3 lines download raw bytes

1/*! For license information please see 9461.5ad4f4a4.chunk.js.LICENSE.txt */
2"use strict";(globalThis.webpackChunkfrontend=globalThis.webpackChunkfrontend||[]).push([[9461],{1842(e,s,t){t.r(s),t.d(s,{default:()=>E});var a=t(5043),r=t(3974),l=t(4980),i=t(6328),n=t(3390),d=t(1140),c=t(2264),o=t(556),m=t(5949),x=t(3416),h=t(4204),u=t(2054),j=t(7719),p=t(6245),g=t(4537),N=t(5258),b=t(2308),f=t(1680),y=t(4459),v=t(2024),w=t(9292),_=t(5088),A=t(6376),k=t(1360),C=t(6174),R=t(4805),$=t(7978),S=t(516),z=t(3005);const M=(0,t(7784).A)("cpu",[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]]);var I=t(67),U=t(579);const E=()=>{var e;const{user:s}=(0,r.As)(),[t,E]=(0,a.useState)(""),[T,D]=(0,a.useState)(null),[F,q]=(0,a.useState)(!1),[P,L]=(0,a.useState)(null),[Z,B]=(0,a.useState)(!1),[G,H]=(0,a.useState)(null),[O,W]=(0,a.useState)(!1),[K,Q]=(0,a.useState)(""),[J,X]=(0,a.useState)(""),[V,Y]=(0,a.useState)(!1),[ee,se]=(0,a.useState)(!1),[te,ae]=(0,a.useState)(null),[re,le]=(0,a.useState)(!1),[ie,ne]=(0,a.useState)(null),[de,ce]=(0,a.useState)(!1),[oe,me]=(0,a.useState)(!1),xe=async()=>{if(t.trim()){q(!0),D(null);try{const e=await l.A.get(`${r.nC}/admin/diagnostics/user-credits/${encodeURIComponent(t.trim())}`);D(e.data)}catch(n){var e,s,a;if(404===(null===(e=n.response)||void 0===e?void 0:e.status))i.oR.error(`User '${t}' not found`);else i.oR.error((null===(s=n.response)||void 0===s||null===(a=s.data)||void 0===a?void 0:a.detail)||"Failed to lookup user")}finally{q(!1)}}else i.oR.error("Please enter an email address")},he=async e=>{if(null!==T&&void 0!==T&&T.email)if(J.trim()){Y(!0);try{const s=await l.A.post(`${r.nC}/admin/diagnostics/credits/adjust`,{email:T.email,amount:e,reason:J.trim()});i.oR.success(`Credits adjusted: ${s.data.previous_balance} \u2192 ${s.data.new_balance}`),Q(""),X(""),xe()}catch(a){var s,t;i.oR.error((null===(s=a.response)||void 0===s||null===(t=s.data)||void 0===t?void 0:t.detail)||"Failed to adjust credits")}finally{Y(!1)}}else i.oR.error("Please provide a reason for the adjustment");else i.oR.error("Please lookup a user first")},ue=async()=>{ce(!0);try{const e=await l.A.get(`${r.nC}/admin/diagnostics/index-status`);ne(e.data),e.data.summary.optimization_needed?i.oR.warning(`${e.data.summary.collections_needing_indexes.length} collections need indexing`):i.oR.success("All collections are properly indexed")}catch(t){var e,s;i.oR.error((null===(e=t.response)||void 0===e||null===(s=e.data)||void 0===s?void 0:s.detail)||"Failed to check index status")}finally{ce(!1)}},je=e=>{switch(e){case"healthy":return(0,U.jsx)(u.A,{className:"w-5 h-5 text-green-500"});case"degraded":return(0,U.jsx)(j.A,{className:"w-5 h-5 text-yellow-500"});case"unhealthy":return(0,U.jsx)(p.A,{className:"w-5 h-5 text-red-500"});default:return(0,U.jsx)(g.A,{className:"w-5 h-5 text-muted-foreground"})}},pe=e=>{switch(e){case"unit_plan":return(0,U.jsx)(N.A,{className:"w-4 h-4 text-blue-500"});case"lesson_plan":return(0,U.jsx)(N.A,{className:"w-4 h-4 text-primary"});case"slideshow":return(0,U.jsx)(b.A,{className:"w-4 h-4 text-secondary"});case"worksheet":return(0,U.jsx)(f.A,{className:"w-4 h-4 text-amber-500"});case"quiz":return(0,U.jsx)(f.A,{className:"w-4 h-4 text-purple-500"});default:return(0,U.jsx)(f.A,{className:"w-4 h-4"})}},ge=e=>{if(!e)return"N/A";try{return new Date(e).toLocaleString("en-AU",{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return e}};return!s||"admin"!==s.role&&"super_admin"!==s.role?(0,U.jsx)(h.A,{children:(0,U.jsx)("div",{className:"flex items-center justify-center min-h-[400px]",children:(0,U.jsx)("p",{className:"text-muted-foreground",children:"Admin access required"})})}):(0,U.jsx)(h.A,{children:(0,U.jsxs)("div",{className:"max-w-6xl mx-auto 
2space-y-6","data-testid":"diagnostic-tools-page",children:[(0,U.jsxs)("div",{className:"flex items-center gap-3 mb-6",children:[(0,U.jsx)("div",{className:"w-12 h-12 rounded-xl bg-gradient-to-br from-orange-500 to-red-500 flex items-center justify-center text-white",children:(0,U.jsx)(g.A,{className:"w-6 h-6"})}),(0,U.jsxs)("div",{className:"min-w-0",children:[(0,U.jsx)("h1",{className:"text-3xl font-bold text-foreground",children:"Diagnostic Tools"}),(0,U.jsx)("p",{className:"text-muted-foreground",children:"Check user credits, system health, and diagnose issues"})]})]}),(0,U.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[(0,U.jsxs)(d.Zp,{className:"border-border/50",children:[(0,U.jsxs)(d.aR,{children:[(0,U.jsxs)(d.ZB,{className:"flex items-center gap-2",children:[(0,U.jsx)(y.A,{className:"w-5 h-5 text-primary"}),"User Credit Lookup"]}),(0,U.jsx)(d.BT,{children:"Check if a user's issues are due to exhausted credits"})]}),(0,U.jsxs)(d.Wu,{className:"space-y-4",children:[(0,U.jsxs)("div",{className:"flex gap-2",children:[(0,U.jsxs)("div",{className:"flex-1",children:[(0,U.jsx)(o.J,{htmlFor:"email-search",className:"sr-only",children:"User Email"}),(0,U.jsx)(c.p,{id:"email-search",placeholder:"Enter user email...",value:t,onChange:e=>E(e.target.value),onKeyDown:e=>"Enter"===e.key&&xe(),"data-testid":"email-search-input"})]}),(0,U.jsx)(n.$,{onClick:xe,disabled:F,"data-testid":"lookup-credits-btn",children:F?(0,U.jsx)(v.A,{className:"w-4 h-4 animate-spin"}):(0,U.jsx)(w.A,{className:"w-4 h-4"})})]}),T&&(0,U.jsxs)("div",{className:"mt-4 p-4 bg-muted/50 rounded-lg space-y-3","data-testid":"user-credits-result",children:[(0,U.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,U.jsxs)("div",{className:"min-w-0",children:[(0,U.jsx)("p",{className:"font-semibold truncate",children:T.name||T.email}),(0,U.jsx)("p",{className:"text-sm text-muted-foreground truncate",children:T.email})]}),(0,U.jsxs)("div",{className:"text-right",children:[T.stripe_trial_ends_at&&new Date(T.stripe_trial_ends_at)>new Date?(0,U.jsx)(m.E,{className:"bg-orange-400 hover:bg-orange-500 text-white border-0",children:"TRIAL"}):"free"===T.subscription_tier?(0,U.jsx)(m.E,{variant:"secondary",children:T.subscription_tier.toUpperCase()}):(0,U.jsx)(m.E,{variant:"default",children:T.subscription_tier.toUpperCase()}),T.role&&(0,U.jsx)(m.E,{variant:"outline",className:"ml-2",children:T.role})]})]}),(0,U.jsxs)("div",{className:"grid grid-cols-4 gap-4 pt-3 border-t",children:[(0,U.jsxs)("div",{className:"text-center",children:[(0,U.jsx)("p",{className:"text-2xl font-bold text-primary",children:T.credits_balance}),(0,U.jsx)("p",{className:"text-xs text-muted-foreground",children:"Credits Left"})]}),(0,U.jsxs)("div",{className:"text-center",children:[(0,U.jsx)("p",{className:"text-2xl font-bold",children:T.credits_used_this_month}),(0,U.jsx)("p",{className:"text-xs text-muted-foreground",children:"Used This Month"})]}),(0,U.jsxs)("div",{className:"text-center",children:[(0,U.jsx)("p",{className:"text-2xl font-bold text-muted-foreground",children:T.monthly_credit_allowance}),(0,U.jsx)("p",{className:"text-xs text-muted-foreground",children:"Monthly Allowance"})]}),null!=T.rollover_cap&&(0,U.jsxs)("div",{className:"text-center",children:[(0,U.jsx)("p",{className:"text-2xl font-bold text-amber-500",children:T.rollover_cap}),(0,U.jsx)("p",{className:"text-xs text-muted-foreground",children:"Rollover Cap"})]})]}),(0,U.jsx)("div",{className:"p-3 rounded-lg "+(0===T.credits_balance?"bg-red-100 text-red-700 border border-red-200":T.credits_balance<20?"bg-yellow-100 text-yellow-700 border border-yellow-200":"bg-green-100 text-green-700 border border-green-200"),children:0===T.credits_balance?(0,U.jsx)("p",{className:"text-sm font-medium",children:"\u26a0\ufe0f CREDITS EXHAUSTED - User cannot generate content"}):T.credits_balance<20?(0,U.jsx)("p",{className:"text-sm font-medium",children:"\u26a0\ufe0f Low credits - User may run out soon"}):(0,U.jsx)("p",{className:"text-sm font-medium",children:"\u2713 Credits OK - User has sufficient balance"})}),(0,U.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,U.jsx)(_.A,{className:"w-4 h-4"}),(0,U.jsxs)("span",{children:["Last credit reset: ",ge(T.last_credit_reset)]})]}),T.last_credit_reset&&(0,U.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,U.jsx)(_.A,{className:"w-4 h-4 opacity-0"}),(0,U.jsxs)("span",{children:["Next credit reset: ",ge(new Date(new Date(T.last_credit_reset).getTime()+2592e6).toISOString())]})]}),(0,U.jsxs)("div",{className:"pt-3 border-t",children:[(0,U.jsx)("p",{className:"text-sm font-medium mb-2",children:"Monthly Counters (from user record):"}),(0,U.jsx)("div",{className:"grid grid-cols-3 gap-2 text-xs",children:[{label:"Unit Plans",value:T.unit_plans_this_month},{label:"Lesson Plans",value:T.lesson_plans_this_month},{label:"Worksheets",value:T.worksheets_this_month},{label:"Slideshows",value:T.slideshows_this_month},{label:"Quizzes",value:T.quizzes_this_month}].map(e=>{let{label:s,value:t}=e;return(0,U.jsxs)("div",{className:"text-center p-2 bg-background rounded",children:[(0,U.jsx)("p",{className:"font-semibold text-sm",children:t}),(0,U.jsx)("p",{className:"text-muted-foreground",children:s})]},s)})})]}),(0,U.jsxs)("div",{className:"pt-3 border-t",children:[(0,U.jsx)("p",{className:"text-sm font-medium mb-2",children:"Recent Generations (from collections):"}),(null===(e=T.recent_generations)||void 0===e?void 0:e.length)>0?(0,U.jsx)("div",{className:"space-y-1 max-h-[200px] overflow-y-auto",children:T.recent_generations.map((e,s)=>(0,U.jsxs)("div",{className:"flex items-center justify-between text-sm p-2 bg-background rounded",children:[(0,U.jsxs)("div",{className:"flex items-center gap-2",children:[pe(e.type),(0,U.jsx)("span",{className:"truncate max-w-[200px]",children:e.title})]}),(0,U.jsx)("span",{className:"text-muted-foreground text-xs",children:ge(e.created_at)})]},e.created_at||`gen-${s}`))}):(0,U.jsx)("p",{className:"text-xs text-muted-foreground italic",children:"No documents found in unit_plans, slideshows, worksheets, or dev_quizzes collections. If counters above are non-zero, documents may have failed to persist."})]}),(0,U.jsxs)("div",{className:"pt-3 border-t",children:[(0,U.jsxs)("p",{className:"text-sm font-semibold mb-3 flex items-center gap-2",children:[(0,U.jsx)(A.A,{className:"w-4 h-4"}),"Admin Credit Management"]}),(0,U.jsxs)("div",{className:"space-y-3",children:[(0,U.jsxs)("div",{className:"flex gap-2",children:[(0,U.jsx)(c.p,{type:"number",placeholder:"Amount",value:K,onChange:e=>Q(e.target.value),className:"w-24","data-testid":"adjust-amount-input"}),(0,U.jsxs)(n.$,{size:"sm",variant:"outline",onClick:()=>he(parseInt(K)||0),disabled:V||!K,className:"text-green-600 border-green-300 hover:bg-green-50","data-testid":"add-credits-btn",children:[V?(0,U.jsx)(v.A,{className:"w-3 h-3 animate-spin"}):(0,U.jsx)(k.A,{className:"w-3 h-3 mr-1"}),"Add"]}),(0,U.jsxs)(n.$,{size:"sm",variant:"outline",onClick:()=>he(-(parseInt(K)||0)),disabled:V||!K,className:"text-red-600 border-red-300 hover:bg-red-50","data-testid":"subtract-credits-btn",children:[V?(0,U.jsx)(v.A,{className:"w-3 h-3 animate-spin"}):(0,U.jsx)(C.A,{className:"w-3 h-3 mr-1"}),"Subtract"]})]}
2),(0,U.jsx)(x.T,{placeholder:"Reason for adjustment (required for add/subtract)",value:J,onChange:e=>X(e.target.value),className:"h-16 text-sm","data-testid":"adjust-reason-input"}),(0,U.jsxs)("div",{className:"flex gap-2",children:[(0,U.jsxs)(n.$,{size:"sm",variant:"outline",onClick:async()=>{if(null!==T&&void 0!==T&&T.email){se(!0);try{const e=await l.A.post(`${r.nC}/admin/diagnostics/credits/reset`,{email:T.email,reason:J.trim()||"Admin reset to monthly allowance"});i.oR.success(`Credits reset: ${e.data.previous_balance} \u2192 ${e.data.new_balance}`),X(""),xe()}catch(t){var e,s;i.oR.error((null===(e=t.response)||void 0===e||null===(s=e.data)||void 0===s?void 0:s.detail)||"Failed to reset credits")}finally{se(!1)}}else i.oR.error("Please lookup a user first")},disabled:ee,className:"flex-1","data-testid":"reset-credits-btn",children:[ee?(0,U.jsx)(v.A,{className:"w-3 h-3 animate-spin mr-1"}):(0,U.jsx)(R.A,{className:"w-3 h-3 mr-1"}),"Reset to Monthly Allowance"]}),(0,U.jsx)(n.$,{size:"sm",variant:"ghost",onClick:async()=>{if(null!==T&&void 0!==T&&T.email){le(!0);try{const e=await l.A.get(`${r.nC}/admin/diagnostics/credits/history/${encodeURIComponent(T.email)}`);ae(e.data.adjustments)}catch(t){var e,s;i.oR.error((null===(e=t.response)||void 0===e||null===(s=e.data)||void 0===s?void 0:s.detail)||"Failed to fetch credit history")}finally{le(!1)}}else i.oR.error("Please lookup a user first")},disabled:re,"data-testid":"credit-history-btn",children:re?(0,U.jsx)(v.A,{className:"w-3 h-3 animate-spin"}):(0,U.jsx)($.A,{className:"w-3 h-3"})})]}),te&&(0,U.jsxs)("div",{className:"mt-2 p-2 bg-background rounded-lg max-h-[150px] overflow-y-auto",children:[(0,U.jsx)("p",{className:"text-xs font-medium mb-2",children:"Adjustment History:"}),0===te.length?(0,U.jsx)("p",{className:"text-xs text-muted-foreground",children:"No adjustments recorded"}):(0,U.jsx)("div",{className:"space-y-1",children:te.map((e,s)=>(0,U.jsxs)("div",{className:"text-xs p-1.5 border-b last:border-0",children:[(0,U.jsxs)("div",{className:"flex justify-between",children:[(0,U.jsxs)("span",{className:e.adjustment>0?"text-green-600":"text-red-600",children:[e.adjustment>0?"+":"",e.adjustment," credits"]}),(0,U.jsx)("span",{className:"text-muted-foreground",children:ge(e.timestamp)})]}),(0,U.jsxs)("div",{className:"text-muted-foreground",children:[e.reason," \u2022 by ",e.adjusted_by]})]},e.timestamp||`adj-${s}`))})]})]})]})]})]})]}),(0,U.jsxs)(d.Zp,{className:"border-border/50",children:[(0,U.jsxs)(d.aR,{children:[(0,U.jsxs)(d.ZB,{className:"flex items-center gap-2",children:[(0,U.jsx)(g.A,{className:"w-5 h-5 text-green-500"}),"System Health"]}),(0,U.jsx)(d.BT,{children:"Check if AI services and platform are operational"})]}),(0,U.jsxs)(d.Wu,{className:"space-y-4",children:[(0,U.jsx)(n.$,{onClick:async()=>{B(!0),L(null);try{const e=await l.A.get(`${r.nC}/admin/diagnostics/system-health`);L(e.data),"healthy"===e.data.status?i.oR.success("All systems operational"):"degraded"===e.data.status?i.oR.warning("Some systems are degraded"):i.oR.error("System health issues detected")}catch(t){var e,s;i.oR.error((null===(e=t.response)||void 0===e||null===(s=e.data)||void 0===s?void 0:s.detail)||"Failed to check system health")}finally{B(!1)}},disabled:Z,className:"w-full","data-testid":"check-health-btn",children:Z?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(v.A,{className:"w-4 h-4 mr-2 animate-spin"}),"Running Health Checks..."]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(S.A,{className:"w-4 h-4 mr-2"}),"Run System Health Check"]})}),P&&(0,U.jsxs)("div",{className:"mt-4 space-y-3","data-testid":"health-results",children:[(0,U.jsxs)("div",{className:"p-4 rounded-lg flex items-center justify-between "+("healthy"===P.status?"bg-green-100 border border-green-200":"degraded"===P.status?"bg-yellow-100 border border-yellow-200":"bg-red-100 border border-red-200"),children:[(0,U.jsxs)("div",{className:"flex items-center gap-2",children:[je(P.status),(0,U.jsx)("span",{className:"font-semibold",children:"Overall Status"})]}),(e=>{switch(e){case"healthy":return(0,U.jsx)(m.E,{className:"bg-green-100 text-green-700 border-green-200",children:"Healthy"});case"degraded":return(0,U.jsx)(m.E,{className:"bg-yellow-100 text-yellow-700 border-yellow-200",children:"Degraded"});case"unhealthy":return(0,U.jsx)(m.E,{className:"bg-red-100 text-red-700 border-red-200",children:"Unhealthy"});default:return(0,U.jsx)(m.E,{variant:"secondary",children:"Unknown"})}})(P.status)]}),(0,U.jsx)("div",{className:"space-y-2",children:Object.entries(P.checks).map(e=>{let[s,t]=e;return(0,U.jsxs)("div",{className:"flex items-start justify-between p-3 bg-muted/50 rounded-lg",children:[(0,U.jsxs)("div",{className:"flex items-start gap-2",children:["database"===s&&(0,U.jsx)(z.A,{className:"w-4 h-4 mt-0.5 text-muted-foreground"}),"ai_text_generation"===s&&(0,U.jsx)(M,{className:"w-4 h-4 mt-0.5 text-muted-foreground"}),"ai_image_generation"===s&&(0,U.jsx)(I.A,{className:"w-4 h-4 mt-0.5 text-muted-foreground"}),"llm_key_configured"===s&&(0,U.jsx)(A.A,{className:"w-4 h-4 mt-0.5 text-muted-foreground"}),"user_activity"===s&&(0,U.jsx)(y.A,{className:"w-4 h-4 mt-0.5 text-muted-foreground"}),!["database","ai_text_generation","ai_image_generation","llm_key_configured","user_activity"].includes(s)&&(0,U.jsx)(g.A,{className:"w-4 h-4 mt-0.5 text-muted-foreground"}),(0,U.jsxs)("div",{children:[(0,U.jsx)("p",{className:"font-medium text-sm capitalize",children:s.replace(/_/g," ")}),(0,U.jsx)("p",{className:"text-xs text-muted-foreground",children:t.message})]})]}),je(t.status)]},s)})}),(0,U.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Last checked: ",ge(P.timestamp)]})]})]})]})]}),(0,U.jsxs)(d.Zp,{className:"border-border/50",children:[(0,U.jsx)(d.aR,{children:(0,U.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,U.jsxs)("div",{className:"min-w-0",children:[(0,U.jsxs)(d.ZB,{className:"flex items-center gap-2",children:[(0,U.jsx)(z.A,{className:"w-5 h-5 text-purple-500"}),"Database Optimization"]}),(0,U.jsx)(d.BT,{children:"Check and create database indexes for faster query performance"})]}),(0,U.jsxs)("div",{className:"flex gap-2",children:[(0,U.jsx)(n.$,{onClick:ue,disabled:de,variant:"outline","data-testid":"check-indexes-btn",children:de?(0,U.jsx)(v.A,{className:"w-4 h-4 animate-spin"}):(0,U.jsx)(w.A,{className:"w-4 h-4"})}),(0,U.jsx)(n.$,{onClick:async()=>{me(!0);try{const e=await l.A.post(`${r.nC}/admin/diagnostics/create-indexes`);
2i.oR.success(`Indexes created for ${e.data.successful} collections`),e.data.results.errors.length>0&&i.oR.warning(`${e.data.results.errors.length} errors occurred`),ue()}catch(t){var e,s;i.oR.error((null===(e=t.response)||void 0===e||null===(s=e.data)||void 0===s?void 0:s.detail)||"Failed to create indexes")}finally{me(!1)}},disabled:oe,"data-testid":"create-indexes-btn",children:oe?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(v.A,{className:"w-4 h-4 mr-2 animate-spin"}),"Creating..."]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(k.A,{className:"w-4 h-4 mr-2"}),"Create Indexes"]})})]})]})}),(0,U.jsx)(d.Wu,{children:ie?(0,U.jsxs)("div",{className:"space-y-4",children:[(0,U.jsx)("div",{className:"p-4 rounded-lg "+(ie.summary.optimization_needed?"bg-yellow-100 border border-yellow-200":"bg-green-100 border border-green-200"),children:(0,U.jsxs)("div",{className:"flex items-center gap-2",children:[ie.summary.optimization_needed?(0,U.jsx)(j.A,{className:"w-5 h-5 text-yellow-600"}):(0,U.jsx)(u.A,{className:"w-5 h-5 text-green-600"}),(0,U.jsx)("span",{className:"font-semibold",children:ie.summary.optimization_needed?`${ie.summary.collections_needing_indexes.length} collections need indexing`:"All collections optimized"})]})}),(0,U.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2",children:Object.entries(ie.collections).map(e=>{let[s,t]=e;return(0,U.jsxs)("div",{className:"p-3 rounded-lg border "+(t.needs_optimization?"bg-yellow-50 border-yellow-200":"bg-muted/30 border-border/50"),children:[(0,U.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,U.jsx)("span",{className:"font-medium text-sm",children:s}),t.needs_optimization?(0,U.jsx)(m.E,{variant:"outline",className:"text-yellow-600 border-yellow-300",children:"Needs Index"}):(0,U.jsxs)(m.E,{variant:"outline",className:"text-green-600 border-green-300",children:[t.custom_indexes," indexes"]})]}),t.index_names&&t.index_names.length>0&&(0,U.jsxs)("p",{className:"text-xs text-muted-foreground truncate",children:[t.index_names.slice(0,2).join(", "),t.index_names.length>2&&` +${t.index_names.length-2} more`]})]},s)})}),(0,U.jsx)("p",{className:"text-xs text-muted-foreground",children:"Proper indexing can reduce query times from 60+ seconds to milliseconds."})]}):(0,U.jsx)("p",{className:"text-sm text-muted-foreground text-center py-4",children:'Click the search button to check index status, or "Create Indexes" to optimize your database.'})})]}),(0,U.jsxs)(d.Zp,{className:"border-border/50",children:[(0,U.jsx)(d.aR,{children:(0,U.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,U.jsxs)("div",{className:"min-w-0",children:[(0,U.jsxs)(d.ZB,{className:"flex items-center gap-2",children:[(0,U.jsx)(_.A,{className:"w-5 h-5 text-blue-500"}),"Recent Generations (All Users)"]}
2),(0,U.jsx)(d.BT,{children:"Monitor recent AI generation activity across the platform"})]}),(0,U.jsx)(n.$,{onClick:async()=>{W(!0);try{const e=await l.A.get(`${r.nC}/admin/diagnostics/recent-generations?limit=20`);H(e.data.recent_generations)}catch(t){var e,s;i.oR.error((null===(e=t.response)||void 0===e||null===(s=e.data)||void 0===s?void 0:s.detail)||"Failed to fetch recent generations")}finally{W(!1)}},disabled:O,variant:"outline","data-testid":"fetch-generations-btn",children:O?(0,U.jsx)(v.A,{className:"w-4 h-4 animate-spin"}):(0,U.jsx)(S.A,{className:"w-4 h-4"})})]})}),(0,U.jsx)(d.Wu,{children:G?(0,U.jsx)("div",{className:"space-y-2 max-h-[400px] overflow-y-auto",children:G.map((e,s)=>(0,U.jsxs)("div",{className:"flex items-center justify-between p-3 bg-muted/30 rounded-lg hover:bg-muted/50 transition-colors",children:[(0,U.jsxs)("div",{className:"flex items-center gap-3",children:[pe(e.type),(0,U.jsxs)("div",{children:[(0,U.jsx)("p",{className:"font-medium text-sm",children:e.title||"Untitled"}),(0,U.jsx)("p",{className:"text-xs text-muted-foreground",children:e.user_email})]})]}),(0,U.jsxs)("div",{className:"text-right",children:[(0,U.jsx)(m.E,{variant:"outline",className:"text-xs capitalize",children:e.type.replace("_"," ")}),(0,U.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:ge(e.created_at)})]})]},e.id||e.created_at||`rgen-${s}`))}):(0,U.jsxs)("div",{className:"text-center py-8 text-muted-foreground",children:[(0,U.jsx)(_.A,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),(0,U.jsx)("p",{children:"Click refresh to load recent generations"})]})})]}),(0,U.jsxs)(d.Zp,{className:"border-border/50 bg-muted/20",children:[(0,U.jsx)(d.aR,{children:(0,U.jsx)(d.ZB,{className:"text-lg",children:"Quick Diagnostic Guide"})}),(0,U.jsx)(d.Wu,{children:(0,U.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 text-sm",children:[(0,U.jsxs)("div",{className:"p-3 bg-background rounded-lg",children:[(0,U.jsx)("p",{className:"font-semibold text-red-600 mb-1",children:'User says "Tools are slow"'}),(0,U.jsxs)("ol",{className:"list-decimal list-inside text-muted-foreground space-y-1",children:[(0,U.jsx)("li",{children:"Check their credits above"}),(0,U.jsx)("li",{children:"If credits = 0, it's their issue"}),(0,U.jsx)("li",{children:"Run system health check"}),(0,U.jsx)("li",{children:"If AI unhealthy, check your Gemini API quota in GCP console"})]})]}),(0,U.jsxs)("div",{className:"p-3 bg-background rounded-lg",children:[(0,U.jsx)("p",{className:"font-semibold text-yellow-600 mb-1",children:'AI Text Generation "Degraded"'}),(0,U.jsxs)("ol",{className:"list-decimal list-inside text-muted-foreground space-y-1",children:[(0,U.jsx)("li",{children:"Go to Profile \u2192 Universal Key"}),(0,U.jsx)("li",{children:"Check your balance"}),(0,U.jsx)("li",{children:"Add balance or enable auto top-up"}),(0,U.jsx)("li",{children:"Re-run health check"})]})]}),(0,U.jsxs)("div",{className:"p-3 bg-background rounded-lg",children:[(0,U.jsx)("p",{className:"font-semibold text-green-600 mb-1",children:"All Systems Healthy"}),(0,U.jsxs)("ol",{className:"list-decimal list-inside text-muted-foreground space-y-1",children:[(0,U.jsx)("li",{children:"Issue is likely user-specific"}),(0,U.jsx)("li",{children:"Check their subscription tier"}),(0,U.jsx)("li",{children:"Ask them to try again"}),(0,U.jsx)("li",{children:"Check browser console for errors"})]})]})]})})]})]})})}},7978(e,s,t){t.d(s,{A:()=>a});const a=(0,t(7784).A)("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]])},4805(e,s,t){t.d(s,{A:()=>a});const a=(0,t(7784).A)("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]])}}]);
3//# sourceMappingURL=9461.5ad4f4a4.chunk.js.map

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.