1import{o as v}from"./rolldown-runtime-ChpBd9eV.js";import{Ka as N,Pa as w,ba as U,ga as k,tt as C}from"./chat-page-C-flp553.js";import{M as S,N as L,jt as _,n as P}from"./education-page-Buqr-MLV.js";var s=v(N(),1),e=w(),D=({onClose:u,onSuccess:h,user:i})=>{const{t:a}=k(),[t,r]=(0,s.useState)({title:"",description:"",type:"article",topic:"patterns",content:"",tags:""}),[o,f]=(0,s.useState)(null),[d,m]=(0,s.useState)(!1),[x,y]=(0,s.useState)(0),[b,n]=(0,s.useState)(""),g=async l=>{if(l.preventDefault(),!t.title.trim()){n(a("libraryUpload.titleRequired"));return}if((t.type==="document"||t.type==="presentation"||t.type==="video")&&!o){n(a("libraryUpload.fileRequired"));return}n("");try{m(!0);const c={...t,tags:t.tags.split(",").map(p=>p.trim()).filter(Boolean),authorId:i?.uid,authorName:i?.displayName||i?.email||"Admin"};await L.createResource(c,o,p=>{y(p)}),h()}catch(c){P("library","Resource upload error:",c)}finally{m(!1)}},j=()=>{switch(t.type){case"document":return".pdf,.doc,.docx";case"presentation":return".ppt,.pptx,.key";case"video":return".mp4,.mov,.webm";default:return""}};return(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/70 backdrop-blur-sm",children:(0,e.jsxs)(U.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:"bg-slate-900 rounded-2xl w-full max-w-2xl max-h-[90vh] overflow-y-auto border border-slate-700",children:[(0,e.jsxs)("div",{className:"sticky top-0 bg-slate-900 p-6 border-b border-slate-700 flex items-center justify-between",children:[(0,e.jsx)("h2",{className:"text-xl font-bold text-white",children:a("libraryUpload.title")}),(0,e.jsx)("button",{onClick:u,className:"p-2 hover:bg-slate-700 rounded-lg transition-colors",children:(0,e.jsx)(C,{className:"w-5 h-5 text-slate-400"})})]}),(0,e.jsxs)("form",{onSubmit:g,className:"p-6 space-y-6",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:a("libraryUpload.typeLabel")}),(0,e.jsx)("div",{className:"grid grid-cols-4 gap-3",children:[{id:"article",icon:"ð°"},{id:"document",icon:"ð"},{id:"presentation",icon:"ð"},{id:"video",icon:"ð¬"}].map(l=>(0,e.jsxs)("button",{type:"button",onClick:()=>r({...t,type:l.id}),className:`p-3 rounded-xl border text-center transition-all ${t.type===l.id?"bg-purple-600/20 border-purple-500 text-white":"bg-slate-800/50 border-slate-700 text-slate-400 hover:border-slate-600"}`,children:[(0,e.jsx)("span",{className:"text-2xl",children:l.icon}),(0,e.jsx)("p",{className:"text-xs mt-1",children:a(`libraryUpload.type.${l.id}`)})]},l.id))})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:a("libraryUpload.topicLabel")}),(0,e.jsx)("select",{value:t.topic,onChange:l=>r({...t,topic:l.target.value}),className:"w-full px-4 py-3 bg-slate-800 border border-slate-700 rounded-xl text-white focus:outline-none focus:ring-2 focus:ring-purple-500",children:S.map(l=>(0,e.jsxs)("option",{value:l.id,children:[l.icon," ",a(`libraryUpload.topic.${l.id}`,{defaultValue:l.name})]},l.id))})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:a("libraryUpload.resourceTitle")}),(0,e.jsx)("input",{type:"text",value:t.title,onChange:l=>r({...t,title:l.target.value}),placeholder:a("libraryUpload.titlePlaceholder"),className:"w-full px-4 py-3 bg-slate-800 border border-slate-700 rounded-xl text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-purple-500"})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:a("libraryUpload.descriptionLabel")}),(0,e.jsx)("textarea",{value:t.description,onChange:l=>r({...t,description:l.target.value}),placeholder:a("libraryUpload.descriptionPlaceholder"),rows:3,className:"w-full px-4 py-3 bg-slate-800 border border-slate-700 rounded-xl text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-purple-500 resize-none"})]}),t.type==="article"&&(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:a("libraryUpload.articleContent")}),(0,e.jsx)("textarea",{value:t.content,onChange:l=>r({...t,content:l.target.value}),placeholder:a("libraryUpload.articlePlaceholder"),rows:10,className:"w-full px-4 py-3 bg-slate-800 border border-slate-700 rounded-xl text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-purple-500 resize-none font-mono text-sm"})]}),(t.type==="document"||t.type==="presentation"||t.type==="video")&&(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:a(`libraryUpload.upload.${t.type}`)}),(0,e.jsxs)("div",{className:"border-2 border-dashed border-slate-700 rounded-xl p-6 text-center hover:border-purple-500/50 transition-colors",children:[(0,e.jsx)("input",{type:"file",accept:j(),onChange:l=>f(l.target.files[0]),className:"hidden",id:"file-upload"}),(0,e.jsxs)("label",{htmlFor:"file-upload",className:"cursor-pointer",children:[(0,e.jsx)(_,{className:"w-12 h-12 mx-auto text-slate-500 mb-3"}),o?(0,e.jsx)("p",{className:"text-white font-medium",children:o.name}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("p",{className:"text-slate-400 mb-1",children:a("libraryUpload.clickOrDrop")}),(0,e.jsxs)("p",{className:"text-xs text-slate-500",children:[t.type==="document"&&a("libraryUpload.documentLimits"),t.type==="presentation"&&a("libraryUpload.presentationLimits"),t.type==="video"&&a("libraryUpload.videoLimits")]})]})]})]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:a("libraryUpload.tagsLabel")}),(0,e.jsx)("input",{type:"text",value:t.tags,onChange:l=>r({...t,tags:l.target.value}),placeholder:a("libraryUpload.tagsPlaceholder"),className:"w-full px-4 py-3 bg-slate-800 border border-slate-700 rounded-xl text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-purple-500"})]}),d&&(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)("div",{className:"flex justify-between text-sm",children:[(0,e.jsx)("span",{className:"text-slate-400",children:a("libraryUpload.uploading")}),(0,e.jsxs)("span",{className:"text-purple-400",children:[Math.round(x),"%"]})]}),(0,e.jsx)("div",{className:"h-2 bg-slate-700 rounded-full overflow-hidden",children:(0,e.jsx)("div",{className:"h-full bg-gradient-to-r from-purple-600 to-blue-600 transition-all",style:{width:`${x}%`}})})]}),b&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-red-300",children:b}),(0,e.jsxs)("div",{className:"flex gap-3 pt-4",children:[(0,e.jsx)("button",{type:"button",onClick:u,className:"flex-1 px-6 py-3 bg-slate-700 hover:bg-slate-600 text-white rounded-xl font-medium transition-colors",children:a("libraryUpload.cancel")}),(0,e.jsx)("button",{type:"submit",disabled:d,className:"flex-1 px-6 py-3 bg-gradient-to-r from-purple-600 to-blue-600 hover:from-purple-500 hover:to-blue-500 text-white rounded-xl font-medium transition-all disabled:opacity-50 disabled:cursor-not-allowed",children:a(d?"libraryUpload.uploading":"libraryUpload.publish")})]})]})]})})};export{D 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.