1"use strict";(globalThis.webpackChunkfrontend=globalThis.webpackChunkfrontend||[]).push([[5178],{8118(e,s,t){t.d(s,{$m:()=>d,As:()=>o,nD:()=>c,ub:()=>u});var a=t(65043),r=t(7844),i=t(92382),n=t(99766),l=t(70579);const c=r.bL,o=a.forwardRef((e,s)=>{let{className:t,...a}=e;return(0,l.jsx)(r.q7,{ref:s,className:(0,n.cn)("border-b",t),...a})});o.displayName="AccordionItem";const d=a.forwardRef((e,s)=>{let{className:t,children:a,...c}=e;return(0,l.jsx)(r.Y9,{className:"flex",children:(0,l.jsxs)(r.l9,{ref:s,className:(0,n.cn)("flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline text-left [&[data-state=open]>svg]:rotate-180",t),...c,children:[a,(0,l.jsx)(i.A,{className:"h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200"})]})})});d.displayName=r.l9.displayName;const u=a.forwardRef((e,s)=>{let{className:t,children:a,...i}=e;return(0,l.jsx)(r.UC,{ref:s,className:"overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...i,children:(0,l.jsx)("div",{className:(0,n.cn)("pb-4 pt-0",t),children:a})})});u.displayName=r.UC.displayName},5178(e,s,t){t.r(s),t.d(s,{default:()=>H});var a=t(65043),r=t(45621),i=t(73824),n=t(4980),l=t(82357),c=t(1673),o=t(56328),d=t(13390),u=t(91140),m=t(5949),x=t(92264),h=t(13416),p=(t(59938),t(25440)),j=t(46258),v=t(29236),g=t(7104),f=t(9855),N=t(37719),b=t(22024),w=t(70579);const y=e=>{let{unitId:s,lesson:t,activity:r,weekNumber:l=null,creditsBalance:c=null,onTopUpCredits:u=null,existingResources:m=[],onResourceGenerated:x,onResourceDeleted:h}=e;const[p,j]=(0,a.useState)(null),[y,_]=(0,a.useState)([]),k=[...y,...m.filter(e=>!y.some(s=>s.resource_id===e.resource_id))],A=new Set(k.map(e=>{var s;return null===(s=e.meta)||void 0===s?void 0:s.subtype})),C=async e=>{j(e);try{const a=(await n.A.post(`${i.nC}/unit-plans/${s}/generate-resource`,{lesson_title:`Lesson ${t.lesson_number}: ${t.title}`,activity_description:r,resource_type:e,context:`Subject: ${t.subject||""}`,week_number:l},{})).data;if(!a||!a.resource_id)throw new Error("No resource data returned");o.oR.success("Resource generated! Starting download..."),_(e=>[a,...e]),x&&x(a)}catch(u){var a,c,d;if(403===(null===(a=u.response)||void 0===a?void 0:a.status))o.oR.error("Limit Reached: "+(u.response.data.detail||"Upgrade to create more."));else o.oR.error((null===(c=u.response)||void 0===c||null===(d=c.data)||void 0===d?void 0:d.detail)||"Failed to generate resource")}finally{j(null)}};return(0,w.jsxs)("div",{className:"mt-2",children:[k.length>0&&(0,w.jsx)("div",{className:"flex flex-wrap gap-2 mb-3",children:k.map(e=>(0,w.jsxs)("div",{className:"relative group w-24 h-24 rounded-lg overflow-hidden border border-border bg-muted flex items-center justify-center",children:[(0,w.jsxs)("div",{className:"flex flex-col items-center justify-center w-full h-full p-2 text-center",children:[(0,w.jsx)(v.A,{className:"w-8 h-8 text-muted-foreground mb-1"}),(0,w.jsx)("span",{className:"text-[10px] leading-tight text-muted-foreground font-medium truncate w-full px-1",children:e.filename})]}),(0,w.jsxs)("div",{className:"absolute inset-0 bg-black/60 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-1",children:[(0,w.jsx)(d.$,{variant:"ghost",size:"icon",className:"h-6 w-6 text-white hover:text-primary hover:bg-white/20",onClick:()=>async function(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"resource";try{const t=await n.A.get(`${i.nC}/resources/${e}/download`,{responseType:"blob",timeout:6e4}),a=t.headers["content-type"]||"application/octet-stream",r=new Blob([t.data],{type:a}),l=URL.createObjectURL(r),c=document.createElement("a");c.href=l;let o="";a.includes("pdf")?o=".pdf":a.includes("png")?o=".png":(a.includes("jpeg")||a.includes("jpg"))&&(o=".jpg"),c.download=`${s}${o}`,document.body.appendChild(c),c.click(),document.body.removeChild(c),URL.revokeObjectURL(l)}catch(t){o.oR.error("Download failed. Please try again.")}}(e.resource_id,e.filename||"resource"),title:"Download",children:(0,w.jsx)(g.A,{className:"w-3 h-3"})}),(0,w.jsx)(d.$,{variant:"ghost",size:"icon",className:"h-6 w-6 text-white hover:text-destructive hover:bg-white/20",onClick:()=>(async e=>{if(window.confirm("Delete this generated resource?"))try{await n.A.delete(`${i.nC}/resources/${e}`),_(s=>s.filter(s=>s.resource_id!==e)),h&&h(e),o.oR.success("Resource deleted")}catch(s){o.oR.error("Failed to delete")}})(e.resource_id),title:"Delete",children:(0,w.jsx)(f.A,{className:"w-3 h-3"})})]})]},e.resource_id))}),null!=c&&c<5&&(0,w.jsxs)("div",{className:"flex items-start gap-2 text-xs px-3 py-2 rounded-md border mb-2 "+(0===c?"bg-red-50 border-red-200 text-red-700":"bg-amber-50 border-amber-200 text-amber-700"),children:[(0,w.jsx)(N.A,{className:"w-3 h-3 mt-0.5 flex-shrink-0"}),0===c?(0,w.jsxs)("span",{children:["You've used all your credits."," ",u?(0,w.jsx)("button",{onClick:u,className:"font-semibold underline underline-offset-2 cursor-pointer",children:"Top up credits"}):(0,w.jsx)("a",{href:"/subscription",className:"font-semibold underline underline-offset-2",children:"Top up credits"})," ","to keep generating."]}):(0,w.jsxs)("span",{children:["You have ",(0,w.jsx)("strong",{children:c})," credit",1===c?"":"s"," left \u2014 each resource costs ",5,"."," ",u?(0,w.jsx)("button",{onClick:u,className:"font-semibold underline underline-offset-2 cursor-pointer",children:"Top up credits"}):(0,w.jsx)("a",{href:"/subscription",className:"font-semibold underline underline-offset-2",children:"Top up credits"}),"."]})]}),(A.size<2||null!==p)&&(0,w.jsxs)("div",{className:"flex flex-wrap gap-2",children:[!A.has("guide")&&(0,w.jsxs)(d.$,{size:"sm",variant:"outline",onClick:()=>C("guide"),disabled:null!==p||null!=c&&c<5,title:"Generate Teacher Guide \u2014 costs 5 credits",children:["guide"===p?(0,w.jsx)(b.A,{className:"w-3 h-3 animate-spin mr-1"}):(0,w.jsx)(v.A,{className:"w-3 h-3 mr-1"}),"Guide",(0,w.jsxs)("span",{className:"ml-1.5 pl-1.5 border-l border-border text-muted-foreground font-normal text-[10px]",children:[5," cr"]})]}),!A.has("worksheet")&&(0,w.jsxs)(d.$,{size:"sm",variant:"outline",onClick:()=>C("worksheet"),disabled:null!==p||null!=c&&c<5,title:"Generate Student Worksheet \u2014 costs 5 credits",children:["worksheet"===p?(0,w.jsx)(b.A,{className:"w-3 h-3 animate-spin mr-1"}):(0,w.jsx)(v.A,{className:"w-3 h-3 mr-1"}),"Worksheet",(0,w.jsxs)("span",{className:"ml-1.5 pl-1.5 border-l border-border text-muted-foreground font-normal text-[10px]",children:[5," cr"]})]})]})]})};
1var _=t(16512),k=t(29994),A=t(91637),C=t(65469),$=t(65505),R=t(88693),S=t(40614),D=t(88306),z=t(92382),L=t(73002),T=t(70764),U=t(72308),G=t(35087),Z=t(19797),W=t(28646),B=t(22626),E=t(23165),I=t(82054),O=t(84808),P=t(71360),F=t(41680),Y=t(50516),V=t(57040),q=t(19040),J=t(97269),Q=t(37167),M=t(22751);t(75088),t(61161);t(8118),t(95258);const H=()=>{var e,s,t,v,N,H,K,X;const{unitId:ee}=(0,r.g)(),se=(0,r.Zp)(),{user:te}=(0,i.As)(),[ae,re]=(0,a.useState)(null),[ie,ne]=(0,a.useState)(!0),[le,ce]=(0,a.useState)(!1),[oe,de]=(0,a.useState)(!1),[ue,me]=(0,a.useState)(!1),[xe,he]=(0,a.useState)(!1),[pe,je]=(0,a.useState)(!1),[ve,ge]=(0,a.useState)(null),[fe,Ne]=(0,a.useState)(!1),[be,we]=(0,a.useState)(""),[ye,_e]=(0,a.useState)(null),[ke,Ae]=(0,a.useState)(null),[Ce,$e]=(0,a.useState)([]),[Re,Se]=(0,a.useState)(null),[De,ze]=(0,a.useState)(!1),[Le,Te]=(0,a.useState)(!1),[Ue,Ge]=(0,a.useState)(!1),Ze=(null===ae||void 0===ae?void 0:ae._permission)||"owner",We="owner"===Ze,Be=We||"edit"===Ze,Ee=(null===ae||void 0===ae?void 0:ae._is_shared)||!1;(0,a.useEffect)(()=>{Ie()},[ee]);const Ie=async()=>{try{var e,s;const[t,a,r]=await Promise.all([n.A.get(`${i.nC}/unit-plans/${ee}`),"admin"!==(null===te||void 0===te?void 0:te.role)?n.A.get(`${i.nC}/subscription/credits`):Promise.resolve(null),n.A.get(`${i.nC}/resources`,{params:{plan_id:ee}})]);re(t.data),a&&Ae(null!==(e=a.data.balance)&&void 0!==e?e:null),$e(null!==(s=r.data)&&void 0!==s?s:[]),ge(t.data.content||{}),we(t.data.title||"")}catch(t){o.oR.error("Failed to load unit plan"),se("/tools/lesson-planner")}finally{ne(!1)}},Oe=()=>{var e;const s=new URLSearchParams;null!==ae&&void 0!==ae&&ae.title&&s.set("title",ae.title),null===ae||void 0===ae||!ae.year_level||null!==ae&&void 0!==ae&&ae.is_composite||s.set("year_level",ae.year_level),null!==ae&&void 0!==ae&&ae.subject&&s.set("subject",ae.subject),null!==ae&&void 0!==ae&&ae.topic&&s.set("topic",ae.topic);const t=null===ae||void 0===ae||null===(e=ae.content)||void 0===e?void 0:e.curriculum_outcomes;if(Array.isArray(t)&&t.length>0){const e=t.map(e=>
1"object"===typeof e&&null!==e?e.code:e).filter(Boolean);e.length>0&&s.set("outcome_codes",e.join(","))}return s.toString()},Pe=(0,a.useCallback)((e,s)=>{ge(t=>({...t,[e]:s}))},[]),Fe=(e,s,t,a)=>{const r=[...ve.weekly_breakdown||[]],i=[...r[e].lessons||[]];i[s]={...i[s],[t]:a},r[e]={...r[e],lessons:i},Pe("weekly_breakdown",r)},Ye=(e,s)=>{const t={...ve.summative_assessment||{},[e]:s};Pe("summative_assessment",t)},Ve=async e=>{_e(e);try{const s=await n.A.post(`${i.nC}/unit-plans/${ee}/regenerate-section`,{section:e});re(s.data),ge(s.data.content||{}),o.oR.success("curriculum_outcomes"===e?"Curriculum outcomes regenerated!":"Differentiation strategies regenerated!")}catch(a){var s,t;const r=(null===(s=a.response)||void 0===s||null===(t=s.data)||void 0===t?void 0:t.detail)||`Failed to regenerate ${e}`;o.oR.error(r)}finally{_e(null)}},qe=e=>"string"===typeof e?{code:e,description:null,strand:null}:"object"===typeof e&&null!==e?{code:e.code||JSON.stringify(e),description:e.description||null,strand:e.strand||null}:{code:String(e),description:null,strand:null};if(ie)return(0,w.jsx)(j.A,{children:(0,w.jsx)("div",{className:"fixed inset-0 z-50 bg-background/95 backdrop-blur-sm flex items-center justify-center",children:(0,w.jsx)(V.A,{type:"lesson",title:"Loading your lesson plan..."})})});if(!ae)return(0,w.jsx)(j.A,{children:(0,w.jsxs)("div",{className:"text-center py-12",children:[(0,w.jsx)("h2",{className:"text-xl font-semibold text-foreground",children:"Unit plan not found"}),(0,w.jsx)(d.$,{onClick:()=>se("/tools/lesson-planner"),className:"mt-4",children:"Back to Unit Planner"})]})});const Je=xe?ve:ae.content||{},Qe=xe?be:ae.title;return(0,w.jsxs)(j.A,{children:[(0,w.jsxs)("div",{className:"max-w-4xl mx-auto","data-testid":"unit-plan-detail",children:[(0,w.jsx)(p.A,{}),Ue&&(0,w.jsx)("div",{className:"mb-4",children:(0,w.jsx)(Q.A,{feature:"lesson_plan",resourceId:ee,onClose:()=>{Ge(!1)}})}),(0,w.jsx)(M.A,{suggestions:[{label:"Create a Quiz",description:"Test students on this topic",route:`/tools/quiz?${Oe()}`},{label:"Create a Worksheet",description:"Practice questions on this topic",route:`/tools/worksheet?${Oe()}`}]}),(0,w.jsxs)("div",{className:"mb-6",children:[(0,w.jsxs)(d.$,{variant:"ghost",onClick:()=>se("/tools/lesson-planner"),className:"mb-4","data-testid":"back-btn",children:[(0,w.jsx)(C.A,{className:"w-4 h-4 mr-2"}),"Back to Unit / Lesson Planner"]}),(0,w.jsxs)("div",{className:"flex gap-2 flex-wrap mb-4",children:[Be&&!xe&&(0,w.jsxs)(d.$,{variant:"outline",size:"sm",onClick:()=>{const e={...ae.content};e.curriculum_outcomes&&(e.curriculum_outcomes=e.curriculum_outcomes.map(e=>"object"===typeof e&&null!==e&&e.code||String(e))),ge(e),we(ae.title),he(!0)},"data-testid":"edit-btn",children:[(0,w.jsx)($.A,{className:"w-4 h-4 mr-2"}),"Edit"]}),xe&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(d.$,{variant:"default",size:"sm",onClick:async()=>{je(!0);try{const e=await n.A.put(`${i.nC}/unit-plans/${ee}`,{title:be,content:ve});re(e.data),he(!1),o.oR.success("Unit plan saved successfully")}catch(e){o.oR.error("Failed to save changes")}finally{je(!1)}},disabled:pe,"data-testid":"save-btn",children:[pe?(0,w.jsx)(b.A,{className:"w-4 h-4 animate-spin mr-2"}):(0,w.jsx)(R.A,{className:"w-4 h-4 mr-2"}),"Save"]}),(0,w.jsxs)(d.$,{variant:"outline",size:"sm",onClick:()=>{ge(ae.content||{}),we(ae.title||""),he(!1)},"data-testid":"cancel-edit-btn",children:[(0,w.jsx)(S.A,{className:"w-4 h-4 mr-2"}),"Cancel"]})]}
1),We&&"schools"===(null===te||void 0===te?void 0:te.subscription_tier)&&!xe&&(0,w.jsxs)(d.$,{variant:"outline",size:"sm",onClick:()=>me(!0),"data-testid":"share-btn",children:[(0,w.jsx)(D.A,{className:"w-4 h-4 mr-2"}),"Share"]}),!xe&&(0,w.jsxs)(A.rI,{children:[(0,w.jsx)(A.ty,{asChild:!0,children:(0,w.jsxs)(d.$,{variant:"outline",size:"sm",disabled:oe,children:[oe?(0,w.jsx)(b.A,{className:"w-4 h-4 animate-spin mr-2"}):(0,w.jsx)(g.A,{className:"w-4 h-4 mr-2"}),"Export",(0,w.jsx)(z.A,{className:"w-4 h-4 ml-2 opacity-50"})]})}),(0,w.jsxs)(A.SQ,{align:"start",children:[(0,w.jsxs)(A._2,{onClick:()=>(async e=>{de(!0);try{const s=await n.A.get(`${i.nC}/unit-plans/${ee}/export?format=${e}`,{responseType:"blob"}),t=s.data,a=window.URL.createObjectURL(t),r=document.createElement("a");r.href=a;const c=s.headers["content-disposition"];let d="Unit_Plan."+("docx"===e?"docx":"pdf");c&&c.includes("filename=")&&(d=c.split("filename=")[1].replace(/"/g,"")),r.setAttribute("download",d),document.body.appendChild(r),r.click(),setTimeout(()=>{r.remove(),window.URL.revokeObjectURL(a)},100),o.oR.success(`Downloaded ${d}`),(0,l.h)(ee)&&((0,l.g)(ee),Ge(!0))}catch(s){o.oR.error("Failed to export file. Please try again.")}finally{de(!1)}})("docx"),children:[(0,w.jsx)(L.A,{className:"w-4 h-4 mr-2"}),"Export Word / Google Docs"]}),(0,w.jsxs)(A._2,{onClick:async()=>{if(De)return;let e=Re;if(null===e)try{e=(await n.A.get(`${i.nC}/google-drive/status`)).data.connected,Se(e)}catch{return void o.oR.error("Could not check Google Drive connection. Please try again.")}if(!e)return void Te(!0);ze(!0);let s=!1;try{const e=await n.A.post(`${i.nC}/unit-plans/${ee}/export/google-drive`,{},{timeout:12e4});window.open(e.data.url,"_blank","noopener,noreferrer"),o.oR.success("Unit plan exported to Google Drive!"),(0,l.h)(ee)&&((0,l.g)(ee),Ge(!0))}catch(r){var t,a;const e=(null===(t=r.response)||void 0===t||null===(a=t.data)||void 0===a?void 0:a.detail)||"Failed to export to Google Drive. Please try again.";if(s=e.toLowerCase().includes("token expired")||e.toLowerCase().includes("reconnect")||e.toLowerCase().includes("access denied")||e.toLowerCase().includes("revoked"),s){try{await n.A.delete(`${i.nC}/google-drive/disconnect`)}catch(c){}Se(!1),o.oR.error("Your Google Drive connection needs to be re-authorised. Please reconnect below.")}else o.oR.error(e)}finally{ze(!1),s&&Te(!0)}},disabled:De,children:[De?(0,w.jsx)(b.A,{className:"w-4 h-4 mr-2 animate-spin"}):(0,w.jsx)(T.A,{className:"w-4 h-4 mr-2"}),"Save to Google Drive"]})]})]}),!xe&&"free"!==(null===te||void 0===te?void 0:te.subscription_tier)&&(0,w.jsxs)(d.$,{variant:"outline",size:"sm",onClick:()=>{se(`/tools/slideshow?${Oe()}`)},"data-testid":"create-slideshow-btn",className:"bg-primary/10 hover:bg-primary/20 border-primary/30",children:[(0,w.jsx)(U.A,{className:"w-4 h-4 mr-2"}),"Create Slideshow"]}),We&&!xe&&(0,w.jsxs)(d.$,{variant:"destructive",size:"sm",onClick:async()=>{if(window.confirm("Are you sure you want to delete this unit plan?")){ce(!0);try{await n.A.delete(`${i.nC}/unit-plans/${ee}`),o.oR.success("Unit plan deleted"),se("/tools/lesson-planner")}catch(e){o.oR.error("Failed to delete unit plan"),ce(!1)}}},disabled:le,"data-testid":"delete-btn",children:[le?(0,w.jsx)(b.A,{className:"w-4 h-4 animate-spin"}):(0,w.jsx)(f.A,{className:"w-4 h-4 mr-2"}),"Delete"]}),!Be&&(0,w.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground",children:[(0,w.jsx)(G.A,{className:"w-4 h-4"}),(0,w.jsx)("span",{className:"text-sm",children:"View Only"})]})]}),(0,w.jsxs)("div",{children:[xe?(0,w.jsx)(x.p,{value:be,onChange:e=>we(e.target.value),className:"text-2xl font-bold mb-2","data-testid":"edit-title-input"}):(0,w.jsx)("h1",{className:"text-2xl sm:text-3xl font-bold text-foreground",children:Qe}),(0,w.jsxs)("div",{className:"flex flex-wrap items-center gap-2 mt-2",children:[Ee&&(0,w.jsx)(q.Dq,{permission:Ze,sharedBy:ae._shared_by}),(0,w.jsxs)(m.E,{variant:"secondary",children:[(0,w.jsx)(Z.A,{className:"w-3 h-3 mr-1"}),"Year ",ae.year_level]}),(0,w.jsx)(m.E,{variant:"outline",children:ae.subject}),(0,w.jsxs)(m.E,{variant:"outline",children:[(0,w.jsx)(W.A,{className:"w-3 h-3 mr-1"}),ae.duration_weeks," weeks"]}),ae.state&&(0,w.jsx)(m.E,{variant:"default",className:"bg-primary",children:ae.state}),(0,w.jsx)(q.QE,{resourceType:"unit_plan",resourceId:ee})]})]})]}),(0,w.jsxs)("div",{className:"space-y-6",children:[(0,w.jsxs)(u.Zp,{className:"border-border/50","data-testid":"overview-card",children:[(0,w.jsx)(u.aR,{children:(0,w.jsxs)(u.ZB,{className:"flex items-center gap-2",children:[(0,w.jsx)(B.A,{className:"w-5 h-5 text-primary"}),"Overview"]})}),(0,w.jsx)(u.Wu,{children:xe?(0,w.jsx)(h.T,{value:Je.overview||"",onChange:e=>Pe("overview",e.target.value),rows:4,className:"w-full",placeholder:"Unit overview...","data-testid":"edit-overview"}):(0,w.jsx)("p",{className:"text-foreground",children:Je.overview||"No overview provided."})})]}),(0,w.jsxs)(u.Zp,{className:"border-border/50 bg-primary/5","data-testid":"learning-intention-card",children:[(0,w.jsx)(u.aR,{children:(0,w.jsxs)(u.ZB,{className:"flex items-center gap-2",children:[(0,w.jsx)(E.A,{className:"w-5 h-5 text-primary"}),"Learning Intention"]})}),(0,w.jsx)(u.Wu,{children:xe?(0,w.jsx)(h.T,{value:Je.learning_intention||"",onChange:e=>Pe("learning_intention",e.target.value),rows:2,className:"w-full",placeholder:"We are learning to...","data-testid":"edit-learning-intention"}):(0,w.jsx)("p",{className:"text-lg font-medium text-foreground",children:Je.learning_intention||"No learning intention provided."})})]}),(0,w.jsxs)(u.Zp,{className:"border-border/50 bg-secondary/5","data-testid":"success-criteria-card",children:[(0,w.jsx)(u.aR,{children:(0,w.jsxs)(u.ZB,{className:"flex items-center gap-2",children:[(0,w.jsx)(I.A,{className:"w-5 h-5 text-secondary"}),"Success Criteria"]})}),(0,w.jsx)(u.Wu,{children:xe?(0,w.jsxs)("div",{className:"space-y-2",children:[(Je.success_criteria||[]).map((e,s)=>(0,w.jsxs)("div",{className:"flex items-center gap-2",children:[(0,w.jsx)(x.p,{value:e,onCh
1ange:e=>((e,s)=>{const t=[...ve.success_criteria||[]];t[e]=s,Pe("success_criteria",t)})(s,e.target.value),className:"flex-1",placeholder:"I can..."}),(0,w.jsx)(d.$,{variant:"ghost",size:"sm",onClick:()=>(e=>{const s=[...ve.success_criteria||[]];s.splice(e,1),Pe("success_criteria",s)})(s),className:"text-destructive hover:text-destructive",children:(0,w.jsx)(O.A,{className:"w-4 h-4"})})]},`sce-${s}`)),(0,w.jsxs)(d.$,{variant:"outline",size:"sm",onClick:()=>{const e=[...ve.success_criteria||[],"I can..."];Pe("success_criteria",e)},className:"mt-2",children:[(0,w.jsx)(P.A,{className:"w-4 h-4 mr-2"}),"Add Success Criteria"]})]}):(0,w.jsxs)("ul",{className:"space-y-2",children:[(Je.success_criteria||[]).map((e,s)=>(0,w.jsxs)("li",{className:"flex items-start gap-3",children:[(0,w.jsx)(I.A,{className:"w-5 h-5 text-secondary flex-shrink-0 mt-0.5"}),(0,w.jsx)("span",{children:e})]},`sc-${s}`)),(!Je.success_criteria||0===Je.success_criteria.length)&&(0,w.jsx)("p",{className:"text-muted-foreground",children:"No success criteria defined."})]})})]}),(0,w.jsxs)(u.Zp,{className:"border-border/50","data-testid":"curriculum-card",children:[(0,w.jsx)(u.aR,{children:(0,w.jsxs)(u.ZB,{className:"flex items-center gap-2",children:[(0,w.jsx)(F.A,{className:"w-5 h-5 text-accent"}),"Curriculum Outcomes"]})}),(0,w.jsx)(u.Wu,{children:xe?(0,w.jsxs)("div",{className:"space-y-2",children:[(0,w.jsx)("div",{className:"flex flex-wrap gap-2",children:(Je.curriculum_outcomes||[]).map((e,s)=>(0,w.jsxs)("div",{className:"flex items-center gap-1",children:[(0,w.jsx)(x.p,{value:e,onChange:e=>((e,s)=>{const t=[...ve.curriculum_outcomes||[]];t[e]=s,Pe("curriculum_outcomes",t)})(s,e.target.value),className:"w-32 font-mono text-sm",placeholder:"Code"}),(0,w.jsx)(d.$,{variant:"ghost",size:"sm",onClick:()=>(e=>{const s=[...ve.curriculum_outcomes||[]];s.splice(e,1),Pe("curriculum_outcomes",s)})(s),className:"text-destructive hover:text-destructive p-1",children:(0,w.jsx)(S.A,{className:"w-4 h-4"})})]},`coe-${s}`))}),(0,w.jsxs)(d.$,{variant:"outline",size:"sm",onClick:()=>{const e=[...ve.curriculum_outcomes||[],""];Pe("curriculum_outcomes",e)},className:"mt-2",children:[(0,w.jsx)(P.A,{className:"w-4 h-4 mr-2"}),"Add Code"]})]}):(0,w.jsx)("div",{children:(Je.curriculum_outcomes||[]).length>0?Je.curriculum_outcomes.some(e=>"object"===typeof e&&null!==e&&e.description)?(0,w.jsx)("div",{className:"space-y-3",children:Je.curriculum_outcomes.map((e,s)=>{const{code:t,description:a,strand:r}=qe(e);return(0,w.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-muted/30 rounded-lg",children:[(0,w.jsx)(m.E,{variant:"outline",className:"font-mono shrink-0 mt-0.5",children:t}),(0,w.jsxs)("div",{children:[a&&(0,w.jsx)("p",{className:"text-sm text-foreground",children:a}),r&&(0,w.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:r})]})]},`co-${t}`)})}):(0,w.jsx)("div",{className:"flex flex-wrap gap-2",children:Je.curriculum_outcomes.map((e,s)=>{const{code:t}=qe(e);return(0,w.jsx)(m.E,{variant:"outline",className:"font-mono",children:t},`cob-${t}`)})}):(0,w.jsxs)("div",{className:"text-center py-4",children:[(0,w.jsx)("p",{className:"text-muted-foreground mb-3",children:"No curriculum outcomes defined."}),Be&&(0,w.jsx)(d.$,{variant:"outline",size:"sm",onClick:()=>Ve("curriculum_outcomes"),disabled:"curriculum_outcomes"===ye,"data-testid":"regenerate-curriculum-btn",children:"curriculum_outcomes"===ye?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(b.A,{className:"w-4 h-4 animate-spin mr-2"}),"Regenerating..."]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(Y.A,{className:"w-4 h-4 mr-2"}),"Regenerate Curriculum Outcomes"]})})]})})})]}),Je.weekly_breakdown&&Je.weekly_breakdown.length>0&&(0,w.jsxs)(u.Zp,{className:"border-border/50","data-testid":"weekly-breakdown-card",children:[(0,w.jsx)(u.aR,{children:(0,w.jsxs)(u.ZB,{className:"flex items-center gap-2",children:[(0,w.jsx)(W.A,{className:"w-5 h-5 text-primary"}),"Weekly Breakdown"]})}),(0,w.jsx)(u.Wu,{children:(0,w.jsx)("div",{className:"space-y-6",children:Je.weekly_breakdown.map((e,s)=>{var t;return(0,w.jsxs)("div",{className:"border-l-4 border-primary/30 pl-4",children:[(0,w.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,w.jsxs)("span",{className:"text-lg font-semibold text-foreground",children:["Week ",e.week_number,":"]}
1),xe?(0,w.jsx)(x.p,{value:e.focus||"",onChange:e=>((e,s)=>{const t=[...ve.weekly_breakdown||[]];t[e]={...t[e],focus:s},Pe("weekly_breakdown",t)})(s,e.target.value),className:"flex-1",placeholder:"Week focus..."}):(0,w.jsx)("span",{className:"text-lg font-semibold text-foreground",children:e.focus})]}),(0,w.jsx)("div",{className:"space-y-4 mt-4",children:null===(t=e.lessons)||void 0===t?void 0:t.map((t,a)=>(0,w.jsxs)("div",{className:"bg-muted/50 rounded-lg p-4",children:[(0,w.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,w.jsxs)("span",{className:"font-medium text-foreground",children:["\ud83d\udcd6 Lesson ",t.lesson_number,":"]}),xe?(0,w.jsx)(x.p,{value:t.title||"",onChange:e=>Fe(s,a,"title",e.target.value),className:"flex-1",placeholder:"Lesson title..."}):(0,w.jsx)("span",{className:"font-medium text-foreground",children:t.title})]}),(0,w.jsxs)("div",{className:"mb-2",children:[(0,w.jsx)("span",{className:"text-xs font-medium text-primary",children:"Learning Intention:"}),xe?(0,w.jsx)(h.T,{value:t.learning_intention||"",onChange:e=>Fe(s,a,"learning_intention",e.target.value),rows:2,className:"w-full mt-1",placeholder:"Learning intention..."}):(0,w.jsx)("p",{className:"text-sm text-foreground",children:t.learning_intention||"Not specified"})]}),(0,w.jsxs)("div",{className:"mb-2",children:[(0,w.jsx)("span",{className:"text-xs font-medium text-secondary",children:"Success Criteria:"}),xe?(0,w.jsxs)("div",{className:"space-y-1 mt-1",children:[(t.success_criteria||[]).map((e,t)=>(0,w.jsxs)("div",{className:"flex items-center gap-2",children:[(0,w.jsx)(x.p,{value:e,onChange:e=>((e,s,t,a)=>{const r=[...ve.weekly_breakdown||[]],i=[...r[e].lessons||[]],n=[...i[s].success_criteria||[]];n[t]=a,i[s]={...i[s],success_criteria:n},r[e]={...r[e],lessons:i},Pe("weekly_breakdown",r)})(s,a,t,e.target.value),className:"flex-1 text-sm",placeholder:"I can..."}),(0,w.jsx)(d.$,{variant:"ghost",size:"sm",onClick:()=>((e,s,t)=>{const a=[...ve.weekly_breakdown||[]],r=[...a[e].lessons||[]],i=[...r[s].success_criteria||[]];i.splice(t,1),r[s]={...r[s],success_criteria:i},a[e]={...a[e],lessons:r},Pe("weekly_breakdown",a)})(s,a,t),className:"text-destructive hover:text-destructive p-1",children:(0,w.jsx)(S.A,{className:"w-3 h-3"})})]},t)),(0,w.jsxs)(d.$,{variant:"ghost",size:"sm",onClick:()=>((e,s)=>{const t=[...ve.weekly_breakdown||[]],a=[...t[e].lessons||[]],r=[...a[s].success_criteria||[],"I can..."];a[s]={...a[s],success_criteria:r},t[e]={...t[e],lessons:a},Pe("weekly_breakdown",t)})(s,a),className:"text-xs",children:[(0,w.jsx)(P.A,{className:"w-3 h-3 mr-1"}),"Add"]})]}):(0,w.jsx)("ul",{className:"text-sm text-foreground ml-4",children:(t.success_criteria||[]).map((e,s)=>(0,w.jsx)("li",{className:"list-disc",children:e},s))})]}),t.activities&&!xe&&(0,w.jsxs)("div",{className:"mb-2",children:[(0,w.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:"Activities:"}),(0,w.jsx)("div",{className:"ml-2",children:(Array.isArray(t.activities)?t.activities:[t.activities]).map((e,s)=>{const t="string"===typeof e?e:e.description||e.name||JSON.stringify(e);return(0,w.jsx)("div",{className:"mb-2 p-2 border border-border/50 rounded bg-background/50",children:(0,w.jsx)("p",{className:"text-sm text-foreground",children:t})},s)})}),(0,w.jsx)(y,{unitId:ee,lesson:t,weekNumber:e.week_number,activity:(Array.isArray(t.activities)?t.activities:[t.activities]).map(e=>"string"===typeof e?e:e.description||e.name||JSON.stringify(e)).join(" "),creditsBalance:"admin"!==(null===te||void 0===te?void 0:te.role)?ke:null,onTopUpCredits:()=>Ne(!0),existingResources:Ce.filter(e=>{var s;return(null===(s=e.meta)||void 0===s?void 0:s.lesson)===`Lesson ${t.lesson_number}: ${t.title}`}),onResourceGenerated:e=>{o.oR.success(`Generated: ${e.filename}`),$e(s=>[e,...s]),null!=e.credits_remaining?Ae(e.credits_remaining):Ae(e=>null!=e?Math.max(0,e-5):null)},onResourceDeleted:e=>{$e(s=>s.filter(s=>s.resource_id!==e))}})]}),t.year_adjustments&&Object.keys(t.year_adjustments).length>0&&!xe&&(0,w.jsxs)("div",{className:"mb-2","data-testid":"lesson-year-adjustments",children:[(0,w.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:"Year-Level Adjustments:"}),(0,w.jsx)("div",{className:"grid gap-2 md:grid-cols-2 mt-1",children:Object.entries(t.year_adju
1stments).map(e=>{let[s,t]=e;return(0,w.jsxs)("div",{className:"p-2 border border-border/50 rounded bg-accent/20",children:[(0,w.jsxs)(m.E,{variant:"outline",className:"text-xs mb-1",children:["Year ",s]}),((null===t||void 0===t?void 0:t.success_criteria)||[]).length>0&&(0,w.jsx)("ul",{className:"text-xs text-foreground ml-4 mb-1",children:t.success_criteria.map((e,s)=>(0,w.jsx)("li",{className:"list-disc",children:e},`ya-sc-${s}`))}),((null===t||void 0===t?void 0:t.activities)||[]).length>0&&(0,w.jsx)("ul",{className:"text-xs text-muted-foreground ml-4",children:t.activities.map((e,s)=>(0,w.jsx)("li",{className:"list-disc",children:"string"===typeof e?e:e.description||e.name||JSON.stringify(e)},`ya-act-${s}`))})]},`ya-${s}`)})})]}),t.resources&&!xe&&(0,w.jsxs)("div",{className:"mb-2",children:[(0,w.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:"Resources:"}),(0,w.jsx)("p",{className:"text-sm text-foreground",children:Array.isArray(t.resources)?t.resources.join(", "):t.resources})]})]},a))})]},s)})})})]}),(0,w.jsxs)(u.Zp,{className:"border-border/50","data-testid":"assessment-card",children:[(0,w.jsx)(u.aR,{children:(0,w.jsxs)(u.ZB,{className:"flex items-center gap-2",children:[(0,w.jsx)(F.A,{className:"w-5 h-5 text-secondary"}),"Summative Assessment"]})}),(0,w.jsx)(u.Wu,{children:(0,w.jsxs)("div",{className:"space-y-4",children:[(0,w.jsxs)("div",{children:[(0,w.jsx)("h4",{className:"font-medium text-foreground mb-2",children:"Description"}),xe?(0,w.jsx)(h.T,{value:(null===(e=Je.summative_assessment)||void 0===e?void 0:e.description)||"",onChange:e=>Ye("description",e.target.value),rows:3,className:"w-full",placeholder:"Assessment description..."}):(0,w.jsx)("p",{className:"text-foreground",children:(null===(s=Je.summative_assessment)||void 0===s?void 0:s.description)||"No description provided."})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("h4",{className:"font-medium text-foreground mb-2",children:"Criteria"}),xe?(0,w.jsx)(h.T,{value:Array.isArray(null===(t=Je.summative_assessment)||void 0===t?void 0:t.criteria)?Je.summative_assessment.criteria.join("\n"):(null===(v=Je.summative_assessment)||void 0===v?void 0:v.criteria)||"",onChange:e=>Ye("criteria",e.target.value.split("\n").filter(e=>e.trim())),rows:3,className:"w-full",placeholder:"Assessment criteria (one per line)..."}):(0,w.jsx)("p",{className:"text-foreground",children:Array.isArray(null===(N=Je.summative_assessment)||void 0===N?void 0:N.criteria)?Je.summative_assessment.criteria.join(", "):(null===(H=Je.summative_assessment)||void 0===H?void 0:H.criteria)||"No criteria defined."})]})]})})]}),(0,w.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-6",children:[((null===(K=Je.cross_curricular_priorities)||void 0===K?void 0:K.length)>0||xe)&&(0,w.jsxs)(u.Zp,{className:"border-border/50",children:[(0,w.jsx)(u.aR,{children:(0,w.jsx)(u.ZB,{className:"text-base",children:"Cross-Curricular Priorities"})}),(0,w.jsx)(u.Wu,{children:(0,w.jsx)("div",{className:"flex flex-wrap gap-2",children:(Je.cross_curricular_priorities||[]).filter(e=>"string"===typeof e).map((e,s)=>(0,w.jsx)(m.E,{variant:"outline",children:e},`ccp-${e}`))})})]}),((null===(X=Je.general_capabilities)||void 0===X?void 0:X.length)>0||xe)&&(0,w.jsxs)(u.Zp,{className:"border-border/50",children:[(0,w.jsx)(u.aR,{children:(0,w.jsx)(u.ZB,{className:"text-base",children:"General Capabilities"})}),(0,w.jsx)(u.Wu,{children:(0,w.jsx)("div",{className:"flex flex-wrap gap-2",children:(Je.general_capabilities||[]).filter(e=>"string"===typeof e).map((e,s)=>(0,w.jsx)(m.E,{variant:"outline",children:e},`gc-${e}`))})})]})]}),(0,w.jsx)(J.i,{content:{differentiation:null===Je||void 0===Je?void 0:Je.differentiation},onRegenerate:Be?Ve:void 0,regenerating:"differentiation"===ye}),(0,w.jsxs)(u.Zp,{className:"border-border/50","data-testid":"youtube-videos-card",children:[(0,w.jsx)(u.aR,{children:(0,w.jsxs)("div",{className:"flex items-center justify-between",children:[(0,w.jsxs)(u.ZB,{className:"flex items-center gap-2",children:[(0,w.jsx)("span",{className:"text-red-500",children:"\u25b6"}),"Video Resources"]}),Be&&(0,w.jsx)(_.A,{planType:"unit_plan",planId:ee,onSelectVideo:()=>Ie(),buttonText:"Add Video",buttonSize:"sm"})]})}),(0,w.jsx)(u.Wu,{children:null!==ae&&void 0!==ae&&ae.videos&&ae.videos.length>0?(0,w.jsx)(k.A,{videos:ae.videos,planType:"unit_plan",planId:ee,onVideoRemoved:()=>Ie(),editable:Be}):(0,w.jsx)("p",{className:"text-muted-foreground italic text-center py-4",children:"No videos attached yet. Add YouTube videos to enrich your unit plan."})})]})]})]}),(0,w.jsx)(q.Zy,{isOpen:ue,onClose:()=>me(!1),resourceType:"unit_plan",resourceId:ee,resourceTitle:null===ae||void 0===ae?void 0:ae.title}),(0,w.jsx)(c.A,{isOpen:fe,onClose:()=>Ne(!1),onPurchaseComplete:()=>Ne(!1)}),Le&&(0,w.jsx)("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:(0,w.jsxs)("div",{className:"bg-white rounded-lg shadow-xl max-w-md w-full p-6",children:[(0,w.jsxs)("div",{className:"flex items-start justify-between mb-4",children:[(0,w.jsx)("h2",{className:"text-lg font-semibold",children:"Connect Google Drive"}),(0,w.jsx)("button",{onClick:()=>Te(!1),className:"text-gray-400 hover:text-gray-600",children:(0,w.jsx)(S.A,{className:"h-5 w-5"})})]}),(0,w.jsx)("p",{className:"text-sm text-gray-600 mb-4",children:"Connect your Google Drive to export this unit plan directly as a native Google Doc."}),(0,w.jsxs)("div",{className:"text-sm text-gray-600 mb-5 space-y-3",children:[(0,w.jsxs)("div",{children:[(0,w.jsx)("p",{className:"font-medium text-gray-800 mb
1-1",children:"What this does:"}),(0,w.jsxs)("ul",{className:"list-disc list-inside space-y-0.5",children:[(0,w.jsx)("li",{children:"Creates a new Google Doc in your Drive"}),(0,w.jsx)("li",{children:"Opens it directly in Google Docs in a new tab"})]})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("p",{className:"font-medium text-gray-800 mb-1",children:"What this does not do:"}),(0,w.jsxs)("ul",{className:"list-disc list-inside space-y-0.5",children:[(0,w.jsx)("li",{children:"Read or access your existing Drive files"}),(0,w.jsx)("li",{children:"Modify previously exported documents"}),(0,w.jsx)("li",{children:"Delete or manage files in your Drive"})]})]})]}),(0,w.jsxs)("div",{className:"flex gap-3",children:[(0,w.jsx)(d.$,{variant:"outline",className:"flex-1",onClick:()=>Te(!1),children:"Cancel"}),(0,w.jsxs)(d.$,{className:"flex-1",onClick:async()=>{Te(!1);try{const e=encodeURIComponent(`/tools/lesson-plan/${ee}`),s=await n.A.get(`${i.nC}/google-drive/auth/start?return_to=${e}`);window.location.href=s.data.authorization_url}catch{o.oR.error("Could not start Google Drive connection. Please try again.")}},children:[(0,w.jsx)(T.A,{className:"h-4 w-4 mr-2"}),"Connect Google Drive"]})]})]})})]})}}}]); 2//# sourceMappingURL=5178.a6bf8ffc.chunk.js.map
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.