PageSourceSearch

https://app.certsim.ai/static/js/4121.c320fc27.chunk.js

js certsim.ai collected 2026-10-05 14:28:47 UTC 119,451 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkcertification_sim_frontend=self.webpackChunkcertification_sim_frontend||[]).push([[4121],{54121(e,n,s){s.d(n,{CertificationQuestionsManager:()=>rn});var i=s(89379),t=s(80045),a=s(9950),o=s(27321),r=s(43711),l=s(6503),c=s(32284),d=s(38796),m=s(20900),u=s(35205),x=s(81415),p=s(91521),h=s(68272),A=s(39451),j=s(99562),g=s(4361),v=s(7356),f=s(13308),b=s(28493),_=s(21457),y=s(25269),w=s(87631),q=s(50943),C=s(33588),S=s(48767),I=s(39172),k=s(57559),z=s(71500),W=s(55859),P=s(84453),B=s(39872),E=s(65827),F=s(6732),D=s(55884),R=s(65250),Q=s(91651),T=s(87209),M=s(65812),L=s(56141),U=s(94837),O=s(47872),N=s(78044),V=s(41680),G=s(18643),H=s(29920),J=s(47371),K=s(22403),Y=s(45774),Z=s(55030),$=s(44414);const X=["children","value","index"];function ee(e){const{children:n,value:s,index:a}=e,r=(0,t.A)(e,X);return(0,$.jsx)("div",(0,i.A)((0,i.A)({role:"tabpanel",hidden:s!==a,id:"question-detail-tabpanel-".concat(a),"aria-labelledby":"question-detail-tab-".concat(a)},r),{},{children:s===a&&(0,$.jsx)(o.A,{sx:{pt:3},children:n})}))}const ne=e=>{let{open:n,onClose:s,question:t,certificationId:r,mode:h="view"}=e;const{t:A}=(0,Z.Bd)(),g="dark"===(0,v.A)().palette.mode,[f,b]=(0,a.useState)(0),[_,y]=(0,a.useState)(!1),[w,q]=(0,a.useState)([]),[C,S]=(0,a.useState)(!1),[I,k]=(0,a.useState)(!1),[W,P]=(0,a.useState)({question_text:"",option_a:"",option_b:"",option_c:"",option_d:"",correct_answer:"A",explanation:"",reference_url:"",domain:"",question_type:"single",is_active:!0,source:""});(0,a.useEffect)(()=>{var e;n&&t&&(y(!1),b(0),P({question_text:t.question_text||"",option_a:t.option_a||"",option_b:t.option_b||"",option_c:t.option_c||"",option_d:t.option_d||"",correct_answer:t.correct_answer||"A",explanation:t.explanation||"",reference_url:t.reference_url||"",domain:t.domain||"",question_type:t.question_type||"single",is_active:null===(e=t.is_active)||void 0===e||e,source:t.source||""}))},[n,t]),(0,a.useEffect)(()=>{n&&r&&B()},[n,r]);const B=async()=>{try{S(!0);const e=await j.t.getDomains(r);q(e.domains)}catch(e){console.error("Error loading domains:",e)}finally{S(!1)}};if(!t)return null;const X=(e,n)=>{P((0,i.A)((0,i.A)({},W),{},{[e]:n}))},ne=()=>{s()};return(0,$.jsxs)(E.A,{open:n,onClose:(e,n)=>{"backdropClick"===n&&_||ne()},maxWidth:"lg",fullWidth:!0,PaperProps:{sx:{height:"90vh",maxHeight:"90vh"}},children:[(0,$.jsx)(F.A,{sx:{pb:1},children:(0,$.jsxs)(o.A,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,$.jsxs)(o.A,{children:[(0,$.jsxs)(m.A,{variant:"h6",fontWeight:700,children:[A("admin.questions.questionText")," #",t.id]}),(0,$.jsxs)(o.A,{sx:{display:"flex",gap:1,mt:1},children:[(0,$.jsx)(p.A,{label:"single"===t.question_type?A("admin.questions.singleChoice"):A("admin.questions.multipleChoice"),size:"small",color:"multiple"===t.question_type?"secondary":"default"}),(0,$.jsx)(p.A,{label:t.is_active?A("admin.questions.active"):A("admin.questions.inactive"),size:"small",color:t.is_active?"success":"default"}),(0,$.jsx)(p.A,{label:t.domain,size:"small",variant:"outlined"}),t.difficulty&&(0,$.jsx)(p.A,{label:"".concat(A("admin.modal.difficulty"),": ").concat(t.difficulty),size:"small",color:"info",variant:"outlined"})]})]}),(0,$.jsx)(z.A,{onClick:ne,children:(0,$.jsx)(Y.A,{})})]})}),(0,$.jsx)(D.A,{}),(0,$.jsx)(o.A,{sx:{borderBottom:1,borderColor:"divider",px:3},children:(0,$.jsxs)(u.A,{value:f,onChange:(e,n)=>{b(n)},children:[(0,$.jsx)(x.A,{label:A("admin.modal.details")}),(0,$.jsx)(x.A,{label:A("admin.modal.translations")}),(0,$.jsx)(x.A,{label:A("admin.modal.history")}),(0,$.jsx)(x.A,{label:A("admin.modal.analytics")})]})}),(0,$.jsxs)(R.A,{sx:{overflow:"auto"},children:[(0,$.jsx)(ee,{value:f,index:0,children:(0,$.jsxs)(o.A,{sx:{display:"flex",flexDirection:"column",gap:3},children:[(0,$.jsxs)(d.A,{elevation:1,sx:{p:2,bgcolor:g?"rgba(255,255,255,0.04)":"grey.50"},children:[(0,$.jsxs)(m.A,{variant:"subtitle2",fontWeight:700,gutterBottom:!0,color:"primary",children:["\ud83d\udcdd ",A("admin.modal.question")]}),(0,$.jsx)(Q.A,{multiline:!0,rows:4,fullWidth:!0,value:W.question_text,onChange:e=>X("question_text",e.target.value),disabled:!_,variant:_?"outlined":"filled",placeholder:"Enter question text..."})]}),(0,$.jsxs)(d.A,{elevation:1,sx:{p:2,bgcolor:g?"rgba(255,255,255,0.04)":"grey.50"},children:[(0,$.jsxs)(m.A,{variant:"subtitle2",fontWeight:700,gutterBottom:!0,color:"primary",children:["\ud83d\udccb ",A("admin.modal.answerOptions")]}),(0,$.jsxs)(o.A,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",md:"1fr 1fr"},gap:2},children:[(0,$.jsx)(Q.A,{label:A("admin.modal.optionA"),multiline:!0,rows:3,fullWidth:!0,value:W.option_a,onChange:e=>X("option_a",e.target.value),disabled:!_,variant:_?"outlined":"filled",InputProps:{startAdornment:(0,$.jsx)(m.A,{sx:{fontWeight:700,mr:1,color:W.correct_answer.includes("A")?"success.main":"text.secondary"},children:"A)"})}}),(0,$.jsx)(Q.A,{label:A("admin.modal.optionB"),multiline:!0,rows:3,fullWidth:!0,value:W.option_b,onChange:e=>X("option_b",e.target.value),disabled:!_,variant:_?"outlined":"filled",InputProps:{startAdornment:(0,$.jsx)(m.A,{sx:{fontWeight:700,mr:1,color:W.correct_answer.includes("B")?"success.main":"text.secondary"},children:"B)"})}}),(0,$.jsx)(Q.A,{label:A("admin.modal.optionC"),multiline:!0,rows:3,fullWidth:!0,value:W.option_c,onChange:e=>X("option_c",e.target.value),disabled:!_,variant:_?"outlined":"filled",InputProps:{startAdornment:(0,$.jsx)(m.A,{sx:{fontWeight:700,mr:1,color:W.correct_answer.includes("C")?"success.main":"text.secondary"},children:"C)"})}}),(0,$.jsx)(Q.A,{label:A("admin.modal.optionD"),multiline:!0,rows:3,fullWidth:!0,value:W.option_d,onChange:e=>X("option_d",e.target.value),disabled:!_,variant:_?"outlined":"filled",InputProps:{startAdornment:(0,$.jsx)(m.A,{sx:{fontWeight:700,mr:1,color:W.correct_answer.includes("D")?"success.main":"text.secondary"},children:"D)"})}})]}),(0,$.jsxs)(o.A,{sx:{mt:2,p:2,bgcolor:g?"rgba(76, 175, 80, 0.2)":"rgba(76, 175, 80, 0.1)",borderRadius:1,border:"1px solid",borderColor:"success.main"},children:[(0,$.jsxs)(m.A,{variant:"subtitle2",fontWeight:700,color:"success.dark",gutterBottom:!0,children:["\u2705 ",A("admin.modal.correctAnswer"),": ",(se=W.correct_answer,{A:"".concat(A("admin.modal.optionA")),B:"".concat(A("admin.modal.optionB")),C:"".concat(A("admin.modal.optionC")),D:"".concat(A("admin.modal.optionD")),AB:"".concat(A("admin.modal.optionA")," and ").concat(A("admin.modal.optionB")),AC:"".concat(A("admin.modal.optionA")," and ").concat(A("admin.modal.optionC")),AD:"".concat(A("admin.modal.optionA")," and ").concat(A("admin.modal.optionD")),BC:"".concat(A("admin.modal.optionB")," and ").concat(A("admin.modal.optionC")),BD:"".concat(A("admin.modal.optionB")," and ").concat(A("admin.modal.optionD")),CD:"".concat(A("admin.modal.optionC")," and ").concat(A("admin.modal.optionD")),ABC:"".concat(A("admin.modal.optionA"),", ").concat(A("admin.modal.optionB")," and ").concat(A("admin.modal.optionC")),ABD:"".concat(A("admin.modal.optionA"),", ").concat(A("admin.modal.optionB")," and ").concat(A("admin.modal.optionD")),ACD:"".concat(A("admin.modal.optionA"),", ").concat(A("admin.modal.optionC")," and ").concat(A("admin.modal.optionD")),BCD:"".concat(A("admin.modal.optionB"),", ").concat(A("admin.modal.optionC")," and ").concat(A("admin.modal.optionD")),ABCD:"All options"}[se]||se)]}),_&&(0,$.jsx)(Q.A,{label:A("admin.modal.correctAnswer"),size:"small",value:W.correct_answer,onChange:e=>X("correct_answer",e.target.value.toUpperCase()),helperText:A("admin.modal.correctAnswerHelper"),sx:{mt:1,bgcolor:"background.paper"}})]})]}),(0,$.jsxs)(d.A,{elevation:1,sx:{p:2,bgcolor:g?"rgba(255,255,255,0.04)":"grey.50"},children:[(0,$.jsxs)(m.A,{variant:"subtitle2",fontWeight:700,gutterBottom:!0,color:"primary",children:["\ud83d\udca1 ",A("admin.modal.explanationAndReference")]}),(0,$.jsx)(Q.A,{label:A("admin.modal.explanation"),multiline:!0,rows:4,fullWidth:!0,value:W.explanation,onChange:e=>X("explanation",e.target.value),disabled:!_,variant:_?"outlined":"filled",placeholder:"Explain why this is the correct answer...",sx:{mb:2}}),(0,$.jsx)(Q.A,{label:A("admin.modal.reference"),fullWidth:!0,value:W.reference_url,onChange:e=>X("reference_url",e.target.value),disabled:!_,variant:_?"outlined":"filled",placeholder:"https://...",helperText:A("admin.modal.referenceHelper")})]}),(0,$.jsxs)(d.A,{elevation:1,sx:{p:2,bgcolor:g?"rgba(255,255,255,0.04)":"grey.50"},children:[(0,$.jsxs)(m.A,{variant:"subtitle2",fontWeight:700,gutterBottom:!0,color:"primary",children:["\u2699\ufe0f ",A("admin.modal.classification")]}),(0,$.jsxs)(o.A,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",md:"1fr 1fr"},gap:2},children:[(0,$.jsxs)(T.A,{fullWidth:!0,disabled:!_||C,children:[(0,$.jsx)(M.A,{children:A("admin.questions.domain")}),(0,$.jsx)(L.A,{value:W.domain,onChange:e=>X("domain",e.target.value),label:A("admin.questions.domain"),variant:_?"outlined":"filled",children:w.map(e=>(0,$.jsxs)(U.A,{value:e.domain,children:[e.domain," (",e.total_questions," questions)"]},e.domain))})]}),(0,$.jsx)(o.A,{children:(0,$.jsxs)(T.A,{component:"fieldset",disabled:!_,fullWidth:!0,children:[(0,$.jsx)(O.A,{component:"legend",children:A("admin.modal.questionType")}
1),(0,$.jsxs)(N.A,{row:!0,value:W.question_type,onChange:e=>X("question_type",e.target.value),children:[(0,$.jsx)(V.A,{value:"single",control:(0,$.jsx)(G.A,{}),label:A("admin.questions.singleChoice")}),(0,$.jsx)(V.A,{value:"multiple",control:(0,$.jsx)(G.A,{}),label:A("admin.questions.multipleChoice")})]})]})}),(0,$.jsx)(Q.A,{label:A("admin.modal.source"),fullWidth:!0,value:W.source,onChange:e=>X("source",e.target.value),disabled:!_,variant:_?"outlined":"filled",helperText:A("admin.modal.sourceHelper")}),(0,$.jsx)(Q.A,{label:A("admin.modal.difficulty"),fullWidth:!0,value:t.difficulty||"Not calculated yet",disabled:!0,variant:"filled",helperText:A("admin.modal.difficultyAuto")})]}),(0,$.jsx)(V.A,{control:(0,$.jsx)(H.A,{checked:W.is_active,onChange:e=>X("is_active",e.target.checked),disabled:!_}),label:A("admin.modal.activeStatus"),sx:{mt:1}})]}),(0,$.jsxs)(d.A,{elevation:1,sx:{p:2,bgcolor:g?"rgba(255,255,255,0.04)":"grey.50"},children:[(0,$.jsxs)(m.A,{variant:"subtitle2",fontWeight:700,gutterBottom:!0,color:"primary",children:["\ud83d\udcca ",A("admin.modal.statistics")]}),(0,$.jsxs)(o.A,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr 1fr",md:"repeat(4, 1fr)"},gap:2},children:[(0,$.jsx)(Q.A,{label:A("admin.modal.upvotes"),type:"number",value:t.upvotes,disabled:!0,variant:"filled",fullWidth:!0}),(0,$.jsx)(Q.A,{label:A("admin.modal.downvotes"),type:"number",value:t.downvotes,disabled:!0,variant:"filled",fullWidth:!0}),(0,$.jsx)(Q.A,{label:A("admin.modal.netScore"),type:"number",value:t.upvotes-t.downvotes,disabled:!0,variant:"filled",fullWidth:!0}),(0,$.jsx)(Q.A,{label:A("admin.modal.totalVotes"),type:"number",value:t.upvotes+t.downvotes,disabled:!0,variant:"filled",fullWidth:!0})]})]}),t.review_status&&(0,$.jsxs)(c.A,{severity:"warning",children:["Review Status: ",t.review_status]})]})}),(0,$.jsx)(ee,{value:f,index:1,children:(0,$.jsx)(c.A,{severity:"info",children:A("admin.modal.comingSoon")})}),(0,$.jsx)(ee,{value:f,index:2,children:(0,$.jsx)(c.A,{severity:"info",children:A("admin.modal.comingSoon")})}),(0,$.jsx)(ee,{value:f,index:3,children:(0,$.jsx)(c.A,{severity:"info",children:A("admin.modal.comingSoon")})})]}),(0,$.jsx)(D.A,{}),(0,$.jsx)(J.A,{sx:{px:3,py:2},children:_?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K.A,{onClick:()=>{y(!1),s()},disabled:I,children:A("admin.modal.cancel")}),(0,$.jsx)(K.A,{onClick:()=>{var e;t&&P({question_text:t.question_text||"",option_a:t.option_a||"",option_b:t.option_b||"",option_c:t.option_c||"",option_d:t.option_d||"",correct_answer:t.correct_answer||"A",explanation:t.explanation||"",reference_url:t.reference_url||"",domain:t.domain||"",question_type:t.question_type||"single",is_active:null===(e=t.is_active)||void 0===e||e,source:t.source||""});y(!1)},disabled:I,children:A("admin.modal.discardChanges")}),(0,$.jsx)(K.A,{variant:"contained",onClick:async()=>{if(t)try{k(!0),await j.t.updateQuestion(t.id,W),console.log("Question updated successfully:",t.id),y(!1),s(!0)}catch(e){console.error("Error saving question:",e),alert("Error saving question. Please try again.")}finally{k(!1)}},disabled:I,startIcon:I?(0,$.jsx)(l.A,{size:16}):null,children:A(I?"admin.modal.saving":"admin.modal.saveChanges")})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K.A,{onClick:ne,disabled:I,children:A("admin.modal.close")}),(0,$.jsx)(K.A,{variant:"contained",onClick:()=>y(!0),disabled:I,children:A("admin.modal.edit")})]})})]});var se};var se=s(51673);const ie=e=>{let{certificationId:n}=e;const s="dark"===(0,v.A)().palette.mode,[t,r]=(0,a.useState)([]),[u,x]=(0,a.useState)(!0),[h,A]=(0,a.useState)(null),[g,E]=(0,a.useState)(null),[F,D]=(0,a.useState)({}),[R,Q]=(0,a.useState)({}),[T,M]=(0,a.useState)({}),[L,U]=(0,a.useState)({}),[O,N]=(0,a.useState)(null),[V,G]=(0,a.useState)(!1),[H,J]=(0,a.useState)("view"),K=(0,a.useCallback)(async()=>{try{x(!0),A(null);const e=await j.t.getDomains(n);r(e.domains),se.A.info("[ByDomainTab] Loaded domains:",e.domains)}catch(e){se.A.error("[ByDomainTab] Error loading domains:",e),A(e.message||"Failed to load domains")}finally{x(!1)}},[n]);(0,a.useEffect)(()=>{K()},[K]);const Y=async(e,s)=>{try{U((0,i.A)((0,i.A)({},L),{},{[e]:!0}));const t=await j.t.getQuestions(n,{domain:e,page:s,limit:10});D((0,i.A)((0,i.A)({},F),{},{[e]:t.questions})),Q((0,i.A)((0,i.A)({},R),{},{[e]:s})),M((0,i.A)((0,i.A)({},T),{},{[e]:t.pagination.total}
1)),se.A.info("[ByDomainTab] Loaded questions for ".concat(e,":"),t.questions)}catch(t){se.A.error("[ByDomainTab] Error loading questions for ".concat(e,":"),t)}finally{U((0,i.A)((0,i.A)({},L),{},{[e]:!1}))}};return u?(0,$.jsx)(o.A,{sx:{display:"flex",justifyContent:"center",p:4},children:(0,$.jsx)(l.A,{})}):h?(0,$.jsx)(c.A,{severity:"error",children:h}):0===t.length?(0,$.jsx)(c.A,{severity:"info",children:"No domains found for this certification. Add questions to see domains here."}):(0,$.jsxs)(o.A,{children:[(0,$.jsx)(m.A,{variant:"body1",color:"text.secondary",sx:{mb:3},children:"Questions organized by domain. Expand each domain to view and manage its questions."}),t.map(e=>(0,$.jsxs)(f.A,{expanded:g===e.domain,onChange:()=>(async e=>{const n=g!==e;E(n?e:null),n&&!F[e]&&await Y(e,1)})(e.domain),sx:{mb:2,"&:before":{display:"none"}},children:[(0,$.jsx)(b.A,{expandIcon:(0,$.jsx)(P.A,{}),sx:{bgcolor:s?"rgba(102, 126, 234, 0.15)":"rgba(102, 126, 234, 0.05)","&:hover":{bgcolor:s?"rgba(102, 126, 234, 0.22)":"rgba(102, 126, 234, 0.1)"}},children:(0,$.jsxs)(o.A,{sx:{display:"flex",alignItems:"center",gap:2,width:"100%",pr:2},children:[(0,$.jsx)(m.A,{variant:"h6",sx:{flexGrow:1},children:e.domain}),(0,$.jsxs)(o.A,{sx:{display:"flex",gap:1,flexWrap:"wrap"},children:[(0,$.jsx)(p.A,{label:"".concat(e.total_questions," total"),size:"small",variant:"outlined"}),(0,$.jsx)(p.A,{label:"".concat(e.active_questions," active"),size:"small",color:"success"}),(0,$.jsx)(p.A,{label:"".concat(e.inactive_questions," inactive"),size:"small",color:"default"}),e.pending_review>0&&(0,$.jsx)(p.A,{label:"".concat(e.pending_review," pending"),size:"small",color:"warning"})]})]})}),(0,$.jsx)(_.A,{children:L[e.domain]?(0,$.jsx)(o.A,{sx:{display:"flex",justifyContent:"center",p:4},children:(0,$.jsx)(l.A,{size:24})}):F[e.domain]&&F[e.domain].length>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(y.A,{component:d.A,variant:"outlined",sx:{bgcolor:"background.paper"},children:(0,$.jsxs)(w.A,{size:"small",children:[(0,$.jsx)(q.A,{children:(0,$.jsxs)(C.A,{children:[(0,$.jsx)(S.A,{children:"ID"}),(0,$.jsx)(S.A,{children:"Question"}),(0,$.jsx)(S.A,{align:"center",children:"Type"}),(0,$.jsx)(S.A,{align:"center",children:"Status"}),(0,$.jsx)(S.A,{align:"center",children:"Votes"}),(0,$.jsx)(S.A,{align:"right",children:"Actions"})]})}),(0,$.jsx)(I.A,{children:F[e.domain].map(e=>(0,$.jsxs)(C.A,{hover:!0,children:[(0,$.jsx)(S.A,{children:e.id}),(0,$.jsx)(S.A,{children:(0,$.jsx)(m.A,{variant:"body2",noWrap:!0,sx:{maxWidth:400},children:e.question_text})}),(0,$.jsx)(S.A,{align:"center",children:(0,$.jsx)(p.A,{label:e.question_type,size:"small",color:"multiple"===e.question_type?"secondary":"default"})}),(0,$.jsx)(S.A,{align:"center",children:(0,$.jsx)(p.A,{label:e.is_active?"Active":"Inactive",size:"small",color:e.is_active?"success":"default"})}),(0,$.jsx)(S.A,{align:"center",children:(0,$.jsxs)(o.A,{sx:{display:"flex",gap:.5,justifyContent:"center"},children:[(0,$.jsx)(p.A,{label:"\ud83d\udc4d ".concat(e.upvotes),size:"small"}),(0,$.jsx)(p.A,{label:"\ud83d\udc4e ".concat(e.downvotes),size:"small"})]})}),(0,$.jsx)(S.A,{align:"right",children:(0,$.jsx)(k.A,{title:"View Details",children:(0,$.jsx)(z.A,{size:"small",color:"primary",onClick:()=>(e=>{N(e),J("view"),G(!0)})(e),children:(0,$.jsx)(B.A,{fontSize:"small"})})})})]},e.id))})]})}),(0,$.jsx)(W.A,{component:"div",count:T[e.domain]||0,page:(R[e.domain]||1)-1,onPageChange:(n,s)=>((e,n)=>{Y(e,n+1)})(e.domain,s),rowsPerPage:10,rowsPerPageOptions:[10]})]}):(0,$.jsx)(c.A,{severity:"info",children:"No questions found for this domain."})})]},e.domain)),(0,$.jsx)(ne,{open:V,onClose:function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];G(!1),N(null),e&&g&&Y(g,R[g]||0)},question:O,certificationId:n,mode:H})]})};var te=s(85105),ae=s(72990),oe=s(30447);const re=e=>{let{certificationId:n}=e;const{t:s}=(0,Z.Bd)(),i="dark"===(0,v.A)().palette.mode,[t,r]=(0,a.useState)([]),[u,x]=(0,a.useState)(!1),[h,A]=(0,a.useState)(null),[g,f]=(0,a.useState)(0),[b,_]=(0,a.useState)(25),[P,E]=(0,a.useState)(0),[F,D]=(0,a.useState)([]),[R,O]=(0,a.useState)(!1),[N,V]=(0,a.useState)(""),[G,H]=(0,a.useState)(""),[J,Y]=(0,a.useState)(""),[X,ee]=(0,a.useState)(""),[se,ie]=(0,a.useState)(""),[re,le]=(0,a.useState)(null),[ce,de]=(0,a.useState)(!1),[me,ue]=(0,a.useState)("view"),xe=(0,a.useCallback)(async()=>{try{x(!0),A(null);const e={page:g+1,limit:b};N&&(e.domain=N),G&&(e.type=G),J&&(e.status=J),X&&(e.source=X),se&&(e.search=se);const s=await j.t.getQuestions(n,e);r(s.questions),E(s.pagination.total)}catch(e){A(e.message||s("admin.questions.error")),console.error("Error loading questions:",e)}finally{x(!1)}},[n,g,b,N,G,J,X,se,s]);(0,a.useEffect)(()=>{xe()},[xe]),(0,a.useEffect)(()=>{(async()=>{try{O(!0);const e=(await j.t.getDomains(n)).domains.map(e=>e.domain);D(e)}catch(e){console.error("Error loading domains:",e)}finally{O(!1)}})()},[n]);const pe=e=>{le(e),ue("view"),de(!0)},he=N||G||J||X||se,Ae=function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100;return e.length<=n?e:e.substring(0,n)+"..."};return(0,$.jsxs)(o.A,{children:[(0,$.jsxs)(d.A,{elevation:2,sx:{p:3,mb:3,bgcolor:"background.paper"},children:[(0,$.jsxs)(o.A,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:2},children:[(0,$.jsxs)(o.A,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,$.jsx)(ae.A,{color:"primary"}),(0,$.jsx)(m.A,{variant:"h6",fontWeight:700,children:s("admin.questions.filters")})]}),he&&(0,$.jsx)(K.A,{variant:"outlined",size:"small",startIcon:(0,$.jsx)(oe.A,{}),onClick:()=>{V(""),H(""),Y(""),ee(""),ie(""),f(0)},children:s("admin.questions.clearFilters")})]}),(0,$.jsxs)(te.A,{direction:{xs:"column",md:"row"},spacing:2,children:[(0,$.jsx)(Q.A,{label:s("admin.questions.searchPlaceholder"),variant:"outlined",size:"small",fullWidth:!0,value:se,onChange:e=>{ie(e.target.value),f(0)},placeholder:s("admin.questions.searchPlaceholder")}),(0,$.jsxs)(T.A,{size:"small",sx:{minWidth:200},children:[(0,$.jsx)(M.A,{children:s("admin.questions.domainFilter")}),(0,$.jsxs)(L.A,{value:N,onChange:e=>{V(e.target.value),f(0)},label:s("admin.questions.domainFilter"),disabled:R,children:[(0,$.jsx)(U.A,{value:"",children:s("admin.questions.allDomains")}),F.map(e=>(0,$.jsx)(U.A,{value:e,children:e},e))]})]}),(0,$.jsxs)(T.A,{size:"small",sx:{minWidth:150},children:[(0,$.jsx)(M.A,{children:s("admin.questions.typeFilter")}),(0,$.jsxs)(L.A,{value:G,onChange:e=>{H(e.target.value),f(0)},label:s("admin.questions.typeFilter"),children:[(0,$.jsx)(U.A,{value:"",children:s("admin.questions.allTypes")}),(0,$.jsx)(U.A,{value:"single",children:s("admin.questions.singleChoice")}),(0,$.jsx)(U.A,{value:"multiple",children:s("admin.questions.multipleChoice")})]})]}),(0,$.jsxs)(T.A,{size:"small",sx:{minWidth:150},children:[(0,$.jsx)(M.A,{children:s("admin.questions.statusFilter")}),(0,$.jsxs)(L.A,{value:J,onChange:e=>{Y(e.target.value),f(0)},label:s("admin.questions.statusFilter"),children:[(0,$.jsx)(U.A,{value:"",children:s("admin.questions.allStatus")}),(0,$.jsx)(U.A,{value:"active",children:s("admin.questions.active")}),(0,$.jsx)(U.A,{value:"inactive",children:s("admin.questions.inactive")}),(0,$.jsx)(U.A,{value:"pending",children:s("admin.questions.pendingReview")})]})]}),(0,$.jsxs)(T.A,{size:"small",sx:{minWidth:160},children:[(0,$.jsx)(M.A,{children:s("admin.questions.sourceFilter")}),(0,$.jsxs)(L.A,{value:X,onChange:e=>{ee(e.target.value),f(0)},label:s("admin.questions.sourceFilter"),children:[(0,$.jsx)(U.A,{value:"",children:s("admin.questions.allSources")}),(0,$.jsx)(U.A,{value:"admin_udemybased",children:s("admin.questions.bulkImportSource")})]})]})]}),he&&(0,$.jsxs)(o.A,{sx:{mt:2,display:"flex",gap:1,flexWrap:"wrap"},children:[se&&(0,$.jsx)(p.A,{label:"".concat(s("admin.questions.searchPlaceholder"),': "').concat(se,'"'),size:"small",onDelete:()=>ie("")}
1),N&&(0,$.jsx)(p.A,{label:"".concat(s("admin.questions.domainFilter"),": ").concat(N),size:"small",onDelete:()=>V("")}),G&&(0,$.jsx)(p.A,{label:"".concat(s("admin.questions.typeFilter"),": ").concat(s("single"===G?"admin.questions.singleChoice":"admin.questions.multipleChoice")),size:"small",onDelete:()=>H("")}),J&&(0,$.jsx)(p.A,{label:"".concat(s("admin.questions.statusFilter"),": ").concat(s("active"===J?"admin.questions.active":"inactive"===J?"admin.questions.inactive":"admin.questions.pendingReview")),size:"small",onDelete:()=>Y("")}),X&&(0,$.jsx)(p.A,{label:"".concat(s("admin.questions.sourceFilter"),": ").concat(s("admin.questions.bulkImportSource")),size:"small",onDelete:()=>ee("")})]})]}),(0,$.jsx)(d.A,{elevation:2,sx:{bgcolor:"background.paper"},children:u?(0,$.jsxs)(o.A,{sx:{display:"flex",justifyContent:"center",p:4},children:[(0,$.jsx)(l.A,{}),(0,$.jsx)(m.A,{sx:{ml:2},children:s("admin.questions.loading")})]}):h?(0,$.jsx)(c.A,{severity:"error",sx:{m:2},children:h}):0===t.length?(0,$.jsx)(c.A,{severity:"info",sx:{m:2},children:s("admin.questions.noQuestionsFound")}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(y.A,{children:(0,$.jsxs)(w.A,{children:[(0,$.jsx)(q.A,{children:(0,$.jsxs)(C.A,{sx:{bgcolor:"primary.main"},children:[(0,$.jsx)(S.A,{sx:{color:"white",fontWeight:700,width:"80px"},children:s("admin.questions.questionId")}),(0,$.jsx)(S.A,{sx:{color:"white",fontWeight:700},children:s("admin.questions.questionText")}),(0,$.jsx)(S.A,{sx:{color:"white",fontWeight:700,width:"200px"},children:s("admin.questions.domain")}),(0,$.jsx)(S.A,{sx:{color:"white",fontWeight:700,width:"120px"},children:s("admin.questions.type")}),(0,$.jsx)(S.A,{sx:{color:"white",fontWeight:700,width:"100px"},children:s("admin.questions.status")}),(0,$.jsx)(S.A,{sx:{color:"white",fontWeight:700,width:"140px"},children:s("admin.questions.votes")}),(0,$.jsx)(S.A,{sx:{color:"white",fontWeight:700,width:"120px"},children:s("admin.questions.actions")})]})}),(0,$.jsx)(I.A,{children:t.map(e=>(0,$.jsxs)(C.A,{hover:!0,sx:{"&:nth-of-type(odd)":{bgcolor:i?"rgba(255,255,255,0.04)":"grey.50"},opacity:e.is_active?1:.6,cursor:"pointer"},onClick:()=>pe(e),children:[(0,$.jsx)(S.A,{children:(0,$.jsxs)(m.A,{variant:"body2",fontWeight:600,children:["#",e.id]})}),(0,$.jsxs)(S.A,{children:[(0,$.jsx)(m.A,{variant:"body2",children:Ae(e.question_text,120)}),e.review_status&&(0,$.jsx)(p.A,{label:e.review_status,size:"small",color:"warning",sx:{mt:.5}})]}),(0,$.jsx)(S.A,{children:(0,$.jsx)(p.A,{label:e.domain,size:"small",variant:"outlined"})}),(0,$.jsx)(S.A,{children:(0,$.jsx)(p.A,{label:"single"===e.question_type?s("admin.questions.singleChoice"):s("admin.questions.multipleChoice"),size:"small",color:"multiple"===e.question_type?"secondary":"default"})}),(0,$.jsx)(S.A,{children:(0,$.jsx)(p.A,{label:e.is_active?s("admin.questions.active"):s("admin.questions.inactive"),size:"small",color:e.is_active?"success":"default"})}),(0,$.jsx)(S.A,{children:(0,$.jsxs)(o.A,{sx:{display:"flex",gap:.5,flexDirection:"column"},children:[(0,$.jsx)(p.A,{label:"\ud83d\udc4d ".concat(e.upvotes),size:"small",color:"success",variant:"outlined",sx:{fontSize:"0.75rem"}}),(0,$.jsx)(p.A,{label:"\ud83d\udc4e ".concat(e.downvotes),size:"small",color:"error",variant:"outlined",sx:{fontSize:"0.75rem"}})]})}),(0,$.jsx)(S.A,{onClick:e=>e.stopPropagation(),children:(0,$.jsx)(k.A,{title:s("admin.questions.viewDetails"),children:(0,$.jsx)(z.A,{size:"small",color:"primary",onClick:()=>pe(e),children:(0,$.jsx)(B.A,{fontSize:"small"})})})})]},e.id))})]})}),(0,$.jsx)(W.A,{component:"div",count:P,page:g,onPageChange:(e,n)=>{f(n)},rowsPerPage:b,onRowsPerPageChange:e=>{_(parseInt(e.target.value,10)),f(0)},rowsPerPageOptions:[10,25,50,100],labelRowsPerPage:s("admin.questions.questionsPerPage")})]})}),(0,$.jsx)(ne,{open:ce,onClose:function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];de(!1),le(null),e&&xe()},question:re,certificationId:n,mode:me})]})};var le=s(55547),ce=s(52036),de=s(89470),me=s(93570),ue=s(20980);const xe=e=>{let{certificationId:n}=e;const{t:s}=(0,Z.Bd)(),i="dark"===(0,v.A)().palette.mode,[t,r]=(0,a.useState)([]),[u,x]=(0,a.useState)(!1),[h,A]=(0,a.useState)(null),[g,f]=(0,a.useState)(0),[b,_]=(0,a.useState)(10),[y,w]=(0,a.useState)(0),[q,C]=(0,a.useState)({open:!1,action:null,questionId:null}),S=async()=>{try{x(!0),A(null);const e=await j.t.getPendingReviewQuestions(n,g+1,b);r(e.questions),w(e.pagination.total)}catch(e){A(e.message||s("admin.questions.error")),console.error("Error loading pending review questions:",e)}finally{x(!1)}};(0,a.useEffect)(()=>{S()},[n,g,b]);const I=()=>{C({open:!1,action:null,questionId:null})};return u&&0===t.length?(0,$.jsxs)(o.A,{sx:{display:"flex",justifyContent:"center",p:4},children:[(0,$.jsx)(l.A,{}),(0,$.jsx)(m.A,{sx:{ml:2},children:s("admin.questions.loading")})]}):h?(0,$.jsx)(c.A,{severity:"error",sx:{m:2},children:h}):0===t.length?(0,$.jsx)(c.A,{severity:"info",sx:{m:2},children:s("admin.pendingReview.noQuestions")}):(0,$.jsxs)(o.A,{children:[(0,$.jsx)(c.A,{severity:"info",sx:{mb:3},children:s("admin.pendingReview.description")}),t.map(e=>{return(0,$.jsxs)(d.A,{elevation:3,sx:{mb:3,p:3,bgcolor:"background.paper"},children:[(0,$.jsxs)(o.A,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[(0,$.jsx)(m.A,{variant:"h6",fontWeight:700,children:s("admin.pendingReview.questionId",{id:e.id})}),(0,$.jsxs)(o.A,{sx:{display:"flex",gap:1},children:[(0,$.jsx)(p.A,{label:e.domain,size:"small",variant:"outlined"}),(0,$.jsx)(p.A,{label:"single"===e.question_type?s("admin.questions.singleChoice"):s("admin.questions.multipleChoice"),size:"small",color:"multiple"===e.question_type?"secondary":"default"})]})]}),(0,$.jsx)(D.A,{sx:{mb:2}}),(0,$.jsx)(le.A,{variant:"outlined",sx:{mb:2,bgcolor:i?"rgba(255,255,255,0.04)":"grey.50"},children:(0,$.jsxs)(ce.A,{children:[(0,$.jsx)(m.A,{variant:"subtitle2",color:"primary",fontWeight:700,gutterBottom:!0,children:s("admin.pendingReview.newQuestion")}),(0,$.jsx)(m.A,{variant:"body1",sx:{mb:2},children:e.question_text}),(0,$.jsx)(o.A,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:1,mb:2},children:["option_a","option_b","option_c","option_d"].map(n=>{const s=n,t=n.split("_")[1].toUpperCase(),a=e.correct_answer===t;return(0,$.jsx)(o.A,{sx:{p:1,border:"1px solid",borderColor:a?"success.main":"divider",borderRadius:1,bgcolor:a?i?"rgba(76, 175, 80, 0.2)":"rgba(76, 175, 80, 0.1)":"background.paper"},children:(0,$.jsxs)(m.A,{variant:"body2",fontWeight:a?700:400,children:[t,". ",e[s]]})},n)})}),(0,$.jsxs)(m.A,{variant:"body2",color:"text.secondary",children:[(0,$.jsxs)("strong",{children:[s("admin.modal.correctAnswer"),":"]})," ",(n=e.correct_answer,{A:s("admin.modal.optionA"),B:s("admin.modal.optionB"),C:s("admin.modal.optionC"),D:s("admin.modal.optionD")}[n]||n)]}),e.explanation&&(0,$.jsxs)(m.A,{variant:"body2",color:"text.secondary",sx:{mt:1},children:[(0,$.jsxs)("strong",{children:[s("admin.modal.explanation"),":"]})," ",e.explanation]})]})}),e.similar_questions.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(m.A,{variant:"subtitle1",fontWeight:700,gutterBottom:!0,children:e.similar_questions.some(e=>"answer_duplicate"===e.match_type)?s("admin.pendingReview.answerDuplicateQuestions",{count:e.similar_questions.length}):s("admin.pendingReview.similarQuestions",{count:e.similar_questions.length})}),e.similar_questions.map((e,n)=>(0,$.jsx)(le.A,{variant:"outlined",sx:{mb:1,bgcolor:i?"rgba(255, 152, 0, 0.15)":"rgba(255, 152, 0, 0.08)"},children:(0,$.jsxs)(ce.A,{children:[(0,$.jsxs)(o.A,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1},children:[(0,$.jsx)(m.A,{variant:"subtitle2",fontWeight:700,children:"answer_duplicate"===e.match_type?s("admin.pendingReview.answerDuplicateQuestion",{index:n+1,id:e.id}):s("admin.pendingReview.similarQuestion",{index:n+1,id:e.id})}),(0,$.jsx)(p.A,{label:"answer_duplicate"===e.match_type?s("admin.pendingReview.answerDuplicate"):"".concat((100*e.similarity_score).toFixed(0),"% ").concat(s("admin.pendingReview.similar")),size:"small",color:"warning"})]}),(0,$.jsx)(m.A,{variant:"body2",sx:{mb:1},children:e.question_text}),(0,$.jsx)(o.A,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:.5},children:["option_a","option_b","option_c","option_d"].map(n=>{const s=n,t=n.split("_")[1].toUpperCase(),a=e.correct_answer===t;return(0,$.jsx)(o.A,{sx:{p:.5,border:"1px solid",borderColor:a?"success.main":"divider",borderRadius:1,bgcolor:a?i?"rgba(76, 175, 80, 0.2)":"rgba(76, 175, 80, 0.1)":"background.paper",fontSize:"0.75rem"},children:(0,$.jsxs)(m.A,{variant:"caption",fontWeight:a?700:400,children:[t,". ",e[s]]})},n)})}),(0,$.jsxs)(o.A,{sx:{display:"flex",gap:1,mt:1},children:[(0,$.jsx)(p.A,{label:"\ud83d\udc4d ".concat(e.upvotes),size:"small",variant:"outlined"}),(0,$.jsx)(p.A,{label:"\ud83d\udc4e ".concat(e.downvotes),size:"small",variant:"outlined"})]})]})},e.id))]}),0===e.similar_questions.length&&(0,$.jsx)(c.A,{severity:"success",sx:{mb:2},children:s("admin.pendingReview.noSimilarFound")}),(0,$.jsxs)(o.A,{sx:{display:"flex",gap:2,justifyContent:"flex-end",mt:2},children:[(0,$.jsx)(K.A,{variant:"outlined",color:"error",startIcon:(0,$.jsx)(me.A,{}),onClick:()=>{return n=e.id,void C({open:!0,action:"reject",questionId:n});var n},disabled:u,children:s("admin.pendingReview.reject")}),(0,$.jsx)(K.A,{variant:"contained",color:"success",startIcon:(0,$.jsx)(de.A,{}),onClick:()=>{return n=e.id,void C({open:!0,action:"approve",questionId:n});var n},disabled:u,children:s("admin.pendingReview.approve")})]})]},e.id);var n}),(0,$.jsx)(W.A,{component:"div",count:y,page:g,onPageChange:(e,n)=>{f(n)},rowsPerPage:b,onRowsPerPageChange:e=>{_(parseInt(e.target.value,10)),f(0)},rowsPerPageOptions:[5,10,25],labelRowsPerPage:s("admin.questions.questionsPerPage")}),(0,$.jsxs)(E.A,{open:q.open,onClose:I,children:[(0,$.jsx)(F.A,{children:"approve"===q.action?s("admin.pendingReview.confirmApprove"):s("admin.pendingReview.confirmReject")}),(0,$.jsx)(R.A,{children:(0,$.jsx)(m.A,{children:"approve"===q.action?s("admin.pendingReview.confirmApproveMessage"):s("admin.pendingReview.confirmRejectMessage")})}),(0,$.jsxs)(J.A,{children:[(0,$.jsx)(K.A,{onClick:I,children:s("admin.modal.cancel")}),(0,$.jsx)(K.A,{onClick:async()=>
1{if(q.questionId&&q.action)try{x(!0),"approve"===q.action?await ue.h.approveQuestion(q.questionId):await ue.h.rejectQuestion(q.questionId),await S(),C({open:!1,action:null,questionId:null})}catch(e){A(e.message||s("admin.questions.error")),console.error("Error performing action:",e)}finally{x(!1)}},color:"approve"===q.action?"success":"error",variant:"contained",children:"approve"===q.action?s("admin.pendingReview.approve"):s("admin.pendingReview.reject")})]})]})]})};var pe=s(98506),he=s(8679),Ae=s(10431),je=s(35742),ge=s(76088),ve=s(3298),fe=s(17500),be=s(41046),_e=s(33476),ye=s(6768);const we=e=>{let{certificationId:n}=e;const{t:s}=(0,Z.Bd)(),i="dark"===(0,v.A)().palette.mode,[t,r]=(0,a.useState)(null),[u,x]=(0,a.useState)(!1),[h,A]=(0,a.useState)(null),[g,f]=(0,a.useState)([]),[b,_]=(0,a.useState)(!1),[y,w]=(0,a.useState)("top_rated"),[q,C]=(0,a.useState)(""),[S,I]=(0,a.useState)("all"),[P,B]=(0,a.useState)("most_upvoted"),[E,F]=(0,a.useState)(0),[R,Q]=(0,a.useState)(10),[O,N]=(0,a.useState)(null),[V,G]=(0,a.useState)(!1),[H,J]=(0,a.useState)(!1);(0,a.useEffect)(()=>{(async()=>{try{_(!0);const e=await j.t.getDomains(n);f(e.domains.map(e=>e.domain))}catch(e){console.error("Error loading domains:",e)}finally{_(!1)}})()},[n]);const Y=async()=>{try{x(!0),A(null);const e=await j.t.getVotesAndFeedback(n,{page:E+1,per_page:R,view_mode:y,domain:q||void 0,status:S,sort:P});r(e)}catch(e){A(e.message||s("admin.questions.error")),console.error("Error loading votes & feedback:",e)}finally{x(!1)}};(0,a.useEffect)(()=>{Y()},[n,E,R,y,q,S,P]);const X=e=>{switch(e){case"excellent":return(0,$.jsx)(de.A,{sx:{color:"#4caf50",mr:.5}});case"good":return(0,$.jsx)(Ae.A,{sx:{color:"#8bc34a",mr:.5}});case"needs_attention":return(0,$.jsx)(ve.A,{sx:{color:"#ff9800",mr:.5}});case"critical":return(0,$.jsx)(fe.A,{sx:{color:"#f44336",mr:.5}});case"controversial":return(0,$.jsx)(be.A,{sx:{color:"#9c27b0",mr:.5}});default:return null}},ee=e=>{switch(e){case"excellent":return s("admin.votes.status.excellent");case"good":return s("admin.votes.status.good");case"needs_attention":return s("admin.votes.status.needsAttention");case"critical":return s("admin.votes.status.critical");case"controversial":return s("admin.votes.status.controversial");default:return""}};return u&&!t?(0,$.jsx)(o.A,{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"400px",children:(0,$.jsx)(l.A,{})}):h?(0,$.jsx)(o.A,{p:3,children:(0,$.jsx)(c.A,{severity:"error",children:h})}):t?(0,$.jsxs)(o.A,{children:[(0,$.jsxs)(d.A,{sx:{p:3,mb:3,bgcolor:"background.paper"},children:[(0,$.jsx)(m.A,{variant:"h6",gutterBottom:!0,children:s("admin.votes.consolidatedMetrics")}),(0,$.jsxs)(o.A,{sx:{display:"flex",flexWrap:"wrap",gap:2},children:[(0,$.jsx)(o.A,{sx:{flex:"1 1 200px"},children:(0,$.jsxs)(o.A,{display:"flex",alignItems:"center",children:[(0,$.jsx)(Ae.A,{sx:{color:"#4caf50",mr:1}}),(0,$.jsxs)(o.A,{children:[(0,$.jsx)(m.A,{variant:"body2",color:"text.secondary",children:s("admin.votes.totalUpvotes")}),(0,$.jsx)(m.A,{variant:"h6",children:t.metrics.total_upvotes.toLocaleString()})]})]})}),(0,$.jsx)(o.A,{sx:{flex:"1 1 200px"},children:(0,$.jsxs)(o.A,{display:"flex",alignItems:"center",children:[(0,$.jsx)(je.A,{sx:{color:"#f44336",mr:1}}),(0,$.jsxs)(o.A,{children:[(0,$.jsx)(m.A,{variant:"body2",color:"text.secondary",children:s("admin.votes.totalDownvotes")}
1),(0,$.jsx)(m.A,{variant:"h6",children:t.metrics.total_downvotes.toLocaleString()})]})]})}),(0,$.jsx)(o.A,{sx:{flex:"1 1 200px"},children:(0,$.jsxs)(o.A,{display:"flex",alignItems:"center",children:[(0,$.jsx)(ge.A,{sx:{color:"#ffc107",mr:1}}),(0,$.jsxs)(o.A,{children:[(0,$.jsx)(m.A,{variant:"body2",color:"text.secondary",children:s("admin.votes.avgRating")}),(0,$.jsxs)(m.A,{variant:"h6",children:[t.metrics.avg_rating,"/5"]})]})]})}),(0,$.jsx)(o.A,{sx:{flex:"1 1 200px"},children:(0,$.jsxs)(o.A,{display:"flex",alignItems:"center",children:[(0,$.jsx)(be.A,{sx:{color:"#9c27b0",mr:1}}),(0,$.jsxs)(o.A,{children:[(0,$.jsx)(m.A,{variant:"body2",color:"text.secondary",children:s("admin.votes.positiveRatio")}),(0,$.jsxs)(m.A,{variant:"h6",children:[t.metrics.positive_ratio,"%"]})]})]})}),(0,$.jsx)(o.A,{sx:{flex:"1 1 200px"},children:(0,$.jsxs)(o.A,{children:[(0,$.jsx)(m.A,{variant:"body2",color:"text.secondary",children:s("admin.votes.mostVoted")}),(0,$.jsxs)(m.A,{variant:"body1",children:["Q#",t.metrics.most_voted_question_id," (",t.metrics.most_voted_count," votes)"]})]})}),(0,$.jsx)(o.A,{sx:{flex:"1 1 200px"},children:(0,$.jsxs)(o.A,{children:[(0,$.jsx)(m.A,{variant:"body2",color:"text.secondary",children:s("admin.votes.controversial")}),(0,$.jsxs)(m.A,{variant:"body1",children:[t.metrics.controversial_count," questions"]})]})}),(0,$.jsx)(o.A,{sx:{flex:"1 1 200px"},children:(0,$.jsxs)(o.A,{display:"flex",alignItems:"center",children:[(0,$.jsx)(_e.A,{sx:{color:"#9e9e9e",mr:1}}),(0,$.jsxs)(o.A,{children:[(0,$.jsx)(m.A,{variant:"body2",color:"text.secondary",children:s("admin.votes.neverVoted")}),(0,$.jsxs)(m.A,{variant:"body1",children:[t.metrics.never_voted_count," questions"]})]})]})})]})]}),(0,$.jsxs)(d.A,{sx:{p:3,mb:3,bgcolor:"background.paper"},children:[(0,$.jsx)(m.A,{variant:"h6",gutterBottom:!0,children:s("admin.votes.insights")}),(0,$.jsxs)(o.A,{mb:3,children:[(0,$.jsx)(m.A,{variant:"subtitle2",gutterBottom:!0,children:s("admin.votes.poolCoverage")}),(0,$.jsxs)(o.A,{display:"flex",alignItems:"center",mb:1,children:[(0,$.jsx)(de.A,{sx:{color:"#4caf50",mr:1}}),(0,$.jsxs)(m.A,{variant:"body2",children:[(0,$.jsx)("strong",{children:t.insights.pool_coverage.with_votes})," ",s("admin.votes.questionsWithVotes")," (",t.insights.pool_coverage.coverage_percentage,"%)"]})]}),(0,$.jsxs)(o.A,{display:"flex",alignItems:"center",children:[(0,$.jsx)(_e.A,{sx:{color:"#9e9e9e",mr:1}}),(0,$.jsxs)(m.A,{variant:"body2",children:[(0,$.jsx)("strong",{children:t.insights.pool_coverage.without_votes})," ",s("admin.votes.questionsWithoutVotes")," (",(100-t.insights.pool_coverage.coverage_percentage).toFixed(1),"%)"]})]}),(0,$.jsxs)(m.A,{variant:"caption",color:"text.secondary",display:"block",mt:1,children:[s("admin.votes.totalPoolQuestions"),": ",t.insights.pool_coverage.total_questions]})]}),(0,$.jsx)(D.A,{sx:{my:2}}),(0,$.jsxs)(o.A,{mb:3,children:[(0,$.jsxs)(o.A,{display:"flex",alignItems:"center",gap:1,mb:1,children:[(0,$.jsxs)(m.A,{variant:"subtitle2",children:[s("admin.votes.ratingDistribution")," (",t.insights.pool_coverage.with_votes," ",s("admin.votes.votedQuestions"),")"]}),(0,$.jsx)(k.A,{title:(0,$.jsxs)(o.A,{children:[(0,$.jsx)(m.A,{variant:"body2",gutterBottom:!0,children:(0,$.jsx)("strong",{children:s("admin.votes.ratingFormula")})}),(0,$.jsx)(m.A,{variant:"caption",component:"div",gutterBottom:!0,children:s("admin.votes.ratingFormulaExplanation")}),(0,$.jsx)(m.A,{variant:"caption",component:"div",sx:{fontFamily:"monospace",mt:1,p:1,bgcolor:i?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.1)",borderRadius:1},children:"Rating = (Upvotes / Total Votos) \xd7 5.0"}),(0,$.jsx)(m.A,{variant:"caption",component:"div",sx:{mt:1},children:s("admin.votes.ratingFormulaExample")}),(0,$.jsxs)(m.A,{variant:"caption",component:"div",sx:{fontFamily:"monospace",fontSize:"0.7rem"},children:["\u2022 2 upvotes, 0 downvotes \u2192 (2/2) \xd7 5 = 5.0\u2b50",(0,$.jsx)("br",{}),"\u2022 1 upvote, 1 downvote \u2192 (1/2) \xd7 5 = 2.5\u2b50",(0,$.jsx)("br",{}),"\u2022 0 upvotes, 1 downvote \u2192 (0/1) \xd7 5 = 0.0\u2b50"]})]}),arrow:!0,placement:"right",children:(0,$.jsx)(z.A,{size:"small",sx:{p:.5},children:(0,$.jsx)(ye.A,{fontSize:"small",color:"action"})})})]}
1),t.insights.pool_coverage.with_votes>0?Object.entries(t.insights.rating_distribution).map(e=>{let[n,s]=e;return(0,$.jsxs)(o.A,{display:"flex",alignItems:"center",mb:1,children:[(0,$.jsxs)(m.A,{variant:"body2",sx:{minWidth:100},children:["5.0"===n?"\u2b50\u2b50\u2b50\u2b50\u2b50":"4.0-4.9"===n?"\u2b50\u2b50\u2b50\u2b50":"3.0-3.9"===n?"\u2b50\u2b50\u2b50":"2.0-2.9"===n?"\u2b50\u2b50":"\u2b50"," (",n,")"]}),(0,$.jsx)(o.A,{flex:1,mx:2,children:(0,$.jsx)(pe.A,{variant:"determinate",value:s/t.insights.pool_coverage.with_votes*100,sx:{height:8,borderRadius:4}})}),(0,$.jsxs)(m.A,{variant:"body2",children:[s," (",(s/t.insights.pool_coverage.with_votes*100).toFixed(1),"%)"]})]},n)}):(0,$.jsx)(m.A,{variant:"body2",color:"text.secondary",children:s("admin.votes.noVotedQuestions")})]}),(0,$.jsx)(D.A,{sx:{my:2}}),(0,$.jsxs)(o.A,{sx:{display:"flex",gap:3,flexWrap:"wrap"},children:[(0,$.jsxs)(o.A,{sx:{flex:"1 1 300px"},children:[(0,$.jsxs)(o.A,{display:"flex",alignItems:"center",gap:1,mb:1,children:[(0,$.jsx)(m.A,{variant:"subtitle2",children:s("admin.votes.topDomains")}),(0,$.jsx)(k.A,{title:(0,$.jsxs)(o.A,{children:[(0,$.jsx)(m.A,{variant:"body2",gutterBottom:!0,children:(0,$.jsx)("strong",{children:s("admin.votes.domainRatingFormula")})}),(0,$.jsx)(m.A,{variant:"caption",component:"div",gutterBottom:!0,children:s("admin.votes.domainRatingExplanation")}),(0,$.jsx)(m.A,{variant:"caption",component:"div",sx:{fontFamily:"monospace",mt:1,p:1,bgcolor:i?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.1)",borderRadius:1},children:"Domain Avg = AVG(rating de cada quest\xe3o votada)"}),(0,$.jsx)(m.A,{variant:"caption",component:"div",sx:{mt:1},children:s("admin.votes.domainRatingExample")}),(0,$.jsxs)(m.A,{variant:"caption",component:"div",sx:{fontFamily:"monospace",fontSize:"0.7rem"},children:["Quest\xe3o A: 5.0\u2b50",(0,$.jsx)("br",{}),"Quest\xe3o B: 5.0\u2b50",(0,$.jsx)("br",{}),"Quest\xe3o C: 0.0\u2b50",(0,$.jsx)("br",{}),"Domain Avg = (5.0 + 5.0 + 0.0) / 3 = 3.33/5"]})]}),arrow:!0,placement:"right",children:(0,$.jsx)(z.A,{size:"small",sx:{p:.5},children:(0,$.jsx)(ye.A,{fontSize:"small",color:"action"})})})]}),t.insights.top_domains.map((e,n)=>(0,$.jsxs)(o.A,{display:"flex",justifyContent:"space-between",mb:1,children:[(0,$.jsxs)(m.A,{variant:"body2",children:[n+1,". ",e.name]}),(0,$.jsxs)(m.A,{variant:"body2",color:"text.secondary",children:[e.avg_rating.toFixed(2),"/5 (",e.question_count," q)"]})]},e.name))]}),(0,$.jsxs)(o.A,{sx:{flex:"1 1 300px"},children:[(0,$.jsx)(m.A,{variant:"subtitle2",gutterBottom:!0,children:s("admin.votes.bottomDomains")}),t.insights.bottom_domains.map((e,n)=>(0,$.jsxs)(o.A,{display:"flex",justifyContent:"space-between",mb:1,children:[(0,$.jsxs)(m.A,{variant:"body2",children:[n+1,". ",e.name]}),(0,$.jsxs)(m.A,{variant:"body2",color:"text.secondary",children:[e.avg_rating.toFixed(2),"/5 (",e.question_count," q)"]})]},e.name))]})]})]}),(0,$.jsx)(d.A,{sx:{p:2,mb:3,bgcolor:"background.paper"},children:(0,$.jsxs)(o.A,{sx:{display:"flex",flexDirection:"column",gap:2},children:[(0,$.jsxs)(o.A,{children:[(0,$.jsx)(m.A,{variant:"body2",color:"text.secondary",gutterBottom:!0,children:s("admin.votes.viewMode")}),(0,$.jsxs)(he.A,{variant:"outlined",size:"small",children:[(0,$.jsx)(K.A,{variant:"top_rated"===y?"contained":"outlined",onClick:()=>w("top_rated"),startIcon:(0,$.jsx)(ge.A,{}),children:s("admin.votes.topRated")}),(0,$.jsx)(K.A,{variant:"needs_review"===y?"contained":"outlined",onClick:()=>w("needs_review"),startIcon:(0,$.jsx)(je.A,{}),children:s("admin.votes.needsReview")}),(0,$.jsx)(K.A,{variant:"controversial"===y?"contained":"outlined",onClick:()=>w("controversial"),startIcon:(0,$.jsx)(be.A,{}),children:s("admin.votes.controversial")}),(0,$.jsx)(K.A,{variant:"no_votes"===y?"contained":"outlined",onClick:()=>w("no_votes"),startIcon:(0,$.jsx)(_e.A,{}),children:s("admin.votes.noVotes")})]})]}),(0,$.jsxs)(o.A,{sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[(0,$.jsxs)(T.A,{size:"small",sx:{minWidth:200},children:[(0,$.jsx)(M.A,{children:s("admin.questions.domain")}),(0,$.jsxs)(L.A,{value:q,onChange:e=>C(e.target.value),label:s("admin.questions.domain"),disabled:b,children:[(0,$.jsx)(U.A,{value:"",children:s("admin.questions.allDomains")}),g.map(e=>(0,$.jsx)(U.A,{value:e,children:e},e))]})]}),(0,$.jsxs)(T.A,{size:"small",sx:{minWidth:150},children:[(0,$.jsx)(M.A,{children:s("admin.questions.status")}),(0,$.jsxs)(L.A,{value:S,onChange:e=>I(e.target.value),label:s("admin.questions.status"),children:[(0,$.jsx)(U.A,{value:"all",children:s("admin.questions.allStatus")}),(0,$.jsx)(U.A,{value:"active",children:s("admin.questions.active")}),(0,$.jsx)(U.A,{value:"inactive",children:s("admin.questions.inactive")})]})]}),(0,$.jsxs)(T.A,{size:"small",sx:{minWidth:200},children:[(0,$.jsx)(M.A,{children:s("admin.questions.sort")}),(0,$.jsxs)(L.A,{value:P,onChange:e=>B(e.target.value),label:s("admin.questions.sort"),children:[(0,$.jsx)(U.A,{value:"most_upvoted",children:s("admin.votes.sort.mostUpvoted")}),(0,$.jsx)(U.A,{value:"most_downvoted",children:s("admin.votes.sort.mostDownvoted")}),(0,$.jsx)(U.A,{value:"highest_rating",children:s("admin.votes.sort.highestRating")}),(0,$.jsx)(U.A,{value:"lowest_rating",children:s("admin.votes.sort.lowestRating")}),(0,$.jsx)(U.A,{value:"most_controversial",children:s("admin.votes.sort.mostControversial")}),(0,$.jsx)(U.A,{value:"newest",children:s("admin.votes.sort.newest")}
1),(0,$.jsx)(U.A,{value:"oldest",children:s("admin.votes.sort.oldest")})]})]})]})]})}),(0,$.jsxs)(o.A,{children:[u&&(0,$.jsx)(pe.A,{sx:{mb:2}}),t.questions.map(e=>(0,$.jsx)(le.A,{sx:{mb:2},children:(0,$.jsxs)(ce.A,{children:[(0,$.jsx)(o.A,{display:"flex",justifyContent:"space-between",alignItems:"flex-start",mb:2,children:(0,$.jsxs)(o.A,{flex:1,children:[(0,$.jsxs)(o.A,{display:"flex",alignItems:"center",gap:1,mb:1,children:[(0,$.jsxs)(m.A,{variant:"body2",color:"text.secondary",children:["#",e.id]}),(0,$.jsx)(p.A,{label:e.domain_name,size:"small"}),(0,$.jsx)(p.A,{label:e.is_active?s("admin.questions.active"):s("admin.questions.inactive"),size:"small",color:e.is_active?"success":"default"}),(0,$.jsx)(p.A,{label:e.question_type,size:"small",variant:"outlined"})]}),(0,$.jsx)(m.A,{variant:"body1",gutterBottom:!0,children:e.question_text})]})}),(0,$.jsx)(D.A,{sx:{my:2}}),(0,$.jsxs)(o.A,{sx:{display:"flex",flexWrap:"wrap",justifyContent:"space-between",alignItems:"center",gap:2},children:[(0,$.jsxs)(o.A,{children:[(0,$.jsxs)(o.A,{display:"flex",gap:3,mb:1,children:[(0,$.jsx)(k.A,{title:s("admin.votes.upvotes"),children:(0,$.jsxs)(o.A,{display:"flex",alignItems:"center",children:[(0,$.jsx)(Ae.A,{sx:{color:"#4caf50",mr:.5,fontSize:20}}),(0,$.jsxs)(m.A,{variant:"body2",children:[e.upvotes," (",e.upvote_ratio.toFixed(1),"%)"]})]})}),(0,$.jsx)(k.A,{title:s("admin.votes.downvotes"),children:(0,$.jsxs)(o.A,{display:"flex",alignItems:"center",children:[(0,$.jsx)(je.A,{sx:{color:"#f44336",mr:.5,fontSize:20}}),(0,$.jsxs)(m.A,{variant:"body2",children:[e.downvotes," (",(100-e.upvote_ratio).toFixed(1),"%)"]})]})})]}),(0,$.jsxs)(o.A,{display:"flex",alignItems:"center",children:[(0,$.jsx)(ge.A,{sx:{color:"#ffc107",mr:.5,fontSize:20}}),(0,$.jsxs)(m.A,{variant:"body2",children:[s("admin.votes.rating"),": ",e.rating.toFixed(2),"/5"]}),(0,$.jsxs)(m.A,{variant:"body2",color:"text.secondary",sx:{ml:1},children:["\u2022 ",s("admin.votes.totalVotes"),": ",e.total_votes]})]})]}),(0,$.jsx)(o.A,{children:(0,$.jsxs)(o.A,{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:1,children:[X(e.status_indicator),(0,$.jsx)(m.A,{variant:"body2",children:ee(e.status_indicator)})]})})]}),(0,$.jsx)(o.A,{display:"flex",justifyContent:"flex-end",mt:2,children:(0,$.jsx)(K.A,{variant:"outlined",size:"small",onClick:()=>(async e=>{try{J(!0);const s=await j.t.getQuestions(n,{page:1,limit:1,search:e.id.toString()});s.questions.length>0?(N(s.questions[0]),G(!0)):console.error("Question not found:",e.id)}catch(s){console.error("Error loading question details:",s)}finally{J(!1)}})(e),disabled:H,children:H?(0,$.jsx)(l.A,{size:20}):s("admin.questions.viewDetails")})})]})},e.id)),(0,$.jsx)(W.A,{component:"div",count:t.pagination.total,page:E,onPageChange:(e,n)=>{F(n)},rowsPerPage:R,onRowsPerPageChange:e=>{Q(parseInt(e.target.value,10)),F(0)},labelRowsPerPage:s("admin.questions.rowsPerPage")})]}),O&&(0,$.jsx)(ne,{open:V,onClose:function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];G(!1),N(null),e&&Y()},question:O,certificationId:n,mode:"view"})]}):null};var qe=s(55143),Ce=s(47152),Se=s(66996),Ie=s(71257),ke=s(27876),ze=s(38812),We=s(72373),Pe=s(25921);const Be=e=>{let{certificationId:n}=e;const{t:s}=(0,Z.Bd)(),[i,t]=(0,a.useState)(null),[r,u]=(0,a.useState)(!1),[x,h]=(0,a.useState)(null),[A,g]=(0,a.useState)([]),[v,y]=(0,a.useState)(!1),[w,q]=(0,a.useState)("most_used"),[C,S]=(0,a.useState)(""),[I,E]=(0,a.useState)("all"),[F,R]=(0,a.useState)(10),[Q,O]=(0,a.useState)("most_used"),[N,V]=(0,a.useState)(0),[G,H]=(0,a.useState)(10),[J,Y]=(0,a.useState)(null),[X,ee]=(0,a.useState)(!1),[se,ie]=(0,a.useState)(!1);(0,a.useEffect)(()=>{(async()=>{try{y(!0);const e=await j.t.getDomains(n);g(e.domains.map(e=>e.domain))}catch(e){console.error("Error loading domains:",e)}finally{y(!1)}})()},[n]);const te=(0,a.useCallback)(async()=>{try{u(!0),h(null);const e=await j.t.getExamPerformance(n,{page:N+1,per_page:G,view_mode:w,domain:C||void 0,status:I,min_usage:F,sort:Q});t(e)}catch(e){h(e.message||s("admin.questions.error")),console.error("Error loading exam performance:",e)}finally{u(!1)}},[n,N,G,w,C,I,F,Q,s]);(0,a.useEffect)(()=>{te()},[te]);const ae=e=>{switch(e){case"popular_balanced":return(0,$.jsx)(ge.A,{sx:{color:"#4caf50"}});case"too_easy":return(0,$.jsx)(Se.A,{sx:{color:"#9e9e9e"}});case"very_difficult":return(0,$.jsx)(fe.A,{sx:{color:"#f44336"}});case"learning_curve":return(0,$.jsx)(Ce.A,{sx:{color:"#ff9800"}});case"rarely_used":return(0,$.jsx)(ve.A,{sx:{color:"#9e9e9e"}});default:return(0,$.jsx)(de.A,{sx:{color:"#2196f3"}})}},oe=e=>{switch(e){case"popular_balanced":return s("admin.performance.status.popularBalanced");case"too_easy":return s("admin.performance.status.tooEasy");case"very_difficult":return s("admin.performance.status.veryDifficult");case"learning_curve":return s("admin.performance.status.learningCurve");case"rarely_used":return s("admin.performance.status.rarelyUsed");default:return s("admin.performance.status.normal")}};return r&&!i?(0,$.jsx)(o.A,{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"400px",children:(0,$.jsx)(l.A,{})}):x?(0,$.jsx)(o.A,{p:3,children:(0,$.jsx)(c.A,{severity:"error",children:x})}):i?(0,$.jsxs)(o.A,{children:[(0,$.jsxs)(d.A,{sx:{p:3,mb:3,bgcolor:"background.paper"},children:[(0,$.jsx)(m.A,{variant:"h6",gutterBottom:!0,children:s("admin.performance.consolidatedMetrics")}),(0,$.jsx)(m.A,{variant:"subtitle2",color:"text.secondary",sx:{mt:2,mb:1,fontWeight:600},children:s("admin.performance.contextBlock")}),(0,$.jsxs)(o.A,{sx:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:2,mb:3},children:[(0,$.jsxs)(o.A,{children:[(0,$.jsx)(m.A,{variant:"body2",color:"text.secondary",mb:.5,children:s("admin.performance.totalExams")}),(0,$.jsx)(m.A,{variant:"h6",children:i.metrics.total_exam_attempts.toLocaleStr
1ing()}),(0,$.jsxs)(m.A,{variant:"caption",color:"text.secondary",children:["(",i.metrics.first_attempt_count," first)"]})]}),(0,$.jsxs)(o.A,{children:[(0,$.jsx)(m.A,{variant:"body2",color:"text.secondary",mb:.5,children:s("admin.performance.questionsInPool")}),(0,$.jsx)(m.A,{variant:"h6",children:i.metrics.questions_in_pool.toLocaleString()}),(0,$.jsx)(m.A,{variant:"caption",color:"text.secondary",children:s("admin.performance.usedInExams")})]}),(0,$.jsxs)(o.A,{children:[(0,$.jsxs)(o.A,{display:"flex",alignItems:"center",mb:.5,children:[(0,$.jsx)(Ie.A,{sx:{color:"#9c27b0",mr:1}}),(0,$.jsx)(m.A,{variant:"body2",color:"text.secondary",children:s("admin.performance.uniqueUsers")})]}),(0,$.jsx)(m.A,{variant:"h6",children:i.metrics.unique_users.toLocaleString()}),(0,$.jsx)(m.A,{variant:"caption",color:"text.secondary",children:s("admin.performance.attemptedExams")})]}),(0,$.jsx)(o.A,{})]}),(0,$.jsx)(m.A,{variant:"subtitle2",color:"text.secondary",sx:{mt:2,mb:1,fontWeight:600},children:s("admin.performance.firstAttemptBlock")}),(0,$.jsxs)(o.A,{sx:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:2,mb:3},children:[(0,$.jsxs)(o.A,{children:[(0,$.jsxs)(o.A,{display:"flex",alignItems:"center",mb:.5,children:[(0,$.jsx)(de.A,{sx:{color:"#4caf50",mr:1}}),(0,$.jsx)(m.A,{variant:"body2",color:"text.secondary",children:s("admin.performance.avgFirstAttemptSuccess")})]}),(0,$.jsxs)(m.A,{variant:"h6",children:[i.metrics.first_attempt_success,"%"]}),(0,$.jsx)(m.A,{variant:"caption",color:"text.secondary",children:s("admin.performance.realDifficulty")})]}),(0,$.jsxs)(o.A,{children:[(0,$.jsx)(m.A,{variant:"body2",color:"text.secondary",mb:.5,children:s("admin.performance.questionsUsedFirst")}),(0,$.jsx)(m.A,{variant:"h6",children:i.metrics.questions_used_first.toLocaleString()})]}),(0,$.jsxs)(o.A,{children:[(0,$.jsx)(m.A,{variant:"body2",color:"text.secondary",mb:.5,children:s("admin.performance.easiest")}),(0,$.jsxs)(m.A,{variant:"h6",children:["Q#",i.metrics.easiest_question_id||"--"," (",i.metrics.easiest_success_rate,"%)"]})]}),(0,$.jsxs)(o.A,{children:[(0,$.jsx)(m.A,{variant:"body2",color:"text.secondary",mb:.5,children:s("admin.performance.hardest")}),(0,$.jsxs)(m.A,{variant:"h6",children:["Q#",i.metrics.hardest_question_id||"--"," (",i.metrics.hardest_success_rate,"%)"]})]})]}),(0,$.jsx)(m.A,{variant:"subtitle2",color:"text.secondary",sx:{mt:2,mb:1,fontWeight:600},children:s("admin.performance.learningBlock")}),(0,$.jsxs)(o.A,{sx:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:2,mb:3},children:[(0,$.jsxs)(o.A,{children:[(0,$.jsx)(m.A,{variant:"body2",color:"text.secondary",mb:.5,children:s("admin.performance.overallSuccess")}),(0,$.jsxs)(m.A,{variant:"h6",children:[i.metrics.overall_success_rate,"%"]}),(0,$.jsx)(m.A,{variant:"caption",color:"text.secondary",children:s("admin.performance.allAttempts")})]}),(0,$.jsxs)(o.A,{children:[(0,$.jsxs)(o.A,{display:"flex",alignItems:"center",mb:.5,children:[(0,$.jsx)(ke.A,{sx:{color:i.metrics.improvement_gap>=0?"#4caf50":"#f44336",mr:1}}),(0,$.jsx)(m.A,{variant:"body2",color:"text.secondary",children:s("admin.performance.improvementGap")})]}),(0,$.jsxs)(m.A,{variant:"h6",sx:{color:i.metrics.improvement_gap>=0?"#4caf50":"#f44336"},children:[i.metrics.improvement_gap>=0?"+":"",i.metrics.improvement_gap,"%"]}),(0,$.jsx)(m.A,{variant:"caption",color:"text.secondary",children:s("admin.performance.vsFirstAttempt")})]}),(0,$.jsxs)(o.A,{children:[(0,$.jsx)(m.A,{variant:"body2",color:"text.secondary",mb:.5,children:s("admin.performance.mostRetried")}),(0,$.jsxs)(m.A,{variant:"h6",children:["Q#",i.metrics.most_retried_question_id||"--"," (",i.metrics.most_retried_count,"\xd7)"]})]}),(0,$.jsx)(o.A,{})]}),(0,$.jsx)(m.A,{variant:"subtitle2",color:"text.secondary",sx:{mt:2,mb:1,fontWeight:600},children:s("admin.performance.highlightsBlock")}),(0,$.jsxs)(o.A,{sx:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:2},children:[(0,$.jsxs)(o.A,{children:[(0,$.jsx)(m.A,{variant:"body2",color:"text.secondary",mb:.5,children:s("admin.performance.mostUsedAll")}),(0,$.jsxs)(m.A,{variant:"h6",children:["Q#",i.metrics.most_used_all_id||"--"," (",i.metrics.most_used_all_count," uses)"]})]}),(0,$.jsxs)(o.A,{children:[(0,$.jsxs)(o.A,{display:"flex",alignItems:"center",mb:.5,children:[(0,$.jsx)(B.A,{sx:{color:"#2196f3",mr:1}}),(0,$.jsx)(m.A,{variant:"body2",color:"text.secondary",children:s("admin.performance.mostSeenFirst")})]}),(0,$.jsxs)(m.A,{variant:"h6",children:["Q#",i.metrics.most_seen_first_id||"--"," (",i.metrics.most_seen_first_count," first)"]})]}),(0,$.jsxs)(o.A,{children:[(0,$.jsx)(m.A,{variant:"body2",color:"text.secondary",mb:.5,children:s("admin.performance.minUsage")}),(0,$.jsxs)(m.A,{variant:"h6",children:[i.metrics.min_usage_applied," uses"]})]}),(0,$.jsx)(o.A,{})]})]}),(0,$.jsxs)(d.A,{sx:{p:3,mb:3,bgcolor:"background.paper"},children:[(0,$.jsx)(m.A,{variant:"h6",gutterBottom:!0,children:s("admin.performance.insights")}),(0,$.jsxs)(o.A,{mb:3,children:[(0,$.jsx)(m.A,{variant:"subtitle2",gutterBottom:!0,children:s("admin.performance.successRateDistribution")}),Object.entries(i.insights.success_rate_distribution).map(e=>{let[n,t]=e;const a={very_hard:s("admin.performance.veryHard")+" (<30%)",hard:s("admin.performance.hard")+" (30-50%)",medium:s("admin.performance.medium")+" (50-70%)",easy:s("admin.performance.easy")+" (70-85%)",very_easy:s("admin.performance.veryEasy")+" (>85%)"},r=Object.values(i.insights.success_rate_distribution).reduce((e,n)=>e+n,0),l=r>0?(t/r*100).toFixed(1):"0.0";return(0,$.jsxs)(o.A,{display:"flex",alignItems:"center",mb:1,children:[(0,$.jsx)(m.A,{variant:"body2",sx:{minWidth:180},children:a[n]}),(0,$.jsx)(o.A,{flex:1,mx:2,children:(0,$.jsx)(pe.A,{variant:"determinate",value:r>0?t/r*100:0,sx:{height:8,borderRadius:4}})}),(0,$.jsxs)(m.A,{variant:"body2",children:[t," (",l,"%)"]})]},n)})]}),(0,$.jsx)(D.A,{sx:{my:2}}),(0,$.jsxs)(o.A,{mb:3,children:[(0,$.jsx)(m.A,{variant:"subtitle2",gutterBottom:!0,children:s("admin.performance.usageDistribution")}),Object.entries(i.insights.usage_distribution).map(e=>{let[n,t]=e;const a=i.insights.usage_thresholds,r={high:"".concat(s("admin.performance.highUsage")," (>").concat(a.high,")"),medium:"".concat(s("admin.performance.mediumUsage")," (").concat(a.medium,"-").concat(a.high,")"),low:"".concat(s("admin.performance.lowUsage")," (").concat(a.low,"-").concat(a.medium,")"),rarely:"".concat(s("admin.performance.rarelyUsed")," (<").concat(a.low,")")},l=Object.values(i.insights.usage_distribution).reduce((e,n)=>e+n,0),c=l>0?(t/l*100).toFixed(1):"0.0";return(0,$.jsxs)(o.A,{display:"flex",alignItems:"center",mb:1,children:[(0,$.jsx)(m.A,{variant:"body2",sx:{minWidth:250},children:r[n]}),(0,$.jsx)(o.A,{flex:1,mx:2,children:(0,$.jsx)(pe.A,{variant:"determinate",value:l>0?t/l*100:0,sx:{height:8,borderRadius:4}})}),(0,$.jsxs)(m.A,{variant:"body2",children:[t," (",c,"%)"]})]},n)})]}),(0,$.jsx)(D.A,{sx:{my:2}}),(0,$.jsxs)(o.A,{mb:3,children:[(0,$.jsx)(m.A,{variant:"subtitle2",gutterBottom:!0,children:s("admin.performance.gapAnalysis")}),(0,$.jsx)(m.A,{variant:"caption",color:"text.secondary",display:"block",mb:2,children:s("admin.performance.gapAnalysisExplanation")}),i.insights.gap_analysis.high_gap.length>0&&(0,$.jsxs)(f.A,{defaultExpanded:!0,children:[(0,$.jsx)(b.A,{expandIcon:(0,$.jsx)(P.A,{}),children:(0,$.jsxs)(o.A,{display:"flex",alignItems:"center",gap:1,flex:1,children:[(0,$.jsx)(ze.A,{color:"warning"}),(0,$.jsxs)(m.A,{variant:"body2",fontWeight:"bold",children:[s("admin.performance.highGap")," (",
1i.insights.gap_analysis.high_gap.length,")"]}),(0,$.jsx)(k.A,{title:s("admin.performance.highGapTooltip"),arrow:!0,children:(0,$.jsx)(z.A,{size:"small",children:(0,$.jsx)(ye.A,{fontSize:"small"})})})]})}),(0,$.jsxs)(_.A,{children:[(0,$.jsx)(m.A,{variant:"caption",color:"text.secondary",display:"block",mb:1,children:s("admin.performance.highGapExplanation")}),i.insights.gap_analysis.high_gap.map(e=>(0,$.jsx)(o.A,{mb:.5,children:(0,$.jsxs)(m.A,{variant:"body2",children:["\u2022 Q#",e.id," (",e.domain,"): ",e.first_success_rate,"% first \u2192 ",e.retry_success_rate,"% retry (Gap: +",e.gap,"%) | ",e.exams_with_retry," exams"]})},e.id))]})]}),i.insights.gap_analysis.low_gap.length>0&&(0,$.jsxs)(f.A,{children:[(0,$.jsx)(b.A,{expandIcon:(0,$.jsx)(P.A,{}),children:(0,$.jsxs)(o.A,{display:"flex",alignItems:"center",gap:1,flex:1,children:[(0,$.jsx)(We.A,{color:"success"}),(0,$.jsxs)(m.A,{variant:"body2",fontWeight:"bold",children:[s("admin.performance.lowGap")," (",i.insights.gap_analysis.low_gap.length,")"]}),(0,$.jsx)(k.A,{title:s("admin.performance.lowGapTooltip"),arrow:!0,children:(0,$.jsx)(z.A,{size:"small",children:(0,$.jsx)(ye.A,{fontSize:"small"})})})]})}),(0,$.jsxs)(_.A,{children:[(0,$.jsx)(m.A,{variant:"caption",color:"text.secondary",display:"block",mb:1,children:s("admin.performance.lowGapExplanation")}),i.insights.gap_analysis.low_gap.map(e=>(0,$.jsx)(o.A,{mb:.5,children:(0,$.jsxs)(m.A,{variant:"body2",children:["\u2022 Q#",e.id," (",e.domain,"): ",e.first_success_rate,"% first \u2192 ",e.retry_success_rate,"% retry (Gap: +",e.gap,"%) | ",e.exams_with_retry," exams"]})},e.id))]})]}),i.insights.gap_analysis.negative_gap.length>0&&(0,$.jsxs)(f.A,{children:[(0,$.jsx)(b.A,{expandIcon:(0,$.jsx)(P.A,{}),children:(0,$.jsxs)(o.A,{display:"flex",alignItems:"center",gap:1,flex:1,children:[(0,$.jsx)(Pe.A,{color:"error"}),(0,$.jsxs)(m.A,{variant:"body2",fontWeight:"bold",children:[s("admin.performance.negativeGap")," (",i.insights.gap_analysis.negative_gap.length,")"]}),(0,$.jsx)(k.A,{title:s("admin.performance.negativeGapTooltip"),arrow:!0,children:(0,$.jsx)(z.A,{size:"small",children:(0,$.jsx)(ye.A,{fontSize:"small"})})})]})}),(0,$.jsxs)(_.A,{children:[(0,$.jsx)(m.A,{variant:"caption",color:"text.secondary",display:"block",mb:1,children:s("admin.performance.negativeGapExplanation")}),i.insights.gap_analysis.negative_gap.map(e=>(0,$.jsx)(o.A,{mb:.5,children:(0,$.jsxs)(m.A,{variant:"body2",children:["\u2022 Q#",e.id," (",e.domain,"): ",e.first_success_rate,"% first \u2192 ",e.retry_success_rate,"% retry (Gap: ",e.gap,"%) | ",e.exams_with_retry," exams"]})},e.id))]})]}),0===i.insights.gap_analysis.high_gap.length&&0===i.insights.gap_analysis.low_gap.length&&0===i.insights.gap_analysis.negative_gap.length&&(0,$.jsx)(m.A,{variant:"body2",color:"text.secondary",children:s("admin.performance.noGapData")})]}),(0,$.jsxs)(o.A,{sx:{display:"flex",gap:3,flexWrap:"wrap"},children:[(0,$.jsxs)(o.A,{sx:{flex:"1 1 300px"},children:[(0,$.jsx)(m.A,{variant:"subtitle2",gutterBottom:!0,children:s("admin.performance.topDomains")}),i.insights.top_domains.map((e,n)=>(0,$.jsxs)(o.A,{display:"flex",justifyContent:"space-between",mb:1,children:[(0,$.jsxs)(m.A,{variant:"body2",children:[n+1,". ",e.domain]}),(0,$.jsxs)(m.A,{variant:"body2",color:"text.secondary",children:[e.avg_success_rate,"% (",e.question_count," q)"]})]},e.domain))]}),(0,$.jsxs)(o.A,{sx:{flex:"1 1 300px"},children:[(0,$.jsx)(m.A,{variant:"subtitle2",gutterBottom:!0,children:s("admin.performance.bottomDomains")}),i.insights.bottom_domains.map((e,n)=>(0,$.jsxs)(o.A,{display:"flex",justifyContent:"space-between",mb:1,children:[(0,$.jsxs)(m.A,{variant:"body2",children:[n+1,". ",e.domain]}),(0,$.jsxs)(m.A,{variant:"body2",color:"text.secondary",children:[e.avg_success_rate,"% (",e.question_count," q)"]})]},e.domain))]})]})]}),(0,$.jsx)(d.A,{sx:{p:2,mb:3,bgcolor:"background.paper"},children:(0,$.jsxs)(o.A,{sx:{display:"flex",flexDirection:"column",gap:2},children:[(0,$.jsxs)(o.A,{children:[(0,$.jsx)(m.A,{variant:"body2",color:"text.secondary",gutterBottom:!0,children:s("admin.performance.viewM
1ode")}),(0,$.jsxs)(he.A,{variant:"outlined",size:"small",children:[(0,$.jsx)(K.A,{variant:"most_used"===w?"contained":"outlined",onClick:()=>q("most_used"),startIcon:(0,$.jsx)(qe.A,{}),children:s("admin.performance.mostUsed")}),(0,$.jsx)(K.A,{variant:"highest_success"===w?"contained":"outlined",onClick:()=>q("highest_success"),startIcon:(0,$.jsx)(de.A,{}),children:s("admin.performance.highestSuccess")}),(0,$.jsx)(K.A,{variant:"lowest_success"===w?"contained":"outlined",onClick:()=>q("lowest_success"),startIcon:(0,$.jsx)(fe.A,{}),children:s("admin.performance.lowestSuccess")}),(0,$.jsx)(K.A,{variant:"first_attempt"===w?"contained":"outlined",onClick:()=>q("first_attempt"),startIcon:(0,$.jsx)(ge.A,{}),children:s("admin.performance.firstAttempt")}),(0,$.jsx)(K.A,{variant:"large_gap"===w?"contained":"outlined",onClick:()=>q("large_gap"),startIcon:(0,$.jsx)(Ce.A,{}),children:s("admin.performance.largeGap")})]})]}),(0,$.jsxs)(o.A,{sx:{display:"flex",gap:2,flexWrap:"wrap",alignItems:"center"},children:[(0,$.jsxs)(T.A,{size:"small",sx:{minWidth:200},children:[(0,$.jsx)(M.A,{children:s("admin.questions.domain")}),(0,$.jsxs)(L.A,{value:C,onChange:e=>S(e.target.value),label:s("admin.questions.domain"),disabled:v,children:[(0,$.jsx)(U.A,{value:"",children:s("admin.questions.allDomains")}),A.map(e=>(0,$.jsx)(U.A,{value:e,children:e},e))]})]}),(0,$.jsxs)(T.A,{size:"small",sx:{minWidth:150},children:[(0,$.jsx)(M.A,{children:s("admin.questions.status")}),(0,$.jsxs)(L.A,{value:I,onChange:e=>E(e.target.value),label:s("admin.questions.status"),children:[(0,$.jsx)(U.A,{value:"all",children:s("admin.questions.allStatus")}),(0,$.jsx)(U.A,{value:"active",children:s("admin.questions.active")}),(0,$.jsx)(U.A,{value:"inactive",children:s("admin.questions.inactive")})]})]}),(0,$.jsxs)(T.A,{size:"small",sx:{minWidth:150},children:[(0,$.jsx)(M.A,{children:s("admin.performance.minUsage")}),(0,$.jsxs)(L.A,{value:F,onChange:e=>R(Number(e.target.value)),label:s("admin.performance.minUsage"),children:[(0,$.jsxs)(U.A,{value:5,children:["5+ ",s("admin.performance.uses")]}),(0,$.jsxs)(U.A,{value:10,children:["10+ ",s("admin.performance.uses")]}),(0,$.jsxs)(U.A,{value:50,children:["50+ ",s("admin.performance.uses")]}),(0,$.jsxs)(U.A,{value:100,children:["100+ ",s("admin.performance.uses")]}),(0,$.jsxs)(U.A,{value:200,children:["200+ ",s("admin.performance.uses")]})]})]}),(0,$.jsxs)(T.A,{size:"small",sx:{minWidth:200},children:[(0,$.jsx)(M.A,{children:s("admin.questions.sort")}),(0,$.jsxs)(L.A,{value:Q,onChange:e=>O(e.target.value),label:s("admin.questions.sort"),children:[(0,$.jsx)(U.A,{value:"most_used",children:s("admin.performance.sort.mostUsed")}),(0,$.jsx)(U.A,{value:"least_used",children:s("admin.performance.sort.leastUsed")}),(0,$.jsx)(U.A,{value:"highest_success",children:s("admin.performance.sort.highestSuccess")}),(0,$.jsx)(U.A,{value:"lowest_success",children:s("admin.performance.sort.lowestSuccess")}),(0,$.jsx)(U.A,{value:"best_first_attempt",children:s("admin.performance.sort.bestFirstAttempt")}),(0,$.jsx)(U.A,{value:"worst_first_attempt",children:s("admin.performance.sort.worstFirstAttempt")}),(0,$.jsx)(U.A,{value:"largest_gap",children:s("admin.performance.sort.largestGap")})]})]})]})]})}),(0,$.jsx)(o.A,{children:r?(0,$.jsx)(o.A,{display:"flex",justifyContent:"center",p:3,children:(0,$.jsx)(l.A,{})}):(0,$.jsxs)($.Fragment,{children:[i.questions.map(e=>(0,$.jsx)(le.A,{sx:{mb:2},children:(0,$.jsxs)(ce.A,{children:[(0,$.jsxs)(o.A,{display:"flex",justifyContent:"space-between",alignItems:"flex-start",mb:1,children:[(0,$.jsxs)(o.A,{display:"flex",alignItems:"center",gap:1,children:[(0,$.jsxs)(m.A,{variant:"h6",component:"span",children:["#",e.id]}),(0,$.jsx)(p.A,{label:e.domain,size:"small",color:"primary",variant:"outlined"}),(0,$.jsx)(p.A,{label:e.is_active?s("admin.questions.active"):s("admin.questions.inactive"),size:"small",color:e.is_active?"success":"default"}),(0,$.jsx)(p.A,{label:"single"===e.question_type?s("admin.questions.single"):s("admin.questions.multiple"),size:"small",variant:"outlined"})]}),(0,$.jsxs)(o.A,{display:"flex",alignItems:"center",gap:1,children:[ae(e.status_indicator),(0,$.jsx)(p.A,{label:oe(e.status_indicator),size:"small"})]})]}),(0,$.jsx)(m.A,{variant:"body2",color:"text.secondary",mb:2,children:e.question_text}),(0,$.jsxs)(o.A,{sx:{display:"flex",gap:3,flexWrap:"wrap",mb:2},children:[(0,$.jsxs)(o.A,{children:[(0,$.jsxs)(m.A,{variant:"caption",color:"text.secondary",children:["\ud83d\udcca ",s("admin.performance.usage")]}),(0,$.jsxs)(m.A,{variant:"body2",children:[e.usage_count," ",s("admin.performance.exams")]})]}),(0,$.jsxs)(o.A,{children:[(0,$.jsxs)(m.A,{variant:"caption",color:"text.secondary",children:["\u2705 ",s("admin.performance.successRate")]}),(0,$.jsxs)(m.A,{variant:"body2",children:[e.success_rate,"% (",e.total_correct,"/",e.usage_count,")"]})]}),null!==e.first_attempt_success_rate&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(o.A,{children:[(0,$.jsxs)(m.A,{variant:"caption",color:"text.secondary",children:["\ud83c\udfaf ",s("admin.performance.firstAttemptSuccess")]}),(0,$.jsxs)(m.A,{variant:"body2",children:[e.first_attempt_success_rate,"% (",e.first_attempt_correct,"/",e.first_attempt_usage,")"]})]}),null!==e.gap&&(0,$.jsxs)(o.A,{children:[(0,$.jsxs)(m.A,{variant:"caption",color:"text.secondary",children:["\ud83d\udcc8 ",s("admin.performance.gap")]}),(0,$.jsxs)(m.A,{variant:"body2",color:e.gap>20?"warning.main":"text.primary",children:[e.gap>0?"+":"",e.gap,"%"]})]})]})]}),e.common_wrong_answer&&(0,$.jsxs)(o.A,{mb:2,children:[(0,$.jsx)(m.A,{variant:"caption",color:"text.secondary",display:"block",mb:.5,children:s("admin.performance.answerDistribution")}),(0,$.jsx)(o.A,{display:"flex",gap:1,children:Object.entries(e.answer_distribution).map(n=>{let[s,i]=n;return(0,$.jsx)(p.A,{label:"".concat(s,": ").concat(i,"%"),size:"small",color:s===e.common_wrong_answer?"error":"default",variant:s===e.common_wrong_answer?"filled":"outlined"},s)})}),e.common_wrong_percentage&&(0,$.jsxs)(m.A,{variant:"caption",color:"error",display:"block",mt:.5,children:["\ud83d\udcac ",s("admin.performance.commonWrongAnswer"),": ",s("admin.performance.option")," ",e.common_wrong_answer," (",e.common_wrong_percentage,"%)"]})]}),(0,$.jsx)(o.A,{display:"flex",justifyContent:"flex-end",mt:2,children:(0,$.jsx)(K.A,{variant:"outlined",size:"small",onClick:()=>(async e=>{try{ie(!0);const s=await j.t.getQuestions(n,{page:1,limit:1,search:e.id.toString()});s.questions.length>0?(Y(s.questions[0]),ee(!0)):console.error("Question not found:",e.id)}catch(s){console.error("Error loading question details:",s)}finally{ie(!1)}})(e),disabled:se,children:se?(0,$.jsx)(l.A,{size:20}):s("admin.questions.viewDetails")})})]})},e.id)),(0,$.jsx)(W.A,{component:"div",count:i.pagination.total,page:N,onPageChange:(e,n)=>{V(n)},rowsPerPage:G,onRowsPerPageChange:e=>{H(parseInt(e.target.value,10)),V(0)},labelRowsPerPage:s("admin.questions.rowsPerPage")})]})}),J&&(0,$.jsx)(ne,{open:X,onClose:function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];ee(!1),Y(null),e&&te()},question:J,certificationId:n,mode:"view"})]}):null};
1var Ee=s(34244),Fe=s(81393),De=s(54150),Re=s(61106),Qe=s(28827),Te=s(93360);const Me=["question_text","option_a","option_b","option_c","option_d","question_type","correct_answer","reference_url","domain"],Le=["A","B","C","D"],Ue=/\b(?:select|choose|pick)\s+(two|three|four|\d+)\b/i,Oe=/\b(option\s+[A-D]|[A-D]\)|alternative?\s+[A-D])\b/i,Ne=/^https?:\/\/[^\s]+$/,Ve={two:2,three:3,four:4};function Ge(e,n){const s=n.id;return void 0!==s&&null!==s&&""!==s?"Question at index ".concat(e," (id ").concat(s,")"):"Question at index ".concat(e)}function He(e){const n=Array.from(e.matchAll(new RegExp(Ue.source,"gi"))),s=[];for(const o of n){var i,t;const e=(null!==(i=o[1])&&void 0!==i?i:"").toLowerCase(),n=null!==(t=Ve[e])&&void 0!==t?t:e?parseInt(e,10):NaN;!isNaN(n)&&n>=2&&n<=4&&s.push(n)}if(0===s.length)return null;const a=Array.from(new Set(s));return{number:a[0],ambiguous:a.length>1}}function Je(e){return"string"!==typeof e?[]:e.split(",").map(e=>e.trim().toUpperCase()).filter(Boolean)}const Ke=[{value:"admin_udemybased",labelKey:"admin.questions.bulkImport.sourceUdemyBased"}],Ye=e=>{let{certificationId:n}=e;const{t:s}=(0,Z.Bd)(),i=(0,a.useRef)(null),[t,r]=(0,a.useState)("admin_udemybased"),[u,x]=(0,a.useState)(!1),[h,A]=(0,a.useState)(null),[g,v]=(0,a.useState)(null),[f,b]=(0,a.useState)([]),[_,y]=(0,a.useState)(null),[w,q]=(0,a.useState)(!1),[C,S]=(0,a.useState)(null),[I,k]=(0,a.useState)([]),[z,W]=(0,a.useState)(!0),[P,B]=(0,a.useState)(null),E=(0,a.useRef)(null),F=(0,a.useCallback)(async()=>{if(n)try{W(!0);const e=await j.t.getDomains(n);k(e.domains.map(e=>e.domain))}catch(e){k([])}finally{W(!1)}},[n]);(0,a.useEffect)(()=>{F()},[F]),(0,a.useEffect)(()=>()=>{E.current&&clearInterval(E.current)},[]);const D=(0,a.useCallback)(e=>{E.current&&clearInterval(E.current);let n=0;const i=async()=>{try{const i=await j.t.getBulkImportJobStatus(e);n=0,"completed"===i.status&&i.result?(E.current&&(clearInterval(E.current),E.current=null),S({created_count:i.result.created_count,created_for_review_count:i.result.created_for_review_count,skipped_exact_count:i.result.skipped_exact_count,skipped_similar_count:i.result.skipped_similar_count,validation_errors_count:i.result.validation_errors_count,message:s("admin.questions.bulkImport.importComplete")}),q(!1),B(null),F()):"error"===i.status&&(E.current&&(clearInterval(E.current),E.current=null),v(i.error_message||s("admin.questions.bulkImport.errorImport")),q(!1),B(null))}catch(i){n++,console.warn("[BulkImport] Polling error (".concat(n,"/").concat(5,"):"),i),n>=5&&(E.current&&(clearInterval(E.current),E.current=null),v(s("admin.questions.bulkImport.errorImport")),q(!1),B(null))}};i(),E.current=setInterval(i,2e3)},[F,s]);return(0,$.jsxs)(o.A,{children:[(0,$.jsx)(m.A,{variant:"h6",gutterBottom:!0,fontWeight:600,children:s("admin.questions.bulkImport.title")}),(0,$.jsx)(m.A,{variant:"body2",color:"text.secondary",sx:{mb:3},children:s("admin.questions.bulkImport.description")}),(0,$.jsxs)(d.A,{variant:"outlined",sx:{p:3,mb:2,bgcolor:"background.paper"},children:[(0,$.jsx)(m.A,{variant:"subtitle2",fontWeight:600,gutterBottom:!0,children:s("admin.questions.bulkImport.settings")}),(0,$.jsxs)(o.A,{sx:{display:"flex",flexDirection:"column",gap:2,mt:2},children:[(0,$.jsxs)(o.A,{children:[(0,$.jsx)(m.A,{variant:"body2",color:"text.secondary",sx:{mb:.5},children:s("admin.questions.bulkImport.certification")}),(0,$.jsx)(m.A,{variant:"body1",fontWeight:500,children:n})]}),(0,$.jsxs)(T.A,{size:"small",sx:{minWidth:220,maxWidth:280,alignSelf:"flex-start"},children:[(0,$.jsx)(M.A,{children:s("admin.questions.bulkImport.source")}),(0,$.jsx)(L.A,{value:t,label:s("admin.questions.bulkImport.source"),onChange:e=>r(e.target.value),children:Ke.map(e=>(0,$.jsx)(U.A,{value:e.value,children:s(e.labelKey)},e.value))})]}),(0,$.jsx)(V.A,{control:(0,$.jsx)(H.A,{checked:u,onChange:e=>x(e.target.checked),color:"primary"}),label:s("admin.questions.bulkImport.importAsActive")}),(0,$.jsx)(m.A,{variant:"caption",color:"text.secondary",children:s("admin.questions.bulkImport.importAsActiveHint")}),(0,$.jsxs)(o.A,{sx:{mt:2},children:[(0,$.jsx)(m.A,{variant:"subtitle2",fontWeight:600,gutterBottom:!0,children:s("admin.questions.bulkImport.validDomains")}),(0,$.jsx)(m.A,{variant:"caption",color:"text.secondary",display:"block",sx:{mb:1},children:s("admin.questions.bulkImport.validDomainsHint")}),z?(0,$.jsx)(l.A,{size:20}):I.length>0?(0,$.jsx)(o.A,{sx:{display:"flex",flexWrap:"wrap",gap:.5},children:I.map(e=>(0,$.jsx)(p.A,{label:e,size:"small",variant:"outlined",sx:{fontFamily:"monospace"}},e))}):(0,$.jsx)(m.A,{variant:"body2",color:"text.secondary",children:s("admin.questions.bulkImport.noDomains")})]})]})]}),(0,$.jsxs)(d.A,{variant:"outlined",sx:{p:3,mb:2,bgcolor:"background.paper"},children:[(0,$.jsx)(m.A,{variant:"subtitle2",fontWeight:600,gutterBottom:!0,children:s("admin.questions.bulkImport.uploadFile")}),(0,$.jsx)(m.A,{variant:"body2",color:"text.secondary",sx:{mb:2},children:s("admin.questions.bulkImport.uploadHint")}),(0,$.jsxs)(o.A,{sx:{display:"flex",alignItems:"center",gap:2,flexWrap:"wrap"},children:[(0,$.jsx)("input",{ref:i,type:"file",accept:".json,application/json",onChange:e=>{var n;const i=null===(n=e.target.files)||void 0===n?void 0:n[0];if(v(null),b([]),y(null),S(null),i){if(!i.name.endsWith(".json"))return v(s("admin.questions.bulkImport.errorFileType")),void A(null);A(i)}else A(null)},style:{display:"none"}}),(0,$.jsx)(K.A,{variant:"outlined",startIcon:(0,$.jsx)(Qe.A,{}),onClick:()=>{var e;null===(e=i.current)||void 0===e||e.click()},children:s("admin.questions.bulkImport.selectFile")}),h&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(m.A,{variant:"body2",color:"text.secondary",children:[h.name," 
1(",(h.size/1024).toFixed(1)," KB)"]}),(0,$.jsx)(K.A,{size:"small",onClick:()=>{A(null),v(null),b([]),y(null),S(null),i.current&&(i.current.value="")},children:s("admin.questions.bulkImport.clear")})]})]}),(0,$.jsx)(o.A,{sx:{mt:2},children:(0,$.jsxs)(Ee.A,{href:"/questions-import-example.json",download:"questions-import-example.json",sx:{display:"inline-flex",alignItems:"center",gap:.5},children:[(0,$.jsx)(Te.A,{fontSize:"small"}),s("admin.questions.bulkImport.downloadExample")]})})]}),g&&(0,$.jsx)(c.A,{severity:null===_||f.length?f.length>0?"error":"info":"success",sx:{mb:2},icon:null===_||f.length?f.length>0?(0,$.jsx)(fe.A,{}):void 0:(0,$.jsx)(de.A,{}),children:g}),P&&!C&&(0,$.jsx)(d.A,{variant:"outlined",sx:{p:2,mb:2,bgcolor:"background.paper"},children:(0,$.jsxs)(o.A,{sx:{display:"flex",alignItems:"center",gap:2},children:[(0,$.jsx)(l.A,{size:24}),(0,$.jsxs)(o.A,{children:[(0,$.jsx)(m.A,{variant:"subtitle2",fontWeight:600,color:"info.main",children:s("admin.questions.bulkImport.processing")}),(0,$.jsx)(m.A,{variant:"body2",color:"text.secondary",children:s("admin.questions.bulkImport.processingHint")})]})]})}),C&&(0,$.jsxs)(d.A,{variant:"outlined",sx:{p:2,mb:2,bgcolor:"background.paper"},children:[(0,$.jsx)(m.A,{variant:"subtitle2",fontWeight:600,gutterBottom:!0,color:"success.main",children:s("admin.questions.bulkImport.importComplete")}),(0,$.jsx)(m.A,{variant:"body2",sx:{mb:1},children:C.message}),(0,$.jsxs)(o.A,{sx:{display:"flex",flexWrap:"wrap",gap:1,mt:1},children:[(0,$.jsx)(p.A,{label:s("admin.questions.bulkImport.created",{count:C.created_count}),size:"small",color:"success",variant:"outlined"}),(0,$.jsx)(p.A,{label:s("admin.questions.bulkImport.createdForReview",{count:C.created_for_review_count}),size:"small",color:"warning",variant:"outlined"}),(0,$.jsx)(p.A,{label:s("admin.questions.bulkImport.skippedExact",{count:C.skipped_exact_count}),size:"small",variant:"outlined"}),(0,$.jsx)(p.A,{label:s("admin.questions.bulkImport.skippedSimilar",{count:C.skipped_similar_count}),size:"small",variant:"outlined"}),C.validation_errors_count>0&&(0,$.jsx)(p.A,{label:s("admin.questions.bulkImport.validationErrorsCount",{count:C.validation_errors_count}),size:"small",color:"error",variant:"outlined"})]})]}),f.length>0&&(0,$.jsxs)(d.A,{variant:"outlined",sx:{p:2,mb:2,maxHeight:300,overflow:"auto",bgcolor:"background.paper"},children:[(0,$.jsx)(m.A,{variant:"subtitle2",fontWeight:600,gutterBottom:!0,color:"error",children:s("admin.questions.bulkImport.validationErrors")}),(0,$.jsx)(Fe.A,{dense:!0,disablePadding:!0,children:f.slice(0,20).map((e,n)=>(0,$.jsx)(De.Ay,{sx:{py:.25},children:(0,$.jsx)(Re.A,{primary:e.message,primaryTypographyProps:{variant:"body2",color:"error.main"}})},n))}),f.length>20&&(0,$.jsx)(m.A,{variant:"caption",color:"text.secondary",sx:{mt:1,display:"block"},children:s("admin.questions.bulkImport.moreErrors",{count:f.length-20})})]}),(0,$.jsx)(K.A,{variant:"contained",onClick:async()=>{if(h){v(null),b([]),y(null),S(null),q(!0);try{var e;const a=await h.text();let o;try{o=JSON.parse(a)}catch(i){return v(s("admin.questions.bulkImport.errorInvalidJson")),void q(!1)}const r=function(e,n){const s=[];if("object"!==typeof e||null===e||Array.isArray(e))return{valid:!1,errors:[{index:-1,field:"root",message:"Invalid JSON: root must be an object"}]};const i=e.questions;if(!Array.isArray(i))return{valid:!1,errors:[{index:-1,field:"root",message:"Root must have 'questions' array"}]};if(0===i.length)return{valid:!1,errors:[{index:-1,field:"root",message:"'questions' array cannot be empty"}]};const t=new Set(n);for(let a=0;a<i.length;a++){const e=i[a],n=Ge(a,e);if("object"!==typeof e||null===e){s.push({index:a,field:"question",message:"".concat(n,": must be an object")});continue}const o=e,r="number"===typeof o.id||"string"===typeof o.id?o.id:void 0;for(const i of Me)i in o||s.push({index:a,id:r,field:i,message:"".concat(n,": missing required field '").concat(i,"'")});if(s.some(e=>e.index===a))continue;const l="string"===typeof o.question_text?o.question_text.trim():"",c="string"===typeof o.option_a?o.option_a.trim():"",d="str
1ing"===typeof o.option_b?o.option_b.trim():"",m="string"===typeof o.option_c?o.option_c.trim():"",u="string"===typeof o.option_d?o.option_d.trim():"",x="string"===typeof o.question_type?o.question_type.trim().toLowerCase():"",p=o.correct_answer,h="string"===typeof o.explanation?o.explanation.trim():"",A=o.reference_url,j="string"===typeof o.domain?o.domain.trim():"";l||s.push({index:a,id:r,field:"question_text",message:"".concat(n,": 'question_text' cannot be empty")});const g=[c,d,m,u];for(let i=0;i<g.length;i++)g[i]||s.push({index:a,id:r,field:"option_".concat(String.fromCharCode(97+i)),message:"".concat(n,": 'option_").concat(String.fromCharCode(97+i),"' cannot be empty")});const v=[[c,d],[c,m],[c,u],[d,m],[d,u],[m,u]];for(const[i,t]of v)if(i&&t&&i===t){s.push({index:a,id:r,field:"options",message:"".concat(n,": options cannot be equal (e.g. '").concat(i.substring(0,30)).concat(i.length>30?"...":"","')")});break}"single"!==x&&"multiple"!==x&&s.push({index:a,id:r,field:"question_type",message:"".concat(n,": 'question_type' must be 'single' or 'multiple'")});const f=Je(p),b=x;if("single"===b)1===f.length&&Le.includes(f[0])||s.push({index:a,id:r,field:"correct_answer",message:"".concat(n,": 'correct_answer' must be one of A,B,C,D for single choice")});else if("multiple"===b)if(f.length<2||f.length>4)s.push({index:a,id:r,field:"correct_answer",message:"".concat(n,": 'correct_answer' for multiple must have 2-4 unique options (A,B,C,D)")});else{new Set(f).size!==f.length&&s.push({index:a,id:r,field:"correct_answer",message:"".concat(n,": 'correct_answer' contains duplicate options")});for(const i of f)if(!Le.includes(i)){s.push({index:a,id:r,field:"correct_answer",message:"".concat(n,": 'correct_answer' must only use A,B,C,D")});break}const e=He(l);e?e.ambiguous?s.push({index:a,id:r,field:"question_text",message:"".concat(n,": multiple with ambiguous selection parameter (e.g. 'Select 2 or Select 3')")}):e.number!==f.length&&s.push({index:a,id:r,field:"correct_answer",message:"".concat(n,": correct_answer has ").concat(f.length," options but question_text says 'Select ").concat(e.number,"'")}):s.push({index:a,id:r,field:"question_text",message:"".concat(n,": multiple without selection parameter in question (add 'Select 2', 'Choose two', etc)")})}if(h&&Oe.test(h)&&s.push({index:a,id:r,field:"explanation",message:"".concat(n,": 'explanation' should not reference option letters (A, B, C, D)")}),null!==A&&void 0!==A){const e="string"===typeof A?A.trim():String(A);e&&!Ne.test(e)&&s.push({index:a,id:r,field:"reference_url",message:"".concat(n,": 'reference_url' must be a valid URL (http:// or https://) or null")})}j?j.length>100?s.push({index:a,id:r,field:"domain",message:"".concat(n,": 'domain' must be at most 100 characters")}):t.size>0&&!t.has(j)&&s.push({index:a,id:r,field:"domain",message:"".concat(n,": 'domain' must match exactly one of the certification domains")}):s.push({index:a,id:r,field:"domain",message:"".concat(n,": 'domain' cannot be empty")})}return{valid:0===s.length,errors:s}}(o,I);if(!r.valid)return b(r.errors),v(s("admin.questions.bulkImport.validationFailed")),void q(!1);const l=null!==(e=o.questions)&&void 0!==e?e:[],c={questions:l,source:t,import_as_active:u},d=await j.t.bulkImportQuestions(n,c);if(d.job_id)return B(d.job_id),y(l.length),v(null),void D(d.job_id);S({created_count:d.created_count||0,created_for_review_count:d.created_for_review_count||0,skipped_exact_count:d.skipped_exact_count||0,skipped_similar_count:d.skipped_similar_count||0,validation_errors_count:d.validation_errors_count||0,message:d.message}),y(l.length),v(null),F()}catch(a){const e=a instanceof Error?a.message:s("admin.questions.bulkImport.errorImport");v(e)}finally{q(!1)}}else v(s("admin.questions.bulkImport.errorNoFile"))},disabled:!h||w||z||!!P,startIcon:w||P?(0,$.jsx)(l.A,{size:16,color:"inherit"}):void 0,children:s(w||P?"admin.questions.bulkImport.validating":"admin.questions.bulkImport.import")})]})};var Ze=s(80727),$e=s(50861),Xe=s(21806),en=s(9013),nn=s(46514),sn=s(62915);const tn=e=>{let{certificationId:n}=e;const[s,t]=(0,a.useState)(0),[r,h]=(0,a.useState)([]),[A,g]=(0,a.useState)(!1),[v,f]=(0,a.useState)(null),[b,_]=(0,a.useState)(""),[W,B]=(0,a.useState)(""),[D,O]=(0,a.useState)("1"),[N,G]=(0,a.useState)(!1),[Y,Z]=(0,a.useState)("full"),[X,ee]=(0,a.useState)(!1),[ne,ie]=(0,a.useState)({jobId:null,status:"",elapsedSeconds:0,error:null}),te=(0,a.useRef)(null),[ae,oe]=(0,a.useState)({jobId:null,status:"",elapsedSeconds:0,error:null}),re=(0,a.useRef)(null),le=(0,a.useRef)(null),[ce,de]=(0,a.useState)(null),[me,ue]=(0,a.useState)("single_domain"),[xe,pe]=(0,a.useState)(!1),[he,Ae]=(0,a.useState)({}),[je,ge]=(0,a.useState)(null),[ve,fe]=(0,a.useState)(!1),[be,_e]=(0,a.useState)(""),[ye,we]=(0,a.useState)(""),[qe,Ce]=(0,a.useState)(!1),[Se,Ie]=(0,a.useState)(null),[ke,ze]=(0,a.useState)(null),We=(0,a.useCallback)(async()=>{g(!0),f(null);try{const e={};""!==b&&(e.collide_r=b),""!==W&&(e.collide_e=W),e.include_admin=D;const s=await j.t.getCollisions(n,e);h(s.pairs||[])}catch(e){f(e.message)}finally{g(!1)}},[n,b,W,D]),Pe=(0,a.useCallback)(async e=>{pe(!0);try{const s=await j.t.getEffectivePool(n,me,e);de(s),ge(e||null)}catch(s){se.A.error("[CollisionsTab] EP load error:",s)}finally{pe(!1)}},[n,me]);(0,a.useEffect)(()=>{0===s&&We(),1===s&&(je?Pe(je):Pe())},[s,me,We,Pe,je]);const Be=()=>{te.current&&(clearInterval(te.current),te.current=null)},Ee=()=>{re.current&&(clearInterval(re.current),re.current=null)},Fe=(0,a.useCallback)(e=>{Be(),te.current=setInterval(async()=>{try{const s=await j.t.getCollisionJobStatus(n,e);ie(e=>(0,i.A)((0,i.A)({},e),{},{status:s.status,preview:s.preview,elapsedSeconds:s.elapsed_seconds||0,error:s.error_message||null})),"completed"!==s.status&&"error"!==s.status||(Be(),"completed"!==s.status||s.preview||We(),"completed"===s.status&&s.preview&&s.effective_pool_job_id&&(oe({jobId:s.effective_pool_job_id,status:"queued",elapsedSeconds:0,error:null,isPreview:!0}),le.current&&le.current(s.effective_pool_job_id,!0)))}catch(s){se.A.error("[CollisionsTab] Poll error:",s)}},3e3)},[n,We]),De=(0,a.useCallback)(function(e){let s=arguments.length>1&&void 0!==arguments[1]&&arguments[1];Ee(),re.current=setInterval(async()=>{try{const a=await j.t.getEffectivePoolJobStatus(n,e);oe(e=>(0,i.A)((0,i.A)({},e),{},{status:a.status,elapsedSeconds:a.elapsed_seconds||0,error:a.error_message||null})),"completed"!==a.status&&"error"!==a.status||(Ee(),"completed"!==a.status||s||Pe(),"completed"===a.status&&s&&(t(1),await Pe(e)))}catch(a){se.A.error("[CollisionsTab] EP poll error:",a)}},3e3)},[n,Pe]);le.current=De,(0,a.useEffect)(()=>{(async()=>{try{const e=await j.t.getLatestCollisionJob(n);if(e&&e.preview&&"completed"===e.status){if(ie({jobId:e.job_id,status:e.status,elapsedSeconds:e.elapsed_seconds||0,error:e.error_message||null,preview:e.preview}),e.effective_pool_job_id){const s=await j.t.getEffectivePoolJobStatus(n,e.effective_pool_job_id);oe({jobId:e.effective_pool_job_id,status:s.status,elapsedSeconds:s.elapsed_seconds||0,error:s.error_message||null,isPreview:!0}),"processing"!==s.status&&"queued"!==s.status||De(e.effective_pool_job_id,!0)}}else e&&e.preview&&("processing"===e.status||"queued"===e.status)&&(ie({jobId:e.job_id,status:e.status,elapsedSeconds:e.elapsed_seconds||0,error:e.error_message||null,preview:e.preview}),Fe(e.job_id))}catch(e){se.A.error("[CollisionsTab] Failed to load latest job:",e)}})()},[n,Fe,De]),(0,a.useEffect)(()=>()=>{Be(),Ee()},[]);const Re=async()=>{try{const e=await j.t.refreshEffectivePool(n);"already_running"===e.status?(oe({jobId:e.job_id,status:"processing",elapsedSeconds:0,error:null}),De(e.job_id,!1)):(oe({jobId:e.job_id,status:"queued",elapsedSeconds:0,error:null}),De(e.job_id,!1))}catch(e){oe(n=>(0,i.A)((0,i.A)({},n),{},{error:e.message}))}},Qe=async()=>{ae.jobId&&(t(1),ge(ae.jobId),await Pe(ae.jobId))},Te=async()=>{ge(null),await Pe()},Me=async()=>
1{if(ne.jobId)try{const e=await j.t.clearPreview(n,ne.jobId);ze({severity:"success",message:"Artefatos de preview removidos (S3: ".concat(e.deleted_s3?"ok":"falhou ou inexistente",", itens de cache preview: ").concat(e.deleted_cache_count,"). ")+'Os pares nesta aba v\xeam do PostgreSQL (dados oficiais), n\xe3o do preview. Na aba Capacidade, "Recarregar" mostra o cache oficial salvo antes \u2014 limpar preview n\xe3o apaga esse cache.'}),ie({jobId:null,status:"",elapsedSeconds:0,error:null}),oe({jobId:null,status:"",elapsedSeconds:0,error:null}),de(null),ge(null),await Pe()}catch(e){se.A.error("[CollisionsTab] Clear preview error:",e),ze({severity:"error",message:"Falha ao limpar preview: ".concat(e.message||"erro desconhecido")})}},Le=["queued","processing"].includes(ne.status),Ue=["queued","processing"].includes(ae.status),Oe=()=>{if(!ne.jobId)return null;const e="completed"===ne.status?"success":"error"===ne.status?"error":"warning",n=ne.preview,s=Le?"".concat(n?"Preview":"Refreshing","... ").concat(ne.elapsedSeconds,"s"):"completed"===ne.status?n?"Preview completo":"Refresh completed":"Error: ".concat(ne.error);return(0,$.jsx)(p.A,{size:"small",color:e,label:s,icon:n?(0,$.jsx)(nn.A,{fontSize:"small"}):void 0,sx:{ml:1}})},Ne=()=>{if(!ae.jobId)return null;const e="completed"===ae.status?"success":"error"===ae.status?"error":"warning",n=ae.isPreview,s=Ue?"".concat(n?"Preview":"Calculating","... ").concat(ae.elapsedSeconds,"s"):"completed"===ae.status?n?"Preview completo":"Completed":"Error: ".concat(ae.error);return(0,$.jsx)(p.A,{size:"small",color:e,label:s,icon:n?(0,$.jsx)(nn.A,{fontSize:"small"}):void 0,sx:{ml:1}})};return(0,$.jsxs)(o.A,{children:[(0,$.jsxs)(u.A,{value:s,onChange:(e,n)=>t(n),sx:{mb:2},children:[(0,$.jsx)(x.A,{label:"Pares de Colisao"}),(0,$.jsx)(x.A,{label:"Capacidade da Pool"})]}),0===s&&(0,$.jsxs)(o.A,{children:[(0,$.jsxs)(o.A,{sx:{display:"flex",gap:2,mb:2,flexWrap:"wrap",alignItems:"center"},children:[(0,$.jsx)(K.A,{variant:"contained",color:"primary",startIcon:Le?(0,$.jsx)(l.A,{size:16,color:"inherit"}):(0,$.jsx)($e.A,{}),disabled:Le,onClick:()=>G(!0),children:"Recalcular Colisoes"}),Oe(),ne.preview&&ae.jobId&&Ne(),ne.preview&&"completed"===ne.status&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K.A,{variant:"contained",color:"info",size:"small",startIcon:(0,$.jsx)(nn.A,{}),onClick:Qe,disabled:!ae.jobId||"completed"!==ae.status,children:"Ver Preview"}),(0,$.jsx)(K.A,{variant:"outlined",color:"error",size:"small",startIcon:(0,$.jsx)(sn.A,{}),onClick:Me,children:"Limpar Preview"})]}),(0,$.jsx)(o.A,{sx:{ml:"auto",display:"flex",gap:1,alignItems:"center"},children:(0,$.jsx)(K.A,{variant:"outlined",size:"small",onClick:()=>fe(!0),children:"+ Admin Collision"})})]}),(0,$.jsx)(c.A,{severity:"info",sx:{mb:2},children:(0,$.jsxs)(m.A,{variant:"body2",children:["Esta lista reflete a tabela ",(0,$.jsx)("strong",{children:"question_collisions"})," no banco. O modo preview s\xf3 grava an\xe1lise em S3/cache tempor\xe1rio; n\xe3o altera estes pares."]})}),ke&&(0,$.jsx)(c.A,{severity:ke.severity,sx:{mb:2},onClose:()=>ze(null),children:ke.message}),(0,$.jsxs)(o.A,{sx:{display:"flex",gap:2,mb:2,flexWrap:"wrap"},children:[(0,$.jsxs)(T.A,{size:"small",sx:{minWidth:130},children:[(0,$.jsx)(M.A,{children:"collide_r"}),(0,$.jsxs)(L.A,{value:b,label:"collide_r",onChange:e=>_(e.target.value),children:[(0,$.jsx)(U.A,{value:"",children:"All"}),(0,$.jsx)(U.A,{value:"1",children:"Bloqueado (1)"}),(0,$.jsx)(U.A,{value:"0",children:"Nao bloqueado (0)"})]})]}),(0,$.jsxs)(T.A,{size:"small",sx:{minWidth:130},children:[(0,$.jsx)(M.A,{children:"collide_e"}),(0,$.jsxs)(L.A,{value:W,label:"collide_e",onChange:e=>B(e.target.value),children:[(0,$.jsx)(U.A,{value:"",children:"All"}),(0,$.jsx)(U.A,{value:"1",children:"Bloqueado (1)"}),(0,$.jsx)(U.A,{value:"0",children:"Nao bloqueado (0)"})]})]}),(0,$.jsxs)(T.A,{size:"small",sx:{minWidth:130},children:[(0,$.jsx)(M.A,{children:"Admin"}),(0,$.jsxs)(L.A,{value:D,label:"Admin",onChange:e=>O(e.target.value),children:[(0,$.jsx)(U.A,{value:"1",children:"Incluir admin"}),(0,$.jsx)(U.A,{value:"0",children:"Excluir admin"})]})]}),(0,$.jsx)(K.A,{variant:"outlined",size:"small",onClick:We,children:"Aplicar filtros"})]}),v&&(0,$.jsx)(c.A,{severity:"error",sx:{mb:2},children:v}),A?(0,$.jsx)(o.A,{sx:{display:"flex",justifyContent:"center",p:4},children:(0,$.jsx)(l.A,{})}):(0,$.jsx)(y.A,{component:d.A,variant:"outlined",sx:{maxHeight:500,bgcolor:"background.paper"},children:(0,$.jsxs)(w.A,{size:"small",stickyHeader:!0,children:[(0,$.jsx)(q.A,{children:(0,$.jsxs)(C.A,{children:[(0,$.jsx)(S.A,{children:"ID A"}),(0,$.jsx)(S.A,{children:"ID B"}),(0,$.jsx)(S.A,{children:"Domain A / Type A"}),(0,$.jsx)(S.A,{children:"Domain B / Type B"}),(0,$.jsx)(S.A,{align:"center",children:"score_r"}),(0,$.jsx)(S.A,{align:"center",children:"score_e"}),(0,$.jsx)(S.A,{align:"center",children:"collide_r"}),(0,$.jsx)(S.A,{align:"center",children:"collide_e"}),(0,$.jsx)(S.A,{align:"center",children:"Admin"}),(0,$.jsx)(S.A,{children:"Source"}),(0,$.jsx)(S.A,{children:"Actions"})]})}),(0,$.jsx)(I.A,{children:0===r.length?(0,$.jsx)(C.A,{children:(0,$.jsx)(S.A,{colSpan:11,align:"center",sx:{py:4,color:"text.secondary"},children:"No collision pairs found"})}):r.map((e,s)=>{var i,t,a,o;return(0,$.jsxs)(C.A,{hover:!0,children:[(0,$.jsx)(S.A,{children:e.id_a}),(0,$.jsx)(S.A,{children:e.id_b}),(0,$.jsxs)(S.A,{children:[(0,$.jsx)(m.A,{variant:"caption",display:"block",children:e.domain_a}),(0,$.jsx)(p.A,{label:e.type_a,size:"small",variant:"outlined"})]}),(0,$.jsxs)(S.A,{children:[(0,$.jsx)(m.A,{variant:"caption",display:"block",children:e.domain_b}),(0,$.jsx)(p.A,{label:e.type_b,size:"small",variant:"outlined"})]}),(0,$.jsx)(S.A,{align:"center",children:(0,$.jsx)(k.A,{title:"lev_r=".concat(e.lev_r," sub_r=").concat(e.token_subset_r," jacc_r=").concat(e.jaccard_r),children:(0,$.jsx)("span",{children:null!==(i=null===(t=e.score_r)||void 0===t?void 0:t.toFixed(3))&&void 0!==i?i:"-"})})}),(0,$.jsx)(S.A,{align:"center",children:(0,$.jsx)(k.A,{title:"w_shing=".concat(e.w_shingling_e," tok_jacc=").concat(e.token_jaccard_e," lev_e=").concat(e.lev_e),children:(0,$.jsx)("span",{children:null!==(a=null===(o=e.score_e)||void 0===o?void 0:o.toFixed(3))&&void 0!==a?a:"-"})})}),(0,$.jsx)(S.A,{align:"center",children:1===e.collide_r?(0,$.jsx)(p.A,{label:"SIM",color:"error",size:"small"}):(0,$.jsx)(p.A,{label:"NAO",size:"small"})}),(0,$.jsx)(S.A,{align:"center",children:1===e.collide_e?(0,$.jsx)(p.A,{label:"SIM",color:"error",size:"small"}):(0,$.jsx)(p.A,{label:"NAO",size:"small"})}),(0,$.jsx)(S.A,{align:"center",children:1===e.collide_admin?(0,$.jsx)(p.A,{label:"ADMIN",color:"warning",size:"small"}):"-"}),(0,$.jsx)(S.A,{children:(0,$.jsx)(p.A,{label:e.source||"-",size:"small",variant:"outlined"})}),(0,$.jsx)(S.A,{children:1===e.collide_admin&&(0,$.jsx)(K.A,{size:"small",color:"warning",onClick:()=>(async e=>{try{await j.t.clearAdminCollision(n,e.id_a,e.id_b),We()}catch(s){se.A.error("[CollisionsTab] Clear admin collision error:",s)}})(e),children:"Desmarcar Admin"})})]},"".concat(e.id_a,"-").concat(e.id_b,"-").concat(s))})})]})}),(0,$.jsxs)(m.A,{variant:"caption",color:"text.secondary",sx:{mt:1,display:"block"},children:[r.length," pares (max 1000)"]})]}),1===s&&(0,$.jsxs)(o.A,{children:[(0,$.jsxs)(o.A,{sx:{display:"flex",gap:2,mb:2,flexWrap:"wrap",alignItems:"center"},children:[!je&&(0,$.jsx)(K.A,{variant:"contained",color:"secondary",startIcon:Ue?(0,$.jsx)(l.A,{size:16,color:"inherit"}):(0,$.jsx)(Xe.A,{}),disabled:Ue,onClick:Re,children:"Calcular Capacidade da Pool"}),ne.preview&&"completed"===ne.status&&ae.jobId&&"completed"===ae.status&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K.A,{variant:je?"contained":"outlined",color:"info",size:"small",startIcon:(0,$.jsx)(nn.A,{}),onClick:Qe,children:je?"Visualizando Preview":"Ver Preview"}),(0,$.jsx)(K.A,{variant:je?"outlined":"contained",color:"primary",size:"small",onClick:Te,children:je?"Ver Dados Oficiais":"Visualizando Oficial"})]}),Ne(),(0,$.jsxs)(T.A,{size:"small",sx:{ml:"auto",minWidth:150},children:[(0,$.jsx)(M.A,{children:"Modo"}),(0,$.jsxs)(L.A,{value:me,label:"Modo",onChange:e=>ue(e.target.value),children:[(0,$.jsx)(U.A,{value:"single_domain",children:"Por Dominio"}),(0,$.jsx)(U.A,{value:"all_domains",children:"Todos os Dominios"})]})]}),(0,$.jsx)(K.A,{variant:"outlined",size:"small",onClick:()=>je?Pe(je):Pe(),children:"Recarregar"})]}),je&&(0,$.jsx)(c.A,{severity:"warning",sx:{mb:2},children:(0,$.jsxs)(o.A,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,$.jsx)(nn.A,{}),(0,$.jsxs)(m.A,{variant:"body2",children:[(0,$.jsx)("strong",{children:"MODO PREVIEW ATIVO"})," \u2014 Dados n\xe3o persistidos no PostgreSQL. Collision Job: ",(0,$.jsx)("strong",{children:ne.j
1obId})]})]})}),!je&&(0,$.jsx)(c.A,{severity:"info",sx:{mb:2},children:(0,$.jsxs)(m.A,{variant:"body2",children:["Por padr\xe3o, estes n\xfameros v\xeam do ",(0,$.jsx)("strong",{children:"cache oficial"})," no DynamoDB (\xfaltimo c\xe1lculo com colis\xf5es persistidas). Limpar preview n\xe3o remove este cache."]})}),xe?(0,$.jsx)(o.A,{sx:{display:"flex",justifyContent:"center",p:4},children:(0,$.jsx)(l.A,{})}):ce?"not_computed"===ce.status?(0,$.jsxs)(c.A,{severity:"warning",children:[ce.message,(0,$.jsx)("br",{}),(0,$.jsxs)(m.A,{variant:"caption",children:["Colisoes: ",ce.collision_count," | Questoes ativas: ",ce.total_active_questions,ce.last_collision_refresh&&" | Ultimo refresh: ".concat(new Date(ce.last_collision_refresh).toLocaleString())]})]}):(0,$.jsxs)(o.A,{children:[(0,$.jsxs)(o.A,{sx:{display:"flex",gap:2,mb:2,flexWrap:"wrap",alignItems:"center"},children:[(0,$.jsx)(p.A,{label:"".concat(ce.collision_count," colisoes"),size:"small"}),(0,$.jsx)(p.A,{label:"".concat(ce.total_active_questions," questoes ativas"),size:"small"}),ce.compute_time_seconds&&(0,$.jsx)(p.A,{label:"".concat(Number(ce.compute_time_seconds).toFixed(1),"s compute"),size:"small"}),ce.last_computed_at&&(0,$.jsx)(p.A,{label:"Calculado: ".concat(new Date(ce.last_computed_at).toLocaleString()),size:"small",variant:"outlined"}),ce.is_stale&&(0,$.jsx)(p.A,{label:"Dados desatualizados",color:"warning",size:"small"})]}),ce.summary&&"single_domain"===me&&(0,$.jsxs)(c.A,{severity:"info",sx:{mb:2},children:["T_max: ",(0,$.jsxs)("strong",{children:[ce.summary.min_t_max_min,"\u2013",ce.summary.min_t_max_max]})," questoes (piso\u2013teto)",ce.summary.bottleneck_domain&&' \u2014 gargalo: "'.concat(ce.summary.bottleneck_domain,'"'),ce.multiple_rule&&" (regra: ".concat(ce.multiple_rule.min_percentage,"-").concat(ce.multiple_rule.max_percentage,"% multiple)")]}),ce.summary&&"all_domains"===me&&(0,$.jsxs)(c.A,{severity:"info",sx:{mb:2},children:["Y_max por dominio: ",(0,$.jsxs)("strong",{children:[ce.summary.y_max_per_domain_min,"\u2013",ce.summary.y_max_per_domain_max]})," | T_max total: ",(0,$.jsxs)("strong",{children:[ce.summary.t_max_total_min,"\u2013",ce.summary.t_max_total_max]})," | Gargalo single: ",(0,$.jsxs)("strong",{children:[ce.summary.bottleneck_single_min,"\u2013",ce.summary.bottleneck_single_max]})," | Gargalo multiple: ",(0,$.jsxs)("strong",{children:[ce.summary.bottleneck_multiple_min,"\u2013",ce.summary.bottleneck_multiple_max]})]}),(0,$.jsx)(y.A,{component:d.A,variant:"outlined",sx:{maxHeight:500,bgcolor:"background.paper"},children:(0,$.jsxs)(w.A,{size:"small",stickyHeader:!0,children:[(0,$.jsx)(q.A,{children:(0,$.jsxs)(C.A,{children:[(0,$.jsx)(S.A,{children:"Dominio"}),"single_domain"===me?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(S.A,{align:"center",children:"Single"}),(0,$.jsx)(S.A,{align:"center",children:"Multiple"}),(0,$.jsx)(S.A,{align:"center",children:"T_max (piso\u2013teto)"}),(0,$.jsx)(S.A,{align:"center",children:"Breakdown"}),(0,$.jsx)(S.A,{align:"center",children:"Matriz S(M)"})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(S.A,{align:"center",children:"MIS Single (piso\u2013teto)"}),(0,$.jsx)(S.A,{align:"center",children:"MIS Multiple (piso\u2013teto)"}),(0,$.jsx)(S.A,{align:"center",children:"Matriz S(M)"})]})]})}),(0,$.jsx)(I.A,{children:(ce.domains||[]).map((e,n)=>{var s,t,r,l,c,d,u;const x=e.domain,h=he[x]||!1,A=Object.entries(e.matrix_max||{}).sort((e,n)=>parseInt(e[0])-parseInt(n[0])),j=Object.entries(e.matrix_min||{}).sort((e,n)=>parseInt(e[0])-parseInt(n[0])),g=Object.fromEntries(j);return(0,$.jsxs)(a.Fragment,{children:[(0,$.jsxs)(C.A,{hover:!0,children:[(0,$.jsx)(S.A,{children:(0,$.jsx)(m.A,{variant:"body2",children:e.domain})}),"single_domain"===me?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(S.A,{align:"center",children:e.total_single}),(0,$.jsx)(S.A,{align:"center",children:e.total_multiple}),(0,$.jsx)(S.A,{align:"center",children:(0,$.jsx)(p.A,{label:"".concat(e.t_max_min,"\u2013").concat(e.t_max_max),color:e.t_max_max===(null===(s=ce.summary)||void 0===s?void 0:s.min_t_max_max)?"warning":"default",size:"small"})}),(0,$.jsx)(S.A,{align:"center",children:(0,$.jsxs)(m.A,{variant:"caption",children:[null===(t=e.t_max_breakdown_min)||void 0===t?void 0:t.single,"\u2013",null===(r=e.t_max_breakdown_max)||void 0===r?void 0:r.single,"S +"," ",null===(l=e.t_max_breakdown_min)||void 0===l?void 0:l.multiple,"\u2013",null===(c=e.t_max_breakdown_max)||void 0===c?void 0:c.multiple,"M"]})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(S.A,{align:"center",children:(0,$.jsx)(p.A,{label:"".concat(e.min_mis_single,"\u2013").concat(e.max_mis_single),color:e.min_mis_single===(null===(d=ce.summary)||void 0===d?void 0:d.bottleneck_single_min)?"warning":"default",size:"small"})}),(0,$.jsx)(S.A,{align:"center",children:(0,$.jsx)(p.A,{label:"".concat(e.min_mis_multiple,"\u2013").concat(e.max_mis_multiple),color:e.min_mis_multiple===(null===(u=ce.summary)||void 0===u?void 0:u.bottleneck_multiple_min)?"warning":"default",size:"small"})})]}),(0,$.jsx)(S.A,{align:"center",children:(0,$.jsx)(z.A,{size:"small",onClick:()=>Ae(e=>(0,i.A)((0,i.A)({},e),{},{[x]:!e[x]})),children:h?(0,$.jsx)(en.A,{fontSize:"small"}):(0,$.jsx)(P.A,{fontSize:"small"})})})]}),h&&(0,$.jsx)(C.A,{children:(0,$.jsx)(S.A,{colSpan:"single_domain"===me?6:4,sx:{py:0,bgcolor:"action.hover"},children:(0,$.jsx)(Ze.A,{in:h,children:(0,$.jsxs)(o.A,{sx:{p:1},children:[(0,$.jsx)(m.A,{variant:"caption",fontWeight:700,children:"Matriz S(M) \u2014 singles disponiveis por M multis (piso\u2013teto):"}),(0,$.jsx)(o.A,{sx:{display:"flex",flexWrap:"wrap",gap:.5,mt:.5},children:A.map(e=>{var n;let[s,i]=e;return(0,$.jsx)(p.A,{size:"small",label:"M=".concat(s,": ").concat(null!==(n=g[s])&&void 0!==n?n:i,"\u2013").concat(i),variant:"outlined"},s)})})]})})})})]},n)})})]})})]}):(0,$.jsx)(c.A,{severity:"info",children:'Nenhum dado de capacidade calculado. Clique em "Calcular Capacidade da Pool".'})]}),(0,$.jsxs)(E.A,{open:N,onClose:()=>G(!1),children:[(0,$.jsx)(F.A,{children:"Recalcular Colisoes"}),(0,$.jsxs)(R.A,{children:[(0,$.jsx)(m.A,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"Selecione o modo de recalculo:"}),(0,$.jsxs)(T.A,{fullWidth:!0,children:[(0,$.jsx)(M.A,{children:"Modo"}),(0,$.jsxs)(L.A,{value:Y,label:"Modo",onChange:e=>Z(e.target.value),children:[(0,$.jsx)(U.A,{value:"full",children:"Full \u2014 recalcula todos os pares (O(n\xb2))"}),(0,$.jsx)(U.A,{value:"incremental_new",children:"Incremental New \u2014 apenas questoes novas"}),(0,$.jsx)(U.A,{value:"incremental_updated",children:"Incremental Updated \u2014 questoes editadas"})]})]}),(0,$.jsx)(V.A,{control:(0,$.jsx)(H.A,{checked:X,onChange:e=>ee(e.target.checked),color:"info"}),label:(0,$.jsxs)(o.A,{children:[(0,$.jsxs)(m.A,{variant:"body2",children:[(0,$.jsx)("strong",{children:"Modo Preview"})," (n\xe3o persiste no banco)"]}),(0,$.jsx)(m.A,{variant:"caption",color:"text.secondary",children:"Calcula colis\xf5es e capacidade sem bloquear quest\xf5es em produ\xe7\xe3o"})]}),sx:{mt:2}}),"full"===Y&&!X&&(0,$.jsx)(c.A,{severity:"warning",sx:{mt:2},children:"Full refresh pode demorar varios minutos para pools grandes."}),X&&(0,$.jsx)(c.A,{severity:"info",sx:{mt:2},children:"Preview permite analisar o impacto de colis\xf5es sem afetar exames em produ\xe7\xe3o. Cache expira em 1 dia automaticamente."})]}),(0,$.jsxs)(J.A,{children:[(0,$.jsx)(K.A,{onClick:()=>G(!1),children:"Cancelar"}),(0,$.jsx)(K.A,{variant:"contained",color:X?"info":"primary",onClick:async()=>{G(!1);try{const e=await j.t.refreshCollisions(n,Y,X);ie({jobId:e.job_id,status:e.status,elapsedSeconds:0,error:null,preview:e.preview}),Fe(e.job_id)}catch(e){ie(n=>(0,i.A)((0,i.A)({},n),{},{error:e.message}))}},children:X?"Iniciar Preview":"Iniciar"})]})]}),(0,$.jsxs)(E.A,{open:ve,onClose:()=>{fe(!1),Ie(null)},children:[(0,$.jsx)(F.A,{children:"Adicionar Colisao Manual (Admin)"}),(0,$.jsxs)(R.A,{children:[(0,$.jsx)(m.A,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"Marque um par de questoes como colisao manualmente."}),(0,$.jsxs)(o.A,{sx:{display:"flex",gap:2},children:[(0,$.jsx)(Q.A,{label:"ID A",type:"number",value:be,onChange:e=>_e(e.target.value),size:"small"}),(0,$.jsx)(Q.A,{label:"ID B",type:"number",value:ye,onChange:e=>we(e.target.value),size:"small"})]}),Se&&(0,$.jsx)(c.A,{severity:"error",sx:{mt:2},children:Se})]}),(0,$.jsxs)(J.A,{children:[(0,$.jsx)(K.A,{onClick:()=>{fe(!1),Ie(null)},children:"Cancelar"}),(0,$.jsx)(K.A,{variant:"contained",color:"warning",disabled:!be||!ye||qe,onClick:async()=>{Ce(!0),Ie(null);try{await j.t.setAdminCollision(n,parseInt(be),parseInt(ye)),fe(!1),_e(""),we(""),We()}catch(e){Ie(e.message)}finally{Ce(!1)}},children:qe?(0,$.jsx)(l.A,{size:16}):"Marcar como Colisao"})]})]})]})},an=["children","value","index"];function on(e){const{children:n,value:s,index:a}=e,r=(0,t.A)(e,an);return(0,$.jsx)("div",(0,i.A)((0,i.A)({role:"tabpanel",hidden:s!==a,id:"questions-tabpanel-".concat(a),"aria-labelledby":"questions-tab-".concat(a)},r),{},{children:s===a&&(0,$.jsx)(o.A,{sx:{pt:3},children:n})}))}const rn=()=>{const{certificationId:e}=(0,h.g)(),n=(0,h.Zp)(),{isAdmin:s}=(0,g.Sk)(),[i,t]=(0,a.useState)(0),[v,f]=(0,a.useState)(!0),[b,_]=(0,a.useState)(null),[y,w]=(0,a.useState)(null);(0,a.useEffect)(()=>{s||n("/")},[s,n]);const q=(0,a.useCallback)(async()=>{try{f(!0),_(null);const n=(await j.t.getCertifications("ALL")).certifications.find(n=>n.certification_id===e);if(!n)return void _("Certification not found");w(n),se.A.info("[CertificationQuestionsManager] Loaded stats:",n)}catch(n){se.A.error("[CertificationQuestionsManager] Error loading stats:",n),_(n.message||"Failed to load certification data")}finally{f(!1)}},[e]);(0,a.useEffect)(()=>{q()},[q]);return v?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(A.z,{title:"Questions Manager",subtitle:"Loading...",icon:(0,$.jsx)(Ce.A,{}),showBackButton:!0,backRoute:"/admin/certifications"}),(0,$.jsx)(r.A,{maxWidth:"xl",sx:{py:4},children:(0,$.jsx)(o.A,{sx:{display:"flex",justifyContent:"center",p:4},children:(0,$.jsx)(l.A,{})})})]}):b||!y?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(A.z,{title:"Questions Manager",subtitle:"Error",icon:(0,$.jsx)(Ce.A,{}),showBackButton:!0,backRoute:"/admin/certifications"}),(0,$.jsx)(r.A,{maxWidth:"xl",sx:{py:4},children:(0,$.jsx)(c.A,{severity:"error",children:b||"Certification not found"})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(A.z,{title:"Questions Manager: ".concat(y.certification_id),subtitle:y.name,icon:(0,$.jsx)(Ce.A,{}),showBackButton:!0,backRoute:"/admin/certifications"}),(0,$.jsxs)(r.A,{maxWidth:"xl",sx:{py:4},children:[(0,$.jsxs)(d.A,{elevation:2,sx:{p:3,mb:3,borderRadius:3,background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)"},children:[(0,$.jsx)(m.A,{variant:"h6",fontWeight:700,sx:{color:"white",mb:2},children:"\ud83d\udcca Consolidated Stats"}),(0,$.jsxs)(o.A,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"repeat(2, 1fr)",md:"repeat(4, 1fr)"},gap:2},children:[(0,$.jsxs)(o.A,{sx:{bgcolor:"rgba(255, 255, 255, 0.15)",borderRadius:2,p:2,backdropFilter:"blur(10px)"},children:[(0,$.jsx)(m.A,{variant:"body2",sx:{color:"rgba(255,255,255,0.8)"},children:"Active Questions"}),(0,$.jsx)(m.A,{variant:"h4",fontWeight:700,sx:{color:"white"},children:y.active_questions})]}),(0,$.jsxs)(o.A,{sx:{bgcolor:"rgba(255, 255, 255, 0.15)",borderRadius:2,p:2,backdropFilter:"blur(10px)"},children:[(0,$.jsx)(m.A,{variant:"body2",sx:{color:"rgba(255,255,255,0.8)"},children:"Total Questions"}),(0,$.jsx)(m.A,{variant:"h4",fontWeight:700,sx:{color:"white"},children:y.total_questions})]}),(0,$.jsxs)(o.A,{sx:{bgcolor:"rgba(255, 255, 255, 0.15)",borderRadius:2,p:2,backdropFilter:"blur(10px)"},children:[(0,$.jsx)(m.A,{variant:"body2",sx:{color:"rgba(255,255,255,0.8)"},children:"Pending Review"}),(0,$.jsx)(m.A,{variant:"h4",fontWeight:700,sx:{color:"white"},children:y.pending_review})]}),(0,$.jsxs)(o.A,{sx:{bgcolor:"rgba(255, 255, 255, 0.15)",borderRadius:2,p:2,backdropFilter:"blur(10px)"},children:[(0,$.jsx)(m.A,{variant:"body2",sx:{color:"rgba(255,255,255,0.8)"},children:"Health Score"}),(0,$.jsxs)(m.A,{variant:"h4",fontWeight:700,sx:{color:"white"},children:[y.health_score,"/100"]})]})]})]}),(0,$.jsxs)(d.A,{elevation:2,sx:{borderRadius:3,overflow:"hidden",bgcolor:"background.paper"},children:[(0,$.jsx)(o.A,{sx:{borderBottom:1,borderColor:"divider"},children:(0,$.jsxs)(u.A,{value:i,onChange:(e,n)=>{t(n)},variant:"scrollable",scrollButtons:"auto","aria-label":"questions manager tabs",children:[(0,$.jsx)(x.A,{label:"By Domain"}),(0,$.jsx)(x.A,{label:"All Questions"}),(0,$.jsx)(x.A,{label:(0,$.jsxs)(o.A,{sx:{display:"flex",alignItems:"center",gap:1},children:["Pending Review",y.pending_review>0&&(0,$.jsx)(p.A,{label:y.pending_review,size:"small",color:"warning",sx:{height:20}})]})}),(0,$.jsx)(x.A,{label:"Analytics"}),(0,$.jsx)(x.A,{label:"Votes & Feedback"}),(0,$.jsx)(x.A,{label:"Exam Performance"}),(0,$.jsx)(x.A,{label:"Bulk Operations"}),(0,$.jsx)(x.A,{label:"Colisoes"})]})}),(0,$.jsxs)(o.A,{sx:{p:3},children:[(0,$.jsx)(on,{value:i,index:0,children:(0,$.jsx)(ie,{certificationId:e})}),(0,$.jsx)(on,{value:i,index:1,children:(0,$.jsx)(re,{certificationId:e})}),(0,$.jsx)(on,{value:i,index:2,children:e&&(0,$.jsx)(xe,{certificationId:e})}),(0,$.jsxs)(on,{value:i,index:3,children:[(0,$.jsx)(m.A,{variant:"h6",gutterBottom:!0,children:"\ud83d\udcca Analytics"}),(0,$.jsx)(m.A,{variant:"body2",color:"text.secondary",children:"Tab 4: Analytics - Coming soon..."})]}),(0,$.jsx)(on,{value:i,index:4,children:e&&(0,$.jsx)(we,{certificationId:e})}),(0,$.jsx)(on,{value:i,index:5,children:e&&(0,$.jsx)(Be,{certificationId:e})}),(0,$.jsx)(on,{value:i,index:6,children:e&&(0,$.jsx)(Ye,{certificationId:e})}),(0,$.jsx)(on,{value:i,index:7,children:e&&(0,$.jsx)(tn,{certificationId:e})})]})]})]})]})}},99562(e,n,s){s.d(n,{t:()=>a});var i=s(69312),t=s(51673);const a={async getCertifications(e){try{const n=e&&"ALL"!==e?"?provider=".concat(e):"",s=await i.A.get("/admin/certifications".concat(n));return t.A.debug("[AdminCertificationService] Loaded certifications:",s.data),s.data}catch(a){var n,s;throw t.A.error("[AdminCertificationService] Error fetching certifications:",a),new Error((null===(n=a.response)||void 0===n||null===(s=n.data)||void 0===s?void 0:s.error)||"Failed to load certifications")}},async getQuestions(e,n){try{const s=new URLSearchParams;null!==n&&void 0!==n&&n.domain&&s.append("domain",n.domain),null!==n&&void 0!==n&&n.type&&s.append("type",n.type),null!==n&&void 0!==n&&n.status&&s.append("status",n.status),null!==n&&void 0!==n&&n.source&&s.append("source",n.source),null!==n&&void 0!==n&&n.search&&s.append("search",n.search),null!==n&&void 0!==n&&n.page&&s.append("page",n.page.toString()),null!==n&&void 0!==n&&n.limit&&s.append("limit",n.limit.toString());const a=s.toString(),o="/admin/certifications/".concat(e,"/questions").concat(a?"?".concat(a):""),r=await i.A.get(o);return t.A.debug("[AdminCertificationService] Loaded questions:",r.data),r.data}catch(o){var s,a;throw t.A.error("[AdminCertificationService] Error fetching questions:",o),new Error((null===(s=o.response)||void 0===s||null===(a=s.data)||void 0===a?void 0:a.error)||"Failed to load questions")}},async getVotesAndFeedback(e,n){try{const s=new URLSearchParams;null!==n&&void 0!==n&&n.page&&s.append("page",n.page.toString()),null!==n&&void 0!==n&&n.per_page&&s.append("per_page",n.per_page.toString()),null!==n&&void 0!==n&&n.view_mode&&s.append("view_mode",n.view_mode),null!==n&&void 0!==n&&n.domain&&s.append("domain",n.domain),null!==n&&void 0!==n&&n.status&&s.append("status",n.status),null!==n&&void 0!==n&&n.sort&&s.append("sort",n.sort);const a=s.toString(),o="/admin/certifications/".concat(e,"/votes-feedback").concat(a?"?".concat(a):""),r=await i.A.get(o);return t.A.debug("[AdminCertificationService] Loaded votes & feedback:",r.data),r.data}catch(o){var s,a;throw t.A.error("[AdminCertificationService] Error fetching votes & feedback:",o),new Error((null===(s=o.response)||void 0===s||null===(a=s.data)||void 0===a?void 0:a.error)||"Failed to load votes and feedback data")}},async getExamPerformance(e,n){try{const s=new URLSearchParams;null!==n&&void 0!==n&&n.page&&s.append("page",n.page.toString()),null!==n&&void 0!==n&&n.per_page&&s.append("per_page",n.per_page.toString()),null!==n&&void 0!==n&&n.view_mode&&s.append("view_mode",n.view_mode),null!==n&&void 0!==n&&n
1.domain&&s.append("domain",n.domain),null!==n&&void 0!==n&&n.status&&s.append("status",n.status),void 0!==(null===n||void 0===n?void 0:n.min_usage)&&s.append("min_usage",n.min_usage.toString()),null!==n&&void 0!==n&&n.sort&&s.append("sort",n.sort);const a=s.toString(),o="/admin/certifications/".concat(e,"/exam-performance").concat(a?"?".concat(a):""),r=await i.A.get(o);return t.A.debug("[AdminCertificationService] Loaded exam performance:",r.data),r.data}catch(o){var s,a;throw t.A.error("[AdminCertificationService] Error fetching exam performance:",o),new Error((null===(s=o.response)||void 0===s||null===(a=s.data)||void 0===a?void 0:a.error)||"Failed to load exam performance data")}},async getDomains(e){try{const n=await i.A.get("/admin/certifications/".concat(e,"/domains"));return t.A.debug("[AdminCertificationService] Loaded domains:",n.data),n.data}catch(a){var n,s;throw t.A.error("[AdminCertificationService] Error fetching domains:",a),new Error((null===(n=a.response)||void 0===n||null===(s=n.data)||void 0===s?void 0:s.error)||"Failed to load domains")}},async updateQuestion(e,n){try{await i.A.patch("/admin/questions/".concat(e),n),t.A.info("[AdminCertificationService] Question updated:",e)}catch(o){var s,a;throw t.A.error("[AdminCertificationService] Error updating question:",o),new Error((null===(s=o.response)||void 0===s||null===(a=s.data)||void 0===a?void 0:a.error)||"Failed to update question")}},async bulkImportQuestions(e,n){try{return(await i.A.post("/admin/certifications/".concat(e,"/questions/import"),n)).data}catch(o){var s,a;throw t.A.error("[AdminCertificationService] Bulk import error:",o),new Error((null===(s=o.response)||void 0===s||null===(a=s.data)||void 0===a?void 0:a.error)||"Failed to import questions")}},async getBulkImportJobStatus(e){try{return(await i.A.get("/admin/questions/jobs/".concat(e))).data}catch(a){var n,s;throw t.A.error("[AdminCertificationService] Get bulk import job status error:",a),new Error((null===(n=a.response)||void 0===n||null===(s=n.data)||void 0===s?void 0:s.error)||"Failed to get job status")}},async getPendingReviewQuestions(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10;try{const a=await i.A.get("/admin/certifications/".concat(e,"/pending-review?page=").concat(n,"&limit=").concat(s));return t.A.debug("[AdminCertificationService] Loaded pending review questions:",a.data),a.data}catch(r){var a,o;throw t.A.error("[AdminCertificationService] Error fetching pending review questions:",r),new Error((null===(a=r.response)||void 0===a||null===(o=a.data)||void 0===o?void 0:o.error)||"Failed to load pending review questions")}},async refreshCollisions(e,n){let s=arguments.length>2&&void 0!==arguments[2]&&arguments[2];try{return(await i.A.post("/admin/certifications/".concat(e,"/collisions/refresh"),{mode:n,preview:s})).data}catch(o){var t,a;throw new Error((null===(t=o.response)||void 0===t||null===(a=t.data)||void 0===a?void 0:a.message)||"Failed to start collision refresh")}},async getCollisionJobStatus(e,n){try{return(await i.A.get("/admin/certifications/".concat(e,"/collisions/jobs/").concat(n))).data}catch(a){var s,t;throw new Error((null===(s=a.response)||void 0===s||null===(t=s.data)||void 0===t?void 0:t.message)||"Failed to get job status")}},async getLatestCollisionJob(e){try{return(await i.A.get("/admin/certifications/".concat(e,"/collisions/jobs"))).data}catch(a){var n,s,t;if(404===(null===(n=a.response)||void 0===n?void 0:n.status))return null;throw new Error((null===(s=a.response)||void 0===s||null===(t=s.data)||void 0===t?void 0:t.message)||"Failed to get latest job")}},async getCollisions(e,n){try{const s=new URLSearchParams(n).toString(),t="/admin/certifications/".concat(e,"/collisions").concat(s?"?".concat(s):"");return(await i.A.get(t)).data}catch(a){var s,t;throw new Error((null===(s=a.response)||void 0===s||null===(t=s.data)||void 0===t?void 0:t.message)||"Failed to load collisions")}},async setAdminCollision(e,n,s){try{await i.A.post("/admin/certifications/".concat(e,"/collisions/admin"),{id_a:n,id_b:s})}catch(o){var t,a;throw new Error((null===(t=o.response)||void 0===t||null===(a=t.data)||void 0===a?void 0:a.message)||"Failed to set admin collision")}},async clearAdminCollision(e,n,s){try{await i.A.delete("/admin/certifications/".concat(e,"/collisions/admin"),{data:{id_a:n,id_b:s}})}catch(o){var t,a;throw new Error((null===(t=o.response)||void 0===t||null===(a=t.data)||void 0===a?void 0:a.message)||"Failed to clear admin collision")}},async refreshEffectivePool(e){try{return(await i.A.post("/admin/certifications/".concat(e,"/effective-pool/refresh"),{})).data}catch(t){var n,s;throw new Error((null===(n=t.response)||void 0===n||null===(s=n.data)||void 0===s?void 0:s.message)||"Failed to start effective pool calculation")}}
1,async getEffectivePoolJobStatus(e,n){try{return(await i.A.get("/admin/certifications/".concat(e,"/effective-pool/jobs/").concat(n))).data}catch(a){var s,t;throw new Error((null===(s=a.response)||void 0===s||null===(t=s.data)||void 0===t?void 0:t.message)||"Failed to get effective pool job status")}},async getEffectivePool(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"single_domain",s=arguments.length>2?arguments[2]:void 0;try{let t="/admin/certifications/".concat(e,"/effective-pool?mode=").concat(n);s&&(t+="&preview_job_id=".concat(s));return(await i.A.get(t)).data}catch(o){var t,a;throw new Error((null===(t=o.response)||void 0===t||null===(a=t.data)||void 0===a?void 0:a.message)||"Failed to load effective pool data")}},async clearPreview(e,n){try{return(await i.A.post("/admin/certifications/".concat(e,"/preview/clear"),{collision_job_id:n})).data}catch(a){var s,t;throw new Error((null===(s=a.response)||void 0===s||null===(t=s.data)||void 0===t?void 0:t.message)||"Failed to clear preview data")}}}},20980(e,n,s){s.d(n,{h:()=>t});var i=s(82932);const t={createQuestions:async e=>(await i.api.post("/admin/questions/create",e)).data,getJobStatus:async e=>(await i.api.get("/admin/questions/jobs/".concat(e))).data,getQuestionsByIds:async e=>(await i.api.post("/admin/questions/batch",{question_ids:e})).data.questions,async deactivateQuestion(e){await i.api.patch("/admin/questions/".concat(e,"/deactivate"))},async approveQuestion(e){await i.api.patch("/admin/questions/".concat(e,"/approve"))},async rejectQuestion(e){await i.api.patch("/admin/questions/".concat(e,"/reject"))}}},69312(e,n,s){s.d(n,{A:()=>r});var i=s(29246),t=s(19658),a=s(51673);const o=i.A.create({baseURL:"/api/v1",headers:{"Content-Type":"application/json"}});o.interceptors.request.use(async e=>{try{const n=(await t.N.currentSession()).getIdToken().getJwtToken();e.headers.Authorization="Bearer ".concat(n),a.A.debug("[API] Token added to request")}catch(n){a.A.debug("[API] No active session")}return e},e=>Promise.reject(e)),o.interceptors.response.use(e=>e,async e=>{var n;const s=e.config;if(401===(null===(n=e.response)||void 0===n?void 0:n.status)&&!s._retry){s._retry=!0;try{const e=(await t.N.currentSession()).getIdToken().getJwtToken();return s.headers.Authorization="Bearer ".concat(e),o(s)}catch(i){return await t.N.signOut(),window.location.href="/login",Promise.reject(i)}}return Promise.reject(e)});const r=o}}]);

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.