1import{r as d,j as e}from"./react-vendor-DDlTsOEd.js";import{g as se,V as tt,F as me,K as ue,R as st,aj as Be,n as He,A as k,ad as C,J as H,X as le,s as at,l as nt}from"./index-dMYrr1t8.js";import{A as rt,F as Ne}from"./AdminLayout-C0t6TWD9.js";import{u as it,a as lt,B as _e,F as ot,t as dt,e as ct,h as xt}from"./BulkFileUploader-BE60z7RV.js";import{I as Ie}from"./image-CrlXsVPe.js";import{C as ae}from"./check-DVW38x0e.js";import{S as mt}from"./sliders-horizontal-B-jxvfEq.js";import{C as W}from"./calendar-CUZFC7dX.js";import{T as ve}from"./trash-2-BFoxcqPY.js";import{C as ut}from"./copy-BQYOwZRh.js";import"./megaphone-CG_Y22E9.js";import"./clipboard-check-H9MOfMyT.js";import"./database-BMcpOIuo.js";import"./tag-CsU2rQcC.js";import"./credit-card-CV_Lm4ZC.js";import"./dialog-CWLM8hAZ.js";import"./index-Cqcshn79.js";import"./upload-Csh4KAbr.js";import"./circle-x-DRWcnEQU.js";const gt=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],pt=se("ellipsis-vertical",gt);const ht=[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",key:"fm4g5t"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m9 16 3-3-3-3",key:"6m91ic"}]],ft=se("folder-input",ht);const yt=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],We=se("folder-plus",yt);const bt=[["path",{d:"M2 9.35V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h7",key:"y8kt7d"}],["path",{d:"m8 16 3-3-3-3",key:"rlqrt1"}]],jt=se("folder-symlink",bt);const Nt=[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]],Oe=se("hard-drive",Nt);const vt=[["path",{d:"M5 12h14",key:"1ays0h"}]],wt=se("minus",vt);function St(s){if(!s)return"";const r=Math.floor(s/3600),i=Math.floor(s%3600/60),m=s%60;return r>0?`${r}:${i.toString().padStart(2,"0")}:${m.toString().padStart(2,"0")}`:`${i}:${m.toString().padStart(2,"0")}`}function we(s){return s?s<1024*1024?`${(s/1024).toFixed(1)} KB`:s<1024*1024*1024?`${(s/1024/1024).toFixed(1)} MB`:`${(s/1024/1024/1024).toFixed(2)} GB`:""}function O(s){if(!s)return"";const r=new Date(s);if(isNaN(r.getTime()))return"";const i=new Date,m=new Date(i.getFullYear(),i.getMonth(),i.getDate()),g=new Date(r.getFullYear(),r.getMonth(),r.getDate()),u=Math.round((m.getTime()-g.getTime())/864e5),c=r.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"});return u===0?`Today ${c}`:u===1?`Yesterday ${c}`:u<7?`${r.toLocaleDateString([],{weekday:"long"})} ${c}`:r.toLocaleDateString([],{month:"short",day:"numeric",year:"numeric"})}function Ge(s){return`${k}/storage${s}`}const Ue={0:{label:"Created",color:"bg-gray-100 text-gray-900"},1:{label:"Uploaded",color:"bg-blue-50 text-blue-600"},2:{label:"Processing",color:"bg-yellow-50 text-yellow-600"},3:{label:"Encoding",color:"bg-orange-50 text-orange-600"},4:{label:"Ready",color:"bg-emerald-50 text-emerald-700"},5:{label:"Error",color:"bg-red-50 text-red-600"},6:{label:"Failed",color:"bg-red-50 text-red-600"}},ge=["#6366f1","#3b82f6","#0ea5e9","#10b981","#f59e0b","#ef4444","#ec4899","#8b5cf6"];function $(s,r){return fetch(s,{...r,headers:{Authorization:`Bearer ${nt()}`,...r?.headers??{}}})}function pe({value:s,label:r}){const[i,m]=d.useState(!1);function g(){navigator.clipboard.writeText(s).then(()=>{m(!0),setTimeout(()=>m(!1),1800)})}return e.jsxs("button",{onClick:g,title:`Copy ${r}`,className:`flex items-center gap-1 text-xs px-2 py-1 rounded-md transition-colors ${i?"bg-emerald-50 text-emerald-700 border border-emerald-200":"bg-gray-50 text-gray-900 border border-gray-200 hover:bg-blue-50 hover:text-blue-700 hover:border-blue-200"}`,children:[i?e.jsx(ae,{size:11}):e.jsx(ut,{size:11}),i?"Copied!":r]})}function Se({folders:s,currentFolderId:r,onAssign:i}){const[m,g]=d.useState(!1),u=d.useRef(null);d.useEffect(()=>{function l(x){u.current&&!u.current.contains(x.target)&&g(!1)}return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[]);const c=s.find(l=>l.id===r);return e.jsxs("div",{className:"relative",ref:u,children:[e.jsxs("button",{onClick:()=>g(l=>!l),className:"flex items-center gap-1 text-xs px-2 py-1 rounded-md bg-gray-50 text-gray-900 border border-gray-200 hover:bg-indigo-50 hover:text-indigo-700 hover:border-indigo-200 transition-colors",title:"Move to folder",children:[e.jsx(ft,{size:11}),c?c.name:"Move toâ¦"]}),m&&e.jsxs("div",{className:"absolute bottom-full mb-1 left-0 z-50 bg-white border border-gray-200 rounded-xl shadow-lg min-w-[160px] py-1 text-sm",children:[e.jsxs("button",{onClick:()=>{i(null),g(!1)},className:`w-full text-left px-3 py-1.5 hover:bg-gray-50 flex items-center gap-2 ${r?"text-gray-900":"text-indigo-600 font-medium"}`,children:[e.jsx(le,{size:12,className:"text-gray-900"})," No folder"]}
1),s.map(l=>e.jsxs("button",{onClick:()=>{i(l.id),g(!1)},className:`w-full text-left px-3 py-1.5 hover:bg-gray-50 flex items-center gap-2 ${r===l.id?"text-indigo-600 font-medium":"text-gray-900"}`,children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-sm shrink-0",style:{background:l.color}}),l.name]},l.id))]})]})}function Ct({video:s,cdnHostname:r,libraryId:i,folders:m,selected:g,onToggleSelect:u,onDelete:c,onAssignFolder:l}){const x=dt(s,r),f=ct(s,i),j=xt(s,r),N=Ue[s.status]??Ue[0],E=s.status===4,F=s.originalDate;return e.jsxs("div",{className:`bg-white rounded-xl border shadow-sm overflow-hidden group hover:shadow-md transition-all flex ${g?"border-indigo-400 ring-2 ring-indigo-200":"border-gray-100"}`,children:[e.jsxs("div",{className:"relative w-44 shrink-0 bg-gray-100 self-stretch flex items-center justify-center overflow-hidden",children:[u&&e.jsx("button",{onClick:b=>{b.stopPropagation(),u()},className:`absolute top-2 left-2 z-10 w-5 h-5 rounded border-2 flex items-center justify-center transition-all ${g?"bg-indigo-500 border-indigo-500 opacity-100":"bg-white/80 border-gray-300 opacity-0 group-hover:opacity-100"}`,children:g&&e.jsx(ae,{size:11,className:"text-white",strokeWidth:3})}),x?e.jsx("img",{src:x,alt:s.title,className:"w-full h-full object-cover absolute inset-0",onError:b=>{b.target.style.display="none"}}):e.jsx(Ne,{size:28,className:"text-gray-900"}),s.length>0&&e.jsx("span",{className:"absolute bottom-1.5 right-1.5 bg-black/70 text-white text-[10px] font-mono px-1.5 py-0.5 rounded",children:St(s.length)}),!E&&e.jsx("div",{className:"absolute inset-0 bg-black/30 flex items-center justify-center",children:s.status>=5?e.jsx(Be,{size:22,className:"text-red-400"}):e.jsxs("div",{className:"text-center",children:[e.jsx(He,{size:22,className:"text-white animate-spin mx-auto"}),s.status===3&&s.encodeProgress>0&&e.jsxs("p",{className:"text-white text-[10px] mt-1",children:[s.encodeProgress,"%"]})]})})]}),e.jsxs("div",{className:"flex flex-1 items-start justify-between p-3 gap-3 min-w-0",children:[e.jsxs("div",{className:"flex-1 min-w-0 space-y-1.5",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("p",{className:"text-sm font-semibold text-gray-900 leading-snug flex-1 min-w-0 line-clamp-2",title:s.title,children:s.title}),e.jsx("span",{className:`text-[10px] font-medium px-2 py-0.5 rounded-full shrink-0 mt-0.5 ${N.color}`,children:N.label})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-0.5",children:[F&&e.jsxs("span",{className:"text-[11px] text-gray-800 flex items-center gap-1",children:[e.jsx(W,{size:10,className:"text-indigo-300"}),e.jsx("span",{className:"text-gray-800",children:"Created:"}),O(F)]}),s.storageSize>0&&e.jsx("span",{className:"text-[11px] text-gray-800",children:we(s.storageSize)}),s.dateUploaded&&e.jsxs("span",{className:"text-[11px] text-gray-800",children:[e.jsx("span",{className:"text-gray-800",children:"Uploaded:"})," ",O(s.dateUploaded)]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 pt-0.5",children:[e.jsx(pe,{value:f,label:"Embed URL"}),j&&e.jsx(pe,{value:j,label:"HLS URL"}),m.length>0&&e.jsx(Se,{folders:m,currentFolderId:s.folderId??null,onAssign:b=>l(s.guid,b)})]})]}),e.jsx("button",{onClick:()=>{confirm(`Delete "${s.title}"?`)&&c(s.guid)},className:"shrink-0 mt-0.5 text-gray-900 hover:text-red-500 transition-colors",title:"Delete video",children:e.jsx(ve,{size:14})})]})]})}function kt({file:s,folders:r,selected:i,onToggleSelect:m,onDelete:g,onAssignFolder:u}){const c=Ge(s.objectPath);return e.jsxs("div",{className:`bg-white rounded-2xl border shadow-sm overflow-hidden group hover:shadow-md transition-all ${i?"border-indigo-400 ring-2 ring-indigo-200":"border-gray-100"}`,children:[e.jsxs("div",{className:"aspect-video bg-gray-50 relative overflow-hidden flex items-center justify-center",children:[m&&e.jsx("button",{onClick:l=>{l.stopPropagation(),m()},className:`absolute top-2 left-2 z-10 w-5 h-5 rounded border-2 flex items-center justify-center transition-all ${i?"bg-indigo-500 border-indigo-500 opacity-100":"bg-white/80 border-gray-300 opacity-0 group-hover:opacity-100"}`,children:i&&e.jsx(ae,{size:11,className:"text-white",strokeWidth:3})}),e.jsx("img",{src:c,alt:s.name,className:"w-full h-full object-contain",onError:l=>{l.target.style.display="none"}})]}),e.jsxs("div",{className:"p-3 space-y-1.5",children:[e.jsx("p",{className:"text-sm font-semibold text-gray-900 line-clamp-2",title:s.name,children:s.name}),e.jsxs("div",{className:"flex flex-col gap-0.5",children:[s.originalDate&&e.jsxs("span",{className:"text-[11px] text-gray-800 flex items-center gap-1",children:[e.jsx(W,{size:10,
1className:"text-indigo-300"}),e.jsx("span",{className:"font-medium text-gray-800",children:"Created:"}),O(s.originalDate)]}),e.jsxs("div",{className:"flex items-center gap-2",children:[s.size>0&&e.jsx("span",{className:"text-[11px] text-gray-800",children:we(s.size)}),e.jsx("span",{className:"text-[11px] uppercase font-medium text-gray-800",children:s.contentType.split("/").pop()}),s.uploadedAt&&!s.originalDate&&e.jsxs("span",{className:"text-[11px] text-gray-800 flex items-center gap-0.5",children:[e.jsx(W,{size:10,className:"text-gray-900"}),O(s.uploadedAt)]}),s.uploadedAt&&s.originalDate&&e.jsxs("span",{className:"text-[11px] text-gray-800",children:[e.jsx("span",{className:"text-gray-800",children:"Uploaded:"})," ",O(s.uploadedAt)]})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5 pt-0.5",children:[e.jsx(pe,{value:c,label:"Copy URL"}),r.length>0&&e.jsx(Se,{folders:r,currentFolderId:s.folderId,onAssign:l=>u(s.id,l)})]}),e.jsxs("button",{onClick:()=>{confirm(`Delete "${s.name}"?`)&&g(s.id)},className:"flex items-center gap-1 text-xs text-gray-900 hover:text-red-500 transition-colors",children:[e.jsx(ve,{size:11})," Delete"]})]})]})}function Ft({file:s,folders:r,selected:i,onToggleSelect:m,onDelete:g,onAssignFolder:u}){const c=Ge(s.objectPath),l=s.name.split(".").pop()?.toUpperCase()??"FILE";return e.jsxs("div",{className:`bg-white rounded-2xl border shadow-sm overflow-hidden group hover:shadow-md transition-all ${i?"border-indigo-400 ring-2 ring-indigo-200":"border-gray-100"}`,children:[e.jsxs("div",{className:"relative",children:[m&&e.jsx("button",{onClick:x=>{x.stopPropagation(),m()},className:`absolute top-2 left-2 z-10 w-5 h-5 rounded border-2 flex items-center justify-center transition-all ${i?"bg-indigo-500 border-indigo-500 opacity-100":"bg-white/80 border-gray-300 opacity-0 group-hover:opacity-100"}`,children:i&&e.jsx(ae,{size:11,className:"text-white",strokeWidth:3})}),e.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"block",children:e.jsxs("div",{className:"aspect-video bg-gray-50 flex flex-col items-center justify-center gap-2",children:[e.jsx(me,{size:40,className:"text-blue-300"}),e.jsx("span",{className:"text-xs font-bold text-blue-400 bg-blue-50 px-2 py-0.5 rounded",children:l})]})})]}),e.jsxs("div",{className:"p-3 space-y-1.5",children:[e.jsx("p",{className:"text-sm font-semibold text-gray-900 line-clamp-2",title:s.name,children:s.name}),e.jsxs("div",{className:"flex flex-col gap-0.5",children:[s.originalDate&&e.jsxs("span",{className:"text-[11px] text-gray-800 flex items-center gap-1",children:[e.jsx(W,{size:10,className:"text-indigo-300"}),e.jsx("span",{className:"font-medium text-gray-800",children:"Created:"}),O(s.originalDate)]}),e.jsxs("div",{className:"flex items-center gap-2",children:[s.size>0&&e.jsx("span",{className:"text-[11px] text-gray-800",children:we(s.size)}),s.uploadedAt&&!s.originalDate&&e.jsxs("span",{className:"text-[11px] text-gray-800 flex items-center gap-0.5",children:[e.jsx(W,{size:10,className:"text-gray-900"}),O(s.uploadedAt)]}),s.uploadedAt&&s.originalDate&&e.jsxs("span",{className:"text-[11px] text-gray-800",children:[e.jsx("span",{className:"text-gray-800",children:"Uploaded:"})," ",O(s.uploadedAt)]})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5 pt-0.5",children:[e.jsx(pe,{value:c,label:"Copy URL"}),e.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-xs px-2 py-1 rounded-md bg-gray-50 text-gray-900 border border-gray-200 hover:bg-blue-50 hover:text-blue-700 hover:border-blue-200 transition-colors",children:"Open"}),r.length>0&&e.jsx(Se,{folders:r,currentFolderId:s.folderId,onAssign:x=>u(s.id,x)})]}),e.jsxs("button",{onClick:()=>{confirm(`Delete "${s.name}"?`)&&g(s.id)},className:"flex items-center gap-1 text-xs text-gray-900 hover:text-red-500 transition-colors",children:[e.jsx(ve,{size:11})," Delete"]})]})]})}function Ve(){return e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-4",children:Array.from({length:8}).map((s,r)=>e.jsxs("div",{className:"bg-white rounded-2xl border border-gray-100 overflow-hidden animate-pulse",children:[e.jsx("div",{className:"aspect-video bg-gray-100"}),e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsx("div",{className:"h-4 bg-gray-100 rounded w-3/4"}),e.jsx("div",{className:"h-3 bg-gray-100 rounded w-1/3"})]})]},r))})}function Dt(){return e.jsx("div",{className:"flex flex-col gap-2",children:Array.from({length:6}).map((s,r)=>e.jsxs("div",{className:"bg-white rounded-xl border border-gray-100 overflow-hidden animate-pulse flex h-20",children:[e.jsx("div",{className:"w-44 shrink-0 bg-gray-100"}),e.jsxs("div",{className:"flex-1 p-3 space-y-2",children:[e.jsx("div",{className:"h-4 bg-gray-100 rounded w-2/3"}),e.jsx("div",{className:"h-3 bg-gray-100 rounded w-1/3"}),e.jsx("div",{className:"h-3 bg-gray-100 rounded w-1/4"})]})]},r))})}function be({icon:s,msg:r}){return e.jsxs("div",{className:"text-center py-20",children:[s,e.jsx("p",{className:"text-gray-900 text-sm",children:r})]})}function zt({folders:s,activeFolderId:r,activeTab:i,videoCounts:m,imageCounts:g,docCounts:u,totalVideos:c,totalImages:l,totalDocs:x,onSelect:f,onCreate:j,onRename:N,onDelete:E}){const[F,b]=d.useState(!1),[A,D]=d.useState(""),[w,h]=d.useState(ge[0]),[z,y]=d.use
1State(null),[_,U]=d.useState(""),[I,T]=d.useState(null),M=d.useRef(null);d.useEffect(()=>{function a(p){M.current&&!M.current.contains(p.target)&&T(null)}return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[]);function V(a){return i==="videos"?m[a]??0:i==="images"?g[a]??0:u[a]??0}function P(){return i==="videos"?c:i==="images"?l:x}function L(){A.trim()&&(j(A.trim(),null,w),D(""),b(!1))}function G(a){if(!_.trim()){y(null);return}N(a,_.trim()),y(null)}const J=s.filter(a=>a.parentId==null);return e.jsxs("div",{className:"w-full md:w-52 md:shrink-0 space-y-1",children:[e.jsxs("button",{onClick:()=>f("all"),className:`w-full text-left flex items-center justify-between px-3 py-2 rounded-xl text-sm font-medium transition-colors ${r==="all"?"bg-indigo-50 text-indigo-700":"text-gray-900 hover:bg-gray-100"}`,children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(ot,{size:15,className:r==="all"?"text-indigo-500":"text-gray-900"}),"All Media"]}),e.jsx("span",{className:"text-xs text-gray-900",children:P()})]}),J.map(a=>e.jsxs("div",{className:"relative group/folder",children:[z===a.id?e.jsxs("div",{className:"flex items-center gap-1 px-2",children:[e.jsx(H,{value:_,onChange:p=>U(p.target.value),onKeyDown:p=>{p.key==="Enter"&&G(a.id),p.key==="Escape"&&y(null)},onBlur:()=>{setTimeout(()=>y(null),150)},className:"h-7 text-xs",autoFocus:!0}),e.jsx("button",{onMouseDown:p=>p.preventDefault(),onClick:()=>G(a.id),className:"text-indigo-600 text-xs font-medium shrink-0",children:"Save"}),e.jsx("button",{onMouseDown:p=>p.preventDefault(),onClick:()=>y(null),className:"text-gray-900 hover:text-gray-600 text-xs shrink-0",title:"Cancel",children:e.jsx(le,{size:12})})]}):e.jsxs("div",{role:"button",tabIndex:0,onClick:()=>f(a.id),onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&f(a.id)},className:`w-full text-left flex items-center justify-between px-3 py-2 rounded-xl text-sm transition-colors cursor-pointer ${r===a.id?"bg-indigo-50 text-indigo-700 font-medium":"text-gray-900 hover:bg-gray-100"}`,children:[e.jsxs("span",{className:"flex items-center gap-2 truncate",children:[e.jsx("span",{className:"w-3 h-3 rounded-sm shrink-0",style:{background:a.color}}),e.jsx("span",{className:"truncate",children:a.name})]}),e.jsxs("span",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("span",{className:"text-xs text-gray-900",children:V(a.id)}),e.jsx("button",{onClick:p=>{p.stopPropagation(),T(I===a.id?null:a.id)},className:"opacity-0 group-hover/folder:opacity-100 text-gray-900 hover:text-gray-700 transition-opacity p-0.5 rounded",children:e.jsx(pt,{size:13})})]})]}),I===a.id&&e.jsxs("div",{ref:M,className:"absolute right-0 top-8 z-50 bg-white border border-gray-200 rounded-xl shadow-lg py-1 min-w-[130px] text-sm",children:[e.jsx("button",{onClick:()=>{y(a.id),U(a.name),T(null)},className:"w-full text-left px-3 py-1.5 text-gray-900 hover:bg-gray-50",children:"Rename"}),e.jsx("button",{onClick:()=>{confirm(`Delete folder "${a.name}"?`)&&(E(a.id),T(null))},className:"w-full text-left px-3 py-1.5 text-red-500 hover:bg-red-50",children:"Delete"})]})]},a.id)),F?e.jsxs("div",{className:"border border-indigo-200 rounded-xl p-2.5 bg-indigo-50/40 space-y-2",children:[e.jsx(H,{value:A,onChange:a=>D(a.target.value),placeholder:"Folder name",className:"h-7 text-xs",autoFocus:!0,onKeyDown:a=>{a.key==="Enter"&&L(),a.key==="Escape"&&b(!1)}}),e.jsx("div",{className:"flex gap-1.5 flex-wrap",children:ge.map(a=>e.jsx("button",{onClick:()=>h(a),className:`w-5 h-5 rounded-sm transition-transform ${w===a?"ring-2 ring-offset-1 ring-gray-400 scale-110":""}`,style:{background:a}},a))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ue,{size:"sm",className:"h-6 text-xs bg-indigo-600 hover:bg-indigo-700 flex-1",onClick:L,children:"Create"}),e.jsx(ue,{size:"sm",variant:"ghost",className:"h-6 text-xs flex-1",onClick:()=>b(!1),children:"Cancel"})]})]}):e.jsxs("button",{onClick:()=>b(!0),className:"w-full text-left flex items-center gap-2 px-3 py-2 rounded-xl text-xs text-gray-900 hover:text-indigo-600 hover:bg-indigo-50 transition-colors",children:[e.jsx(We,{size:14})," New Folder"]})]})}function $t({tab:s,search:r,onSearch:i,videoStatus:m,onVideoStatus:g,typeFilter:u,onTypeFilter:c,sortField:l,sortDir:x,onSort:f,onSortDir:j,dateFrom:N,dateTo:E,onDateFrom:F,onDateTo:b,sizeMin:A,sizeMax:D,onSizeMin:w,onSizeMax:h,hasActiveFilters:z,onClear:y}
1){const[_,U]=d.useState(!1),[I,T]=d.useState(null),M=d.useRef(null);d.useEffect(()=>{if(!I)return;function a(p){M.current&&!M.current.contains(p.target)&&T(null)}return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[I]);const V=[{value:"all",label:"All"},{value:"ready",label:"Ready"},{value:"processing",label:"Processing"},{value:"failed",label:"Failed"}],P=["All","JPG","PNG","GIF","WebP","SVG"],L=["All","PDF","Word","Excel","PowerPoint"],G=[{value:"date",label:"Date",icon:e.jsx(W,{size:12}),descLabel:"Newest first",ascLabel:"Oldest first"},{value:"name",label:"Name",icon:e.jsx("span",{className:"font-bold text-[10px]",children:"Aâ"}),descLabel:"Z â A",ascLabel:"A â Z"},{value:"size",label:"Size",icon:e.jsx(Oe,{size:12}),descLabel:"Largest first",ascLabel:"Smallest first"},...s==="videos"?[{value:"duration",label:"Duration",icon:e.jsx(Ne,{size:12}),descLabel:"Longest first",ascLabel:"Shortest first"}]:[]];function J(a){l===a.value?T(p=>p===a.value?null:a.value):(f(a.value),T(a.value))}return e.jsxs("div",{className:"bg-white border border-gray-100 rounded-2xl shadow-sm overflow-hidden",children:[e.jsxs("div",{className:"flex items-center border-b border-gray-100 bg-gray-50/70 px-3 py-1.5 gap-0.5",ref:M,children:[e.jsx("span",{className:"text-[10px] text-gray-900 font-medium mr-2 uppercase tracking-wide",children:"Arrange by"}),G.map(a=>{const p=l===a.value,ne=I===a.value;return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>J(a),title:`Sort by ${a.label}`,className:`flex items-center gap-1 px-3 py-1 rounded-lg text-xs font-medium transition-all ${p?"bg-indigo-600 text-white shadow-sm":"text-gray-900 hover:bg-gray-200 hover:text-gray-700"}`,children:[a.icon,a.label,p&&e.jsx("span",{className:"ml-0.5 text-[11px] opacity-90",children:x==="desc"?"â":"â"})]}),ne&&e.jsx("div",{className:"absolute top-full left-0 mt-1 z-50 bg-white border border-gray-200 rounded-xl shadow-lg py-1 min-w-[150px]",children:["desc","asc"].map(R=>e.jsxs("button",{onClick:()=>{j(R),T(null)},className:`w-full text-left px-3 py-2 text-xs flex items-center gap-2 hover:bg-indigo-50 transition-colors ${x===R?"text-indigo-600 font-semibold":"text-gray-900"}`,children:[e.jsx("span",{children:R==="desc"?"â":"â"}),R==="desc"?a.descLabel:a.ascLabel,x===R&&e.jsx(ae,{size:11,className:"ml-auto text-indigo-500"})]},R))})]},a.value)}),e.jsx("div",{className:"flex-1"}),e.jsxs("button",{onClick:()=>U(a=>!a),className:`flex items-center gap-1.5 text-xs px-3 py-1 rounded-lg border transition-colors ${_||z?"bg-indigo-50 text-indigo-700 border-indigo-200":"bg-white text-gray-900 border-gray-200 hover:bg-gray-100"}`,children:[e.jsx(mt,{size:12}),"Filters",z&&e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-indigo-500 shrink-0"})]}),z&&e.jsxs("button",{onClick:y,className:"ml-1 text-[11px] text-gray-900 hover:text-red-500 transition-colors flex items-center gap-0.5",children:[e.jsx(le,{size:11})," Clear"]})]}),e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(at,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-900"}),e.jsx(H,{value:r,onChange:a=>i(a.target.value),placeholder:`Search ${s}â¦`,className:"pl-9 h-9 bg-gray-50 border-gray-200 text-gray-900 text-sm"})]}),s==="videos"&&e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-xs text-gray-900 font-medium",children:"Status:"}),V.map(a=>e.jsx("button",{onClick:()=>
1g(a.value),className:`text-xs px-3 py-1 rounded-full border transition-colors ${m===a.value?"bg-indigo-600 text-white border-indigo-600":"bg-white text-gray-900 border-gray-200 hover:border-indigo-300 hover:text-indigo-600"}`,children:a.label},a.value))]}),s==="images"&&e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-xs text-gray-900 font-medium",children:"Type:"}),P.map(a=>e.jsx("button",{onClick:()=>c(a==="All"?"":a.toLowerCase()),className:`text-xs px-3 py-1 rounded-full border transition-colors ${a==="All"&&!u||u===a.toLowerCase()?"bg-indigo-600 text-white border-indigo-600":"bg-white text-gray-900 border-gray-200 hover:border-indigo-300 hover:text-indigo-600"}`,children:a},a))]}),s==="documents"&&e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-xs text-gray-900 font-medium",children:"Type:"}),L.map(a=>{const p=a==="PDF"?"pdf":a==="Word"?"word":a==="Excel"?"excel":a==="PowerPoint"?"presentation":"";return e.jsx("button",{onClick:()=>c(a==="All"?"":p),className:`text-xs px-3 py-1 rounded-full border transition-colors ${a==="All"&&!u||u&&p&&p===u?"bg-indigo-600 text-white border-indigo-600":"bg-white text-gray-900 border-gray-200 hover:border-indigo-300 hover:text-indigo-600"}`,children:a},a)})]}),_&&e.jsxs("div",{className:"grid grid-cols-2 gap-3 pt-1 border-t border-gray-100",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("label",{className:"text-xs font-medium text-gray-900 flex items-center gap-1",children:[e.jsx(W,{size:11})," Date range"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{type:"date",value:N,onChange:a=>F(a.target.value),className:"h-8 text-xs flex-1"}),e.jsx("span",{className:"text-gray-900 text-xs shrink-0",children:"to"}),e.jsx(H,{type:"date",value:E,onChange:a=>b(a.target.value),className:"h-8 text-xs flex-1"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("label",{className:"text-xs font-medium text-gray-900 flex items-center gap-1",children:[e.jsx(Oe,{size:11})," Size range (MB)"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{type:"number",value:A,onChange:a=>w(a.target.value),className:"h-8 text-xs flex-1",placeholder:"Min",min:"0"}),e.jsx("span",{className:"text-gray-900 text-xs shrink-0",children:"â"}),e.jsx(H,{type:"number",value:D,onChange:a=>h(a.target.value),className:"h-8 text-xs flex-1",placeholder:"Max",min:"0"})]})]})]})]})]})}function At(){const[s,r]=d.useState([]),[i,m]=d.useState(!1),g=d.useCallback(async()=>{m(!0);try{const x=await(await $(`${k}/admin/media/files`)).json();x.success&&r(x.data??[])}finally{m(!1)}},[]);d.useEffect(()=>{g()},[g]);async function u(l){await $(`${k}/admin/media/files/${l}`,{method:"DELETE"}),r(x=>x.filter(f=>f.id!==l))}async function c(l,x){await $(`${k}/admin/media/files/${l}/folder`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({folderId:x})}),r(f=>f.map(j=>j.id===l?{...j,folderId:x}:j))}return{files:s,loading:i,fetchFiles:g,deleteFile:u,assignFolder:c}}function Tt(){const[s,r]=d.useState([]),i=d.useCallback(async()=>{try{const l=await(await $(`${k}/admin/media/folders`)).json();l.success&&r(l.data??[])}catch{}},[]);d.useEffect(()=>{i()},[i]);async function m(c,l,x){try{const j=await(await $(`${k}/admin/media/folders`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:c,parentId:l,color:x})})).json();return j.success?(C({title:`Folder "${c}" created`}),await i(),j.data):null}catch{return C({title:"Failed to create folder",variant:"destructive"}),null}}async function g(c,l){try{const f=await(await $(`${k}/admin/media/folders/${c}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:l})})).json();f.success&&(r(j=>j.map(N=>N.id===c?f.data:N)),C({title:"Folder renamed"}))}catch{C({title:"Failed to rename folder",variant:"destructive"})}}async function u(c){try{await $(`${k}/admin/media/folders/${c}`,{method:"DELETE"}),r(l=>l.filter(x=>x.id!==c)),C({title:"Folder deleted"})}catch{C({title:"Failed to delete folder",variant:"destructive"})}}return{folders:s,fetchFolders:i,createFolder:m,renameFolder:g,deleteFolder:u}}function je({count:s,allCount:r,folders:i,onSelectAll:m,onClear:g,onMove:u,onCreateAndMove:c}
1){const[l,x]=d.useState(!1),[f,j]=d.useState(""),[N,E]=d.useState(ge[0]),[F,b]=d.useState(!1),A=d.useRef(null);if(s===0)return null;async function D(h){b(!0),await u(h),b(!1)}async function w(){const h=f.trim();if(!h){A.current?.focus();return}b(!0),await c(h,N),j(""),x(!1),b(!1)}return e.jsxs("div",{className:"sticky top-0 z-20 bg-indigo-600 text-white rounded-2xl px-4 py-3 flex flex-wrap items-center gap-3 shadow-lg",children:[e.jsxs("button",{onClick:m,className:"flex items-center gap-2 text-sm font-medium hover:text-indigo-200 transition-colors",children:[e.jsx("span",{className:"w-5 h-5 rounded border-2 border-indigo-300 bg-indigo-500 flex items-center justify-center",children:s===r?e.jsx(ae,{size:11,strokeWidth:3}):e.jsx(wt,{size:11,strokeWidth:3})}),s," selected"]}),e.jsx("div",{className:"flex-1"}),i.length>0&&e.jsxs("div",{className:"relative",children:[e.jsxs("select",{disabled:F,defaultValue:"",onChange:async h=>{const z=h.target.value;h.target.value="",z==="__remove__"?await D(null):z&&await D(Number(z))},className:"appearance-none bg-indigo-500 border border-indigo-400 text-white text-sm rounded-lg px-3 py-1.5 pr-8 cursor-pointer hover:bg-indigo-400 transition-colors focus:outline-none focus:ring-2 focus:ring-white/30 disabled:opacity-60",children:[e.jsx("option",{value:"",disabled:!0,className:"text-gray-900",children:"Move to folderâ¦"}),i.map(h=>e.jsx("option",{value:h.id,className:"text-gray-900",children:h.name},h.id)),e.jsx("option",{value:"__remove__",className:"text-gray-900",children:"â Remove from folder"})]}),e.jsx(jt,{size:13,className:"absolute right-2.5 top-1/2 -translate-y-1/2 pointer-events-none text-indigo-200"})]}),l?e.jsxs("div",{className:"flex items-center gap-2 bg-indigo-500 border border-indigo-400 rounded-lg px-2 py-1",children:[e.jsx("div",{className:"flex gap-1",children:ge.map(h=>e.jsx("button",{onClick:()=>E(h),className:`w-4 h-4 rounded-full border-2 ${N===h?"border-white":"border-transparent"}`,style:{background:h}},h))}),e.jsx("input",{ref:A,autoFocus:!0,value:f,onChange:h=>j(h.target.value),onKeyDown:h=>{h.key==="Enter"&&w(),h.key==="Escape"&&x(!1)},placeholder:"Folder nameâ¦",className:"bg-transparent text-white placeholder-indigo-300 text-sm border-none outline-none w-36"}),e.jsx("button",{onClick:w,disabled:F,className:"text-xs bg-white text-indigo-700 font-semibold px-2 py-0.5 rounded hover:bg-indigo-100 transition-colors disabled:opacity-60",children:F?"â¦":"Create & Move"}),e.jsx("button",{onClick:()=>x(!1),className:"text-indigo-300 hover:text-white",children:e.jsx(le,{size:13})})]}):e.jsxs("button",{onClick:()=>x(!0),className:"flex items-center gap-1.5 text-sm bg-indigo-500 border border-indigo-400 px-3 py-1.5 rounded-lg hover:bg-indigo-400 transition-colors",children:[e.jsx(We,{size:13})," New folder"]}),e.jsx("button",{onClick:g,className:"text-indigo-200 hover:text-white transition-colors",title:"Clear selection",children:e.jsx(le,{size:16})})]})}function Xt(){const[s,r]=d.useState("videos"),[i,m]=d.useState("all"),{videos:g,config:u,loading:c,search:l,setSearch:x,fetchVideos:f,deleteVideo:j}=it(),[N,E]=d.useState({});async function F(t,n){await $(`${k}/admin/media/videos/${t}/folder`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({folderId:n})}),E(o=>({...o,[t]:n})),C({title:n?"Video moved to folder":"Video removed from folder"})}const b=g.map(t=>({...t,folderId:Object.prototype.hasOwnProperty.call(N,t.guid)?N[t.guid]:t.folderId??null})),{files:A,loading:D,fetchFiles:w,deleteFile:h,assignFolder:z}=At(),{folders:y,fetchFolders:_,createFolder:U,renameFolder:I,deleteFolder:T}=Tt(),[M,V]=d.useState(new Set),[P,L]=d.useState(new Set);function G(t){V(n=>{const o=new Set(n);return o.has(t)?o.delete(t):o.add(t),o})}function J(t){L(n=>{const o=new Set(n);return o.has(t)?o.delete(t):o.add(t),o})}function a(){V(new Set),L(new Set)}async function p(t){if(s==="videos"){const n=[...M];await $(`${k}/admin/media/videos/bulk-folder`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({guids:n,folderId:t})}),E(o=>{const v={...o};
1return n.forEach(S=>{v[S]=t}),v}),a(),await f(),C({title:t?`Moved ${n.length} video${n.length!==1?"s":""} to folder`:`Removed ${n.length} video${n.length!==1?"s":""} from folder`})}else{const n=[...P];await $(`${k}/admin/media/files/bulk-folder`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:n,folderId:t})}),a(),await w(),C({title:t?`Moved ${n.length} file${n.length!==1?"s":""} to folder`:`Removed ${n.length} file${n.length!==1?"s":""} from folder`})}}async function ne(t,n){const o=await U(t,null,n);o&&await p(o.id)}const[R,Ce]=d.useState(!1);async function Je(){Ce(!0);try{const n=await(await $(`${k}/admin/media/files/attach-pdfs-by-name`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dryRun:!0})})).json();if(!n.success)throw new Error(n.error??"PDF matching failed");const o=n.data?.summary??{},v=Number(o.matched??0),S=Number(o.ambiguous??0);if(v===0){C({title:"No PDF names matched course steps",description:"Rename uploaded PDFs to match the lesson/section title, then try again.",variant:"destructive"});return}if(S>0){C({title:"Some PDF names are duplicated",description:`${S} step${S!==1?"s":""} matched more than one file. Remove duplicates before attaching.`,variant:"destructive"});return}const fe=await(await $(`${k}/admin/media/files/attach-pdfs-by-name`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dryRun:!1})})).json();if(!fe.success)throw new Error(fe.error??"PDF attachment failed");const ye=fe.data?.summary??{};C({title:"PDFs attached to course steps",description:`${ye.created??0} created, ${ye.updated??0} updated, ${ye.unchanged??0} already correct.`}),await w()}catch(t){C({title:"PDF attachment failed",description:t instanceof Error?t.message:"Try again after checking file names.",variant:"destructive"})}finally{Ce(!1)}}const[re,ke]=d.useState("all"),[Y,Fe]=d.useState(""),[B,De]=d.useState("date"),[he,oe]=d.useState("desc"),[K,ze]=d.useState(""),[q,$e]=d.useState(""),[Z,Ae]=d.useState(""),[X,Te]=d.useState(""),[ie,Me]=d.useState("");function Ye(t){t===B?oe(n=>n==="asc"?"desc":"asc"):(De(t),oe("desc"))}function Ee(){ke("all"),Fe(""),De("date"),oe("desc"),ze(""),$e(""),Ae(""),Te(""),x(""),Me("")}const Q=(()=>{let t=b;return i!=="all"&&(t=t.filter(n=>n.folderId===i)),l&&(t=t.filter(n=>n.title.toLowerCase().includes(l.toLowerCase()))),re==="ready"?t=t.filter(n=>n.status===4):re==="processing"?t=t.filter(n=>n.status>=1&&n.status<=3):re==="failed"&&(t=t.filter(n=>n.status>=5)),K&&(t=t.filter(n=>{const o=n.originalDate??n.dateUploaded;return new Date(o)>=new Date(K)})),q&&(t=t.filter(n=>{const o=n.originalDate??n.dateUploaded;return new Date(o)<=new Date(q+"T23:59:59")})),Z&&(t=t.filter(n=>n.storageSize>=Number(Z)*1024*1024)),X&&(t=t.filter(n=>n.storageSize<=Number(X)*1024*1024)),t=[...t].sort((n,o)=>{let v=0;if(B==="name")v=n.title.localeCompare(o.title);else if(B==="size")v=(n.storageSize??0)-(o.storageSize??0);else if(B==="duration")v=(n.length??0)-(o.length??0);else{const S=n.originalDate??n.dateUploaded,Re=o.originalDate??o.dateUploaded;v=new Date(S).getTime()-new Date(Re).getTime()}return he==="asc"?v:-v}),t})();function Pe(t,n){return i!=="all"&&(t=t.filter(o=>o.folderId===i)),ie&&(t=t.filter(o=>o.name.toLowerCase().includes(ie.toLowerCase()))),Y&&(n?t=t.filter(o=>o.contentType.split("/").pop()?.toLowerCase()===Y||o.contentType.includes(Y)):t=t.filter(o=>o.contentType.includes(Y))),K&&(t=t.filter(o=>new Date(o.uploadedAt)>=new Date(K))),q&&(t=t.filter(o=>new Date(o.uploadedAt)<=new Date(q+"T23:59:59"))),Z&&(t=t.filter(o=>o.size>=Number(Z)*1024*1024)),X&&(t=t.filter(o=>o.size<=Number(X)*1024*1024)),t=[...t].sort((o,v)=>{let S=0;return B==="name"?S=o.name.localeCompare(v.name):B==="size"?S=o.size-v.size:S=new Date(o.uploadedAt).getTime()-new Date(v.uploadedAt).getTime(),he==="asc"?S:-S}),t}const de=A.filter(t=>t.contentType.startsWith("image/")),ce=A.filter(t=>!t.contentType.startsWith("image/")&&!t.contentType.startsWith("video/")),ee=Pe(de,!0),te=Pe(ce,!1),Ke=Object.fromEntries(y.map(t=>[t.id,b.filter(n=>n.folderId===t.id).length])),qe=Object.fromEntries(y.map(t=>[t.id,de.filter(n=>n.folderId===t.id).length])),Ze=Object.fromEntries(y.map(t=>[t.id,ce.filter(n=>n.folderId===t.id).length])),xe=re!=="all"||!!Y||!!K||!!q||!!Z||!!X,Xe=[{id:"videos",label:"Videos",icon:e.jsx(tt,{size:14}),count:g.length},{id:"images",label:"Images",icon:e.jsx(Ie,{size:14}),count:de.length},{id:"documents",label:"Documents",icon:e.jsx(me,{size:14}),count:ce.length}],Le=s==="videos"?c:D,Qe=s==="videos"?l:ie,et=s==="videos"?x:Me;return e.jsx(rt,{children:e.jsxs("div",{className:"max-w-7xl mx-auto
1space-y-5",children:[e.jsxs("div",{className:"flex items-start justify-between flex-wrap gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Media Library"}),e.jsx("p",{className:"text-gray-900 text-sm mt-0.5",children:"Upload and manage all your course media assets"})]}),e.jsxs(ue,{variant:"outline",size:"sm",onClick:()=>{_(),s==="videos"?f():w()},disabled:Le,className:"border-gray-200 text-gray-900 gap-1.5",children:[e.jsx(st,{size:14,className:Le?"animate-spin":""})," Refresh"]})]}),e.jsx("div",{className:"flex gap-1 bg-gray-100 p-1 rounded-xl overflow-x-auto",children:Xe.map(t=>e.jsxs("button",{onClick:()=>{r(t.id),m("all"),Ee()},className:`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-all ${s===t.id?"bg-white text-gray-900 shadow-sm":"text-gray-900 hover:text-gray-700"}`,children:[t.icon,t.label,t.count>0&&e.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${s===t.id?"bg-blue-100 text-blue-700":"bg-gray-200 text-gray-900"}`,children:t.count})]},t.id))}),s==="videos"&&u&&!u.configured&&e.jsxs("div",{className:"bg-amber-50 border border-amber-200 rounded-2xl p-5 flex gap-3",children:[e.jsx(Be,{size:20,className:"text-amber-500 shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-amber-800",children:"Bunny Stream not configured"}),e.jsx("p",{className:"text-sm text-amber-700 mt-1",children:"Add these secrets in the Replit Secrets panel:"}),e.jsx("ul",{className:"mt-2 space-y-1",children:["BUNNY_STREAM_ACCESS_KEY","BUNNY_STREAM_LIBRARY_ID","BUNNY_CDN_HOSTNAME"].map(t=>e.jsx("li",{children:e.jsx("code",{className:"bg-amber-100 text-amber-800 text-xs px-2 py-0.5 rounded",children:t})},t))})]})]}),e.jsxs("div",{className:"flex flex-col md:flex-row gap-4 md:gap-6 items-start",children:[e.jsx(zt,{folders:y,activeFolderId:i,activeTab:s,videoCounts:Ke,imageCounts:qe,docCounts:Ze,totalVideos:b.length,totalImages:de.length,totalDocs:ce.length,onSelect:m,onCreate:U,onRename:I,onDelete:t=>{T(t),i===t&&m("all")}}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-4",children:[e.jsx($t,{tab:s,search:Qe,onSearch:et,videoStatus:re,onVideoStatus:ke,typeFilter:Y,onTypeFilter:Fe,sortField:B,sortDir:he,onSort:Ye,onSortDir:oe,dateFrom:K,dateTo:q,onDateFrom:ze,onDateTo:$e,sizeMin:Z,sizeMax:X,onSizeMin:Ae,onSizeMax:Te,hasActiveFilters:xe,onClear:Ee}),s==="videos"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(lt,{folders:y,defaultFolderId:typeof i=="number"?i:null,onComplete:f}),e.jsx(je,{count:M.size,allCount:Q.length,folders:y,onSelectAll:()=>V(new Set(Q.map(t=>t.guid))),onClear:a,onMove:p,onCreateAndMove:ne}),c?e.jsx(Dt,{}):Q.length===0?e.jsx(be,{icon:e.jsx(Ne,{size:40,className:"text-gray-900 mx-auto mb-3"}),msg:l||xe?"No videos match the current filters":"No videos uploaded yet"}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-xs text-gray-900",children:[Q.length," video",Q.length!==1?"s":""]}),e.jsx("div",{className:"flex flex-col gap-2",children:Q.map(t=>e.jsx(Ct,{video:t,cdnHostname:u?.cdnHostname??"",libraryId:u?.libraryId??"",folders:y,selected:M.has(t.guid),onToggleSelect:()=>G(t.guid),onDelete:j,onAssignFolder:F},t.guid))})]})]}),s==="images"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(_e,{accept:"image/jpeg,image/png,image/gif,image/webp,image/svg+xml",acceptMime:["image/jpeg","image/png","image/gif","image/webp","image/svg+xml"],label:"Drag & drop images here, or click to browse",hint:"Select multiple files â JPG, PNG, GIF, WebP, SVG",isImage:!0,folders:y,defaultFolderId:typeof i=="number"?i:null,onComplete:w}),e.jsx(je,{count:P.size,allCount:ee.length,folders:y,onSelectAll:()=>L(new Set(ee.map(t=>t.id))),onClear:a,onMove:p,onCreateAndMove:ne}),D?e.jsx(Ve,{}):ee.length===0?e.jsx(be,{icon:e.jsx(Ie,{size:40,className:"text-gray-900 mx-auto mb-3"}),msg:ie||xe?"No images match the current filters":"No images uploaded yet"}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-xs text-gray-900",children:[ee.length," image",ee.length!==1?"s":""]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-4",children:ee.map(t=>e.jsx(kt,{file:t,folders:y,selected:P.has(t.id),onToggleSelect:()=>J(t.id),onDelete:h,onAssignFolder:z},t.id))})]})]}),s==="documents"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(_e,{accept:".pdf,.doc,.docx,.ppt,.pptx,.xls,.xlsx",acceptMime:["application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],label:"Drag & drop documents here, or click to browse",hint:"Select multiple files â PDF, Word, Excel, PowerPoint",isImage:!1,folders:y,defaultFolderId:typeof i=="number"?i:null,onComplete:w}),e.jsxs("div",{className:"flex flex-col gap-2 rounded-xl border border-blue-100 bg-blue-50/70 p-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-blue-900",children:"Attach uploaded PDFs to course steps"}),e.jsx("p",{className:"text-xs text-blue-700/80",children:"Matches PDF filenames to course section titles, then creates or updates the sibling PDF step."})]}),e.jsxs(ue,{type:"button",onClick:Je,disabled:R||D,className:"bg-blue-600 hover:bg-blue-700 text-white gap-2",children:[R?e.jsx(He,{size:14,className:"animate-spin"}):e.jsx(me,{size:14}),"Attach PDFs"]})]}),e.jsx(je,{count:P.size,allCount:te.length,folders:y,onSelectAll:()=>L(new Set(te.map(t=>
1t.id))),onClear:a,onMove:p,onCreateAndMove:ne}),D?e.jsx(Ve,{}):te.length===0?e.jsx(be,{icon:e.jsx(me,{size:40,className:"text-gray-900 mx-auto mb-3"}),msg:ie||xe?"No documents match the current filters":"No documents uploaded yet"}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-xs text-gray-900",children:[te.length," document",te.length!==1?"s":""]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-4",children:te.map(t=>e.jsx(Ft,{file:t,folders:y,selected:P.has(t.id),onToggleSelect:()=>J(t.id),onDelete:h,onAssignFolder:z},t.id))})]})]})]})]})]})})}export{Xt 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.