PageSourceSearch

https://bmg-smartschool.web.app/assets/PorBor5SubmissionMemoPage-D9Xc_rCW.js

js bmg-smartschool.web.app collected 2026-10-03 12:20:39 UTC 67,669 bytes, 12 lines download raw bytes

1import{j as e,V as we,T as ct,D as Ut,a as tt,I as es,F as vt,P as ts,p as ss}from"./vendor-pdf-CAs81Xpx.js";import{R as Ct,a as b,d as rs,i as as}from"./vendor-react-WakpR0wD.js";import{b as st}from"./vendor-charts-Dhh0UBmn.js";import{aA as He,X as Yt,i as Ee,C as $t,s as Tt,p as ht,o as ls,c5 as ns,E as os,ap as is}from"./index-BQksJ-U7.js";import{m as cs,c as Ze,T as ds,g as At,d as It,b as rt,q as _t,e as Lt}from"./vendor-firestore-C84qCbTf.js";import{a6 as xs,$ as Pt,a1 as ms}from"./vendor-firebase-core-DfI3m37w.js";import{M as us}from"./MainLayout-Svkkv2is.js";import{B as hs}from"./BackButton-voeEGv1I.js";import{S as at}from"./vendor-swal-BgUaMQbp.js";import{F as bs}from"./FileSaver.min-CB2AuxH4.js";import{a as fs}from"./pdfArchiveUtils-TL2GCZ7K.js";import{T as ps}from"./ThaiDatePicker-CalwPZw0.js";import{F as gs}from"./file-down-ClSTePcc.js";import{C as ft}from"./circle-check-6jn1nmmv.js";import{A as ys}from"./AcademicYearSemesterFilter-BFMoMFpz.js";import{c as js}from"./remediationUtils-v4xztunY.js";import{R as vs}from"./refresh-cw-g24bzswf.js";import{L as ks}from"./layers-BqW9rdU4.js";import{G as Ss}from"./graduation-cap-CekbwC8_.js";import{T as Ns}from"./triangle-alert-ChTRPd_F.js";import{C as Et}from"./circle-alert-PQlQFZ8S.js";import"./vendor-firebase-auth-DWo6Js8N.js";import"./Navbar-BYlHuWeG.js";import"./ProfileAvatar-C57cy0cU.js";import"./users-FNKwIhe4.js";import"./profile-DDlO39M8.js";import"./index-CTJayJtD.js";import"./SkeletonLoader-ODolvGj-.js";import"./AIAssistantWidget-DjAJzlhp.js";import"./arrow-left-Bz7UVE-D.js";import"./calendar-range-BtbhMTlm.js";import"./learnerActivityUtils-DGtKX1gk.js";const kt={0:.362,1:.362,2:.362,3:.362,4:.362,5:.362,6:.362,7:.362,8:.362,9:.362," ":.216,"!":.147,'"':.208,"#":.403,$:.361,"%":.585,"&":.423,"'":.12,"(":.19,")":.19,"*":.285,"+":.411,",":.162,"-":.216,".":.162,"/":.27,":":.162,";":.162,"<":.411,"=":.411,">":.411,"?":.283,"@":.536,A:.4,B:.378,C:.406,D:.431,E:.351,F:.351,G:.425,H:.441,I:.147,J:.264,K:.376,L:.353,M:.548,N:.441,O:.486,P:.378,Q:.487,R:.379,S:.352,T:.379,U:.466,V:.39,W:.588,X:.418,Y:.366,Z:.424,"[":.196,"\\":.262,"]":.196,"^":.412,_:.352,"`":.204,a:.344,b:.401,c:.331,d:.401,e:.374,f:.206,g:.311,h:.39,i:.143,j:.155,k:.316,l:.2,m:.601,n:.39,o:.398,p:.401,q:.401,r:.217,s:.282,t:.238,u:.39,v:.341,w:.507,x:.318,y:.337,z:.321,"{":.208,"|":.153,"}":.208,"~":.416," ":.216,ก:.386,ข:.378,ฃ:.382,ค:.393,ฅ:.393,ฆ:.408,ง:.294,จ:.367,ฉ:.377,ช:.38,ซ:.384,ฌ:.519,ญ:.519,ฎ:.425,ฏ:.425,ฐ:.343,ฑ:.461,ฒ:.532,ณ:.543,ด:.391,ต:.391,ถ:.378,ท:.43,ธ:.335,น:.42,บ:.428,ป:.428,ผ:.381,ฝ:.381,พ:.447,ฟ:.447,ภ:.425,ม:.4,ย:.375,ร:.322,ฤ:.378,ล:.381,ฦ:.425,ว:.335,ศ:.393,ษ:.438,ส:.381,ห:.427,ฬ:.454,อ:.387,ฮ:.372,ฯ:.391,ะ:.357,"ั":0,า:.316,ำ:.316,"ิ":0,"ี":0,"ึ":0,"ื":0,"ุ":0,"ู":0,"ฺ":0,"฿":.411,เ:.203,แ:.377,โ:.237,ใ:.242,ไ:.244,ๅ:.205,ๆ:.399,"็":0,"่":0,"้":0,"๊":0,"๋":0,"์":0,"ํ":0,"๎":0,"๏":.45,"๐":.449,"๑":.449,"๒":.449,"๓":.449,"๔":.449,"๕":.449,"๖":.449,"๗":.449,"๘":.449,"๙":.449,"๚":.522,"๛":.697},Kt={0:.378,1:.378,2:.378,3:.378,4:.378,5:.378,6:.378,7:.378,8:.378,9:.378," ":.226,"!":.168,'"':.291,"#":.462,$:.367,"%":.688,"&":.486,"'":.169,"(":.244,")":.244,"*":.343,"+":.417,",":.172,"-":.226,".":.172,"/":.276,":":.172,";":.172,"<":.417,"=":.417,">":.417,"?":.289,"@":.572,A:.451,B:.396,C:.432,D:.459,E:.358,F:.358,G:.454,H:.472,I:.163,J:.282,K:.411,L:.359,M:.574,N:.472,O:.518,P:.39,Q:.518,R:.395,S:.365,T:.421,U:.482,V:.422,W:.612,X:.426,Y:.396,Z:.451,"[":.234,"\\":.268,"]":.234,"^":.418,_:.376,"`":.21,a:.367,b:.435,c:.347,d:.435,e:.391,f:.254,g:.332,h:.423,i:.163,j:.171,k:.34,l:.213,m:.636,n:.423,o:.412,p:.431,q:.431,r:.246,s:.296,t:.258,u:.418,v:.358,w:.48,x:.349,y:.361,z:.358,"{":.255,"|":.177,"}":.255,"~":.422," ":.226,ก:.391,ข:.415,ฃ:.431,ค:.403,ฅ:.403,ฆ:.453,ง:.318,จ:.39,ฉ:.405,ช:.415,ซ:.431,ฌ:.565,ญ:.565,ฎ:.425,ฏ:.425,ฐ:.372,ฑ:.492,ฒ:.551,ณ:.576,ด:.405,ต:.405,ถ:.391,ท:.438,ธ:.358,น:.433,บ:.445,ป:.445,ผ:.414,ฝ:.414,พ:.482,ฟ:.482,ภ:.425,ม:.417,ย:.386,ร:.329,ฤ:.391,ล:.399,ฦ:.425,ว:.379,ศ:.403,ษ:.461,ส:.399,ห:.438,ฬ:.468,อ:.394,ฮ:.385,ฯ:.38,ะ:.34,"ั":0,า:.336,ำ:.336,"ิ":0,"ี":0,"ึ":0,"ื":0,"ุ":0,"ู":0,"ฺ":0,"฿":.389,เ:.208,แ:.395,โ:.252,ใ:.269,ไ:.252,ๅ:.209,ๆ:.437,"็":0,"่":0,"้":0,"๊":0,"๋":0,"์":0,"ํ":0,"๎":0,"๏":.45,"๐":.456,"๑":.456,"๒":.456,"๓":.456,"๔":.456,"๕":.456,"๖":.456,"๗":.456,"๘":.456,"๙":.456,"๚":.525,"๛":.697},ws=.5,Bt=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter("th",{granularity:"grapheme"}):null,Dt=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter("th",{granularity:"word"}):null,Cs=s=>Bt?Array.from(Bt.segment(s)).map(t=>t.segment):Array.from(s),Ft=s=>Dt?Array.from(Dt.segment(s)).map(t=>t.segment):s.split(/(\s+)/),pt=s=>s===" "||s===" ",$s=s=>kt[s]??ws,Vt=s=>Array.from(s).reduce((t,i)=>t+$s(i),0),gt=(s,t,i=15,x=0,C=[])=>{const f=$=>Vt($)*i,S=[];if(C.length){const $=C.map(_=>_.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),G=s.split(new RegExp(`(${$.join("|")})`));for(const _ of G)_&&(C.includes(_)?S.push(_):S.push(...Ft(_)))}else S.push(...Ft(s));const d=[];let g=[],N=0;const B=$=>t-($===0?x:0)-.5,k=()=>{for(;g.length&&pt(g[g.length-1]);)g.pop();d.push(g),g=[],N=0};for(const $ of S){const G=Cs($),_=G.reduce((L,A)=>L+f(A),0),F=G.every(pt);if(!(g.length===0&&F)){if(!F&&N+_>B(d.length)&&g.length>0&&k(),!F&&_>B(d.length)){for(const L of G){const A=f(L);N+A>B(d.length)&&g.length>0&&k(),g.push(L),N+=A}continue}g.push(...G),N+=_}}return g.length&&k(),d},Mt=({text:s,width:t,fontSize:i=15,lineHeight:x=1.3,firstLineIndent:C=0,noBreak:f,style:S})=>{const d=k=>Vt(k)*i,g=gt(s,t,i,C,f),N=i*x,B={fontSize:i,lineHeight:x};return e.jsx(we,{style:S,children:g.map((k,$)=>{const G=$===g.length-1,_=$===0?C:0;return G?e.jsx(we,{style:{paddingLeft:_,height:N},wrap:!1,children:e.jsx(ct,{style:B,children:k.join("")})},$):e.jsx(we,{style:{flexDirection:"row",justifyContent:"space-between",paddingLeft:_,height:N},wrap:!1,children:k.map((F,L)=>pt(F)?e.jsx(we,{style:{width:d(F),flexShrink:0}},L):e.jsx(ct,{style:{...B,flexShrink:0},children:F},L))},$)})})};vt.register({family:"TH Sarabun PSK",src:"/fonts/THSarabunNew.ttf",fontWeight:"normal"});vt.register({family:"TH Sarabun PSK",src:"/fonts/THSarabunNew-Bold.ttf",fontWeight:"bold"});vt.registerHyphenationCallback(s=>[s]);const Oe="TH Sarabun PSK",P=s=>{if(s==null)return"";const t=["๐","๑","๒","๓","๔","๕","๖","๗","๘","๙"];return String(s).replace(/[0-9]/g,i=>t[parseInt(i,10)])},it=["4","3.5","3","2.5","2","1.5","1","0","ร","มส","ผ","มผ"],Ts={4:"๔","3.5":"๓.๕",3:"๓","2.5":"๒.๕",2:"๒","1.5":"๑.๕",1:"๑",0:"๐",ร:"ร",มส:"มส",ผ:"ผ",มผ:"มผ"},Ge=["3","2","1","0"],As={3:"๓",2:"๒",1:"๑",0:"๐"},Is=()=>it.reduce((s,t)=>({...s,[t]:0}),{}),_s=()=>Ge.reduce((s,t)=>({...s,[t]:0}),{}),ze=(s,t)=>t?(s/t*100).toFixed(1):"0.0",Xt=842/1755,qt=kt["."],dt=(s,t)=>Array.from(s).reduce((i,x)=>i+(kt[x]??.5),0)*t,yt=(s,t)=>Array.from(s).reduce((i,x)=>i+(Kt[x]??.5),0)*t,jt=Kt["."],Se=(s,t=16)=>".".repeat(Math.max(0,Math.floor(s/(qt*t)))),ye=(s,t,i=16)=>
1Se(t-s,i),Le="  ",Be=(s,t,i)=>({position:"absolute",top:s,left:t,...i}),c=({cy:s,x:t,size:i=16,bold:x,w:C,align:f,children:S})=>e.jsx(ct,{style:{...Be(s-i/2,t),fontFamily:Oe,fontSize:i,fontWeight:x?"bold":"normal",lineHeight:1,...C?{width:C,textAlign:f||"left"}:{}},children:S}),Ne=({cy:s,x:t,width:i,data:x,size:C=16,align:f="center",bold:S,inset:d=0})=>{const g=S?yt:dt,N=i-d,B=x?Math.min(C,C*(N-2)/Math.max(g(x,C),1)):C;return e.jsxs(e.Fragment,{children:[e.jsx(c,{cy:s,x:t,size:C,bold:S,children:".".repeat(Math.max(0,Math.floor(i/((S?jt:qt)*C))))}),x?e.jsx(c,{cy:s-1.6,x:t+d,size:B,w:N,align:f,bold:S,children:x}):null]})},zt=({cy:s,leftX:t,rightX:i,leftDots:x,rightDots:C,spaceBeforeRightDots:f,sem:S,year:d})=>{const g="ประจำภาคเรียนที่",N=f?"ปีการศึกษา ":"ปีการศึกษา";return S||d?e.jsx(c,{cy:s,x:449.3-150,w:300,align:"center",bold:!0,children:`${g} ${S||"............"}   ปีการศึกษา ${d||"................"}`}):e.jsxs(e.Fragment,{children:[e.jsx(c,{cy:s,x:t,bold:!0,children:g}),e.jsx(Ne,{cy:s,x:t+yt(g,16),width:x*jt*16,data:S||void 0,bold:!0}),e.jsx(c,{cy:s,x:i,bold:!0,children:N}),e.jsx(Ne,{cy:s,x:i+yt(N,16),width:C*jt*16,data:d||void 0,bold:!0})]})},qe=.5,Ls="#000000",he="#C2D69B",de="#FFFF99",Pe="#F7F34A",T=({x0:s,x1:t,y0:i,y1:x,fill:C,text:f,bold:S,align:d="center",size:g=16,noBorder:N,labelH:B})=>{const k=t-s,$=f?Math.min(g,g*(k-(d==="left"?6:2))/Math.max(dt(f,g),1)):g;return e.jsx(we,{style:{position:"absolute",left:s-qe/2,top:i-qe/2,width:k+qe,height:x-i+qe,backgroundColor:C,borderWidth:N?0:qe,borderColor:Ls,borderStyle:"solid",justifyContent:B?"flex-start":"center",alignItems:d==="center"?"center":"flex-start",paddingLeft:d==="left"?3:0,paddingTop:B?Math.max(0,(B-$)/2-.5):0},children:f?e.jsx(ct,{style:{fontFamily:Oe,fontSize:$,fontWeight:S?"bold":"normal",lineHeight:1,position:"relative",top:-.5},wrap:!1,children:f}):null})},be=s=>s*Xt,Ps=.48,We=s=>s*Xt+Ps,Es=[147,199,546,665,747,833,933,988,1047,1099.5,1168,1221,1280,1332,1384,1441,1500,1559,1618].map(We),Bs=[338,389,736,854,937,1022,1123,1224,1327,1431,1535].map(We),Rt=585,Re=(s,t=56)=>s?`( ${s} )`:`( ${".".repeat(t)} )`,lt=dt("ลงชื่อ",16),bt=s=>s.courseTitle||"-",nt=s=>s.classLevel||"",Gt=({schoolName:s,docNo:t="",dateStr:i="",academicYear:x,semester:C,learningArea:f="",teacherName:S,courses:d=[],targetPercentage:g="",summarySheetCount:N="1",characteristicsSheetCount:B="1",reviewerName:k="",deputyDirectorName:$="",directorName:G=""})=>{const _=C==="annual"||C==="0",F=!C||_?"":P(C),L=x?P(x):"",A=s!=null&&s.startsWith("โรงเรียน")?s:`โรงเรียน${s||""}`,le=d.length,ne=d,X=it.reduce((a,o)=>(a[o]=ne.reduce((n,w)=>{var z;return n+(((z=w.gradeBuckets)==null?void 0:z[o])||0)},0),a),{}),D=ne.reduce((a,o)=>a+(o.studentCount||0),0),je=X[4]+X["3.5"]+X[3],xe=X[0]+X.ร+X.มส,Ce=Ge.reduce((a,o)=>(a[o]=d.reduce((n,w)=>{var z;return n+(((z=w.charBuckets)==null?void 0:z[o])||0)},0),a),{}),K=d.reduce((a,o)=>a+(o.studentCount||0),0),fe=g?P(g):D?P(ze(je,D)):"",J=71.5,se=467.6,$e=18,I=18,U=["การจัดการเรียนการสอน","และแบบบันทึกผลการเรียนรายบุคคล"],Z=15,oe=_?`ประจำปีการศึกษา${L?` ${L}`:Se(60)}`:`ประจำภาคเรียนที่${F?` ${F} `:Se(21)}ปีการศึกษา${L?` ${L}`:Se(34)}`,me=`ตามที่${A}${Le}กำหนดมาตรฐานการปฏิบัติงานด้านการวัดผล และประเมินผล การจัดการเรียนการสอน โดยให้มีการนำส่งแบบสรุปผลสัมฤทธิ์ทางการเรียน แบบสรุปผลคุณลักษณะอันพึงประสงค์ และแบบบันทึกผลการเรียนรายบุคคล${Le}เมื่อทำการเรียนการสอนเสร็จสิ้นแล้ว${Le}ข้าพเจ้า`+(S?` ${S} `:".".repeat(53))+"สังกัดกลุ่มสาระการเรียนรู้"+(f?` ${f} `:".".repeat(54))+`จึงขอรายงานผลสัมฤทธิ์ทางการเรียน ${_?`ประจำปีการศึกษา${L?` ${L}`:Se(60)}`:`ประจำภาคเรียนที่ ${F?`${F} `:`${".".repeat(9)} `}ปีการศึกษา${L?` ${L}`:".".repeat(19)}`}${Le}รายละเอียดดังนี้`,ee=`รายวิชาที่ดำเนินการจัดการเรียนการสอนทั้งหมด จำนวน${le?` ${P(le)} `:".".repeat(19)}วิชา (ระบุทุกรายวิชาที่สอน รวม IS, หน้าที่พลเมือง, กลุ่มสนใจ ยกเว้นชุมนุม)`,Qe=gt(me,se,Z,72,U).length,De=gt(ee,se,16,72).length,ve=Math.max(5,d.length),pe=(Qe-5)*I,Ye=(De-2)*I,xt=(ve-5)*$e,Fe=273.9,Ke=372.7+pe,mt=418.3+pe+Ye,Te=pe+Ye+xt,ie=789.2+Te>812,te=(a,o)=>{const n=w=>w+a;return e.jsxs(e.Fragment,{children:[e.jsxs(e.Fragment,{children:[e.jsx(c,{cy:n(516.7),x:107.4,children:"รวมแบบบันทึกผลการเรียนประจำรายวิชา (ปพ.๕) ทั้งสิ้น"}
1),e.jsx(c,{cy:n(516.7),x:349.7,children:"จำนวน"}),e.jsx(Ne,{cy:n(516.7),x:377.5,width:59,data:le?P(le):void 0}),e.jsx(c,{cy:n(516.7),x:436.5,children:"เล่ม"})]}),e.jsx(c,{cy:n(543.5),x:143.4,children:"จึงเรียนมาเพื่อโปรดทราบและพิจารณา"}),e.jsxs(c,{cy:n(571.8),x:290.7,children:["ลงชื่อ",ye(290.7+lt,495.5)]}),e.jsx(c,{cy:n(590),x:318.5,w:168,align:"center",children:Re(S,60)}),e.jsx(c,{cy:n(607.8),x:J,children:"งานวัดผลและประเมินผลตรวจแล้ว"}),e.jsx(we,{style:Be(n(626.5)-5.55,72.4,{width:11.1,height:11.1,borderWidth:1.6,borderColor:"#000",borderStyle:"solid"})}),e.jsx(c,{cy:n(626.5),x:89.2,children:"ถูกต้องครบถ้วน"}),e.jsx(we,{style:Be(n(626.5)-5.55,180.4,{width:11.1,height:11.1,borderWidth:1.6,borderColor:"#000",borderStyle:"solid"})}),e.jsxs(c,{cy:n(626.5),x:196.2,children:["ไม่ถูกต้อง/ไม่ครบถ้วน ระบุ",ye(196.2+dt("ไม่ถูกต้อง/ไม่ครบถ้วน ระบุ",16),534.4)]}),e.jsxs(c,{cy:n(644.2),x:287.3,children:["ลงชื่อ",ye(287.3+lt,462.9)]}),e.jsx(c,{cy:n(644.2),x:462.9,children:"ผู้ตรวจ"}),k?e.jsx(c,{cy:n(662.4),x:287.3,w:202,align:"center",size:15,children:Re(k)}):null,e.jsx(c,{cy:n(680.8),x:J,bold:!0,children:"ความเห็นรองผู้อำนวยการกลุ่มบริหารวิชาการ"}),e.jsx(c,{cy:n(680.8),x:323.3,bold:!0,children:"ความเห็นผู้อำนวยการโรงเรียน"}),e.jsx(c,{cy:n(698.9),x:73.4,children:ye(72,271)}),e.jsx(c,{cy:n(698.9),x:324.6,children:ye(323.8,522.8)}),e.jsx(c,{cy:n(717.2),x:73.4,children:ye(72,272)}),e.jsx(c,{cy:n(717.2),x:324.6,children:ye(323.8,523.8)}),e.jsxs(c,{cy:n(734.9),x:J,children:["ลงชื่อ",ye(J+lt,237.4)]}),e.jsxs(c,{cy:n(734.9),x:323.3,children:["ลงชื่อ",ye(323.3+lt,489.3)]}),e.jsx(c,{cy:n(753.1),x:65.4,w:200,align:"center",children:Re($,40)}),e.jsx(c,{cy:n(753.1),x:314.9,w:200,align:"center",children:Re(G,40)}),e.jsx(c,{cy:n(770.9),x:62.4,w:200,align:"center",children:"รองผู้อำนวยการกลุ่มบริหารวิชาการ"}),e.jsxs(c,{cy:n(770.9),x:323.3,children:["ผู้อำนวยการ",A.replace(/ /g,Le)]}),e.jsx(c,{cy:n(789.2),x:61,w:200,align:"center",children:"............/......................./..............."}),e.jsx(c,{cy:n(789.2),x:311.5,w:200,align:"center",children:"............/......................./..............."})]})},ge=[{cy:208.7,no:"๑.",label:"แบบสรุปผลสัมฤทธิ์ทางการเรียน",count:N,unit:"แผ่น"},{cy:226.4,no:"๒.",label:"แบบสรุปผลคุณลักษณะอันพึงประสงค์",count:B,unit:"แผ่น"},{cy:244.7,no:"๓.",label:"แบบบันทึกผลการเรียนรายบุคคล (ปพ.๕)",count:le?String(le):"",unit:"เล่ม"}],Ae=ne,Ie=Math.max(13,Ae.length),H=We(274),M=be(38.5),Ve=We(351),_e=Math.min(be(38.77),(Rt-130-Ve-2*be(38.5))/Ie),ue=Ve+Ie*_e,V=ue+be(38.5),r=V+be(38.5),l=Es,m=Math.min(14,_e*.78),u=Bs,p=Math.max(13,d.length),y=We(236),h=be(39),E=We(314),W=Math.min(be(38.69),(Rt-100-E-2*be(39))/p),O=E+p*W,Y=O+be(39),re=Y+be(39),ae=Math.min(14,W*.78),j=a=>e.jsxs(e.Fragment,{children:[e.jsxs(c,{cy:a,x:322.9,children:["ลงชื่อ",Se(205),"ครูผู้สอน"]}),e.jsx(c,{cy:a+18,x:344.6,w:205.1,align:"center",children:Re(S,44)}),e.jsxs(c,{cy:a+36,x:322.9,children:["ลงชื่อ",Se(205),"งานวัดและประเมินผล"]}),e.jsx(c,{cy:a+54,x:344.6,w:205.1,align:"center",children:Re(k,44)})]}),v=`ประจำปีการศึกษา ${L||"................"}`;return e.jsxs(Ut,{title:`บันทึกข้อความ_รายงานผลสัมฤทธิ์ทางการเรียน_${S}_ปี${x}`,children:[e.jsxs(tt,{size:"A4",style:{fontFamily:Oe,fontSize:16,color:"#000"},children:[e.jsx(es,{src:"/assets/images/garuda_official.jpg",style:{...Be(61.8,71),width:44.6,height:46.3,objectFit:"fill"}}),e.jsx(c,{cy:86.2,x:J,size:28,bold:!0,w:se,align:"center",children:"บันทึกข้อความ"}),e.jsx(c,{cy:130.5,x:71.5,size:18,bold:!0,children:"ส่วนราชการ"}),e.jsxs(c,{cy:131,x:143.4,children:["กลุ่มบริหารวิชาการ",Le,A]}),e.jsx(c,{cy:151.1,x:71,size:18,bold:!0,children:"ที่"}),e.jsx(c,{cy:151.6,x:87.8,children:t||Se(190)}),e.jsx(c,{cy:151.1,x:287.3,size:18,bold:!0,children:"วันที่"}),e.jsx(Ne,{cy:151.6,x:308.4,width:162.6,data:i||void 0,align:"left",inset:6}),e.jsx(c,{cy:171.3,x:72,size:18,bold:!0,children:"เรื่อง"}),e.jsxs(c,{cy:171.8,x:104.1,children:["รายงานผลสัมฤทธิ์ทางการเรียน ",oe]}),e.jsx(c,{cy:190.5,x:71.5,size:16,bold:!0,children:"เรียน"}),e.jsxs(c,{cy:190.5,x:103.6,children:["ผู้อำนวยการ",A.replace(/ /g,Le)]}),e.jsx(c,{cy:209.1,x:71.5,size:16,bold:!0,children:"สิ่งที่ส่งมาด้วย"}),ge.map(a=>e.jsxs(Ct.Fragment,{children:[e.jsx(c,{cy:a.cy,x:142.5,children:a.no}),e.jsx(c,{cy:a.cy,x:156.4,children:a.label}
1),e.jsx(c,{cy:a.cy,x:431.2,children:"จำนวน"}),e.jsx(Ne,{cy:a.cy,x:459.1,width:34,data:a.count?P(a.count):void 0}),e.jsx(c,{cy:a.cy,x:493.1,children:a.unit})]},a.no)),e.jsx(Mt,{text:me,width:se,fontSize:Z,noBreak:U,lineHeight:I/Z,firstLineIndent:72,style:Be(Fe-I/2,J,{width:se})}),e.jsx(Mt,{text:ee,width:se,fontSize:16,lineHeight:I/16,firstLineIndent:72,style:Be(Ke-I/2,J,{width:se})}),Array.from({length:ve}).map((a,o)=>{const n=mt+o*$e,w=d[o];return e.jsxs(Ct.Fragment,{children:[e.jsxs(c,{cy:n,x:107.4,children:[P(o+1),"."]}),e.jsx(c,{cy:n,x:123.8,children:"วิชา"}),e.jsx(Ne,{cy:n,x:139.1,width:158.8,data:w?`${bt(w)}${nt(w)?` ${nt(w)}${w.room?`/${w.room}`:""}`:""}`:void 0}),e.jsx(c,{cy:n,x:297.9,children:"รหัสวิชา"}),e.jsx(Ne,{cy:n,x:330.5,width:58.5,data:(w==null?void 0:w.courseCode)||void 0}),e.jsx(c,{cy:n,x:389,children:"จำนวน ปพ.๕"}),e.jsx(Ne,{cy:n,x:445.1,width:62.4,data:w?"๑":void 0}),e.jsx(c,{cy:n,x:507.5,children:"เล่ม"})]},o)}),ie?null:te(Te)]}),ie?e.jsx(tt,{size:"A4",style:{fontFamily:Oe,fontSize:16,color:"#000"},children:te(80-516.7)}):null,e.jsxs(tt,{size:"A4",orientation:"landscape",style:{fontFamily:Oe,fontSize:16,color:"#000"},children:[e.jsx(c,{cy:66.6,x:449.3-149.5,w:300,align:"center",size:18,bold:!0,children:"แบบสรุปผลสัมฤทธิ์ทางการเรียน"}),_?e.jsx(c,{cy:86,x:449.3-151,w:300,align:"center",bold:!0,children:v}):e.jsx(zt,{cy:86,leftX:341.1,rightX:464.4,leftDots:13,rightDots:16,sem:F,year:L}),e.jsx(c,{cy:104.3,x:250.4,bold:!0,children:"ค่าเป้าหมายผลการเรียนระดับดี (เกรด ๓-๔) ของกลุ่มสาระฯ คือ ร้อยละ"}),e.jsx(we,{style:Be(112.3,559,{width:89.6,borderBottomWidth:.75,borderBottomColor:"#000",borderBottomStyle:"solid",height:0})}),fe?e.jsx(c,{cy:104.3,x:559,w:89.6,align:"center",bold:!0,children:fe}):null,[0,1,2,3,4].map(a=>e.jsx(T,{x0:l[a],x1:l[a+1],y0:H,y1:H+2*M,fill:he,bold:!0,labelH:M,text:["ที่","รายวิชา","รหัส","ชั้น","ห้อง"][a]},`h${a}`)),e.jsx(T,{x0:l[5],x1:l[6],y0:H,y1:H+M,fill:he,bold:!0,text:"จำนวน"}),e.jsx(T,{x0:l[5],x1:l[6],y0:H+M,y1:H+2*M,fill:he,bold:!0,text:"(คน)"}),e.jsx(T,{x0:l[6],x1:l[18],y0:H,y1:H+M,fill:he,bold:!0,text:"จำนวนนักเรียนที่มีผลการเรียน (คน)"}),it.map((a,o)=>e.jsx(T,{x0:l[6+o],x1:l[7+o],y0:H+M,y1:H+2*M,fill:he,bold:!0,text:Ts[a]},a)),Array.from({length:Ie}).map((a,o)=>{const n=Ae[o],w=Ve+o*_e,z=w+_e;return[n?P(o+1):void 0,n?bt(n):void 0,(n==null?void 0:n.courseCode)||void 0,n?nt(n):void 0,n?n.room:void 0,n?P(n.studentCount??0):void 0,...it.map(q=>{var R;return n?P(((R=n.gradeBuckets)==null?void 0:R[q])||0):void 0})].map((q,R)=>e.jsx(T,{x0:l[R],x1:l[R+1],y0:w,y1:z,text:q,align:R===1?"left":"center",size:m},`${o}-${R}`))}),e.jsx(T,{x0:l[0],x1:l[4],y0:ue,y1:V,fill:de,bold:!0,text:"รวม"}),e.jsx(T,{x0:l[4],x1:l[5],y0:ue,y1:V,fill:de}),e.jsx(T,{x0:l[5],x1:l[6],y0:ue,y1:V,fill:de,bold:!0,size:m+1,text:D?P(D):void 0}),e.jsx(T,{x0:l[6],x1:l[9],y0:ue,y1:V,fill:de,bold:!0,size:m+1,text:D?P(je):void 0}),e.jsx(T,{x0:l[13],x1:l[16],y0:ue,y1:V,fill:de,bold:!0,size:m+1,text:D?P(xe):void 0}),e.jsx(T,{x0:l[16],x1:l[17],y0:ue,y1:V,fill:de,bold:!0,size:m+1,text:D?P(X.ผ):void 0}),e.jsx(T,{x0:l[17],x1:l[18],y0:ue,y1:V,fill:de,bold:!0,size:m+1,text:D?P(X.มผ):void 0}),e.jsx(T,{x0:l[0],x1:l[6],y0:V,y1:r,fill:Pe,bold:!0,text:"คิดเป็นร้อยละ"}),e.jsx(T,{x0:l[6],x1:l[9],y0:V,y1:r,fill:Pe,bold:!0,size:m+1,text:D?P(ze(je,D)):void 0}),e.jsx(T,{x0:l[13],x1:l[16],y0:V,y1:r,fill:Pe,bold:!0,size:m+1,text:D?P(ze(xe,D)):void 0}),e.jsx(T,{x0:l[16],x1:l[17],y0:V,y1:r,fill:Pe,bold:!0,size:m+1,text:D?P(ze(X.ผ,D)):void 0}),e.jsx(T,{x0:l[17],x1:l[18],y0:V,y1:r,fill:Pe,bold:!0,size:m+1,text:D?P(ze(X.มผ,D)):void 0}),j(r+27.7)]}),e.jsxs(tt,{size:"A4",orientation:"landscape",style:{fontFamily:Oe,fontSize:16,color:"#000"},children:[e.jsx(c,{cy:66.5,x:449.5-149.5,w:300,align:"center",size:18,bold:!0,children:"แบบสรุปคุณลักษณะอันพึงประสงค์"}),_?e.jsx(c,{cy:86,x:448.6-148.5,w:300,align:"center",bold:!0,children:v}):e.jsx(zt,{cy:86,leftX:332,rightX:455.3,leftDots:13,rightDots:21,spaceBeforeRightDots:!0,sem:F,year:L}),[0,1,2,3,4].map(a=>e.jsx(T,{x0:u[a],x1:u[a+1],y0:y,y1:y+2*h,fill:he,bold:!0,labelH:
1h,text:["ที่","รายวิชา","รหัส","ชั้น","ห้อง"][a]},`h${a}`)),e.jsx(T,{x0:u[5],x1:u[6],y0:y,y1:y+h,fill:he,bold:!0,text:"จำนวน"}),e.jsx(T,{x0:u[5],x1:u[6],y0:y+h,y1:y+2*h,fill:he,bold:!0,text:"(คน)"}),e.jsx(T,{x0:u[6],x1:u[10],y0:y,y1:y+h,fill:he,bold:!0,text:"จำนวนนักเรียนที่มีผลการประเมิน (คน)"}),Ge.map((a,o)=>e.jsx(T,{x0:u[6+o],x1:u[7+o],y0:y+h,y1:y+2*h,fill:he,bold:!0,text:As[a]},a)),Array.from({length:p}).map((a,o)=>{const n=d[o],w=E+o*W,z=w+W;return[n?P(o+1):void 0,n?bt(n):void 0,(n==null?void 0:n.courseCode)||void 0,n?nt(n):void 0,n?n.room:void 0,n?P(n.studentCount??0):void 0,...Ge.map(q=>{var R;return n?P(((R=n.charBuckets)==null?void 0:R[q])||0):void 0})].map((q,R)=>e.jsx(T,{x0:u[R],x1:u[R+1],y0:w,y1:z,text:q,align:R===1?"left":"center",size:ae},`${o}-${R}`))}),e.jsx(T,{x0:u[0],x1:u[4],y0:O,y1:Y,fill:de,bold:!0,text:"รวม"}),e.jsx(T,{x0:u[4],x1:u[5],y0:O,y1:Y,fill:de}),e.jsx(T,{x0:u[5],x1:u[6],y0:O,y1:Y,fill:de,bold:!0,size:ae+1,text:K?P(K):void 0}),Ge.map((a,o)=>e.jsx(T,{x0:u[6+o],x1:u[7+o],y0:O,y1:Y,fill:de,bold:!0,size:ae+1,text:K?P(Ce[a]):void 0},`s${a}`)),e.jsx(T,{x0:u[0],x1:u[6],y0:Y,y1:re,fill:Pe,bold:!0,text:"คิดเป็นร้อยละ"}),Ge.map((a,o)=>e.jsx(T,{x0:u[6+o],x1:u[7+o],y0:Y,y1:re,fill:o===3?"#FFFF00":Pe,bold:!0,size:ae+1,text:K?P(ze(Ce[a],K)):void 0},`p${a}`)),j(re+26.9)]})]})},Ds=["มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน","กรกฎาคม","สิงหาคม","กันยายน","ตุลาคม","พฤศจิกายน","ธันวาคม"],Fs=s=>{const[t,i,x]=s.split("-").map(Number);return!t||!i||!x?"":`${x} ${Ds[i-1]} ${t+543}`},Ms=({isOpen:s,onClose:t,pdfProps:i,schoolId:x,createdBy:C})=>{const[f,S]=b.useState(!1),[d,g]=b.useState(""),[N,B]=b.useState(""),[k,$]=b.useState(""),[G,_]=b.useState(""),[F,L]=b.useState(!1),[A,le]=b.useState(""),[ne,X]=b.useState(""),[D,je]=b.useState(""),[xe,Ce]=b.useState(!1);b.useEffect(()=>{if(s){g(""),le(""),L(!1),_(""),je("");const I=new Date,U=["มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน","กรกฎาคม","สิงหาคม","กันยายน","ตุลาคม","พฤศจิกายน","ธันวาคม"],Z=I.getDate(),oe=U[I.getMonth()],me=I.getFullYear()+543,ee=`${Z} ${oe} ${me}`;B(ee),X(ee)}},[s]),b.useEffect(()=>{if(!s)return;Ce(!0);const I=setTimeout(()=>{le(d),X(N),je(G),Ce(!1)},500);return()=>clearTimeout(I)},[d,N,G,s]);const K=i.semester==="1"?"เทอม1":i.semester==="2"?"เทอม2":"ตลอดปี",J=`บันทึกข้อความ_รายงานผลสัมฤทธิ์ทางการเรียน${i.teacherName?`_${i.teacherName.replace(/\s+/g,"_")}`:""}_ปี${i.academicYear}_${K}.pdf`,se=b.useMemo(()=>({...i,docNo:A.trim(),dateStr:ne.trim(),targetPercentage:D.trim()}),[i,A,ne,D]),$e=async()=>{S(!0);try{const I={...i,docNo:d.trim(),dateStr:N.trim(),targetPercentage:G.trim()},U=await ss(e.jsx(Gt,{...I})).toBlob();if(bs.saveAs(U,J),x)try{let Z,oe;try{const ee=await fs(x,"porbor5-submission-memos",U,J);Z=ee.url,oe=ee.storagePath}catch(ee){console.warn("Could not archive memo PDF:",ee)}const me=`รายงานผลสัมฤทธิ์ทางการเรียน ภาคเรียนที่ ${i.semester} ปีการศึกษา ${i.academicYear}`;await cs(Ze(Ee,"school-settings",x,"memos"),{memoNo:d.trim()||"ยังไม่ระบุเลขที่",subject:me,to:i.directorName||"ผู้อำนวยการโรงเรียน",sender:i.teacherName,notes:`รายงานผลสัมฤทธิ์ทางการเรียน จำนวน ${i.courses.length} รายวิชา/ห้อง`,academicYear:i.academicYear,semester:i.semester,createdBy:C||i.teacherName||"ระบบ",createdAt:ds.now(),...Z?{pdfUrl:Z,storagePath:oe}:{}}),L(!0)}catch(Z){console.error("Error saving memo to registry:",Z)}}catch(I){console.error("Error generating PorBor5 submission memo PDF:",I)}finally{S(!1)}};return s?rs.createPortal(e.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center bg-black/60 px-4 pb-4 pt-[76px] backdrop-blur-sm",onClick:t,children:e.jsxs("div",{className:"flex h-full max-h-[calc(100vh-92px)] w-full max-w-5xl flex-col rounded-2xl bg-white shadow-2xl dark:bg-[#1e1f21]",onClick:I=>I.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 px-5 py-4 dark:border-gray-700",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"truncate text-base font-bold text-gray-900 dark:text-white",children:"ตัวอย่างเอกสาร — บันทึกข้อความรายงานผลสัมฤทธิ์ทางการเรียน"}),e.jsxs("p",{className:"truncate text-xs text-gray-500 dark:text-gray-400",children:[i.teacherName," • ประจำภาคเรียนที่ ",i.semester," ปีการศึกษา ",i.academicYear," (",i.courses.length," รายวิชา)"]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:$e,disabled:f,className:"inline-flex h-9 items-center justify-center gap-2 rounded-lg bg-indigo-600 px-4 text-sm font-bold text-white shadow-sm transition hover:bg-indigo-700 disabled:cursor-not-allowed disabled:opacity-50",children:[f?e.jsx(He,{size:16,className:"animate-spin"}):e.jsx(gs,{size:16}),f?"กำลังบันทึก...":"ดาวน์โหลด"]}),e.jsx("button",{type:"button",onClick:t,className:"inline-flex h-9 w-9 items-center justify-center rounded-lg text-gray-500 transition hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-700",title:"ปิด",children:e.jsx(Yt,{size:18})})]})]}),e.jsxs("div",{className:"px-5 py-3 bg-gray-50/50 dark:bg-gray-800/40 border-b border-gray-200 dark:border-gray-700 flex flex-wrap items-end gap-3 text-xs",children:[e.jsxs("div",{className:"flex-1 min-w-[140px] max-w-[200px]",children:[e.jsx("label",{className:"block text-[11px] font-semibold text-gray-600 dark:text-gray-300 mb-1",children:"เลขที่บันทึกข้อความ"}),e.jsx("input",{type:"text",value:d,onChange:I=>g(I.target.value),placeholder:"เช่น ศธ 04.../...",className:"w-full px-2.5 py-1.5 bg-white dark:bg-gray-900 border border-gray-300 dark:border-gray-700 rounded-lg text-xs focus:ring-2 focus:ring-rose-500 focus:outline-none dark:text-white"})]}),e.jsxs("div",{className:"flex-1 min-w-[140px] max-w-[200px]",children:[e.jsx("label",{className:"block text-[11px] font-semibold text-gray-600 dark:text-gray-300 mb-1",children:"วันที่ในบันทึกข้อความ"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(ps,{value:k||null,placeholder:"เลือกวันที่จากปฏิทิน",onChange:I=>{$(I),B(Fs(I))},className:"text-xs [&>div:first-child]:min-h-[32px] [&>div:first-child]:py-1.5 [&>div:first-child]:px-2.5"}),k?e.jsx("button",{type:"button",onClick:()=>{$(""),B("")},title:"ล้างวันที่ (ปล่อยเป็นเส้นจุดไข่ปลาให้เขียนเอง)",className:"shrink-0 rounded-lg border border-gray-300 px-2 py-1.5 text-[11px] font-semibold text-gray-600 hover:bg-gray-100 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800",children:"ล้าง"}):null]})]}),e.jsxs("div",{className:"flex-1 min-w-[160px] max-w-[220px]",children:[e.jsx("label",{className:"block text-[11px] font-semibold text-gray-600 dark:text-gray-300 mb-1",children:"ค่าเป้าหมายผลการเรียนระดับดี (ร้อยละ)"}),e.jsx("input",{type:"text",value:G,onChange:I=>_(I.target.value),placeholder:"เช่น 70",className:"w-full px-2.5 py-1.5 bg-white dark:bg-gray-900 border border-gray-300 dark:border-gray-700 rounded-lg text-xs focus:ring-2 focus:ring-rose-500 focus:outline-none dark:text-white"})]}),xe&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-amber-600 dar
1k:text-amber-400 py-2",children:[e.jsx(He,{size:13,className:"animate-spin"}),e.jsx("span",{children:"กำลังอัปเดตตัวอย่าง..."})]})]}),F&&e.jsxs("div",{className:"px-5 py-2 bg-emerald-50 dark:bg-emerald-950/30 border-b border-emerald-100 dark:border-emerald-800 text-emerald-700 dark:text-emerald-300 text-xs flex items-center gap-2",children:[e.jsx(ft,{size:14}),e.jsx("span",{children:"ดาวน์โหลดสำเร็จ พร้อมบันทึกลงสู่ทะเบียนบันทึกข้อความของโรงเรียนเรียบร้อยแล้ว"})]}),e.jsx("div",{className:"flex-1 overflow-hidden rounded-b-2xl bg-gray-100 dark:bg-[#1e1f21]",children:e.jsx(ts,{width:"100%",height:"100%",className:"h-full w-full border-none",showToolbar:!0,children:e.jsx(Gt,{...se})})})]})}),document.body):null},zs=["4","3.5","3","2.5","2","1.5","1","0","ร","มส","ผ","มผ"],Ht=new Set(zs),Ot=s=>{if(s==null)return null;const t=String(s).trim();if(!t)return null;if(Ht.has(t))return t;const i=Number(t);if(Number.isFinite(i)){const x=String(Math.round(i*2)/2);return Ht.has(x)?x:null}return null},Rs=(s,t)=>{if(!s)return null;const i=Ot(s.status);if(i&&!/^[0-9.]+$/.test(i))return i;const x=Ot(s.grade);if(x==="ร"||x==="มส"||x==="ผ"||x==="มผ")return x;const C=Array.isArray(t==null?void 0:t.formativeAssessments)?t.formativeAssessments:[],f=s.formativeDetails||{},S=Object.values(f).map(k=>Number(k)||0);let d;C.length>0?d=C.reduce((k,$)=>k+(Number(f[$.id||$.name||""])||0),0):s.preMidterm!==void 0||s.postMidterm!==void 0?d=(Number(s.preMidterm)||0)+(Number(s.postMidterm)||0):d=Number(s.formative)||S.reduce((k,$)=>k+$,0);const g=d+(Number(s.midterm)||0)+(Number(s.final)||0);if(!(g>0||S.some(k=>k>0)||["formative","preMidterm","postMidterm","midterm","final"].some(k=>s[k]!==void 0&&s[k]!==null&&s[k]!=="")))return x;const B=js(g);return x&&s.originalGrade&&x!==B?x:B},Gs=(s,t)=>{const i=s||"",x=(t||"").toUpperCase();return i.includes("หน้าที่พลเมือง")||/\bIS\b/i.test(i)||i.includes("การศึกษาค้นคว้าด้วยตนเอง")||i.includes("การศึกษาค้นคว้าอิสระ")||x.startsWith("IS")},Wt=s=>{if(!s)return!1;const t=String(s).toLowerCase().trim();return t.startsWith("p")||t.startsWith("ป.")||t.startsWith("ป")||["1","2","3","4","5","6"].includes(t)},ot=s=>{if(!s)return"1";const t=String(s).trim().toLowerCase();return["1","2"].includes(t)?t:["0","annual","all","ทั้งปี","ตลอดปี","ตลอดปีการศึกษา"].includes(t)?"annual":t},Hs=s=>{const t=Array.isArray(s==null?void 0:s.teacherIds)&&s.teacherIds.length>0?s.teacherIds:s!=null&&s.teacherId?[s.teacherId]:[];return Array.from(new Set(t.filter(i=>i&&i!=="pending"&&!String(i).startsWith("GHOST"))))},vr=()=>{const s=as(),t=st(r=>r.auth.user),i=st(r=>r.userMap.teachers),x=st(r=>r.schoolSettings.currentAcademicYear),C=st(r=>r.calendar.academicYear),[f,S]=b.useState(""),[d,g]=b.useState(C||x||String(new Date().getFullYear()+543)),[N,B]=b.useState("1"),[k,$]=b.useState(!0),[G,_]=b.useState(!1),[F,L]=b.useState([]),[A,le]=b.useState(null),[ne,X]=b.useState(""),[D,je]=b.useState("my"),[xe,Ce]=b.useState("all"),[K,fe]=b.useState(new Set),[J,se]=b.useState(!1),[$e,I]=b.useState(null),[U,Z]=b.useState(!1),[oe,me]=b.useState(null),[ee,Qe]=b.useState(null),De=b.useRef(new Map),ve=b.useRef(new Map),pe=b.useRef(new Set),Ye=b.useMemo(()=>t!=null&&t.role?Array.isArray(t.role)?t.role:[t.role]:[],[t]),xt=b.useMemo(()=>Ye.some(r=>["admin","director","academic","academic_head","registrar","super_admin"].includes(r)),[Ye]),Fe=(t==null?void 0:t.docId)||(t==null?void 0:t.uid)||"";b.useEffect(()=>{const r=t==null?void 0:t.schoolId;r&&(S(r),At(It(Ee,"school-settings",r)).then(l=>{l.exists()&&le(l.data())}))},[t]),b.useEffect(()=>{De.current.clear()},[f,d]);const Ke=b.useCallback(async(r=!1)=>{var l;if(!f||!d){$(!1),L([]);return}r?_(!0):$(!0);try{const[m,u,p]=await Promise.all([rt(Ze(Ee,"school-settings",f,"courses")),rt(_t(Ze(Ee,"school-settings",f,"course_assignments"),Lt("academicYear","==",String(d)))),rt(_t(Ze(Ee,"school-settings",f,"enrollments"),Lt("academicYear","==",String(d))))]),y=new Map;m.docs.forEach(j=>y.set(j.id,{id:j.id,...j.data()}));const h=new Map;u.docs.forEach(j=>{const v=j.data(),a=v.courseId,o=String(v.semester||"1");a&&(h.has(a)||h.set(a,[]),h.get(a).push({semester:o,list:v.teacherAssignments||[]}))});const E=new Map;
1y.forEach((j,v)=>{const a=String(j.code||"").trim();a&&!E.has(a)&&E.set(a,v)});const W=j=>{const v=String(j??"").trim().replace(/^กลุ่ม\s*/,"").replace(/^ก\./,"").trim(),a=Number(v);return v!==""&&Number.isFinite(a)&&a>0?a:null},Q=j=>{const v=new Set;return[j.groupNumber,j.group,j.groupName].forEach(a=>{const o=W(a);o&&v.add(o)}),v.size===0&&[j.room,j.roomNumber].forEach(a=>{const o=W(a);o&&v.add(o)}),v.size===0&&v.add(1),Array.from(v)},O=new Map,Y=(j,v)=>{O.has(j)||O.set(j,new Set),O.get(j).add(v)};p.docs.forEach(j=>{const v=j.data(),a=v.courseId||(v.courseCode?E.get(String(v.courseCode).trim()):void 0),o=v.studentId,n=v.semester;!a||!o||Q(v).forEach(w=>{Y(`${a}_${w}`,o),Y(`${a}_${w}_${n}`,o)})});const re=[],ae=ot(N);for(const[j,v]of Array.from(h.entries())){const a=y.get(j);if(!a)continue;const o=String(a.title||a.name||"").toLowerCase(),n=String(a.code||"").toLowerCase(),w=String(a.type||"").toLowerCase();if(!(o.includes("ชุมนุม")||o.includes("โฮมรูม")||o.includes("แนะแนว")||o.includes("ลูกเสือ")||n.startsWith("ก")||w.includes("กิจกรรม")))for(const{semester:z,list:Xe}of v){const q=ot(z),R=Wt(a.classId);let Me=!1;if(ae==="annual"||R?Me=!0:Me=!q||q==="annual"||q===ae,!!Me)for(const ce of Xe){const Je=Number(ce.groupNumber)||1,Nt=Hs(ce),Ue=Nt[0]||ce.teacherId||"";if(!Ue)continue;const Zt=((l=i[Ue])==null?void 0:l.name)||ce.teacherName||Ue,et=ce.room?String(ce.room).trim():"1";let ke="";Array.isArray(ce.classLevels)&&ce.classLevels.length>0?ke=ce.classLevels[0]:ce.classLevel?ke=ce.classLevel:typeof a.classId=="string"?ke=a.classId:Array.isArray(a.classId)&&a.classId.length>0&&(ke=a.classId[0]);const wt=Array.from(O.get(`${j}_${Je}_${z}`)||O.get(`${j}_${Je}`)||[]),ut=wt.length,Qt=`${$t[ke]||ke}${et?`/${et}`:""}`,Jt=`${j}_${ke}_${et}_${Je}_${z}`;re.push({id:Jt,courseId:j,courseCode:a.code||"",courseTitle:a.title||a.name||"ไม่ระบุชื่อวิชา",subjectGroup:a.subjectGroup||a.learningArea||"",classLevel:ke,room:et,classLabel:Qt,groupNumber:Je,teacherId:Ue,teacherIds:Nt,teacherName:Zt,studentCount:ut,passCount:ut,failCount:0,incompleteCount:0,hasPdf:!1,pdfUrl:null,pdfStoragePath:null,overallPercentage:ut>0?50:0,sectionSemester:z,enrolledStudentIds:wt,includeInGradeTable:!Gs(a.title||a.name||"",a.code||"")})}}}ve.current=new Map,pe.current=new Set,L(re),$(!1),_(!1)}catch(m){console.error("Error fetching PorBor5 courses:",m),$(!1),_(!1)}},[f,d,N,i]);b.useEffect(()=>{Ke()},[Ke]);const mt=async r=>{if(r.pdfUrl){me({url:r.pdfUrl,title:`ปพ.5 — ${r.courseTitle} (${r.classLabel})`});return}if(r.pdfStoragePath){Qe(r.id);try{const l=await ms(Pt(Tt,r.pdfStoragePath));r.pdfUrl=l,me({url:l,title:`ปพ.5 — ${r.courseTitle} (${r.classLabel})`})}catch(l){console.error("Error fetching booklet PDF URL:",l),at.fire({icon:"error",title:"ไม่สามารถเปิดไฟล์ได้",text:"เกิดข้อผิดพลาดในการโหลดไฟล์ PDF จากระบบจัดเก็บ",confirmButtonColor:"#e11d48"})}finally{Qe(null)}}},Te=b.useCallback((r,l,m)=>{if(m==="all")return!0;const u=[r,...l||[]].filter(Boolean);if(m==="my"){const h=[Fe,t==null?void 0:t.uid,t==null?void 0:t.docId,t==null?void 0:t.teacherId].filter(Boolean);for(const[W,Q]of Object.entries(i||{}))(Q.uid===(t==null?void 0:t.uid)||W===(t==null?void 0:t.uid)||Q.id===Fe)&&h.push(W,Q.id,Q.uid||"",Q.teacherId||"");const E=new Set(h.filter(Boolean));return u.some(W=>E.has(W))}const p=new Set([m]),y=i[m];return y&&(y.id&&p.add(y.id),y.uid&&p.add(y.uid),y.teacherId&&p.add(y.teacherId)),u.some(h=>p.has(h))},[Fe,t,i]),ie=b.useMemo(()=>F.filter(r=>Te(r.teacherId,r.teacherIds,D)),[F,Te,D]);b.useEffect(()=>{if(!f||!d||ie.length===0)return;const r=Array.from(new Set(ie.map(p=>p.courseId))).filter(p=>!pe.current.has(p));if(r.length===0)return;r.forEach(p=>pe.current.add(p));const l=ot(N),m=l==="annual"?["semester_annual"]:l==="2"?["semester_2","semester_annual"]:["semester_1","semester_annual"];let u=!1;return(async()=>{for(let y=0;y<r.length;y+=6){if(u)return;const h=r.slice(y,y+6);await Promise.allSettled(h.flatMap(E=>m.map(async W=>{try{const Q=await xs(Pt(Tt,`school-settings/${f}/grading/courses/${E}/year_${d}/${W}`)),O=ve.current.get(E)||new Set;
1Q.items.forEach(Y=>O.add(Y.fullPath)),ve.current.set(E,O)}catch{}})))}u||L(y=>y.map(h=>{if(!pe.current.has(h.courseId)||h.hasPdf)return h;const E=Wt(h.classLevel),W=[h.room?`_${h.room}`:"",h.groupNumber?`_${h.groupNumber}`:"",""],Q=E?["semester_annual","semester_1","semester_2"]:[`semester_${ot(h.sectionSemester)||"1"}`,"semester_annual","semester_1","semester_2"],O=[h.classLevel,h.classLevel.toLowerCase(),h.classLevel.toUpperCase()].filter(Boolean),Y=[];for(const v of Array.from(new Set(Q)))for(const a of Array.from(new Set(O)))for(const o of Array.from(new Set(W)))Y.push(`school-settings/${f}/grading/courses/${h.courseId}/year_${d}/${v}/ปพ5_${h.courseId}_${a}${o}.pdf`);const re=ve.current.get(h.courseId),ae=re?Y.find(v=>re.has(v)):void 0,j=!!ae;return{...h,hasPdf:j,pdfStoragePath:ae||null,overallPercentage:j?100:h.studentCount>0?50:0}}))})(),()=>{u=!0,r.forEach(p=>{ve.current.has(p)||pe.current.delete(p)})}},[ie,f,d,N]);const te=ie.length,ge=ie.filter(r=>r.hasPdf).length,Ae=te-ge,Ie=te>0?Math.round(ge/te*100):0,H=te>0&&ge===te,M=b.useMemo(()=>ie.filter(r=>{if(xe==="saved"&&!r.hasPdf||xe==="pending"&&r.hasPdf)return!1;if(ne.trim()){const l=ne.toLowerCase().trim(),m=r.courseCode.toLowerCase().includes(l),u=r.courseTitle.toLowerCase().includes(l),p=r.classLabel.toLowerCase().includes(l),y=r.teacherName.toLowerCase().includes(l);if(!m&&!u&&!p&&!y)return!1}return!0}),[ie,xe,ne]),Ve=b.useMemo(()=>{const r=new Map;return F.forEach(l=>{l.teacherId&&l.teacherName&&r.set(l.teacherId,l.teacherName)}),Array.from(r.entries()).filter(([l])=>!Te(l,void 0,"my")).map(([l,m])=>{var y;const u=(y=i[l])==null?void 0:y.name,p=!u&&m===l;return{id:l,unresolved:p,name:p?`ไม่พบชื่อครู (${l.slice(0,6)}…)`:u||m}}).sort((l,m)=>Number(l.unresolved)-Number(m.unresolved)||l.name.localeCompare(m.name,"th"))},[F,Te,i]),_e=()=>{K.size===M.length&&M.length>0?fe(new Set):fe(new Set(M.map(r=>r.id)))},St=r=>{fe(l=>{const m=new Set(l);return m.has(r)?m.delete(r):m.add(r),m})},ue=r=>{const l=Object.values((r==null?void 0:r.characteristicsScores)||{});if(l.length===0)return null;const m=Math.round(l.reduce((u,p)=>u+p,0)/l.length);return m<0||m>3?null:String(m)},V=async r=>{const l=r||(K.size>0?M.filter(p=>K.has(p.id)):ie);if(l.length===0){at.fire({icon:"info",title:"ไม่พบรายวิชา",text:"กรุณาเลือกรายวิชาที่ต้องการออกบันทึกข้อความอย่างน้อย 1 วิชา",confirmButtonText:"ตกลง",confirmButtonColor:"#e11d48"});return}const m=l.filter(p=>!p.hasPdf),u=async()=>{var p,y;Z(!0);try{const h=l[0],E=(p=Object.entries(i||{}).find(([o,n])=>o===(t==null?void 0:t.uid)||n.uid===(t==null?void 0:t.uid)||n.id===Fe))==null?void 0:p[1],W=(E==null?void 0:E.name)||(t==null?void 0:t.fullName)||(t==null?void 0:t.displayName)||h.teacherName,Q=(E==null?void 0:E.subjectGroup)||(E==null?void 0:E.learningArea)||h.subjectGroup,O=Array.from(new Set(l.map(o=>o.courseId))),Y=O.filter(o=>!De.current.has(o));Y.length>0&&await Promise.allSettled(Y.map(async o=>{try{const n=await rt(Ze(Ee,"school-settings",f,"courses",o,"grades")),w={};n.docs.forEach(z=>{w[z.id]=z.data()}),De.current.set(o,w)}catch(n){console.warn(`Could not load grades for course ${o}:`,n)}}));const re={};await Promise.allSettled(O.map(async o=>{try{const n=await At(It(Ee,"school-settings",f,"courses",o));n.exists()&&(re[o]=n.data())}catch(n){console.warn(`Could not load course ${o}:`,n)}}));const ae=l.map(o=>{const n=De.current.get(o.courseId)||{},w=Is(),z=_s();return o.enrolledStudentIds.forEach(Xe=>{const q=n[Xe];if(!q)return;const R=Rs(q,re[o.courseId]);R&&w[R]++;const Me=ue(q);Me&&z[Me]++}),{courseCode:o.courseCode,courseTitle:o.courseTitle,classLevel:$t[o.classLevel]||o.classLevel,room:o.room,studentCount:o.studentCount,gradeBuckets:w,charBuckets:z,includeInGradeTable:o.includeInGradeTable}}),j=is(A,"academic"),v=((y=Object.values(i||{}).find(o=>o.isHeadOfAssessment))==null?void 0:y.name)||(A==null?void 0:A.assessmentHeadName)||"",a={schoolName:(A==null?void 0:A.schoolName)||"โรงเรียน",schoolAffiliation:(A==null?void 0:A.affiliation)||"",academicYear:String(d),semester:String(N),learningArea:Q,teacherName:W,teacherPosition:"ครูผู้สอน",courses:ae,directorName:A!=null&&A.directorName?`${A.directorPrefix||""}${A.directorName}`.trim():"",reviewerName:v,deputyDirectorName:(j==null?void 0:j.name)||""};I(a),se(!0)}catch(h){console.error("Error generating memo:",h),at.fire({icon:"error",title:"เกิดข้อผิดพลาดในการประมวลผล",text:"ไม่สามารถดึงข้อมูลผลการเรียนได้ กรุณาลองใหม่อีกครั้ง",confirmButtonColor:"#e11d48"})}finally{Z(!1)}};m.length>0?at.fire({icon:"warning",title:"ตรวจพบรายวิชาที่ยังไม่ได้ออกเล่ม ปพ.5 (PDF)",html:`
2          <div class="text-left text-xs space-y-2 mt-2">
3            <p>มีจำนวน <b>${m.length} รายวิชา</b> ที่ยังไม่มีไฟล์เล่ม ปพ.5 (PDF) ในคลังเอกสาร:</p>
4            <ul class="list-disc pl-5 text-gray-600 dark:text-gray-300 max-h-36 overflow-y-auto space-y-1">
5              ${m.slice(0,10).map(p=>`<li><b>${p.courseCode}</b> ${p.courseTitle} (${p.classLabel})</li>`).join("")}
6              ${m.length>10?`<li>...และอีก ${m.length-10} รายวิชา</li>`:""}
7            </ul>
8            <p class="text-gray-500 pt-2 border-t border-gray-200 dark:border-gray-700">
9              * ตามระเบียบงานวัดผลควรบันทึกเล่ม ปพ.5 ให้ครบà¸
9à¹ˆà¸­à¸™ แต่หากท่านต้องการพิมพ์บันทึกข้อความนำส่งทันที สามารถกดยืนยันเพื่อดำเนินการได้
10            </p>
11          </div>
12        `,showCancelButton:!0,confirmButtonText:"ยืนยันออกบันทึกข้อความต่อไป",cancelButtonText:"ยกเลิก (ไปบันทึกเล่ม ปพ.5 ก่อน)",confirmButtonColor:"#e11d48",cancelButtonColor:"#6b7280"}).then(p=>{p.isConfirmed&&u()}):u()};return e.jsx(us,{children:e.jsxs("div",{className:"max-w-[1400px] mx-auto px-4 sm:px-6 lg:px-8 py-6 space-y-5 text-slate-800 dark:text-slate-200",children:[e.jsxs("header",{className:"border border-slate-300 dark:border-slate-700 bg-white dark:bg-[#202125]",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-6 gap-y-1 bg-[#1e3a5f] px-5 py-2 text-[11px] tracking-wide text-white",children:[e.jsx("span",{children:"กลุ่มบริหารวิชาการ · งานวัดผลและประเมินผล"}),e.jsxs("span",{children:["ปีการศึกษา ",d," · ",N==="annual"?"ตลอดปีการศึกษา":`ภาคเรียนที่ ${N}`]})]}),e.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(hs,{to:"/academic/hub/evaluation"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-slate-900 dark:text-white sm:text-2xl",children:"บันทึกข้อความรายงานผลสัมฤทธิ์ทางการเรียน"}),e.jsxs("div",{className:"mt-1.5 space-y-0.5 text-xs leading-relaxed text-slate-600 dark:text-slate-400",children:[e.jsxs("p",{children:[e.jsx("span",{className:"font-bold text-slate-800 dark:text-slate-100",children:"เอกสารที่จัดทำ: "}),["บันทึกข้อความนำส่งเล่ม ปพ.5","แบบสรุปผลสัมฤทธิ์ทางการเรียน","แบบสรุปคุณลักษณะอันพึงประสงค์"].map((r,l)=>e.jsxs("span",{className:"mr-3 inline-block whitespace-nowrap",children:[["๑","๒","๓"][l],") ",r]},r))]}),e.jsxs("p",{children:[e.jsx("span",{className:"font-bold text-slate-800 dark:text-slate-100",children:"เงื่อนไข: "}),"ต้องบันทึกเล่ม ปพ.5 (PDF) ของทุกรายวิชาที่ได้รับมอบหมายให้ครบถ้วนก่อนส่งออกเอกสาร"]})]})]})]}),e.jsxs("div",{className:"grid w-full shrink-0 grid-cols-1 gap-2 sm:grid-cols-3 lg:w-auto",children:[e.jsxs("button",{onClick:()=>Ke(!0),disabled:k||G,title:"ตรวจสอบสถานะไฟล์ PDF ล่าสุดในระบบ",className:"inline-flex h-10 items-center justify-center gap-2 whitespace-nowrap border border-slate-300 bg-white px-4 text-xs font-semibold text-slate-700 transition hover:bg-slate-50 disabled:opacity-50 dark:border-slate-600 dark:bg-transparent dark:text-slate-200 dark:hover:bg-slate-800",children:[e.jsx(vs,{size:15,className:G?"animate-spin":""}),G?"กำลังตรวจสอบ...":"ตรวจสอบสถานะล่าสุด"]}),e.jsxs("button",{onClick:()=>s("/academic/course-assignment"),className:"inline-flex h-10 items-center justify-center gap-2 whitespace-nowrap border border-slate-300 bg-white px-4 text-xs font-semibold text-slate-700 transition hover:bg-slate-50 dark:border-slate-600 dark:bg-transparent dark:text-slate-200 dark:hover:bg-slate-800",children:[e.jsx(ks,{size:15}),"ตารางมอบหมายการสอน"]}),e.jsxs("button",{onClick:()=>s("/academic/grade-book"),className:"inline-flex h-10 items-center justify-center gap-2 whitespace-nowrap border border-slate-300 bg-white px-4 text-xs font-semibold text-slate-700 transition hover:bg-slate-50 dark:border-slate-600 dar
12k:bg-transparent dark:text-slate-200 dark:hover:bg-slate-800",children:[e.jsx(Ss,{size:15}),"ทะเบียนวัดผล (ปพ.5)"]})]})]})]}),e.jsxs("section",{className:"border border-slate-300 bg-white dark:border-slate-700 dark:bg-[#202125]",children:[e.jsx("div",{className:"border-b border-slate-300 bg-slate-100 px-5 py-2.5 text-sm font-bold text-slate-800 dark:border-slate-700 dark:bg-slate-800/60 dark:text-slate-100",children:"ส่วนที่ ๑ สรุปสถานะการจัดทำเล่ม ปพ.5"}),e.jsx("dl",{className:"grid grid-cols-2 divide-x divide-y divide-slate-200 dark:divide-slate-700 sm:grid-cols-4 sm:divide-y-0",children:[{label:"รายวิชาที่ได้รับมอบหมาย",value:te,tone:"text-slate-900 dark:text-white"},{label:"บันทึกเล่ม PDF แล้ว",value:ge,tone:"text-emerald-700 dark:text-emerald-400"},{label:"ยังไม่บันทึกเล่ม PDF",value:Ae,tone:Ae>0?"text-red-700 dark:text-red-400":"text-slate-400"},{label:"ร้อยละความครบถ้วน",value:`${Ie}%`,tone:H?"text-emerald-700 dark:text-emerald-400":"text-amber-700 dark:text-amber-400"}].map(r=>e.jsxs("div",{className:"px-5 py-3",children:[e.jsx("dt",{className:"text-[11px] text-slate-500 dark:text-slate-400",children:r.label}),e.jsx("dd",{className:`mt-0.5 text-2xl font-bold tabular-nums ${r.tone}`,children:r.value})]},r.label))}),!k&&te>0&&e.jsxs("div",{className:`flex flex-col gap-3 border-t border-slate-300 border-l-4 px-5 py-4 dark:border-slate-700 md:flex-row md:items-center md:justify-between ${H?"border-l-emerald-600 bg-emerald-50/50 dark:bg-emerald-950/10":"border-l-amber-500 bg-amber-50/50 dark:bg-amber-950/10"}`,children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:`mt-0.5 ${H?"text-emerald-700 dark:text-emerald-400":"text-amber-700 dark:text-amber-400"}`,children:H?e.jsx(ft,{size:20}):e.jsx(Ns,{size:20})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-slate-900 dark:text-white",children:H?"บันทึกเล่ม ปพ.5 (PDF) ครบทุกรายวิชาที่ได้รับมอบหมาย พร้อมส่งออกบันทึกข้อความ":`ยังไม่สามารถส่งออกบันทึกข้อความได้ — บันทึกแล้ว ${ge} จาก ${te} รายวิชา`}),e.jsx("p",{className:"mt-0.5 text-xs text-slate-600 dark:text-slate-400",children:H?"ข้อมูลครบถ้วน สามารถจัดทำบันทึกข้อความนำส่งเล่ม ปพ.5 ได้":`คงเหลือ ${Ae} รายวิชาที่ต้องบันทึกเล่ม ปพ.5 (PDF) ก่อนส่งออก`}),e.jsx("div",{className:"mt-2 h-2 w-full max-w-sm bg-slate-200 dark:bg-slate-700",role:"progressbar","aria-valuenow":Ie,"aria-valuemin":0,"aria-valuemax":100,children:e.jsx("div",{className:`h-full transition-all duration-500 ${H?"bg-emerald-600":"bg-amber-500"}`,style:{width:`${Ie}%`}})})]})]}),e.jsxs("button",{onClick:()=>V(),disabled:U,title:"พิมพ์และส่งออกบันทึกข้อความรายงานผลสัมฤทธิ์ทางการเรียน",className:"inline-flex shrink-0 items-center justify-center gap-2 border border-red-700 bg-red-700 px-5 py-2.5 text-sm font-bold text-white transition hover:bg-red-800 disabled:opacity-50",children:[U?e.jsx(He,{size:16,className:"animate-spin"}):e.jsx(ht,{size:16}),U?"กำลังประมวลผลข้อมูลเกรด...":H?"ส่งออกบันทึกข้อความ":`ส่งออกบันทึกข้อความ (${ge}/${te})`]})]})]}),e.jsxs("section",{className:"border border-slate-300 bg-white dark:border-slate-700 dark:bg-[#202125]",children:[e.jsx("div",{className:"border-b border-slate-300 bg-slate-100 px-5 py-2.5 text-sm font-bold text-slate-800 dark:border-slate-700 dark:bg-slate-800/60 dark:text-slate-100",children:"ส่วนที่ ๒ กำหนดขอบเขตข้อมูล"}),e.jsxs("div",{className:"grid gap-4 px-5 py-4 md:grid-cols-2 xl:grid-cols-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-[11px] font-semibold text-slate-600 dar
12k:text-slate-400",children:"ปีการศึกษา / ภาคเรียน"}),e.jsx(ys,{schoolId:f,academicYear:d,onAcademicYearChange:g,semester:N,onSemesterChange:B})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"porbor5-teacher",className:"mb-1 block text-[11px] font-semibold text-slate-600 dark:text-slate-400",children:"ครูผู้สอน"}),e.jsxs("select",{id:"porbor5-teacher",value:D,onChange:r=>{je(r.target.value),fe(new Set)},className:"w-full border border-slate-300 bg-white px-3 py-2 text-xs text-slate-800 focus:border-[#1e3a5f] focus:outline-none focus:ring-1 focus:ring-[#1e3a5f] dark:border-slate-600 dark:bg-slate-800 dark:text-slate-100",children:[e.jsxs("option",{value:"my",children:["วิชาที่ฉันสอน (",(t==null?void 0:t.fullName)||"ครูผู้ใช้ปัจจุบัน",")"]}),xt&&e.jsx("option",{value:"all",children:"ครูทุกคนในโรงเรียน (ทั้งหมด)"}),Ve.map(r=>e.jsx("option",{value:r.id,children:r.name},r.id))]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"mb-1 block text-[11px] font-semibold text-slate-600 dark:text-slate-400",children:"สถานะเล่ม ปพ.5"}),e.jsx("div",{className:"inline-flex w-full border border-slate-300 dark:border-slate-600",role:"group","aria-label":"กรองตามสถานะเล่ม ปพ.5",children:[{key:"all",label:`ทั้งหมด (${te})`},{key:"saved",label:`บันทึกแล้ว (${ge})`},{key:"pending",label:`ค้าง (${Ae})`}].map((r,l)=>e.jsx("button",{type:"button",onClick:()=>Ce(r.key),"aria-pressed":xe===r.key,className:`flex-1 px-2 py-2 text-xs font-semibold transition ${l>0?"border-l border-slate-300 dark:border-slate-600":""} ${xe===r.key?"bg-[#1e3a5f] text-white":"bg-white text-slate-700 hover:bg-slate-50 dark:bg-transparent dark:text-slate-300 dark:hover:bg-slate-800"}`,children:r.label},r.key))})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"porbor5-search",className:"mb-1 block text-[11px] font-semibold text-slate-600 dark:text-slate-400",children:"ค้นหา"}),e.jsxs("div",{className:"relative",children:[e.jsx(ls,{className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-slate-400",size:14}),e.jsx("input",{id:"porbor5-search",type:"text",placeholder:"รหัสวิชา / ชื่อวิชา / ชั้น-ห้อง / ชื่อครู",value:ne,onChange:r=>X(r.target.value),className:"w-full border border-slate-300 bg-white py-2 pl-9 pr-3 text-xs text-slate-800 placeholder-slate-400 focus:border-[#1e3a5f] focus:outline-none focus:ring-1 focus:ring-[#1e3a5f] dark:border-slate-600 dark:bg-slate-800 dark:text-slate-100"})]})]})]})]}),e.jsxs("section",{className:"border border-slate-300 bg-white dark:border-slate-700 dark:bg-[#202125]",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 border-b border-slate-300 bg-slate-100 px-5 py-2.5 dark:border-slate-700 dark:bg-slate-800/60",children:[e.jsxs("h2",{className:"text-sm font-bold text-slate-800 dark:text-slate-100",children:["ส่วนที่ ๓ รายการรายวิชาที่ได้รับมอบหมาย (",M.length," รายการ)"]}),M.length>0&&e.jsx("button",{onClick:_e,className:"text-xs font-semibold text-[#1e3a5f] underline-offset-2 hover:underline dark:text-sky-300",children:K.size===M.length?"ยกเลิกการเลือกทั้งหมด":"เลือกทั้งหมด"})]}),k?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-slate-500",children:[e.jsx(He,{size:28,className:"mb-2 animate-spin text-[#1e3a5f] dark:text-sky-300"}),e.jsx("p",{className:"text-xs",children:"กำลังตรวจสอบสถานะไฟล์ ปพ.5 จากฐานข้อมูล..."})]}):M.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center px-4 py-14 text-center",children:[e.jsx(Et,{size:32,className:"mb-2 text-slate-300 dark:text-slate-600"}),e.jsx("p",{className:"text-sm font-bold text-slate-700 dark:text-slate-200",children:"ไม่พบรายวิชาที่ได้รับมอบหมายสอน"}),e.jsx("p",{className:"mt-1 max-w-md text-xs text-slate-500",children:"หากยังไม่มีการมอบหมายงานสอน กรุณาตรวจสอบที่หน้าระบบมอบหมายงานสอน หรือเปลี่ยนปีการศึกษา/ภาคเรียน"})]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[960px] border-collapse text-left text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-[#1e3a5f] text-white",children:[e.jsx("th",{className:"w-12 border border-[#2c4a72] px-3 py-2.5 text-center font-semibold",children:e.jsx("input",{type:"checkbox","aria-label":"เลือกทั้งหมด",checked:K.size===M.length&&M.length>0,onChange:_e,className:"h-4 w-4 accent-amber-500"})}),e.jsx("th",{className:"w-12 border border-[#2c4a72] px-3 py-2.5 text-center font-semibold",children:"ที่"}),e.jsx("th",{className:"w-28 border border-[#2c4a72] px-3 py-2.5 font-semibold",children:"รหัสวิชา"}),e.jsx("th",{className:"border border-[#2c4a72] px-3 py-2.5 font-semibold",children:"ชื่อรายวิชา"}),e.jsx("th",{className:"w-24 border border-[#2c4a72] px-3 py-2.5 text-center font-semibold",children:"ชั้น/ห้อง"}),e.jsx("th",{className:"w-40 border border-[#2c4a72] px-3 py-2.5 font-semibold",children:"ครูผู้สอน"}),e.jsx("th",{className:"w-24 border border-[#2c4a72] px-3 py-2.5 text-center font-semibold",children:"à¸
12ˆà¸³à¸™à¸§à¸™ (คน)"}),e.jsx("th",{className:"w-36 border border-[#2c4a72] px-3 py-2.5 text-center font-semibold",children:"สถานะเล่ม ปพ.5"}),e.jsx("th",{className:"w-56 border border-[#2c4a72] px-3 py-2.5 text-center font-semibold",children:"การดำเนินการ"})]})}),e.jsx("tbody",{className:"text-slate-700 dark:text-slate-300",children:M.map((r,l)=>{const m=K.has(r.id);return e.jsxs("tr",{className:`transition-colors hover:bg-sky-50/60 dark:hover:bg-slate-800/50 ${m?"bg-sky-50 dark:bg-sky-950/20":l%2===1?"bg-slate-50/70 dark:bg-slate-800/20":""}`,children:[e.jsx("td",{className:"border border-slate-200 px-3 py-2.5 text-center dark:border-slate-700",children:e.jsx("input",{type:"checkbox","aria-label":`เลือก ${r.courseCode}`,checked:m,onChange:()=>St(r.id),className:"h-4 w-4 accent-[#1e3a5f]"})}),e.jsx("td",{className:"border border-slate-200 px-3 py-2.5 text-center tabular-nums text-slate-500 dark:border-slate-700",children:l+1}),e.jsx("td",{className:"border border-slate-200 px-3 py-2.5 font-mono font-semibold text-slate-900 dark:border-slate-700 dark:text-white",children:r.courseCode}),e.jsxs("td",{className:"border border-slate-200 px-3 py-2.5 dark:border-slate-700",children:[e.jsx("div",{className:"font-semibold text-slate-900 dark:text-white",children:r.courseTitle}),r.subjectGroup&&e.jsx("div",{className:"text-[10px] text-slate-500",children:r.subjectGroup})]}),e.jsx("td",{className:"border border-slate-200 px-3 py-2.5 text-center font-semibold dark:border-slate-700",children:r.classLabel}),e.jsx("td",{className:"max-w-[160px] truncate border border-slate-200 px-3 py-2.5 dark:border-slate-700",title:r.teacherName,children:r.teacherName}),e.jsx("td",{className:"border border-slate-200 px-3 py-2.5 text-center tabular-nums dark:border-slate-700",children:r.studentCount}),e.jsx("td",{className:"border border-slate-200 px-3 py-2.5 text-center dark:border-slate-700",children:r.hasPdf?e.jsxs("span",{className:"inline-flex items-center gap-1 border border-emerald-600 px-2 py-0.5 text-[11px] font-semibold text-emerald-800 dark:border-emerald-500 dark:text-emerald-300",children:[e.jsx(ft,{size:12})," บันทึกแล้ว"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 border border-red-600 px-2 py-0.5 text-[11px] font-semibold text-red-800 dark:border-red-500 dark:text-red-300",children:[e.jsx(Et,{size:12})," ยังไม่บันทึก"]})}),e.jsx("td",{className:"border border-slate-200 px-3 py-2.5 dark:border-slate-700",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-1.5",children:[r.hasPdf?e.jsxs("button",{onClick:()=>mt(r),disabled:ee===r.id,title:"ดูตัวอย่างเล่ม ปพ.5 (PDF)",className:"inline-flex items-center gap-1 border border-slate-300 bg-white px-2.5 py-1.5 font-semibold text-slate-700 transition hover:bg-slate-50 disabled:opacity-50 dark:border-slate-600 dark:bg-transparent dark:text-slate-200 dark:hover:bg-slate-800",children:[ee===r.id?e.jsx(He,{size:13,className:"animate-spin"}):e.jsx(ns,{size:13}),"ดูเล่ม PDF"]}):e.jsxs("button",{onClick:()=>s(`/academic/grade-book?courseId=${r.courseId}&classId=${r.classLevel}&room=${r.room}&semester=${r.sectionSemester||N}`),title:"เปิดหน้า ปพ.5 เพื่อบันทึกและส่งออกเล่ม PDF",className:"inline-flex items-center gap-1 border border-amber-600 bg-amber-50 px-2.5 py-1.5 font-semibold text-amber-900 transition hover:bg-amber-100 dark:border-amber-500 dark:bg-amber-950/20 dark:text-amber-200",children:[e.jsx(os,{size:13}),"ไปบันทึกเล่ม ปพ.5"]}),e.jsxs("button",{onClick:()=>V([r]),title:"พิมพ์บันทึกข้อความเฉพาะรายวิชานี้",className:"inline-flex items-center gap-1 border border-[#1e3a5f] bg-white px-2.5 py-1.5 font-semibold text-[#1e3a5f] transition hover:bg-[#1e3a5f] hover:text-white dark:border-sky-400 dark:bg-transparent dark:text-sky-300 dark:hover:bg-sky-400 dark:hover:text-slate-900",children:[e.jsx(ht,{size:13}),"ออกบันทึกข้อความ"]})]})})]},r.id)})})]})}),e.jsx("div",{className:"border-t border-slate-200 px-5 py-2.5 text-[11px] text-slate-500 dark:border-slate-700 dark:text-slate-400",children:'หมายเหตุ: เลือกรายวิชาในตารางเพื่อออกบันทึกข้อความหลายรายวิชาพร้อมก
12ัน หรือกด "ออกบันทึกข้อความ" ที่แถวเพื่อออกเฉพาะรายวิชานั้น'})]}),K.size>0&&e.jsxs("div",{className:"fixed bottom-6 left-1/2 z-40 flex -translate-x-1/2 flex-wrap items-center gap-4 border border-slate-600 bg-[#14273f] px-5 py-3 text-white shadow-2xl animate-slide-up",children:[e.jsxs("span",{className:"text-xs font-semibold",children:["เลือกแล้ว ",e.jsx("span",{className:"tabular-nums text-amber-300",children:K.size})," รายวิชา"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>fe(new Set),className:"border border-slate-500 px-3 py-1.5 text-xs font-semibold transition hover:bg-slate-700",children:"ยกเลิกการเลือก"}),e.jsxs("button",{onClick:()=>V(),disabled:U,title:"พิมพ์บันทึกข้อความรายงานผลสัมฤทธิ์ทางการเรียน",className:"inline-flex items-center gap-1.5 border border-amber-400 bg-amber-400 px-4 py-1.5 text-xs font-bold text-slate-900 transition hover:bg-amber-300 disabled:opacity-50",children:[U?e.jsx(He,{size:14,className:"animate-spin"}):e.jsx(ht,{size:14}),"ออกบันทึกข้อความ (",K.size," วิชา)"]})]})]}),J&&$e&&e.jsx(Ms,{isOpen:J,onClose:()=>se(!1),pdfProps:$e,schoolId:f,createdBy:(t==null?void 0:t.fullName)||(t==null?void 0:t.displayName)||(t==null?void 0:t.email)||"ครูผู้สอน"}),oe&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center px-4 pb-4 pt-[76px] bg-black/60 backdrop-blur-sm animate-fade-in",children:e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-2xl shadow-2xl flex flex-col w-full max-w-5xl h-full max-h-[calc(100vh-92px)] border border-gray-200 dark:border-gray-800 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-gray-200 dark:border-gray-800",children:[e.jsx("h3",{className:"text-sm font-bold text-gray-800 dark:text-white truncate",children:oe.title}),e.jsx("button",{onClick:()=>me(null),className:"p-1 rounded-lg text-gray-400 hover:text-gray-600 dark:hover:text-white transition",children:e.jsx(Yt,{size:18})})]}),e.jsx("div",{className:"flex-1 bg-gray-100 dark:bg-gray-950 p-2",children:e.jsx("iframe",{src:oe.url,className:"w-full h-full border-0 rounded-lg shadow-inner",title:oe.title})})]})})]})})};export{vr as PorBor5SubmissionMemoPage,vr as default};

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.