1import{r as u,j as e}from"./framework-DSMy1d1o.js";import{R as ce,I as b,p as _,g as $,w as ie}from"./index-B5ibDl7T.js";import{M as J,X as Se,Z as ke,_ as De,Y as de}from"./emailConfiguration-BfFBnkQF.js";import"./firebase-G6kAZrpJ.js";import"./vendor-Co-R6l_k.js";import"./editor-5AjVNlXF.js";const Me=x=>x.startsWith("image/")?"image":x.startsWith("video/")?"video":x.startsWith("audio/")?"music":x==="application/pdf"?"fileText":"file",ze=({userData:x,terminology:G,policyOnly:M=!1})=>{const[T,V]=u.useState([]),[A,F]=u.useState([]),[j,N]=u.useState([]),[w,O]=u.useState([]),[q,E]=u.useState(!0),[B,h]=u.useState(0),[K,L]=u.useState(M?"policy":"all"),[W,P]=u.useState(!1),[t,l]=u.useState(null),[o,c]=u.useState(new Set),[i,z]=u.useState(!1),[I,U]=u.useState(!1),[Q,ue]=u.useState(null),[v,R]=u.useState(null),[me,X]=u.useState(null),ee=x.role===ce.ACCOUNT_ADMIN||x.role===ce.SUPER_ADMIN,g=M?"policy":K,se=u.useMemo(()=>g==="policy"?new Set(["policy"]):new Set(["global","membership_group","course"]),[g]);u.useEffect(()=>{M&&L("policy")},[M]),u.useEffect(()=>{(async()=>{E(!0);try{const[r,a,p,m,n]=await Promise.all([$("resources","coachingAccountId",x.coachingAccountId),$("resource_categories","coachingAccountId",x.coachingAccountId),$("member_groups","coachingAccountId",x.coachingAccountId),$("chapters","coachingAccountId",x.coachingAccountId).catch(()=>[]),$("courses","coachingAccountId",x.coachingAccountId)]);V(r.sort((d,y)=>d.order-y.order)),F(a.sort((d,y)=>d.order-y.order)),N(Se(p,m)),O(n)}catch(r){console.error("Error fetching resources:",r)}finally{E(!1)}})()},[x.coachingAccountId,B]);const S=u.useMemo(()=>A.filter(s=>{const r=String(s.scopeType||"global");return g==="policy"?r==="policy":r!=="policy"}),[A,g]),te=u.useMemo(()=>new Set(S.map(s=>String(s.id))),[S]),Y=u.useMemo(()=>T.filter(s=>!(s.categoryId&&!te.has(String(s.categoryId)))),[T,te]),pe=u.useMemo(()=>{const s={uncategorized:[]};return S.forEach(r=>s[r.id]=[]),Y.forEach(r=>{const a=r.categoryId||"uncategorized";s[a]?s[a].push(r):s.uncategorized.push(r)}),Object.keys(s).forEach(r=>{s[r].sort((a,p)=>a.order-p.order)}),s},[Y,S]),Z=(s=null)=>{l(s||{}),c(new Set((s==null?void 0:s.accessGroupIds)||[])),P(!0)},xe=s=>{ue(s),c(new Set(s.accessGroupIds||[])),U(!0)},[ae,re]=u.useState(!1),he=async s=>{s.preventDefault();const r=new FormData(s.currentTarget),a=r.get("fileContent"),p=r.get("name"),m=r.get("description"),n=r.get("categoryId"),d=r.get("resourceType"),y=r.get("externalUrl"),f=r.get("isActive")==="true";if(!p)return alert("Resource name is required.");if(d==="file"&&!(t!=null&&t.id)&&(!a||a.size===0))return alert("A file is required for new file resources.");if(d==="external_url"&&!y)return alert("A URL is required for external link resources.");re(!0);try{let k=(t==null?void 0:t.fileContent)||"",C=(t==null?void 0:t.fileName)||"",D=(t==null?void 0:t.fileType)||"";if(d==="file"&&a&&a.size>0){const H=ke(x.coachingAccountId,"resources",a.name);k=await De(a,H),C=a.name,D=a.type}const Ie={id:(t==null?void 0:t.id)||`res_${Date.now()}`,coachingAccountId:x.coachingAccountId,name:p,description:m,resourceType:d,fileName:d==="file"?C:void 0,fileType:d==="file"?D:void 0,fileContent:d==="file"?k:void 0,externalUrl:d==="external_url"?y:void 0,isActive:f,createdAt:(t==null?void 0:t.createdAt)||new Date,categoryId:n==="uncategorized"?void 0:n,order:(t==null?void 0:t.order)??T.length,accessGroupIds:de(Array.from(o),j)};await _("resources",Ie),h(H=>H+1),P(!1)}catch(k){console.error("Error saving resource:",k),alert("Failed to save resource.")}finally{re(!1)}},ge=async s=>{if(s.preventDefault(),!!Q)try{const r={...Q,accessGroupIds:de(Array.from(o),j)};await _("resources",r),h(a=>a+1),U(!1)}catch(r){console.error("Error saving resource access:",r),alert("Failed to save resource access.")}},be=async s=>{window.confirm("Are you sure you want to delete this file?")&&(await ie("resources",s),h(r=>r+1))},ye=s=>{if(s.resourceType==="external_url"&&s.externalUrl){window.open(s.externalUrl,"_blank","noopener,noreferrer");return}if(!s.fileContent)return;const r=document.createElement("a");r.href=s.fileContent,r.target="_blank",r.rel="noopener noreferrer",r.download=s.fileName||"download",document.body.appendChild(r),r.click(),document.body.removeChild(r)},fe=async s=>{const a=A.filter(n=>se.has(n.scopeType||"global")).filter(n=>!s.some(d=>d.id===n.id)),p=T.filter(n=>n.categoryId&&a.some(d=>d.id===n.categoryId));for(const n of p)await _("resources",{...n,categoryId:void 0});for(const n of a)await ie("resource_categories",n.id);
1for(const n of s)await _("resource_categories",n);const m=A.filter(n=>!se.has(n.scopeType||"global"));F([...m,...s].sort((n,d)=>n.order-d.order)),h(n=>n+1),z(!1)},le=s=>{const r=j.find(m=>m.id===s||m.aliasIds.includes(s)),a=(r==null?void 0:r.aliasIds)||[s],p=new Set(o);a.some(m=>p.has(m))?a.forEach(m=>p.delete(m)):p.add(s),c(p)},oe=(s,r,a)=>{R({id:r,type:a}),s.dataTransfer.effectAllowed="move"},ve=(s,r)=>{s.preventDefault(),(v==null?void 0:v.type)==="resource"&&X(r)},ne=async(s,r,a,p)=>{if(s.preventDefault(),!v)return;let m=[...T],n=[...A];if(v.type==="resource"&&r){const d=m.findIndex(C=>C.id===v.id);if(d===-1)return;const[y]=m.splice(d,1);let f=p;if(a==="category"?f=r==="uncategorized"?void 0:r:a==="resource"&&p!==void 0?f=p:a==="resource"&&p===void 0&&(f=void 0),y.categoryId=f,a==="resource"){const C=m.findIndex(D=>D.id===r);m.splice(C,0,y)}else m.push(y);const k=m.map((C,D)=>_("resources",{...C,order:D}));await Promise.all(k)}else if(v.type==="category"&&a==="category"&&r){const d=n.findIndex(f=>f.id===v.id),y=n.findIndex(f=>f.id===r);if(d>-1&&y>-1){const[f]=n.splice(d,1);n.splice(y,0,f);const k=n.map((C,D)=>_("resource_categories",{...C,order:D}));await Promise.all(k)}}R(null),X(null),h(d=>d+1)};if(q)return e.jsx("div",{className:"p-8",children:"Loading resources..."});const je=[...S,{id:"uncategorized",name:"Uncategorized",order:999,coachingAccountId:""}],Ne=g==="policy"?"Policy Documents":"Resource Library",we=g==="policy"?"Admin-only policy documents for academic governance, review, and compliance. Admins can view, open, and download these documents, and the starter categories cover Academic Board, Assessment, Enrolment, Quality Assurance, Appeals and Complaints, and Teaching and Learning.":"Manage shared files, links, and category organization for your coaching account.",Ce=g==="policy"&&S.length===0&&Y.length===0,Ae=g==="policy"&&g==="policy"?"View / Download":"";return e.jsxs("div",{className:"p-8 space-y-6",children:[e.jsxs("div",{className:"flex flex-wrap justify-between items-start gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h1",{className:"text-3xl font-bold text-gray-800",children:Ne}),e.jsx("p",{className:"text-sm text-gray-600 max-w-2xl",children:we})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[!M&&ee&&e.jsxs("div",{className:"flex items-center rounded-xl border border-gray-200 bg-white p-1",children:[e.jsx("button",{type:"button",onClick:()=>L("all"),className:`rounded-lg px-3 py-2 text-sm font-bold transition-all ${g==="all"?"bg-blue-600 text-white shadow-sm":"text-gray-500 hover:text-gray-800"}`,children:"Library"}),e.jsx("button",{type:"button",onClick:()=>L("policy"),className:`rounded-lg px-3 py-2 text-sm font-bold transition-all ${g==="policy"?"bg-blue-600 text-white shadow-sm":"text-gray-500 hover:text-gray-800"}`,children:"Policy documents"})]}),e.jsxs("button",{onClick:()=>z(!0),className:"flex items-center gap-2 px-3 py-1.5 bg-gray-600 text-white font-semibold rounded-md hover:bg-gray-700 text-sm",children:[e.jsx(b,{name:"settings",className:"w-4 h-4"})," ",g==="policy"?"Manage Policy Categories":"Manage Categories"]}),e.jsxs("button",{onClick:()=>Z(),className:"flex items-center gap-2 px-4 py-2 bg-blue-600 text-white font-semibold rounded-md hover:bg-blue-700",children:[e.jsx(b,{name:"add",className:"w-5 h-5"})," ",g==="policy"?"Add Policy Document":"Add Resource"]})]})]}),e.jsxs("div",{className:"space-y-6",children:[Ce&&e.jsx("div",{className:"rounded-3xl border border-dashed border-slate-300 bg-white p-6 shadow-sm",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h2",{className:"text-lg font-black text-slate-900",children:"No policy documents yet"}),e.jsx("p",{className:"max-w-3xl text-sm text-slate-600",children:"Use the starter categories to organise approved policies, procedures, and governance documents. Add a policy document to begin building the policy register."})]}),e.jsxs("button",{onClick:()=>Z(),className:"flex items-center gap-2 rounded-2xl bg-blue-600 px-4 py-2.5 text-sm font-bold text-white hover:bg-blue-700",children:[e.jsx(b,{name:"add",className:"w-4 h-4"}),"Add Policy Document"]})]})}),je.map(s=>{const r=pe[s.id]||[];return s.id==="uncategorized"&&r.length===0&&S.length>0?null:e.jsxs("div",{onDragOver:a=>ve(a,s.id),onDrop:a=>ne(a,s.id,"category"),onDragLeave:()=>X(null),className:`p-4 rounded-lg transition-colors border-2 ${me===s.id?"bg-blue-50 border-blue-300":"bg-gray-50 border-transparent"}`,children:[e.jsxs("div",{draggable:s.id!=="uncategorized",onDragStart:a=>oe(a,s.id,"category"),className:`flex items-center gap-2 mb-4 ${s.id!=="uncategorized"?"curs
1or-move":""}`,children:[s.id!=="uncategorized"&&e.jsx(b,{name:"gripVertical",className:"text-gray-400"}),e.jsx("h2",{className:"text-xl font-semibold text-gray-700",children:s.name}),e.jsxs("span",{className:"text-gray-400 font-medium",children:["(",r.length,")"]})]}),e.jsxs("div",{className:"space-y-2",children:[r.map(a=>{const p=a.accessGroupIds&&a.accessGroupIds.length>0;return e.jsxs("div",{draggable:!0,onDragStart:m=>oe(m,a.id,"resource"),onDrop:m=>ne(m,a.id,"resource",a.categoryId),className:`p-3 bg-white border rounded-md flex items-center justify-between shadow-sm cursor-move ${(v==null?void 0:v.id)===a.id?"opacity-50":""}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(b,{name:"gripVertical",className:"text-gray-400"}),e.jsx(b,{name:a.resourceType==="external_url"?"link":Me(a.fileType||""),className:"w-5 h-5 text-gray-500"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium",children:a.name}),!a.isActive&&e.jsx("span",{className:"px-1.5 py-0.5 bg-gray-100 text-gray-500 text-[10px] font-bold rounded uppercase tracking-wider border border-gray-200",children:"Unavailable"})]}),a.description&&e.jsx("p",{className:"text-xs text-gray-500 line-clamp-1",children:a.description})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>ye(a),className:`inline-flex items-center gap-2 rounded-full text-blue-600 hover:text-blue-700 hover:bg-blue-50 ${g==="policy"?"px-3 py-1.5 text-xs font-bold":"p-1.5"}`,title:a.resourceType==="external_url"?"Open Link":"Download Resource",children:[e.jsx(b,{name:a.resourceType==="external_url"?"externalLink":"download",className:"w-4 h-4"}),g==="policy"&&e.jsx("span",{children:Ae})]}),e.jsx("button",{onClick:()=>{const m={...a,isActive:!a.isActive};_("resources",m).then(()=>h(n=>n+1))},className:`p-1.5 rounded-full transition-colors ${a.isActive?"text-green-500 hover:bg-green-50":"text-gray-400 hover:bg-gray-100"}`,title:a.isActive?"Make Unavailable":"Make Available",children:e.jsx(b,{name:a.isActive?"eye":"eyeOff",className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>Z(a),className:"p-1.5 text-gray-400 hover:text-blue-600 rounded-full",title:"Edit Resource",children:e.jsx(b,{name:"edit",className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>xe(a),className:`p-1.5 rounded-full ${p?"text-blue-500 hover:text-blue-700":"text-gray-400 hover:text-blue-600"}`,title:"Manage Access",children:e.jsx(b,{name:"users",className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>be(a.id),className:"p-1.5 text-gray-400 hover:text-red-600 rounded-full",title:"Delete Resource",children:e.jsx(b,{name:"trash",className:"w-4 h-4"})})]})]},a.id)}),r.length===0&&e.jsx("p",{className:"text-sm text-center text-gray-500 py-4",children:"Drag resources here to add them to this category."})]})]},s.id)})]}),W&&e.jsx(J,{isOpen:W,onClose:()=>P(!1),title:t!=null&&t.id?"Edit Resource":"Add Resource",children:e.jsxs("form",{onSubmit:he,className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-4 p-1 bg-gray-100 rounded-lg",children:[e.jsxs("button",{type:"button",onClick:()=>l({...t,resourceType:"file"}),className:`flex-1 py-2 text-sm font-medium rounded-md transition ${(t==null?void 0:t.resourceType)!=="external_url"?"bg-white shadow-sm text-blue-600":"text-gray-500 hover:text-gray-700"}`,children:[e.jsx(b,{name:"file",className:"w-4 h-4 inline-block mr-2"})," File Upload"]}),e.jsxs("button",{type:"button",onClick:()=>l({...t,resourceType:"external_url"}),className:`flex-1 py-2 text-sm font-medium rounded-md transition ${(t==null?void 0:t.resourceType)==="external_url"?"bg-white shadow-sm text-blue-600":"text-gray-500 hover:text-gray-700"}`,children:[e.jsx(b,{name:"link",className:"w-4 h-4 inline-block mr-2"})," External Link"]}),e.jsx("input",{type:"hidden",name:"resourceType",value:(t==null?void 0:t.resourceType)||"file"})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 bg-blue-50/50 rounded-lg border border-blue-100",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-semibold text-blue-900 block",children:"Available to Clients"}),e.jsx("p",{className:"text-[11px] text-blue-700",children:"If disabled, this resource will be hidden from all client accounts."})]}),e.jsx("button",{type:"button",onClick:()=>l({...t,isActive:!(t!=null&&t.isActive)}),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none ${(t==null?void 0:t.isActive)!==!1?"bg-blue-600":"bg-gray-200"}`,children:e.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${(t==null?void 0:t.isActive)!==!1?"translate-x-6":"translate-x-1"}`})}),e.jsx("input",{type:"hidden",name:"isActive",value:(t==null?void 0:t.isActive)!==!1?"true":"false"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium",children:"Name"}),e.jsx("input",{name:"name",defaultValue:t==null?void 0:t.name,required:!0,className:"w-full mt-1 p-2 border rounded"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium",children:"Description (Optional)"}),e.jsx("textarea",{name:"description",defaultValue:t==null?void 0:t.description,className:"w-full mt-1 p-2 border rounded",rows:2})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium",children:"Category"}),e.jsxs("select",{name:"categoryId",defaultValue:(t==null?void 0:t.categoryId)||"uncategorized",className:"w-full mt-1 p-2 border rounded bg-white",children:[e.jsx("option",{value:"uncategorized",children:"Uncategorized"}),A.map(s=>e.jsx("option",{value:s.id,children:s.name},s.id))]})]}),(t==null?void 0:t.resourceType)==="external_url"?e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium",children:"URL"}),e.jsx("input",{name:"externalUrl",type:"url",defaultValue:t==null?void 0:t.externalUrl,required:!0,className:"w-full mt-1 p-2 border rounded",placeholder:"https://example.com"})]}):e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium",children:["File ",(t==null?void 0:t.id)&&"(Optional: leave blank to keep existing file)"]}),e.jsx("input",{type:"file",name:"fileContent",className:"w-full mt-1 p-2 border rounded",required:!(t!=null&&t.id)}),(t==null?void 0:t.fileName)&&e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Current: ",t.fileName]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Accessible By"}),e.jsxs("p",{className:"text-xs text-gray-500 mb-2",children:["If no access control records are selected, the resource will be visible to all ",G.clientPlural.toLowerCase(),"."]}),e.jsxs("div",{className:"space-y-2 max-h-40 overflow-y-auto border p-2 rounded-md",children:[j.map(s=>e.jsxs("label",{className:"flex items-center p-1 cursor-pointer",children:[e.jsx("input",{type:"checkbox",className:"h-4 w-4 roun
1ded border-gray-300",checked:s.aliasIds.some(r=>o.has(r)),onChange:()=>le(s.id)}),e.jsx("span",{className:"ml-2 text-sm",children:s.displayLabel||s.name})]},s.id)),j.length===0&&e.jsx("p",{className:"text-xs text-gray-500 text-center",children:"No access control records have been created yet."})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx("button",{type:"button",onClick:()=>P(!1),className:"px-4 py-2 bg-gray-200 rounded-md",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:ae,className:"px-4 py-2 bg-blue-600 text-white rounded-md flex items-center gap-2",children:ae?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"})," Uploading..."]}):"Save"})]})]})}),I&&Q&&e.jsx(J,{isOpen:I,onClose:()=>U(!1),title:`Manage Access for "${Q.name}"`,children:e.jsxs("form",{onSubmit:ge,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Accessible By"}),e.jsxs("p",{className:"text-xs text-gray-500 mb-2",children:["If no access control records are selected, the resource will be visible to all ",G.clientPlural.toLowerCase(),"."]}),e.jsxs("div",{className:"space-y-2 max-h-60 overflow-y-auto border p-2 rounded-md",children:[j.map(s=>e.jsxs("label",{className:"flex items-center p-1 cursor-pointer",children:[e.jsx("input",{type:"checkbox",className:"h-4 w-4 rounded border-gray-300",checked:s.aliasIds.some(r=>o.has(r)),onChange:()=>le(s.id)}),e.jsx("span",{className:"ml-2 text-sm",children:s.displayLabel||s.name})]},s.id)),j.length===0&&e.jsx("p",{className:"text-xs text-gray-500 text-center",children:"No access control records have been created yet."})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx("button",{type:"button",onClick:()=>U(!1),className:"px-4 py-2 bg-gray-200 rounded-md",children:"Cancel"}),e.jsx("button",{type:"submit",className:"px-4 py-2 bg-blue-600 text-white rounded-md",children:"Save"})]})]})}),i&&e.jsx(Te,{categories:S,coachingAccountId:x.coachingAccountId,groups:j,courses:w,onClose:()=>z(!1),onSave:fe,allowPolicyScope:ee,defaultScopeType:g==="policy"?"policy":"global"})]})},Te=({categories:x,coachingAccountId:G,groups:M,courses:T,onClose:V,onSave:A,allowPolicyScope:F=!1,defaultScopeType:j="global"})=>{const[N,w]=u.useState([...x].sort((l,o)=>l.order-o.order)),[O,q]=u.useState(""),[E,B]=u.useState(null),h=l=>String(l.scopeType||"global")==="policy"&&Number(l.order)>=0&&Number(l.order)<6,K=()=>{if(!O.trim())return;const l={id:`cat_${Date.now()}`,name:O.trim(),order:N.length,coachingAccountId:G,scopeType:j,uploaderPolicy:"admins_only"};w([...N,l]),q("")},L=l=>{const o=N.find(c=>c.id===l);o&&h(o)||w(N.filter(c=>c.id!==l))},W=l=>{const o=N.find(c=>c.id===l);o&&h(o)||B(l)},P=l=>l.preventDefault(),t=l=>{if(!E||E===l)return;const o=[...N],c=o.findIndex(I=>I.id===E),i=o.findIndex(I=>I.id===l);if(c===-1||i===-1||h(o[c])||h(o[i]))return;const[z]=o.splice(c,1);o.splice(i,0,z),w(o.map((I,U)=>({...I,order:U})))};return e.jsxs(J,{isOpen:!0,onClose:V,title:"Manage Categories",children:[e.jsx("div",{className:"space-y-3 max-h-[60vh] overflow-y-auto pr-1",children:N.map(l=>e.jsxs("div",{draggable:!h(l),onDragStart:()=>W(l.id),onDragOver:P,onDrop:()=>t(l.id),onDragEnd:()=>B(null),className:`rounded-lg border border-gray-200 bg-white p-3 ${h(l)?"cursor-not-allowed bg-slate-50":"cursor-move"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[e.jsx(b,{name:"gripVertical",className:`text-gray-400 ${h(l)?"opacity-50":""}`}),e.jsx("input",{value:l.name,onChange:o=>w(c=>c.map(i=>i.id===l.id?{...i,name:o.target.value}:i)),className:"flex-1 p-2 border rounded bg-white text-sm font-semibold",placeholder:"Category name"}),h(l)&&e.jsx("span",{className:"inline-flex items-center rounded-full border border-slate-200 bg-white px-2.5 py-1 text-[10px] font-black uppercase tracking-[0.22em] text-slate-500",children:"Starter"})]}),e.jsx("button",{onClick:()=>L(l.id),disabled:h(l),className:"p-2 rounded hover:bg-red-50 text-gray-500 hover:text-red-600 disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent disabled:hover:text-gray-500",title:h(l)?"Starter categories cannot be deleted":"Delete category",children:e.jsx(b,{name:"trash",className:"w-4 h-4"})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-2",children:[e.jsxs("select",{value:l.scopeType||"global",onChange:o=>w(c=>c.map(i=>i.id===l.id?{...i,scopeType:o.target.value,scopeId:o.target.value==="global"||o.target.value==="policy"?void 0:i.scopeId}:i)),className:"p-2 border rounded bg-white text-sm",children:[e.jsx("option",{value:"global",children:"Scope: Global"}),e.jsx("option",{value:"membership_group",children:"Scope: Membership Group"}),e.jsx("option",{value:"course",children:"Scope: Course"}),F&&e.jsx("option",{value:"policy",children:"Scope: Policy Documents"})]}),(l.scopeType||"global")==="membership_group"?e.jsxs("select",{value:l.scopeId||"",onChange:o=>w(c=>c.map(i=>i.id===l.id?{...i,scopeId:o.target.value||void 0}:i)),className:"p-2 border rounded bg-white text-sm",children:[e.jsx("option",{value:"",children:"Select membership group..."}),M.slice().sort((o,c)=>String(o.name||"").localeCompare(String(c.name||""))).map(o=>e.jsx("option",{value:o.id,children:o.displayLabel||o.name},o.id))]}):(l.scopeType||"global")==="course"?e.jsxs("select",{value:l.scopeId||"",onChange:o=>w(c=>c.map(i=>i.id===l.id?{...i,scopeId:o.target.value||void 0}:i)),className:"p-2 border rounded bg-white text-sm",children:[e.jsx("option",{value:"",children:"Select course..."}),T.slice().sort((o,c)=>String(o.title||"").localeCompare(String(c.title||""))).map(o=>e.jsx("option",{value:o.id,children:o.title},o.id))]}):(l.scopeType||"global")==="policy"?e.jsx("input",{value:"",placeholder:"Policy documents do not use a scope ID",className:"p-2 border rounded text-sm bg-gray-50 text-gray-400",disabled:!0}):e.jsx("input",{value:"",placeholder:"No scope id needed",className:"p-2 border rounded text-sm bg-gray-50 text-gray-400",disabled:!0}),e.jsxs("select",{value:l.uploaderPolicy||"admins_only",onChange:o=>w(c=>c.map(i=>i.id===l.id?{...i,uploaderPolicy:o.target.value}:i)),className:"p-2 border rounded bg-white text-sm",children:[e.jsx("option",{value:"admins_only",children:"Uploads: Admins only"}),e.jsx("option",{value:"all_members",children:"Uploads: Allowed members"})]})]})]},l.id))}),e.jsxs("div",{className:"mt-4 pt-4 border-t flex gap-2",children:[e.jsx("input",{value:O,onChange:l=>q(l.target.value),onKeyDown:l=>l.key==="Enter"&&K(),placeholder:"New category name",className:"flex-grow p-2 border rounded"}),e.jsx("button",{onClick:K,className:"px-4 py-2 bg-blue-600 text-white rounded",children:"Add"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx("button",{type:"button",onClick:V,className:"px-4 py-2 bg-gray-200 text-gray-800 rounded-md",children:"Cancel"}),e.jsx("button",{type:"button",onClick:()=>A(N),className:"px-4 py-2 bg-blue-600 text-white rounded-md",children:"Save Changes"})]})]})};export{ze 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.