1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2918],{63815:function(e,n,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/daily-challenges/[challengeId]",function(){return t(61783)}])},61783:function(e,n,t){"use strict";t.r(n);var l=t(82729),a=t(85893),s=t(67294),i=t(11163),r=t(41664),c=t.n(r),o=t(19521),d=t(99428),u=t(62069),h=t(73857),p=t(70933),f=t(4584),g=t(86893);function _templateObject(){let e=(0,l._)(["\n margin-top: 80px;\n padding-bottom: 80px;\n min-height: calc(100vh - 80px);\n"]);return _templateObject=function(){return e},e}function _templateObject1(){let e=(0,l._)(['\n &.backlink {\n display: inline-flex;\n align-items: center;\n gap: 8px;\n font-family: "Mulish", sans-serif;\n font-size: 14px;\n color: ',";\n text-decoration: none;\n margin-bottom: 24px;\n cursor: pointer;\n\n &.backlink:hover {\n text-decoration: underline;\n color: ",";\n }\n\n svg {\n width: 16px;\n height: 16px;\n }\n }\n"]);return _templateObject1=function(){return e},e}function _templateObject2(){let e=(0,l._)(["\n display: flex;\n justify-content: space-between;\n align-items: flex-start;\n margin-bottom: 32px;\n"]);return _templateObject2=function(){return e},e}function _templateObject3(){let e=(0,l._)(['\n display: flex;\n flex-direction: column;\n gap: 8px;\n\n h1 {\n font-family: "PixelGridM", sans-serif;\n font-size: 32px;\n font-weight: 700;\n line-height: 1.4;\n letter-spacing: 0.03em;\n color: ',';\n margin: 0;\n }\n\n .date-input {\n font-family: Mulish;\n font-size: 24px;\n font-style: normal;\n font-weight: 700;\n line-height: 150%;\n font-family: "Mulish", sans-serif;\n font-size: 18px;\n color: ',";\n background: none;\n border: none;\n outline: none;\n padding: 0;\n cursor: pointer;\n width: fit-content;\n\n &::-webkit-calendar-picker-indicator {\n cursor: pointer;\n opacity: 0.6;\n background-color: ",";\n }\n }\n"]);return _templateObject3=function(){return e},e}function _templateObject4(){let e=(0,l._)(["\n display: flex;\n gap: 8px;\n\n .nav-btn {\n width: 50px;\n height: 50px;\n display: flex;\n align-items: center;\n justify-content: center;\n\n svg {\n width: 20px;\n height: 20px;\n }\n }\n"]);return _templateObject4=function(){return e},e}function _templateObject5(){let e=(0,l._)(["\n display: flex;\n gap: 12px;\n margin-bottom: 32px;\n flex-wrap: wrap;\n\n .action-btn {\n display: flex;\n align-items: center;\n gap: 8px;\n\n svg {\n width: 18px;\n height: 18px;\n }\n }\n"]);return _templateObject5=function(){return e},e}function _templateObject6(){let e=(0,l._)(['\n display: flex;\n justify-content: center;\n align-items: center;\n min-height: 400px;\n font-family: "Mulish", sans-serif;\n font-size: 16px;\n color: ',";\n"]);return _templateObject6=function(){return e},e}function _templateObject7(){let e=(0,l._)(["\n padding: 24px;\n background: ",";\n border: 2px solid ",';\n border-radius: 4px;\n font-family: "Mulish", sans-serif;\n color: ',";\n margin-bottom: 24px;\n"]);return _templateObject7=function(){return e},e}function _templateObject8(){let e=(0,l._)(["\n padding: 16px 24px;\n background: ",";\n border: 2px solid ",';\n border-radius: 4px;\n font-family: "Mulish", sans-serif;\n color: ',";\n margin-bottom: 24px;\n"]);return _templateObject8=function(){return e},e}function _templateObject9(){let e=(0,l._)(["\n padding: 24px;\n background: ",";\n border: 2px solid ",';\n border-radius: 4px;\n margin-bottom: 24px;\n\n h4 {\n font-family: "Mulish", sans-serif;\n font-weight: 700;\n font-size: 16px;\n color: ',';\n margin: 0 0 16px 0;\n }\n\n .test-result {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 8px 0;\n font-family: "Mulish", sans-serif;\n font-size: 14px;\n\n &.passed {\n color: ',";\n }\n\n &.failed {\n color: ",";\n }\n }\n"]);return _templateObject9=function(){return e},e}let m=o.default.div.withConfig({componentId:"sc-f71c4288-0"}
1)(_templateObject()),x=o.default.a.withConfig({componentId:"sc-f71c4288-1"})(_templateObject1(),e=>{let{theme:n}=e;return n.colors.text.accent.blue},e=>{let{theme:n}=e;return n.colors.text.accent.blue}),b=o.default.div.withConfig({componentId:"sc-f71c4288-2"})(_templateObject2()),y=o.default.div.withConfig({componentId:"sc-f71c4288-3"})(_templateObject3(),e=>{let{theme:n}=e;return n.colors.text.primary},e=>{let{theme:n}=e;return n.colors.text.primary},e=>{let{theme:n}=e;return n.colors.text.primary}),j=o.default.div.withConfig({componentId:"sc-f71c4288-4"})(_templateObject4()),v=o.default.div.withConfig({componentId:"sc-f71c4288-5"})(_templateObject5()),_=o.default.div.withConfig({componentId:"sc-f71c4288-6"})(_templateObject6(),e=>{let{theme:n}=e;return n.colors.text.tertiary}),w=o.default.div.withConfig({componentId:"sc-f71c4288-7"})(_templateObject7(),e=>{let{theme:n}=e;return n.colors.palette.red["100"]},e=>{let{theme:n}=e;return n.colors.palette.red["500"]},e=>{let{theme:n}=e;return n.colors.palette.red["700"]}),C=o.default.div.withConfig({componentId:"sc-f71c4288-8"})(_templateObject8(),e=>{let{theme:n}=e;return n.colors.palette.green["100"]},e=>{let{theme:n}=e;return n.colors.palette.green["500"]},e=>{let{theme:n}=e;return n.colors.palette.green["700"]}),O=o.default.div.withConfig({componentId:"sc-f71c4288-9"})(_templateObject9(),e=>{let{theme:n}=e;return n.colors.background.grey.secondary},e=>{let{theme:n}=e;return n.colors.border.grey.light},e=>{let{theme:n}=e;return n.colors.text.primary},e=>{let{theme:n}=e;return n.colors.palette.green["600"]},e=>{let{theme:n}=e;return n.colors.palette.red["600"]});n.default=function(){let e=(0,i.useRouter)(),{challengeId:n}
1=e.query,[t,l]=(0,s.useState)(null),[r,o]=(0,s.useState)(!0),[k,S]=(0,s.useState)(null),[F,I]=(0,s.useState)(null),[N,P]=(0,s.useState)(!1),[Z,z]=(0,s.useState)(!1),[D,R]=(0,s.useState)(!1),[M,T]=(0,s.useState)(!1),[A,E]=(0,s.useState)(!1),[L,B]=(0,s.useState)(!1),[U,q]=(0,s.useState)(!1),[G,X]=(0,s.useState)(null),[K,V]=(0,s.useState)(""),W=(0,s.useCallback)(async()=>{if(n&&"string"==typeof n){o(!0),S(null);try{let e=await (0,f.CD)(n);l(e)}catch(e){console.error("Failed to fetch challenge:",e),S("Failed to load challenge. Please try again.")}finally{o(!1)}}},[n]),Y=(0,s.useCallback)(async e=>{if(!e||!n){q(!1);return}try{let[t,l]=e.split("-").map(Number),{challenges:a}=await (0,f.xV)({year:t,month:l}),s=a.some(t=>t.id!==n&&t.scheduledDate===e&&"active"===t.status);q(s)}catch(e){q(!1)}},[n]);(0,s.useEffect)(()=>{W()},[W]),(0,s.useEffect)(()=>{(null==t?void 0:t.scheduledDate)&&Y(t.scheduledDate)},[null==t?void 0:t.scheduledDate,Y]);let H=(0,s.useCallback)(e=>{l(n=>n?{...n,...e}:null),I(null)},[]);async function handleSave(){if(t){P(!0),S(null),I(null);try{await (0,f.bs)({challengeId:t.id,updates:{title:t.title,description:t.description,examples:t.examples,instructions:t.instructions,hints:t.hints,starterCode:t.starterCode,solution:t.solution,testCases:t.testCases,scheduledDate:t.scheduledDate}}),I("Changes saved successfully!")}catch(e){console.error("Failed to save challenge:",e),S("Failed to save changes. Please try again.")}finally{P(!1)}}}async function handleTest(){if(t){z(!0),S(null),X(null);try{let e=await (0,f.sR)({challengeId:t.id,language:"python"});X(e.results),e.success&&I("All tests passed!")}catch(e){console.error("Failed to test challenge:",e),S("Failed to run tests. Please try again.")}finally{z(!1)}}}async function handleApprove(){if(t){R(!0),S(null);try{await (0,f.uS)({challengeId:t.id,scheduledDate:t.scheduledDate}),l(e=>e?{...e,status:"scheduled"}:null),I("Challenge approved and ready to publish!")}catch(e){console.error("Failed to approve challenge:",e),S("Failed to approve challenge. Please try again.")}finally{R(!1)}}}async function handleUnschedule(){if(t){E(!0),S(null);try{await (0,f.bs)({challengeId:t.id,updates:{status:"needs_review"}}),l(e=>e?{...e,status:"needs_review"}:null),I("Challenge moved back to review.")}catch(e){console.error("Failed to unschedule challenge:",e),S("Failed to unschedule challenge. Please try again.")}finally{E(!1)}}}async function handlePublish(){if(t){B(!0),S(null);try{await (0,f.G7)({challengeId:t.id,forceReplace:!1}),l(e=>e?{...e,status:"active"}:null),I("Challenge is now active!")}catch(e){console.error("Failed to publish challenge:",e),S("Failed to activate challenge. Please try again.")}finally{B(!1)}}}async function handleRegenerate(){if(t){T(!0),S(null);try{let n=await (0,f.ZS)({scheduledDate:t.scheduledDate,difficulty:t.difficulty,tags:t.tags,...K.trim()&&{customPrompt:K.trim()}});e.push("/admin/daily-challenges/".concat(n.challenge.id))}catch(e){console.error("Failed to regenerate challenge:",e),S("Failed to regenerate challenge. Please try again."),T(!1)}}}return r?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.Z,{}),(0,a.jsx)(u.Z,{children:(0,a.jsx)(m,{children:(0,a.jsx)(_,{children:"Loading challenge..."})})})]}):t?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.Z,{}),(0,a.jsx)(u.Z,{children:(0,a.jsxs)(m,{children:[(0,a.jsx)(c(),{href:"/admin/daily-challenges",legacyBehavior:!0,children:(0,a.jsxs)(x,{className:"backlink",children:[(0,a.jsx)(g.Ao2,{}),"Back to Daily Challenge Admin"]})}),(0,a.jsxs)(b,{children:[(0,a.jsxs)(y,{children:[(0,a.jsx)("h1",{children:t.title}),(0,a.jsx)("input",{name:"schedule-date",type:"date",className:"date-input",value:t.scheduledDate,onChange:e=>H({scheduledDate:e.target.value})})]}),(0,a.jsxs)(j,{children:[(0,a.jsx)(h.Z,{variant:"subtle",size:"small",className:"nav-btn",children:(0,a.jsx)(g.YFh,{})}),(0,a.jsx)(h.Z,{variant:"subtle",size:"small",className:"nav-btn",children:(0,a.jsx)(g.Tfp,{})})]})]}),(0,a.jsxs)(v,{children:[(0,a.jsx)(c(),{href:"/admin/daily-challenges/".concat(t.id,"/test"),target:"_blank",children:(0,a.jsxs)(h.Z,{variant:"blue",size:"small",className:"action-btn",children:[(0,a.jsx)(g.KCr,{}),"Test as User"]}
1)}),(0,a.jsx)(h.Z,{variant:"yellow",size:"small",onClick:handleTest,isLoading:Z,className:"action-btn",children:"Run Tests"}),"scheduled"===t.status?(0,a.jsx)(h.Z,{variant:"subtle",size:"small",onClick:handleUnschedule,isLoading:A,className:"action-btn",children:"Move back to Review"}):(0,a.jsx)(h.Z,{variant:"subtle",size:"small",onClick:handleApprove,isLoading:D,disabled:"approved"===t.status||"active"===t.status,className:"action-btn",children:"Mark as Ready to Publish"}),"active"!==t.status&&"archived"!==t.status&&(0,a.jsxs)(h.Z,{variant:"green",size:"small",onClick:handlePublish,isLoading:L,disabled:U,className:"action-btn",children:[(0,a.jsx)(g.Wqx,{}),U?"Another challenge active on this date":"Set Active"]})]}),k&&(0,a.jsx)(w,{children:k}),F&&(0,a.jsx)(C,{children:F}),G&&(0,a.jsxs)(O,{children:[(0,a.jsx)("h4",{children:"Test Results"}),G.map(e=>(0,a.jsxs)("div",{className:"test-result ".concat(e.passed?"passed":"failed"),children:[e.passed?"â":"â"," ",e.testId,e.error&&" - ".concat(e.error)]},e.testId))]}),(0,a.jsx)(p.ZO,{challenge:t,onChange:H,onSave:handleSave,onTest:handleTest,onApprove:handleApprove,onRegenerate:handleRegenerate,regenPrompt:K,onRegenPromptChange:V,isSaving:N,isTesting:Z,isApproving:D,isRegenerating:M})]})})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.Z,{}),(0,a.jsx)(u.Z,{children:(0,a.jsxs)(m,{children:[(0,a.jsx)(w,{children:"Challenge not found."}),(0,a.jsx)(c(),{href:"/admin/daily-challenges",children:(0,a.jsx)(h.Z,{variant:"subtle",children:"Back to list"})})]})})]})}}},function(e){e.O(0,[1272,8700,4153,1622,9280,8649,9428,5270,9774,2888,179],function(){return e(e.s=63815)}),_N_E=e.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.