PageSourceSearch

https://online.timganmath.edu.sg/_next/static/chunks/99573.c81cd12a83bf5c46.js

js timganmath.edu.sg collected 2026-09-30 14:38:44 UTC 23,716 bytes, 537 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[99573],{64170:(e,t,a)=>{a.d(t,{A:()=>s});let s=(0,a(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"}]])},99573:(e,t,a)=>{a.r(t),a.d(t,{ExamAnswerSheetPreview:()=>C});var s=a(37876),n=a(14232),i=a(20967),r=a(97194),o=a(72895),l=a(64170),d=a(29985),m=a(23059),h=a(39806),c=a(60067),w=a(31441);a(33154);var p=a(99184),g=a(55871);let u="#444";function b(e){return`<span class="answer-sheet-scan-marker ${e}" aria-hidden="true"></span>`}function f(e={}){return!1===e.scanMarkers?"":`
2    ${b("answer-sheet-scan-marker--top-left")}
3    ${b("answer-sheet-scan-marker--top-right")}
4    ${b("answer-sheet-scan-marker--bottom-left")}
5    ${b("answer-sheet-scan-marker--bottom-right")}
6  `}function x(){let e=(0,g.ZD)("DO NOT WRITE IN THIS MARGIN - SCANNED SCRIPTS ARE CROPPED HERE");return`
7    <div class="answer-sheet-margin-warning answer-sheet-side-margin-warning answer-sheet-side-margin-warning--left">${e}</div>
8    <div class="answer-sheet-margin-warning answer-sheet-side-margin-warning answer-sheet-side-margin-warning--right">${e}</div>
9    <div class="answer-sheet-margin-warning answer-sheet-bottom-margin-warning">${e}</div>
10  `}var v=a(55137),$=a(1773),y=a(97685),k=a(71459);let j=`
11.exam-answer-sheet-preview .answer-sheet-page {
12  outline: 1px solid hsl(var(--border));
13  box-shadow: 0 4px 14px hsl(var(--foreground) / 0.16);
14}
15
16.exam-answer-sheet-preview .answer-sheet-row--interactive {
17  cursor: pointer;
18  position: relative;
19}
20
21.exam-answer-sheet-preview .answer-sheet-row--interactive:hover .answer-sheet-row-space {
22  background: hsl(var(--primary) / 0.06);
23}
24
25.exam-answer-sheet-preview .answer-sheet-row--selected {
26  outline: 1.2px solid hsl(var(--primary));
27  outline-offset: -1px;
28  background: hsl(var(--primary) / 0.07);
29}
30
31.exam-answer-sheet-preview .answer-sheet-row--pending::after {
32  content: "";
33  position: absolute;
34  inset: 1mm;
35  border: 1px dashed hsl(var(--primary) / 0.7);
36  pointer-events: none;
37}
38`,N=["none","quarter","third","half","3/4","full","1.5-pages","2-pages"];function C({sections:e,settings:t,courseTitle:a,className:b,onRowSpaceChange:I,onRowEdit:z,canGenerateSavedVersion:M=!0,onVersionGenerated:S}){let[A,Z]=(0,n.useState)(1),[E,D]=(0,n.useState)(!1),[_,L]=(0,n.useState)(!1),[T,R]=(0,n.useState)(null),[P,q]=(0,n.use
38State)(null),F=(0,n.useMemo)(()=>{var s;return s={courseTitle:a,settings:t,sections:e},{header:(0,p.cL)(s.settings,s.sections,s.courseTitle),pages:(0,p.NH)(s.sections,{continuationPageCount:s.continuationPageCount})}},[a,e,t]),H=(0,n.useMemo)(()=>`
39    .answer-sheet-page {
40      position: relative;
41      width: ${p.Lw}mm;
42      height: ${p.yb}mm;
43      min-width: ${p.Lw}mm;
44      min-height: ${p.yb}mm;
45      overflow: hidden;
46      background: #fff;
47      color: #000;
48      font-family: ${w.b};
49      break-after: page;
50      page-break-after: always;
51    }
52
53    .answer-sheet-scan-marker {
54      position: absolute;
55      width: ${p.B$}mm;
56      height: ${p.B$}mm;
57      border: 1.2px solid ${u};
58      z-index: 5;
59      pointer-events: none;
60    }
61
62    .answer-sheet-scan-marker::before,
63    .answer-sheet-scan-marker::after {
64      content: "";
65      position: absolute;
66      background: ${u};
67    }
68
69    .answer-sheet-scan-marker::before {
70      left: 50%;
71      top: 1mm;
72      bottom: 1mm;
73      width: 0.5px;
74      transform: translateX(-50%);
75    }
76
77    .answer-sheet-scan-marker::after {
78      top: 50%;
79      left: 1mm;
80      right: 1mm;
81      height: 0.5px;
82      transform: translateY(-50%);
83    }
84
85    .answer-sheet-scan-marker--top-left {
86      top: ${p.Zm}mm;
87      left: ${p.Zm}mm;
88    }
89
90    .answer-sheet-scan-marker--top-right {
91      top: ${p.Zm}mm;
92      right: ${p.Zm}mm;
93    }
94
95    .answer-sheet-scan-marker--bottom-left {
96      bottom: ${p.Zm}mm;
97      left: ${p.Zm}mm;
98    }
99
100    .answer-sheet-scan-marker--bottom-right {
101      bottom: ${p.Zm}mm;
102      right: ${p.Zm}mm;
103    }
104
105    .answer-sheet-margin-warning {
106      position: absolute;
107      height: 5.5mm;
108      display: flex;
109      align-items: center;
110      justify-content: center;
111      color: ${u};
112      font-family: Arial, sans-serif;
113      font-size: 6.5pt;
114      font-weight: 700;
115      line-height: 1;
116      text-align: center;
117      white-space: nowrap;
118      z-index: 4;
119      pointer-events: none;
120    }
121
122    .answer-sheet-side-margin-warning {
123      top: 50%;
124      width: 148mm;
125    }
126
127    .answer-sheet-side-margin-warning--left {
128      left: 14mm;
129      transform: translate(-50%, -50%) rotate(-90deg);
130    }
131
132    .answer-sheet-side-margin-warning--right {
133      right: 14mm;
134      transform: translate(50%, -50%) rotate(90deg);
135    }
136
137    .answer-sheet-bottom-margin-warning {
138      left: 24mm;
139      right: 24mm;
140      bottom: 7mm;
141    }
142
143    .answer-sheet-page:last-child {
144      break-after: auto;
145      page-break-after: auto;
146    }
147
148    .answer-sheet-page-number {
149      position: absolute;
150      top: 12mm;
151      left: 0;
152      right: 0;
153      text-align: center;
154      font-size: 12pt;
155      font-weight: 700;
156      line-height: 1;
157    }
158
159    .answer-sheet-header {
160      position: absolute;
161      top: 21mm;
162      left: ${p.zc}mm;
163      right: ${p.Sm}mm;
164    }
165
166    .answer-sheet-logo-row {
167      height: 11mm;
168      display: flex;
169      align-items: center;
170      justify-content: center;
171    }
172
173    .answer-sheet-logo {
174      display: block;
175      width: 60mm;
176      max-height: 11mm;
177      object-fit: contain;
178    }
179
180    .answer-sheet-title-row {
181      display: grid;
182      grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
183      align-items: end;
184      gap: 8mm;
185      margin-top: 1.5mm;
186      padding-bottom: 1.8mm;
187      border-bottom: 0.6px solid #000;
188    }
189
190    .answer-sheet-document-label {
191      font-size: 8pt;
192      line-height: 1.05;
193      text-transform: uppercase;
194    }
195
196    .answer-sheet-subject {
197      margin-top: 0.6mm;
198      font-size: 17pt;
199      font-weight: 700;
200      line-height: 1;
201      overflow-wrap: anywhere;
202    }
203
204    .answer-sheet-title-block {
205      min-width: 0;
206      text-align: right;
207    }
208
209    .answer-sheet-paper-title {
210      font-size: 15pt;
211      font-weight: 700;
212      line-height: 1.05;
213      overflow-wrap: anywhere;
214    }
215
216    .answer-sheet-paper-subtitle {
217      margin-top: 0.8mm;
218      font-size: 9pt;
219      line-height: 1.1;
220    }
221
222    .answer-sheet-detail-grid {
223      display: grid;
224      margin-top: 2.2mm;
225      border: 0.6px solid #000;
226      border-right: 0;
227      border-bottom: 0;
228      font-size: 9pt;
229      line-height: 1.1;
230    }
231
232    .answer-sheet-detail-item {
233      min-width: 0;
234      min-height: 9mm;
235      padding: 1mm ${p.kq}mm;
236      border-right: 0.6px solid #000;
237      border-bottom: 0.6px solid #000;
238    }
239
240    .answer-sheet-detail-label {
241      font-size: 7.5pt;
242      line-height: 1;
243      text-transform: uppercase;
244    }
245
246    .answer-sheet-detail-value {
247      margin-top: 0.8mm;
248      font-size: 10pt;
249      font-weight: 700;
250      line-height: 1.05;
251      overflow-wrap: anywhere;
252    }
253
254    .answer-sheet-detail-item--school .answer-sheet-detail-value {
255      font-size: 8.5pt;
256    }
257
258    .answer-sheet-candidate-grid {
259      display: grid;
260      grid-template-columns: minmax(0, 1.9fr) minmax(0, 0.75fr);
261      margin-top: 2.2mm;
262      margin-bottom: 3mm;
263      border: 0.6px solid #000;
264      border-right: 0;
265      border-bottom: 0;
266      line-height: 1;
267    }
268
269    .answer-sheet-candidate-box {
270      display: flex;
271      align-items: center;
272      gap: 3mm;
273      min-width: 0;
274      min-height: 9mm;
275      padding: 1mm 1.5mm;
276      border-right: 0.6px solid #000;
277      border-bottom: 0.6px solid #000;
278    }
279
280    .answer-sheet-candidate-writing-space {
281      display: block;
282      flex: 1 1 auto;
283      align-self: stretch;
284      min-width: 0;
285    }
286
287    .answer-sheet-score-table {
288      width: 100%;
289      border-collapse: collapse;
290      table-layout: fixed;
291      font-size: 12pt;
292      line-height: 1.1;
293    }
294
295    .answer-sheet-score-table th,
296    .answer-sheet-score-table td {
297      border: 0.6px solid #000;
298      height: 8mm;
299      text-align: center;
300      vertical-align: middle;
301      font-weight: 400;
302      padding: 0 2mm;
303    }
304
305    .answer-sheet-table {
306      position: absolute;
307      border: 0.6px solid #000;
308      display: flex;
309      flex-direction: column;
310      font-size: 13pt;
311      line-height: 1.1;
312    }
313
314    .answer-sheet-table::before {
315      content: "";
316      position: absolute;
317      top: 0;
318      bottom: 0;
319      left: ${p.dy}mm;
320      border-left: 0.6px solid #000;
321      pointer-events: none;
322      z-index: 1;
323    }
324
325    .answer-sheet-row {
326      display: grid;
327      grid-template-columns: ${p.dy}mm minmax(0, 1fr);
328      flex: 0 0 auto;
329      min-height: 24mm;
330      border-bottom: 0.6px solid #000;
331    }
332
333    .answer-sheet-row:last-child {
334      border-bottom: 0;
335    }
336
337    .answer-sheet-row-label {
338      display: flex;
339      flex-direction: column;
340      align-items: flex-start;
341      gap: 0.6mm;
342      padding: 2mm 1mm;
343      overflow: hidden;
344    }
345
346    .answer-sheet-row-label-main {
347      display: block;
348      max-width: 100%;
349      /* Part markers wrap onto their own line instead of being clipped, e.g. "3 (b)" / "(i)". */
350      white-space: normal;
351      overflow-wrap: break-word;
352      line-height: 1.05;
353    }
354
355    .answer-sheet-row-continuation {
356      display: block;
357      max-width: 100%;
358      font-size: 7pt;
359      line-height: 1;
360      white-space: nowrap;
361    }
362
363    .answer-sheet-row-space {
364      min-width: 0;
365    }
366
367    .answer-sheet-continuation-header {
368      position: absolute;
369      top: 17mm;
370      left: ${p.zc}mm;
371      right: ${p.Sm}mm;
372      display: grid;
373      grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
374      align-items: end;
375      gap: 8mm;
376      padding-bottom: 2mm;
377      border-bottom: 0.6px solid #000;
378      font-family: ${w.b};
379    }
380
381    .answer-sheet-continuation-title {
382      margin-top: 0.8mm;
383      font-size: 16pt;
384      font-weight: 700;
385      line-height: 1;
386    }
387
388    .answer-sheet-continuation-meta {
389      text-align: right;
390      font-size: 8pt;
391      line-height: 1.25;
392    }
393
394    .answer-sheet-continuation-box {
395      position: absolute;
396      border: 0.6px solid #000;
397      font-family: ${w.b};
398    }
399
400    .answer-sheet-continuation-box-header {
401      display: grid;
402      grid-template-columns: auto minmax(32mm, 1fr) auto;
403      align-items: center;
404      gap: 3mm;
405      height: ${p.N0}mm;
406      padding: 0 2.5mm;
407      border-bottom: 0.6px solid #000;
408      font-size: 10pt;
409      line-height: 1;
410    }
411
412    .answer-sheet-continuation-question-field {
413      align-self: stretch;
414      border-bottom: 0.6px solid #000;
415    }
416
417    .answer-sheet-continuation-box-label {
418      font-size: 8pt;
419      color: #222;
420      white-space: nowrap;
421    }
422
423    .answer-sheet-continuation-writing-space {
424      min-height: calc(100% - ${p.N0}mm);
425    }
426  `,[]),O=(0,n.useMemo)(()=>{let e=new Map;return F.pages.forEach(t=>{t.rows.forEach(t=>e.set(t.sourceRowId,t))}),e},[F.pages]),B=T&&O.get(T)||null,J=(0,n.useMemo)(()=>(function(e,t={}){return e.pages.map(a=>(function(e,t,a,s={}){let n,i;return"continuation"===e.pageKind?function(e,t,a={}){let s=e.continuationBoxes?.length||p.fx;return`
427    <section class="answer-sheet-page answer-sheet-page--continuation">
428      ${f(a)}
429      ${x()}
430      <div class="answer-sheet-page-number">${e.pageNumber}</div>
431      <header class="answer-sheet-continuation-header">
432        <div>
433          <div class="answer-sheet-document-label">Continuation Sheet</div>
434          <div class="answer-sheet-continuation-title">${(0,g.ZD)(t.subjectLabel)}</div>
435        </div>
436        <div class="answer-sheet-continuation-meta">
437          <div>${(0,g.ZD)(t.title)}</div>
438          <div>Write the question/part before continuing your answer.</div>
439        </div>
440      </header>
441      ${Array.from({length:s},(t,a)=>{let s,n,i,r,o,l;return n=Math.max(0,(s=e.continuationBoxes?.length||p.fx)-1)*p.Lz,i=(e.tableHeightMm-n)/s,r=e.tableTopMm+a*(i+p.Lz),o=e.continuationBoxes?.[a],l=(e.continuationPageIndex||0)+1,`
442    <div
443      class="answer-sheet-continuation-box"
444      style="top:${r.toFixed(2)}mm; left:${p.zc}mm; right:${p.Sm}mm; height:${i.toFixed(2)}mm;"
445      data-answer-sheet-region-type="continuation"
446      data-answer-sheet-continuation-page-index="${e.continuationPageIndex||0}"
447      data-answer-sheet-continuation-box-index="${a}"
448      data-answer-sheet-continuation-box-id="${(0,g.ZD)(o?.id||`continuation-${l}-box-${a+1}`)}"
449    >
450      <div class="answer-sheet-continuation-box-header">
451        <span>Question / Part</span>
452        <span class="answer-sheet-continuation-question-field"></span>
453        <span class="answer-sheet-continuation-box-label">Extra ${l}.${a+1}</span>
454      </div>
455      <div class="answer-sheet-continuation-writing-space"></div>
456    </div>
457  `}).join("")}
458    </section>
459  `}(e,t,s):`
460    <section class="answer-sheet-page">
461      ${f(s)}
462      ${x()}
463      <div class="answer-sheet-page-number">${e.pageNumber}</div>
464      ${1===e.pageNumber?`
465    <header class="answer-sheet-header">
466      <div class="answer-sheet-logo-row">
467        ${a?`<img class="answer-sheet-logo" src="${a}" alt="Tim Gan Math" />`:"<div></div>"}
468      </div>
469      <div class="answer-sheet-title-row">
470        <div class="answer-sheet-subject-block">
471          <div class="answer-sheet-document-label">Answer Sheet</div>
472          <div class="answer-sheet-subject">${(0,g.ZD)(t.subjectLabel)}</div>
473        </div>
474        <div class="answer-sheet-title-block">
475          <div class="answer-sheet-paper-title">${(0,g.ZD)(t.title)}</div>
476          ${t.examTypeLabel&&!t.title.toLowerCase().includes(t.examTypeLabel.toLowerCase())?`<div class="answer-sheet-paper-subtitle">${(0,g.ZD)(t.examTypeLabel)}</div>`:""}
477        </div>
478      </div>
479      ${function(e){let t=[{label:"School",value:e.schoolLabel,allowEmpty:!0,className:"answer-sheet-detail-item--school"},{label:"Paper",value:e.paperCodeLabel},{label:"Year",value:e.yearLabel},{label:"Duration",value:e.durationLabel}].map(e=>(function(e,t,a=!1,s=""){return a||t.trim()?`
480    <div class="answer-sheet-detail-item${s?` ${s}`:""}">
481      <div class="answer-sheet-detail-label">${(0,g.ZD)(e)}</div>
482      <div class="answer-sheet-detail-value">${(0,g.ZD)(t)}</div>
483    </div>
484  `:""})(e.label,e.value||"",e.allowEmpty,e.className)).filter(Boolean);if(0===t.length)return"";let[a,s,n,i]=p.wy,r=t.length>=4?[a,s,n,i]:3===t.length?[a,s,i]:null,o=r?r.map(e=>`minmax(0, ${e}fr)`).join(" "):`repeat(${t.length}, minmax(0, 1fr))`;return`<div class="answer-sheet-detail-grid" style="grid-template-columns:${o};">${t.join("")}</div>`}(t)}
485      <div class="answer-sheet-candidate-grid">
486        <div class="answer-sheet-candidate-box answer-sheet-candidate-box--name">
487          <div class="answer-sheet-detail-label">Name</div>
488          <div class="answer-sheet-candidate-writing-space"></div>
489        </div>
490        <div class="answer-sheet-candidate-box">
491          <div class="answer-sheet-detail-label">Class</div>
492          <div class="answer-sheet-candidate-writing-space"></div>
493        </div>
494      </div>
495      ${i=(n=t.scoreColumns.length>0?t.scoreColumns:[]).length>0?`width:calc((100% - 34mm) / ${n.length});`:"",`
496    <table class="answer-sheet-score-table" aria-label="Marks table">
497      <thead>
498        <tr>
499          ${n.map(e=>`<th style="${i}">${(0,g.ZD)(e.label)}</th>`).join("")}
500          <th style="width:34mm;">Total marks</th>
501        </tr>
502      </thead>
503      <tbody>
504        <tr>
505          ${n.map(()=>"<td></td>").join("")}
506          <td>${t.totalMarks||""}</td>
507        </tr>
508      </tbody>
509    </table>
510  `}
511    </header>
512  `:""}
513      <div
514        class="answer-sheet-table"
515        style="top:${e.tableTopMm}mm; left:${p.zc}mm; right:${p.Sm}mm; height:${e.tableHeightMm}mm;"
516      >
517        ${function(e,t={}){return e.rows.map((a,s)=>{let n;return`
518    <div
519      class="answer-sheet-row${t.interactiveRows?" answer-sheet-row--interactive":""}${t.selectedRowId===a.sourceRowId?" answer-sheet-row--selected":""}${t.pendingRowId===a.sourceRowId?" answer-sheet-row--pending":""}"
520      style="height:${(function(e,t,a){let s=t.fragmentFraction*p.jJ;if(a===e.rows.length-1&&.2>=Math.abs(e.rows.reduce((e,t)=>e+t.fragmentFraction*p.jJ,0)-e.tableHeightMm)){let t=e.rows.slice(0,a).reduce((e,t)=>e+t.fragmentFraction*p.jJ,0);return Math.max(24,e.tableHeightMm-t)}return Math.max(24,s)})(e,a,s).toFixed(2)}mm;"
521      data-answer-sheet-row-id="${(0,g.ZD)(a.sourceRowId)}"
522      data-answer-sheet-row-fragment-id="${(0,g.ZD)(a.fragmentId)}"
523      data-answer-sheet-section-id="${(0,g.ZD)(a.sectionId)}"
524      data-answer-sheet-question-id="${(0,g.ZD)(a.questionId)}"
525      data-answer-sheet-area-id="${(0,g.ZD)(a.areaId)}"
526      data-answer-sheet-area-index="${a.areaIndex}"
527      data-answer-sheet-row-continuation="${a.isContinuation?"true":"false"}"
528      data-answer-sheet-region-type="answer"
529    >
530      <div class="answer-sheet-row-label">${n=`<span class="answer-sheet-row-label-main">${(0,g.ZD)(a.label)}</span>`,!a.isContinuation?n:`${n}<br><span class="answer-sheet-row-continuation">(cont.)</span>`}</div>
531      <div class="answer-sheet-row-space"></div>
532    </div>
533  `}).join("")}(e,s)}
534      </div>
535    </section>
536  `})(a,e.header,t.logoSrc,t)).join("\n")})(F,{logoSrc:"/brand/logo.svg",interactiveRows:!!(I||z),selectedRowId:T,pendingRowId:P}),[F,z,I,P,T]),G=(0,n.useMemo)(()=>(0,p.yo)(F.pages),[F.pages]),U=(0,n.useMemo)(()=>e.reduce((e,t)=>
536e+t.questions.length,0),[e]),V=A<1.5,Y=A>.4,W=(0,n.useCallback)(()=>Z(e=>Math.min(1.5,Math.round((e+.1)*10)/10)),[]),K=(0,n.useCallback)(()=>Z(e=>Math.max(.4,Math.round((e-.1)*10)/10)),[]),Q=(0,n.useCallback)(()=>Z(1),[]);(0,n.useEffect)(()=>{T&&!O.has(T)&&R(null)},[O,T]);let X=(0,n.useCallback)(e=>{if(!I&&!z)return;let t=e.target instanceof HTMLElement?e.target:null,a=t?.closest("[data-answer-sheet-row-id]"),s=a?.dataset.answerSheetRowId;s&&O.has(s)&&R(s)},[z,I,O]),ee=(0,n.useCallback)(async e=>{if(B&&I&&e!==B.writingSpaceType){q(B.id);try{await I({sectionId:B.sectionId,questionId:B.questionId,areaId:B.areaId,areaIndex:B.areaIndex,writingSpaceType:e})}finally{q(null)}}},[I,B]),et=(0,n.useCallback)(()=>{B&&z&&z({sectionId:B.sectionId,questionId:B.questionId,areaId:B.areaId,areaIndex:B.areaIndex})},[z,B]),ea=(0,n.useCallback)(()=>({courseTitle:a,settings:t,sections:e}),[a,e,t]),es=(0,n.useCallback)(async()=>{if(0!==U&&0!==G)try{D(!0);let e=await fetch(`/api/admin/exam-papers/${t.course_id}/answer-sheet-pdf`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify(ea())});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||"Failed to generate answer sheet")}let s=await e.blob(),n=URL.createObjectURL(s),i=e.headers.get("Content-Disposition"),r=i?.match(/filename="([^"]+)"/),o=r?.[1]||`${a.replace(/[^a-zA-Z0-9-_ ]/g,"").replace(/\s+/g,"_")||"exam_paper"}_answer_sheet.pdf`,l=document.createElement("a");l.href=n,l.download=o,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(n)}catch(e){console.error("[ExamAnswerSheetPreview] PDF generation failed:",e),y.Ay.error(e instanceof Error?e.message:"Failed to generate answer sheet")}finally{D(!1)}},[ea,a,U,G,t.course_id]),en=(0,n.useCallback)(async()=>{if(M&&0!==U&&0!==G)try{L(!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({...ea(),document_type:"answer_sheet"})}),a=await e.json().catch(()=>({}));if(!e.ok||!a.success)throw Error(a.error||"Failed to generate answer sheet version");let s=a.version?.version_number?`v${a.version.version_number}`:"version";a.made_primary?y.Ay.success(`Answer sheet ${s} generated and marked primary`):(y.Ay.success(`Answer sheet ${s} generated`),a.primary_warning&&y.Ay.error(a.primary_warning)),S?.()}catch(e){console.error("[ExamAnswerSheetPreview] PDF version generation failed:",e),y.Ay.error(e instanceof Error?e.message:"Failed to generate answer sheet version")}finally{L(!1)}},[ea,M,S,U,G,t.course_id]),ei=(0,n.useMemo)(()=>1!==A?{zoom:A}:void 0,[A]);return 0===U||0===G?(0,s.jsxs)("div",{className:(0,$.cn)("flex h-full flex-col items-center justify-center p-8",b),children:[(0,s.jsx)(i.A,{className:"mb-4 h-12 w-12 text-muted-foreground/50","aria-hidden":"true"}),(0,s.jsx)("p",{className:"mb-1 font-medium text-muted-foreground",children:"No Answer Sheet Yet"}),(0,s.jsx)("p",{className:"max-w-md text-center text-sm text-muted-foreground",children:"Add questions to generate answer-sheet writing spaces."})]}):(0,s.jsxs)("div",{className:(0,$.cn)("exam-answer-sheet-preview relative flex h-full flex-col",b),children:[(0,s.jsx)("style",{dangerouslySetInnerHTML:{__html:`${H}
537${j}`}}),(0,s.jsxs)("div",{className:"z-20 flex shrink-0 items-center justify-between border-b bg-background/95 px-4 py-2 backdrop-blur",children:[(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[(0,s.jsxs)("span",{className:"text-sm font-medium",children:[F.pages.length," page",1!==F.pages.length?"s":""]}),(0,s.jsxs)("span",{className:"text-sm text-muted-foreground",children:[G," answer row",1!==G?"s":""]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[B&&(0,s.jsxs)("div",{className:"flex items-center gap-1.5 rounded-md border border-border bg-card px-2 py-1",children:[(0,s.jsx)("span",{className:"max-w-24 truncate text-xs font-medium",title:B.label,children:B.label}),(0,s.jsxs)(k.l6,{value:B.writingSpaceType,onValueChange:ee,disabled:P===B.id||!I,children:[(0,s.jsx)(k.bq,{className:"h-7 w-[7.25rem] text-xs",children:(0,s.jsx)(k.yv,{})}),(0,s.jsx)(k.gC,{align:"end",children:N.map(e=>(0,s.jsx)(k.eb,{value:e,className:"text-xs",children:v.c7[e]},e))})]}),z&&(0,s.jsx)(c.$,{type:"button",variant:"ghost",size:"icon",onClick:et,className:"h-7 w-7",t
537itle:"Edit response template","aria-label":"Edit response template",children:(0,s.jsx)(r.A,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]}),(0,s.jsxs)(c.$,{variant:"outline",size:"sm",onClick:en,disabled:_||!M,className:"h-7",title:M?"Generate saved answer sheet version":"Save changes before generating a version",children:[_?(0,s.jsx)(o.A,{className:"mr-1.5 h-3.5 w-3.5 animate-spin","aria-hidden":"true"}):(0,s.jsx)(l.A,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":"true"}),"Generate Version"]}),(0,s.jsxs)(c.$,{variant:"outline",size:"sm",onClick:es,disabled:E,className:"h-7",children:[E?(0,s.jsx)(o.A,{className:"mr-1.5 h-3.5 w-3.5 animate-spin","aria-hidden":"true"}):(0,s.jsx)(d.A,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":"true"}),"PDF"]}),(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsx)(c.$,{variant:"ghost",size:"icon",onClick:K,disabled:!Y,className:"h-7 w-7",title:"Zoom out",children:(0,s.jsx)(m.A,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),(0,s.jsxs)(c.$,{variant:"ghost",size:"sm",onClick:Q,className:"h-7 min-w-[50px] text-xs",title:"Reset zoom",children:[Math.round(100*A),"%"]}),(0,s.jsx)(c.$,{variant:"ghost",size:"icon",onClick:W,disabled:!V,className:"h-7 w-7",title:"Zoom in",children:(0,s.jsx)(h.A,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]})]})]}),(0,s.jsx)("div",{className:"flex-1 overflow-auto bg-muted/40 p-6",children:(0,s.jsx)("div",{className:"flex flex-col items-center gap-6",style:ei,onClick:X,dangerouslySetInnerHTML:{__html:J}})})]})}}}]);

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.