PageSourceSearch

https://online.timganmath.edu.sg/_next/static/chunks/25740.010ce20ff425191c.js

js timganmath.edu.sg collected 2026-09-30 14:37:45 UTC 17,610 bytes, 59 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[25740],{25740:(e,t,s)=>{s.r(t),s.d(t,{ExamPaperPreview:()=>q});var a=s(37876),r=s(14232),n=s(72895),i=s(43e3),l=s(20967),o=s(64170),m=s(29985),c=s(23059),d=s(39806),u=s(60067),p=s(73567),h=s(31441),x=s(64558),f=s(4521);let g=(0,r.memo)(function({settings:e,template:t,courseTitle:s,totalPages:r}){let n=e.subject_code||t?.subjectCode||"",i=e.subject_display_name||t?.subjectName||"MATHEMATICS",l=e.additional_materials||t?.additionalMaterials,o=e.custom_instructions||e.instructions||t?.instructions||"",m=(0,x.sK)(n,e.paper_number),c=null!==e.paper_number,d=(0,x.FW)(e.duration_minutes),u=e.header_text||s,p=(0,f.UL)(e,{preferFullNameForSingle:!0});return(0,a.jsxs)("div",{className:"bg-white shadow-md relative",style:{width:"210mm",height:"297mm",minWidth:"210mm",minHeight:"297mm",padding:"15mm 20mm 20mm 20mm",fontFamily:h.b,color:"#000",overflow:"hidden"},children:[(0,a.jsx)("div",{className:"flex justify-start mb-4",children:(0,a.jsx)("img",{src:"/brand/logo.svg",alt:"Tim Gan Math",style:{display:"block",width:"70mm",height:"auto"}})}),(0,a.jsxs)("div",{className:"flex items-start gap-2 mb-4",children:[(0,a.jsxs)("div",{className:"flex flex-col text-[11pt] font-bold leading-tight shrink-0",style:{width:"28mm"},children:[(0,a.jsx)("span",{children:"CANDIDATE"}),(0,a.jsx)("span",{children:"NAME"})]}),(0,a.jsx)("div",{className:"flex-1 border border-black",style:{height:"10mm",minHeight:"10mm"}})]}),(0,a.jsx)("hr",{className:"border-t border-black mb-4"}),(0,a.jsxs)("div",{className:"mb-1",children:[(0,a.jsxs)("div",{className:"flex justify-between items-baseline",children:[(0,a.jsx)("span",{className:"text-[14pt] font-bold",children:i}),(0,a.jsx)("span",{className:"text-[14pt] font-bold",children:m})]}),(c||e.exam_year)&&(0,a.jsxs)("div",{className:"flex justify-between items-baseline mt-2",children:[(0,a.jsx)("span",{className:"text-[12pt]",children:c?`Paper ${e.paper_number}`:""}),(0,a.jsx)("span",{className:"text-[14pt] font-bold",children:e.exam_year||""})]}),(0,a.jsxs)("div",{className:"flex justify-between items-baseline mt-2",children:[(0,a.jsx)("span",{className:"text-[12pt] font-bold",children:u}),(0,a.jsx)("span",{className:"text-[14pt] font-bold",children:d})]}),p&&(0,a.jsxs)("p",{className:"text-[10pt] mt-3",children:["School: ",p]}),l&&(0,a.jsxs)("p",{className:`text-[10pt] ${p?"mt-1":"mt-3"}`,children:["Additional Materials: ",l]})]}),(0,a.jsx)("hr",{className:"border-t border-black mt-4 mb-6"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"text-[12pt] font-bold mb-4",children:"READ THESE INSTRUCTIONS FIRST"}),(0,a.jsx)("div",{className:"space-y-0",children:o.split("\n").map((e,t)=>{if(""===e.trim())return(0,a.jsx)("div",{className:"h-3"},t);let s=e.split(/(\*\*[^*]+\*\*)/);return(0,a.jsx)("p",{className:"text-[11pt] leading-[1.5]",children:s.map((e,t)=>e.startsWith("**")&&e.endsWith("**")?(0,a.jsx)("strong",{children:e.slice(2,-2)},t):e)},t)})})]}),(0,a.jsxs)("div",{className:"absolute text-center text-[11pt] italic",style:{bottom:"28mm",left:"20mm",right:"20mm"},children:["This document consists of ",(0,a.jsx)("strong",{className:"underline",children:r})," printed pages."]}),(0,a.jsx)("div",{className:"absolute",style:{bottom:"20mm",left:"20mm",right:"20mm",height:"2px",backgroundColor:"#1E6FBA"}})]})});function b({pageNumber:e,paperCode:t,isLastPage:s}){return(0,a.jsxs)("div",{className:"absolute inset-0 pointer-events-none",style:{zIndex:10},children:[(0,a.jsx)("div",{className:"absolute",style:{top:"13mm",left:0,right:0,textAlign:"center",fontSize:"11pt",fontFamily:h.b,fontWeight:"bold",color:"#000"},children:e}),s&&(0,a.jsx)("div",{className:"absolute",style:{bottom:"18mm",left:"15mm",right:"15mm",textAlign:"center",fontSize:"11pt",fontFamily:h.b,fontWeight:"bold",color:"#000"},children:"END OF PAPER"}),(0,a.jsx)("div",{className:"absolute",style:{bottom:"14mm",left:"15mm",right:"15mm",height:"0.5px",backgroundColor:"#000"}}),(0,a.jsxs)("div",{className:"absolute",style:{bottom:"9mm",left:"15mm",right:"15mm",fontSize:"8pt",fontFamily:h.b,color:"#000"},children:[(0,a.jsx)("span",{style:{position:"absolute",left:0},children:"timganmath.edu.sg"}),(0,a.jsx)("span",{style:{position:"absolute",left:"50%",transform:"translateX(-50%)"},children:t}),s?(0,a.jsx)("span",{}):(0,a.jsx)("span",{style:{position:"absolute",right:0},children:"[Turn over"})]})]})}var v=s(61695),w=s(8091);let j=(0,r.memo)(function({pageNumber:e,htmlContent:t,paperCode:s,isLastPage:n,isAnswerKeyPage:i,onQuestionClick:l}){let o=(0,r.useRef)(null),m=(0,r.useRef)(null);(0,r.useEffect)(()=>{let e,s;o.current&&t&&(o.current.innerHTML=`<div class="worksheet-preview-content">${(e=document.createElement("template")).innerHTML=t.trim(),s=1===e.content.childElementCount?e.content.firstElementChild:null,s?.classList.contains("worksheet-preview-content")?s.innerHTML:t}</div>`)},[t]),(0,r.useEffect)(()=>{let e=o.current;if(!e||!l)return;let t=t=>{if(!(t instanceof Element))return null;let s=t.closest(".question-wrapper[data-question-id]");return s&&e.contains(s)?s:null},s=t=>{if(!(t instanceof Element))return!1;let s=t.closest('a, button, input, textarea, select, [contenteditable="true"], .exam-response-area');return!!(s&&e.contains(s))},a=e=>{let t=e.dataset.questionId;t&&l({questionId:t,sectionId:e.dataset.sectionId||null})};e.querySelectorAll(".question-wrapper[data-question-id]").forEach(e
1=>{e.setAttribute("role","button"),e.setAttribute("tabindex","0"),e.setAttribute("title","Edit response template")});let r=e=>{if(s(e.target))return;let r=t(e.target);r&&(e.preventDefault(),e.stopPropagation(),a(r))},n=e=>{if("Enter"!==e.key&&" "!==e.key||s(e.target))return;let r=t(e.target);r&&(e.preventDefault(),e.stopPropagation(),a(r))};return e.addEventListener("click",r),e.addEventListener("keydown",n),()=>{e.removeEventListener("click",r),e.removeEventListener("keydown",n)}},[t,l]);let c=(0,r.useCallback)(()=>{m.current?.(),m.current=null,o.current&&(m.current=(0,w.w)(o.current))},[]),d=(0,r.useMemo)(()=>({enabled:!0,onComplete:c}),[c]);return(0,v.PB)(o,t,d),(0,r.useEffect)(()=>()=>{m.current?.()},[]),(0,a.jsxs)("div",{className:"exam-page-preview relative bg-white shadow-[0_4px_12px_rgba(0,0,0,0.15)]",style:{width:"210mm",height:"297mm",minWidth:"210mm",minHeight:"297mm"},children:[(0,a.jsx)(b,{pageNumber:e,paperCode:s,isLastPage:n&&!i}),(0,a.jsx)("div",{ref:o,className:"worksheet-content-area absolute",style:{top:"26mm",bottom:"22mm",left:"20mm",right:"20mm",display:"flex",flexDirection:"column",fontFamily:h.b,fontSize:"12pt",lineHeight:1.5}})]})});var y=s(75887),N=s(8951),k=s(55137),_=s(65004),A=s(44385),C=s(61586);let E=`
2.exam-page-preview .worksheet-content-area > .worksheet-preview-content {
3  background: transparent;
4  height: 100%;
5  min-height: 0;
6  flex: 1 1 auto;
7  display: flex;
8  flex-direction: column;
9}
10
11.exam-page-preview .worksheet-content-area > .worksheet-preview-content:has(.question-item-standalone[data-bottom-response-template="true"]),
12.exam-page-preview .worksheet-content-area > .worksheet-preview-content:has(.question-row[data-bottom-response-template="true"]),
13.exam-page-preview .worksheet-content-area > .worksheet-preview-content:has(.working-space-dynamic[data-bottom-response-template="true"]) {
14  height: 100%;
15  flex: 1;
16}
17
18.exam-page-preview .worksheet-preview-content .section-title {
19  font-family: ${h.b};
20  font-size: 12pt;
21  line-height: 1.5;
22  font-weight: bold;
23  color: #000;
24  text-align: center;
25  margin-top: 10pt;
26  margin-bottom: 8pt;
27}
28
29.exam-page-preview .worksheet-preview-content > .section-title:first-child {
30  margin-top: 0;
31}
32
33.exam-page-preview .worksheet-preview-content .question-content mjx-container[jax="CHTML"]:not([display="true"]) {
34  vertical-align: baseline;
35}
36
37.exam-page-preview .worksheet-preview-content .question-content mjx-container[jax="CHTML"]:not([display="true"]):has(mjx-mfrac) {
38  line-height: normal;
39  overflow: visible;
40}
41
42.exam-page-preview .question-wrapper[data-question-id] {
43  cursor: pointer;
44  border-radius: 3px;
45  outline: 1.5px solid transparent;
46  outline-offset: 2px;
47  transition: background-color 120ms ease, outline-color 120ms ease;
48}
49
50.exam-page-preview .question-wrapper[data-question-id] .exam-response-area {
51  cursor: default;
52}
53
54.exam-page-preview .question-wrapper[data-question-id]:hover,
55.exam-page-preview .question-wrapper[data-question-id]:focus-visible {
56  background: color-mix(in oklab, var(--primary) 5%, transparent);
57  outline-color: var(--primary);
58}
59`;var M=s(1773),P=s(97685);function q({sections:e,settings:t,courseTitle:s,className:h,onQuestionClick:f,canGenerateSavedVersion:b=!0,onVersionGenerated:v}){let[w,S]=(0,r.useState)(1),T=(0,r.useRef)(null),[F,$]=(0,r.useState)({start:0,end:5}),[L,z]=(0,r.useState)(!1),[H,D]=(0,r.useState)(!1),R=(0,r.useMemo)(()=>{let t;return t=0,[...e].sort((e,t)=>e.order_index-t.order_index).map(e=>{let s=(0,C.h1)(e),a=(0,_.$e)(e),r=s&&a?` [${a} marks]`:"",n=[...e.questions].sort((e,t)=>e.order_index-t.order_index).map(e=>{var s,a;let r,n,i=(0,A.t)(t);t+=1;let l=(0,_.Ts)(e);return{type:"question",question:{...e.question,exam_response_template:(0,k.kE)(e.question.exam_response_template,l,e.question.content_blocks)},displayLabel:(s=i,a=l,r=s||"",n=`[${a} mark${1!==a?"s":""}]`,r?`${r}  ${n}`:n),suppressAutoTitle:!0,examQuestionNumber:i,includeWorkingSpace:!1,columnWidth:"full",startOnNewPage:!1}});return e.instructions&&n.unshift({id:`${e.id}-instructions`,type:"subsection",title:e.instructions}),{id:e.id,title:s?`${s}${r}`:"",items:n,includeWorkingSpace:!1}})},[e,t]),W=(0,r.useMemo)(()=>({answerKeyPlacement:t.include_answer_key?"end":"none",paperSize:"A4",includeWorkingSpace:!1,bodyFontSizePt:12,marginTopMm:26,marginBottomMm:22,marginLeftMm:20,marginRightMm:20,fontFamily:"serif",renderExamResponseTemplates:!0}),[t.include_answer_key]),{pages:I,isCalculating:O,error:K,recalculate:U}=(0,p.q)(R,W,s,{includeAnswerKey:t.include_answer_key,includeTitle:!1,debounceMs:300}),G=I.length>0&&!O,Q=(0,r.useMemo)(()=>(0,N.ck)(W),[W]),B=(0,r.useMemo)(()=>(0,N.gH)(12),[]),Z=(0,r.useMemo)(()=>(0,y.gG)(Q,B,void 0,"serif",void 0,void 0),[Q,B]),J=(0,r.useMemo)(()=>(0,x.Fl)(t.instruction_template_id),[t.instruction_template_id]),V=(0,r.useMemo)(()=>{let e=t.subject_code||J?.subjectCode;return(0,x.bE)(e,t.paper_number,t.exam_year)},[t.subject_code,J?.subjectCode,t.paper_number,t.exam_year]),X=I.length+1,Y=(0,r.useMemo)(()=>e.reduce((e,t)=>
59e+t.questions.length,0),[e]),ee=(0,r.useCallback)(()=>{let e=T.current;if(!e)return;let t=e.scrollTop,s=e.clientHeight,a=1146.5196850393702*w,r=Math.max(0,Math.floor(t/a)-2),n=Math.min(X-1,Math.ceil((t+s)/a)+2);$(e=>e.start!==r||e.end!==n?{start:r,end:n}:e)},[X,w]);(0,r.useEffect)(()=>{let e=T.current;if(!e)return;ee();let t=!1,s=()=>{t||(requestAnimationFrame(()=>{ee(),t=!1}),t=!0)};return e.addEventListener("scroll",s,{passive:!0}),()=>e.removeEventListener("scroll",s)},[ee]),(0,r.useEffect)(()=>{ee()},[I.length,ee]);let et=w<1.5,es=w>.4,ea=(0,r.useCallback)(()=>S(e=>Math.min(1.5,Math.round((e+.1)*10)/10)),[]),er=(0,r.useCallback)(()=>S(e=>Math.max(.4,Math.round((e-.1)*10)/10)),[]),en=(0,r.useCallback)(()=>S(1),[]),ei=(0,r.useCallback)(()=>({courseTitle:s,settings:t,sections:e,previewPages:I.map(e=>({pageNumber:e.pageNumber,htmlContent:e.htmlContent,isAnswerKeyPage:!0===e.isAnswerKeyPage}))}),[s,I,e,t]),el=(0,r.useCallback)(async()=>{if(G)try{z(!0);let e=await fetch(`/api/admin/exam-papers/${t.course_id}/preview-pdf`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify(ei())});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||"Failed to generate PDF")}let a=await e.blob(),r=URL.createObjectURL(a),n=e.headers.get("Content-Disposition"),i=n?.match(/filename="([^"]+)"/),l=i?.[1]||`${s.replace(/[^a-zA-Z0-9-_ ]/g,"").replace(/\s+/g,"_")||"exam_paper"}.pdf`,o=document.createElement("a");o.href=r,o.download=l,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(r)}catch(e){console.error("[ExamPaperPreview] PDF generation failed:",e),P.Ay.error(e instanceof Error?e.message:"Failed to generate PDF")}finally{z(!1)}},[ei,s,G,t.course_id]),eo=(0,r.useCallback)(async()=>{if(b&&G)try{D(!0);let e=await fetch(`/api/admin/exam-papers/${t.course_id}/pdf-versions`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({...ei(),document_type:"question_paper"})}),s=await e.json().catch(()=>({}));if(!e.ok||!s.success)throw Error(s.error||"Failed to generate PDF version");let a=s.version?.version_number?`v${s.version.version_number}`:"version";s.made_primary?P.Ay.success(`Question paper ${a} generated and marked primary`):(P.Ay.success(`Question paper ${a} generated`),s.primary_warning&&P.Ay.error(s.primary_warning)),v?.()}catch(e){console.error("[ExamPaperPreview] PDF version generation failed:",e),P.Ay.error(e instanceof Error?e.message:"Failed to generate PDF version")}finally{D(!1)}},[ei,b,G,v,t.course_id]),em=(0,r.useMemo)(()=>1!==w?{zoom:w}:void 0,[w]);return O&&0===I.length?(0,a.jsxs)("div",{className:(0,M.cn)("flex flex-col items-center justify-center h-full p-8",h),children:[(0,a.jsx)(n.A,{className:"h-8 w-8 animate-spin text-muted-foreground mb-4","aria-hidden":"true"}),(0,a.jsx)("p",{className:"text-muted-foreground",children:"Calculating page layout..."})]}):K?(0,a.jsxs)("div",{className:(0,M.cn)("flex flex-col items-center justify-center h-full p-8",h),role:"alert",children:[(0,a.jsx)(i.A,{className:"h-8 w-8 text-destructive mb-4","aria-hidden":"true"}),(0,a.jsx)("p",{className:"text-destructive font-medium mb-2",children:"Preview Error"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground text-center max-w-md",children:K}),(0,a.jsx)(u.$,{onClick:U,variant:"default",size:"sm",className:"mt-4",children:"Retry"})]}):0===e.length||0===Y?(0,a.jsxs)("div",{className:(0,M.cn)("flex flex-col items-center justify-center h-full p-8",h),children:[(0,a.jsx)(l.A,{className:"h-12 w-12 text-muted-foreground/50 mb-4","aria-hidden":"true"}),(0,a.jsx)("p",{className:"text-muted-foreground font-medium mb-1",children:"No Content to Preview"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground text-center max-w-md",children:"Add sections and questions to see the exam paper preview."})]}):(0,a.jsxs)("div",{className:(0,M.cn)("exam-preview-container relative h-full flex flex-col",h),children:[(0,a.jsx)("style",{dangerouslySetInnerHTML:{__html:Z}}),(0,a.jsx)("style",{dangerouslySetInnerHTML:{__html:E}}),(0,a.jsxs)("div",{className:"z-20 bg-background/95 backdrop-blur border-b px-4 py-2 flex items-center justify-between flex-shrink-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-4",children:[(0,a.jsxs)("span",{className:"text-sm font-medium",children:[X," page",1!==X?"s":""]}),(0,a.jsxs)("span",{className:"text-sm text-muted-foreground",children:[Y," question",1!==Y?"s":""]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[O&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,a.jsx)(n.A,{className:"h-3 w-3 animate-spin","aria-hidden":"true"}),(0,a.jsx)("span",{children:"Updating..."})]}),(0,a.jsxs)(u.$,{variant:"outline",size:"sm",onClick:eo,disabled:H||!G||!b,className:"h-7",title:b?"Generate saved PDF version":"Save changes before generating a version",children:[H?(0,a.jsx)(n.A,{className:"h-3.5 w-3.5 mr-1.5 animate-spin","aria-hidden":"true"}):(0,a.jsx)(o.A,{className:"h-3.5 w-3.5 mr-1.5","aria-hidden":"true"}),"Generate Version"]}),(0,a.jsxs)(u.$,{variant:"outline",size:"sm",onClick:el,disabled:L||!G,className:"h-7",children:[L?(0,a.jsx)(n.A,{className:"h-3.5 w-3.5 mr-1.5 animate-spin","aria-hidden":"true"}):(0,a.jsx)(m.A,{className:"h-3.5 w-3.5 mr-1.5","aria-hidden":"true"}),"PDF"]}),(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)(u.$,{variant:"ghost",size:"icon",onClick:er,disabled:!es,className:"h-7 w-7",t
59itle:"Zoom out",children:(0,a.jsx)(c.A,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),(0,a.jsxs)(u.$,{variant:"ghost",size:"sm",onClick:en,className:"h-7 min-w-[50px] text-xs",title:"Reset zoom",children:[Math.round(100*w),"%"]}),(0,a.jsx)(u.$,{variant:"ghost",size:"icon",onClick:ea,disabled:!et,className:"h-7 w-7",title:"Zoom in",children:(0,a.jsx)(d.A,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]})]})]}),(0,a.jsx)("div",{ref:T,className:"flex-1 overflow-auto p-6 bg-muted/30",children:(0,a.jsxs)("div",{className:"flex flex-col items-center gap-6",style:em,children:[(0,a.jsx)(g,{settings:t,template:J,courseTitle:s,totalPages:X}),I.map((e,t)=>{let s=t+1;return s>=F.start&&s<=F.end?(0,a.jsx)(j,{pageNumber:t+2,htmlContent:e.htmlContent,paperCode:V,isLastPage:t===I.length-1,isAnswerKeyPage:e.isAnswerKeyPage,onQuestionClick:f},e.pageNumber):(0,a.jsx)("div",{className:"bg-muted/20",style:{width:"210mm",height:"297mm",minWidth:"210mm",minHeight:"297mm"},"aria-hidden":"true"},e.pageNumber)})]})})]})}},43e3:(e,t,s)=>{s.d(t,{A:()=>a});let a=(0,s(92949).A)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]])},64170:(e,t,s)=>{s.d(t,{A:()=>a});let a=(0,s(92949).A)("file-plus-corner",[["path",{d:"M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35",key:"17jvcc"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M14 19h6",key:"bvotb8"}],["path",{d:"M17 16v6",key:"18yu1i"}]])}}]);

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.