(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[405],{9013:function(e,t,a){"use strict";a.d(t,{Z:function(){return r}});/**
 * @license lucide-react v0.344.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let r=(0,a(4297).Z)("Hexagon",[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}]])},8312:function(e,t,a){(window.__NEXT_P=window.__NEXT_P||[]).push(["/",function(){return a(3124)}])},3124:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return K}});var r=a(5893),s=a(7294),n=a(9008),o=a.n(n),i=a(1664),l=a.n(i),c=a(9013),d=a(7764),x=a(4297);/**
 * @license lucide-react v0.344.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let m=(0,x.Z)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),p=e=>{let{user:t,onOpenCreate:a,onProfileClick:s,searchQuery:n,onSearch:o}=e,i=encodeURIComponent("<svg xmlns='http://www.w3.org/2000/svg' width='64' height='64'><rect width='100%' height='100%' fill='#0b0b0b'/><circle cx='32' cy='32' r='28' fill='#111' stroke='#39ff14'/><text x='50%' y='56%' dominant-baseline='middle' text-anchor='middle' fill='#39ff14' font-size='18' font-family='monospace'>NM</text></svg>"),x=t&&t.avatarUrl&&t.avatarUrl.trim()?t.avatarUrl:"data:image/svg+xml;utf8,".concat(i);return(0,r.jsxs)("nav",{className:"sticky top-0 z-50 w-full backdrop-blur-md bg-cyber-black/80 border-b border-cyber-glass",children:[(0,r.jsx)("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:(0,r.jsxs)("div",{className:"flex items-center justify-between h-16",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 group cursor-pointer",onClick:()=>window.location.hash="",children:[(0,r.jsx)(c.Z,{className:"text-cyber-neon w-8 h-8 group-hover:rotate-180 transition-transform duration-700"}),(0,r.jsxs)("span",{className:"text-2xl font-mono font-bold tracking-tighter text-white",children:["NEXUS_MAT",(0,r.jsx)("span",{className:"text-cyber-neon",children:".OS"})]})]}),(0,r.jsx)("div",{className:"hidden md:flex flex-1 max-w-lg mx-8",children:(0,r.jsxs)("div",{className:"relative w-full",children:[(0,r.jsx)("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:(0,r.jsx)(d.Z,{className:"h-4 w-4 text-gray-500"})}),(0,r.jsx)("input",{type:"text",className:"block w-full pl-10 pr-3 py-2 border border-cyber-panel rounded-sm leading-5 bg-cyber-dark text-gray-300 placeholder-gray-600 focus:outline-none focus:border-cyber-neon focus:ring-1 focus:ring-cyber-neon sm:text-sm font-mono transition-all",placeholder:"SEARCH_PROTOCOL...",value:null!=n?n:"",onChange:e=>null==o?void 0:o(e.target.value)})]})}),(0,r.jsx)("div",{className:"flex items-center gap-4",children:t?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("button",{onClick:a,className:"flex items-center gap-2 px-4 py-2 bg-cyber-neon/10 border border-cyber-neon text-cyber-neon hover:bg-cyber-neon hover:text-black transition-all duration-300 font-mono text-sm uppercase tracking-wide group",children:[(0,r.jsx)(m,{className:"w-4 h-4 group-hover:rotate-90 transition-transform"}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"Upload_Data"})]}),(0,r.jsxs)("div",{onClick:s,className:"relative cursor-pointer group",children:[(0,r.jsx)("div",{className:"w-10 h-10 rounded-full border border-cyber-panel overflow-hidden bg-cyber-panel group-hover:border-cyber-pink group-hover:shadow-[0_0_15px_rgba(255,0,85,0.4)] transition-all duration-300",children:(0,r.jsx)("img",{src:x,alt:"User",width:40,height:40,className:"w-full h-full object-cover"})}),(0,r.jsx)("div",{className:"absolute bottom-0 right-0 w-3 h-3 bg-cyber-neon rounded-full border-2 border-black"})]})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l(),{href:"/auth/login",className:"flex items-center gap-2 px-4 py-2 bg-cyber-neon/10 border border-cyber-neon text-cyber-neon hover:bg-cyber-neon hover:text-black transition-all duration-300 font-mono text-sm uppercase tracking-wide",children:(0,r.jsx)("span",{children:"Login"})}),(0,r.jsx)(l(),{href:"/auth/register",className:"flex items-center gap-2 px-4 py-2 bg-cyber-pink text-white hover:bg-white hover:text-black transition-all duration-300 font-mono text-sm uppercase tracking-wide",children:(0,r.jsx)("span",{children:"Register"})})]})})]})}),(0,r.jsx)("div",{className:"h-[1px] w-full bg-gradient-to-r from-transparent via-cyber-neon/50 to-transparent"})]})};var h=a(5675),u=a.n(h),b=a(3789);/**
 * @license lucide-react v0.344.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let y=(0,x.Z)("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]),g=(0,x.Z)("Video",[["path",{d:"m22 8-6 4 6 4V8Z",key:"50v9me"}],["rect",{width:"14",height:"12",x:"2",y:"6",rx:"2",ry:"2",key:"1rqjg6"}]]),f=(0,x.Z)("Package",[["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]]);var v=a(7338);/**
 * @license lucide-react v0.344.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let w=(0,x.Z)("Eye",[["path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z",key:"rwhkz3"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),j=(0,x.Z)("Heart",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}]]),N=e=>{var t;let{material:a,onClick:s,currentUser:n}=e,o=a.type===b.x.CODE?y:a.type===b.x.VIDEO?g:f,i=a.type===b.x.CODE?"text-cyber-blue":a.type===b.x.VIDEO?"text-cyber-pink":"text-cyber-neon",l=a.type===b.x.CODE?"hover:border-cyber-blue/50":a.type===b.x.VIDEO?"hover:border-cyber-pink/50":"hover:border-cyber-neon/50",c=n&&(null===(t=a.favorites)||void 0===t?void 0:t.some(e=>e.userId===n.id)),d=encodeURIComponent("<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32'><rect width='100%' height='100%' fill='#0b0b0b'/><circle cx='16' cy='16' r='14' fill='#111' stroke='#39ff14'/><text x='50%' y='56%' dominant-baseline='middle' text-anchor='middle' fill='#39ff14' font-size='12' font-family='monospace'>NM</text></svg>"),x=a.author.avatarUrl&&a.author.avatarUrl.trim()?a.author.avatarUrl:"data:image/svg+xml;utf8,".concat(d);return(0,r.jsxs)("div",{onClick:()=>s(a.id),className:"group relative bg-cyber-panel/40 backdrop-blur-sm border border-white/5 ".concat(l," overflow-hidden cursor-pointer transition-all duration-500 hover:-translate-y-1 hover:shadow-2xl hover:shadow-cyber-neon/5"),children:[(0,r.jsx)("div",{className:"absolute top-0 right-0 p-2",children:(0,r.jsx)(o,{className:"w-5 h-5 ".concat(i," opacity-50 group-hover:opacity-100 transition-opacity")})}),(0,r.jsxs)("div",{className:"p-6 h-full flex flex-col",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,r.jsx)("div",{className:"text-[10px] font-mono text-gray-500 uppercase tracking-widest border border-gray-800 px-1 rounded",children:a.type}),a.language&&(0,r.jsxs)("div",{className:"text-[10px] font-mono text-cyber-blue uppercase tracking-widest px-1",children:[".",a.language]})]}),(0,r.jsx)("h3",{className:"text-xl font-bold text-gray-100 mb-2 font-mono group-hover:text-cyber-neon transition-colors line-clamp-1",children:a.title}),(0,r.jsx)("p",{className:"text-sm text-gray-400 mb-6 line-clamp-2 flex-grow font-sans",children:a.description}),(0,r.jsxs)("div",{className:"w-full h-24 bg-black/50 mb-4 rounded border border-white/5 p-2 font-mono text-xs text-gray-600 overflow-hidden relative",children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-gradient-to-b from-transparent to-black/80 pointer-events-none"}),a.type===b.x.CODE?(0,r.jsx)("pre",{children:a.codeSnippet}):(0,r.jsx)("div",{className:"flex items-center justify-center h-full text-cyber-pink opacity-50",children:(0,r.jsx)(v.Z,{size:24})})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between pt-4 border-t border-white/5 text-xs font-mono text-gray-500",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsxs)("span",{className:"flex items-center gap-1 hover:text-white",children:[(0,r.jsx)(w,{size:12})," ",a.stats.views]}),(0,r.jsxs)("span",{className:"flex items-center gap-1 ".concat(c?"text-cyber-pink":"hover:text-cyber-pink"),children:[(0,r.jsx)(j,{size:12,className:c?"fill-cyber-pink":""}),a.stats.favorites]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(u(),{src:x,alt:"author",width:20,height:20,className:"w-5 h-5 rounded-full border border-gray-700"}),(0,r.jsx)("span",{className:"opacity-75",children:a.author.username})]})]})]}),(0,r.jsx)("div",{className:"absolute bottom-0 left-0 w-0 h-[2px] bg-cyber-neon group-hover:w-full transition-all duration-500 ease-out"})]})};var k=a(1352);/**
 * @license lucide-react v0.344.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let S=(0,x.Z)("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]),E=(0,x.Z)("Cpu",[["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"9",y:"9",width:"6",height:"6",key:"o3kz5p"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]]),A=(0,x.Z)("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),C=(0,x.Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]),O=(0,x.Z)("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]),D=(0,x.Z)("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);var I=a(3982),M=a(1426);let U="your_google_api_key_here",T=null;U&&(T=new M.fA({apiKey:U}));let P={isEnabled:!!U,analyzeCode:async e=>{if(!T)return{description:"AI Unavailable (Missing Key)",tags:[]};try{let t=(await T.models.generateContent({model:"gemini-2.5-flash",contents:"Analyze this code snippet. Return a JSON object with a 'description' (max 50 words, technical style) and 'tags' (array of strings, max 5). Code: \n\n".concat(e),config:{responseMimeType:"application/json"}})).text;if(!t)return{description:"Analysis failed",tags:[]};let a=JSON.parse(t);return{description:a.description||"No description generated.",tags:a.tags||[]}}catch(e){return console.error("Gemini Error:",e),{description:"Error during AI analysis.",tags:[]}}},explainCode:async e=>{if(!T)return"AI Configuration Missing.";try{return(await T.models.generateContent({model:"gemini-2.5-flash",contents:"Explain this code snippet like a senior engineer doing a code review. Be concise, point out optimizations if any. Code: \n".concat(e)})).text||"No explanation available."}catch(e){return"Failed to generate explanation."}}};var _=a(9189);let L=e=>{let{id:t,onClose:a,currentUser:n}=e,[o,i]=(0,s.useState)(null),[l,c]=(0,s.useState)(!0),[d,x]=(0,s.useState)(""),[m,p]=(0,s.useState)(""),[h,y]=(0,s.useState)(!1),[g,v]=(0,s.useState)(!1),w=(0,_.p)(),N=(0,s.useCallback)(async()=>{try{c(!0);let e=await I.D.getMaterialById(t);i(e)}catch(e){w.error("Failed to load material details"),console.error("Error loading material:",e)}finally{c(!1)}},[t,w]);(0,s.useEffect)(()=>{N()},[N]);let M=async()=>{if(null==o?void 0:o.codeSnippet)try{v(!0);let e=await P.explainCode(o.codeSnippet);p(e)}catch(e){w.error("AI analysis failed"),console.error("Error getting AI analysis:",e)}finally{v(!1)}},U=async()=>{if(d.trim()&&o)try{await I.D.addComment(o.id,d),x(""),w.success("Comment added"),N()}catch(e){w.error("Please login to comment")}},T=async()=>{if(confirm("CONFIRM DELETION PROTOCOL?"))try{await I.D.deleteMaterial(t),w.success("Material deleted"),a()}catch(e){w.error((null==e?void 0:e.message)||"Only author/admin can delete")}};return l?(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-cyber-black/90 text-cyber-neon font-mono",children:"LOADING_ASSET..."}):o?(0,r.jsx)("div",{className:"fixed inset-0 z-40 overflow-y-auto bg-black/60 backdrop-blur-md flex items-center justify-center p-4",children:(0,r.jsxs)("div",{className:"bg-cyber-dark border border-cyber-panel w-full max-w-5xl rounded-lg shadow-2xl shadow-black relative flex flex-col md:flex-row overflow-hidden max-h-[90vh]",children:[(0,r.jsx)("button",{onClick:a,className:"absolute top-4 right-4 z-50 p-2 bg-black/50 rounded-full hover:bg-cyber-pink hover:text-white transition-colors text-gray-400",children:(0,r.jsx)(k.Z,{size:20})}),(0,r.jsxs)("div",{className:"w-full md:w-2/3 bg-black/40 border-r border-cyber-panel flex flex-col overflow-hidden",children:[(0,r.jsxs)("div",{className:"p-6 border-b border-cyber-panel",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 mb-2",children:[(0,r.jsx)("span",{className:"px-2 py-0.5 bg-cyber-neon/10 text-cyber-neon text-xs font-mono rounded border border-cyber-neon/20",children:o.type}),(0,r.jsx)("h1",{className:"text-2xl font-bold font-mono text-white",children:o.title})]}),(0,r.jsx)("div",{className:"flex flex-wrap gap-2 mt-2",children:o.tags.map(e=>(0,r.jsxs)("span",{className:"text-xs text-gray-500 font-mono",children:["#",e]},e))})]}),(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto p-6 bg-cyber-black/50 relative group",children:[o.type===b.x.CODE&&(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("pre",{className:"font-mono text-sm text-gray-300 p-4 bg-[#0d0d0d] rounded border border-gray-800 overflow-x-auto whitespace-pre-wrap",children:o.codeSnippet}),(0,r.jsx)("button",{onClick:()=>{(null==o?void 0:o.codeSnippet)&&(navigator.clipboard.writeText(o.codeSnippet),w.success("Code copied to clipboard"))},className:"absolute top-2 right-2 p-2 bg-cyber-panel rounded hover:text-cyber-neon transition-colors",children:(0,r.jsx)(S,{size:16})})]}),o.type===b.x.VIDEO&&(0,r.jsxs)("div",{className:"aspect-video bg-black flex items-center justify-center border border-gray-800 relative overflow-hidden",children:[(0,r.jsx)("video",{src:o.contentUrl,controls:!0,className:"w-full h-full object-cover opacity-80 hover:opacity-100 transition-opacity"}),(0,r.jsx)("div",{className:"absolute inset-0 pointer-events-none bg-gradient-to-t from-black/50 to-transparent"})]}),o.type===b.x.ASSET_ZIP&&(0,r.jsxs)("div",{className:"h-64 flex flex-col items-center justify-center border-2 border-dashed border-gray-700 rounded-lg bg-gray-900/20",children:[(0,r.jsx)(f,{size:64,className:"text-cyber-neon mb-4 animate-pulse-fast"}),(0,r.jsx)("p",{className:"font-mono text-gray-400",children:"ENCRYPTED_ARCHIVE.ZIP"})]}),o.type===b.x.CODE&&(0,r.jsxs)("div",{className:"mt-6 border-t border-cyber-panel pt-6",children:[(0,r.jsxs)("button",{onClick:M,disabled:g,className:"flex items-center gap-2 text-xs font-mono text-cyber-blue hover:text-white transition-colors disabled:opacity-50 mb-2",children:[(0,r.jsx)(E,{size:14}),g?"ANALYZING_NEURAL_NET...":"AI_CODE_REVIEW"]}),m&&(0,r.jsx)("div",{className:"bg-cyber-blue/5 border-l-2 border-cyber-blue p-4 text-sm text-gray-300 font-sans",children:(0,r.jsx)("p",{className:"whitespace-pre-line",children:m})})]})]}),(0,r.jsxs)("div",{className:"p-4 border-t border-cyber-panel bg-cyber-panel/30 flex justify-between items-center",children:[(0,r.jsxs)("div",{className:"flex gap-4",children:[(0,r.jsxs)("button",{onClick:()=>I.D.toggleFavorite(o.id).then(()=>N()),className:"flex items-center gap-2 text-gray-400 hover:text-cyber-pink transition-colors",children:[(0,r.jsx)(j,{size:20,className:o.stats.favorites>0?"fill-cyber-pink text-cyber-pink":""}),(0,r.jsx)("span",{className:"font-mono text-sm",children:o.stats.favorites})]}),(0,r.jsx)("button",{className:"flex items-center gap-2 text-gray-400 hover:text-white transition-colors",children:(0,r.jsx)(A,{size:20})})]}),(0,r.jsxs)("div",{className:"flex gap-3",children:[(null==n?void 0:n.id)===o.author.id&&(0,r.jsx)("button",{onClick:T,className:"p-2 text-red-500 hover:bg-red-900/20 rounded",children:(0,r.jsx)(C,{size:18})}),(0,r.jsxs)("button",{onClick:()=>{w.info("Preparing secure download for protocol: ".concat(null==o?void 0:o.id))},className:"flex items-center gap-2 px-6 py-2 bg-cyber-neon text-black font-bold font-mono text-sm hover:bg-white transition-colors",children:[(0,r.jsx)(O,{size:16})," DOWNLOAD_ASSET"]})]})]})]}),(0,r.jsxs)("div",{className:"w-full md:w-1/3 bg-cyber-dark flex flex-col",children:[(0,r.jsxs)("div",{className:"p-6 border-b border-cyber-panel flex items-center gap-4",children:[(0,r.jsx)(u(),{src:((e,t)=>{if(t&&t.trim())return t;let a=encodeURIComponent("<svg xmlns='http://www.w3.org/2000/svg' width='48' height='48'><rect width='100%' height='100%' fill='#0b0b0b'/><circle cx='24' cy='24' r='21' fill='#111' stroke='#39ff14'/><text x='50%' y='56%' dominant-baseline='middle' text-anchor='middle' fill='#39ff14' font-size='14' font-family='monospace'>NM</text></svg>");return"data:image/svg+xml;utf8,".concat(a)})(o.author.username,o.author.avatarUrl),alt:"author",width:48,height:48,className:"w-12 h-12 rounded-full ring-2 ring-cyber-panel"}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"font-mono text-white font-bold",children:o.author.username}),(0,r.jsxs)("p",{className:"text-xs text-gray-500",children:["Joined ",new Date(o.author.createdAt).toLocaleDateString()]})]})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-px bg-cyber-panel border-b border-cyber-panel",children:[(0,r.jsxs)("div",{className:"bg-cyber-dark p-4 text-center",children:[(0,r.jsx)("p",{className:"text-xs text-gray-500 font-mono mb-1",children:"VIEWS"}),(0,r.jsx)("p",{className:"text-xl text-white font-bold",children:o.stats.views})]}),(0,r.jsxs)("div",{className:"bg-cyber-dark p-4 text-center",children:[(0,r.jsx)("p",{className:"text-xs text-gray-500 font-mono mb-1",children:"DOWNLOADS"}),(0,r.jsx)("p",{className:"text-xl text-white font-bold",children:o.stats.downloads})]})]}),(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto p-4 flex flex-col gap-4",children:[(0,r.jsxs)("h4",{className:"text-xs font-mono text-gray-500 uppercase",children:["Comm_Log (",o.comments.length,")"]}),o.comments.map(e=>(0,r.jsxs)("div",{className:"bg-cyber-panel/50 p-3 rounded border border-white/5",children:[(0,r.jsxs)("div",{className:"flex justify-between items-start mb-2",children:[(0,r.jsx)("span",{className:"text-cyber-neon text-xs font-bold",children:e.author.username}),(0,r.jsx)("span",{className:"text-[10px] text-gray-600",children:new Date(e.createdAt).toLocaleDateString()})]}),(0,r.jsx)("p",{className:"text-sm text-gray-300",children:e.content})]},e.id)),0===o.comments.length&&(0,r.jsx)("div",{className:"text-center py-10 opacity-30 text-xs font-mono",children:"NO_TRANSMISSIONS_YET"})]}),(0,r.jsx)("div",{className:"p-4 border-t border-cyber-panel bg-cyber-panel/20",children:(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("textarea",{value:d,onChange:e=>x(e.target.value),className:"w-full bg-black/50 border border-cyber-panel rounded p-3 text-sm text-white focus:border-cyber-neon focus:outline-none resize-none h-20 font-sans",placeholder:"Enter secure message..."}),(0,r.jsx)("button",{onClick:U,className:"absolute bottom-2 right-2 p-1.5 bg-cyber-neon text-black rounded hover:bg-white transition-colors",children:(0,r.jsx)(D,{size:14})})]})})]})]})}):null},R=(0,x.Z)("Wand2",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72Z",key:"1bcowg"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]),z=(0,x.Z)("UploadCloud",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M12 12v9",key:"192myk"}],["path",{d:"m16 16-4-4-4 4",key:"119tzi"}]]),Z=e=>{let{onClose:t,onSuccess:a}=e,n=(0,_.p)(),[o,i]=(0,s.useState)({title:"",description:"",type:b.x.CODE,codeSnippet:"",tags:[]}),[l,c]=(0,s.useState)(null),[d,x]=(0,s.useState)(null),[m,p]=(0,s.useState)(!1);(0,s.useEffect)(()=>{I.D.getCurrentUser().then(x).catch(()=>x(null))},[]);let h=async()=>{if(!o.codeSnippet)return;p(!0);let{description:e,tags:t}=await P.analyzeCode(o.codeSnippet);i(a=>({...a,description:e,tags:[...a.tags,...t]})),p(!1)},u=async e=>{e.preventDefault(),p(!0);try{if(o.type===b.x.CODE)await I.D.createMaterial(o);else if(o.type===b.x.ASSET_ZIP){if(!l)throw Error("Please select ZIP file");if(l.size>3145728)throw Error("ZIP must be ≤ 3MB");await I.D.uploadZip(l,{title:o.title,description:o.description,tags:o.tags})}else if(o.type===b.x.VIDEO){if(!((null==d?void 0:d.role)==="MANAGER"||(null==d?void 0:d.role)==="ADMIN"))throw Error("Manager role required");if(!l)throw Error("Please select video file");await I.D.uploadVideo(l,{title:o.title,description:o.description,tags:o.tags})}a()}catch(e){n.error(e.message||"Upload failed")}finally{p(!1)}};return(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm p-4",children:(0,r.jsxs)("div",{className:"bg-cyber-dark border border-cyber-neon/30 w-full max-w-2xl rounded-xl shadow-2xl relative overflow-hidden",children:[(0,r.jsx)("div",{className:"h-1 w-full bg-gradient-to-r from-cyber-neon via-cyber-blue to-cyber-pink"}),(0,r.jsxs)("div",{className:"p-8",children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-8",children:[(0,r.jsx)("h2",{className:"text-2xl font-mono font-bold text-white tracking-tight",children:"UPLOAD_NEW_PROTOCOL"}),(0,r.jsx)("button",{onClick:t,className:"text-gray-500 hover:text-white",children:(0,r.jsx)(k.Z,{})})]}),(0,r.jsxs)("form",{onSubmit:u,className:"space-y-6",children:[(0,r.jsx)("div",{className:"flex gap-4",children:Object.values(b.x).map(e=>{let t=e!==b.x.VIDEO||(null==d?void 0:d.role)==="MANAGER"||(null==d?void 0:d.role)==="ADMIN";return(0,r.jsx)("button",{type:"button",onClick:()=>{if(!t){n.error("Manager role required");return}i({...o,type:e})},className:"flex-1 py-3 text-xs font-mono border ".concat(o.type===e?"bg-cyber-neon/20 border-cyber-neon text-cyber-neon":"border-cyber-panel text-gray-500 hover:border-gray-500"," ").concat(t?"":"opacity-50 cursor-not-allowed"),children:e},e)})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-xs font-mono text-gray-400 mb-1",children:"TITLE_IDENTIFIER"}),(0,r.jsx)("input",{required:!0,className:"w-full bg-black/50 border border-cyber-panel p-3 text-white focus:border-cyber-neon focus:outline-none",value:o.title,onChange:e=>i({...o,title:e.target.value})})]}),o.type===b.x.CODE?(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("label",{className:"block text-xs font-mono text-gray-400 mb-1",children:"SOURCE_CODE"}),(0,r.jsx)("textarea",{required:!0,className:"w-full h-40 bg-black/50 border border-cyber-panel p-3 text-xs font-mono text-cyber-blue focus:border-cyber-blue focus:outline-none",value:o.codeSnippet,onChange:e=>i({...o,codeSnippet:e.target.value})}),(0,r.jsxs)("button",{type:"button",onClick:h,disabled:!o.codeSnippet||m,className:"absolute bottom-2 right-2 px-3 py-1 bg-cyber-blue/20 text-cyber-blue border border-cyber-blue/50 text-xs font-mono flex items-center gap-2 hover:bg-cyber-blue hover:text-black transition-colors",children:[(0,r.jsx)(R,{size:12})," ",m?"SCANNING...":"AI_AUTO_FILL"]})]}):(0,r.jsxs)("div",{children:[(0,r.jsxs)("label",{className:"block text-xs font-mono text-gray-400 mb-1",children:["LOCAL_FILE ",o.type===b.x.ASSET_ZIP?"(ZIP ≤ 3MB)":"(Video ≤ 3MB)"]}),(0,r.jsxs)("label",{className:"relative w-full block bg-black/50 border border-cyber-panel p-3 text-gray-400 hover:border-cyber-neon cursor-pointer transition-colors",children:[(0,r.jsx)("input",{required:!0,type:"file",accept:o.type===b.x.ASSET_ZIP?".zip,application/zip":"video/*,.mp4,.webm,.mov",className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer",onChange:e=>{var t;return c((null===(t=e.target.files)||void 0===t?void 0:t[0])||null)}}),(0,r.jsxs)("span",{className:"flex items-center gap-2",children:[(0,r.jsx)(z,{size:16}),l?l.name:"点击或拖拽文件到此处"]})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-xs font-mono text-gray-400 mb-1",children:"DESCRIPTION"}),(0,r.jsx)("textarea",{className:"w-full h-24 bg-black/50 border border-cyber-panel p-3 text-sm text-gray-300 focus:border-cyber-neon focus:outline-none",value:o.description,onChange:e=>i({...o,description:e.target.value})})]}),(0,r.jsx)("button",{type:"submit",disabled:m,className:"w-full py-4 bg-cyber-neon text-black font-bold font-mono tracking-widest hover:bg-white transition-colors flex items-center justify-center gap-2",children:m?"UPLOADING...":(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(z,{size:20})," INITIALIZE_UPLOAD"]})})]})]})]})})};var V=a(4009);/**
 * @license lucide-react v0.344.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let F=(0,x.Z)("Grid3x3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]),G=(0,x.Z)("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]),q=(0,x.Z)("Calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);var B=a(3696),H=a(8051);let J=e=>{let{user:t,onClose:a,onUpdate:n}=e,[o,i]=(0,s.useState)({username:t.username,avatarUrl:t.avatarUrl}),[l,c]=(0,s.useState)(!1),[d,x]=(0,s.useState)("info"),[m,p]=(0,s.useState)([]),[h,b]=(0,s.useState)([]),[y,g]=(0,s.useState)(!1),[v,w]=(0,s.useState)(1),[S,E]=(0,s.useState)(1),[A,C]=(0,s.useState)(0),[O,D]=(0,s.useState)(!1),[M,U]=(0,s.useState)(0),[T,P]=(0,s.useState)(!1),L=(0,_.p)(),R=encodeURIComponent("<svg xmlns='http://www.w3.org/2000/svg' width='64' height='64'><rect width='100%' height='100%' fill='#0b0b0b'/><circle cx='32' cy='32' r='28' fill='#111' stroke='#39ff14'/><text x='50%' y='56%' dominant-baseline='middle' text-anchor='middle' fill='#39ff14' font-size='18' font-family='monospace'>NM</text></svg>"),z=(0,s.useCallback)(async()=>{try{g(!0);let e=await I.D.getUserFavorites(S,20);b(e.items),U(e.total),P(e.hasNext)}catch(e){L.error("Failed to load favorites")}finally{g(!1)}},[L,S]),Z=(0,s.useCallback)(async()=>{try{g(!0);let e=await I.D.getUserMaterials(v,20);p(e.items),C(e.total),D(e.hasNext)}catch(e){L.error("Failed to load materials")}finally{g(!1)}},[L,v]);(0,s.useEffect)(()=>{"created"===d?Z():"favorites"===d&&z()},[d,z,Z]);let J=async e=>{e.preventDefault();try{c(!0),await I.D.updateUserProfile(t.id,o),L.success("Profile updated"),n(),a()}catch(e){L.error("Failed to update profile")}finally{c(!1)}},Y=async()=>{try{await fetch("/api/v1/auth/logout",{method:"POST"}),localStorage.removeItem("NEXUS_DATA_MODE"),window.location.href="/auth/login"}catch(e){L.error("Logout failed")}};return(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-md p-4",children:(0,r.jsxs)("div",{className:"bg-cyber-dark border border-cyber-pink/30 w-[900px] h-[640px] rounded-lg shadow-[0_0_50px_rgba(255,0,85,0.15)] relative overflow-hidden flex flex-col",children:[(0,r.jsx)("div",{className:"absolute inset-0 opacity-10 pointer-events-none",style:{backgroundImage:"radial-gradient(circle at 2px 2px, rgba(255,0,85,0.5) 1px, transparent 0)",backgroundSize:"24px 24px"}}),(0,r.jsx)("button",{onClick:a,className:"absolute top-4 right-4 z-50 text-gray-500 hover:text-white transition-colors",children:(0,r.jsx)(k.Z,{size:20})}),(0,r.jsxs)("div",{className:"border-b border-cyber-panel p-6",children:[(0,r.jsxs)("div",{className:"flex items-center gap-4 mb-6",children:[(0,r.jsxs)("div",{className:"relative w-16 h-16",children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-cyber-pink rounded-full blur-lg opacity-20"}),(0,r.jsx)(u(),{src:o.avatarUrl&&o.avatarUrl.trim()?o.avatarUrl:t.avatarUrl&&t.avatarUrl.trim()?t.avatarUrl:"data:image/svg+xml;utf8,".concat(R),alt:"Profile",width:64,height:64,className:"w-full h-full rounded-full border-2 border-cyber-pink object-cover relative z-10"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{className:"text-2xl font-bold font-mono text-white",children:o.username}),(0,r.jsxs)("p",{className:"text-xs text-gray-500 font-mono",children:[t.role," • ",t.status]})]})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsxs)("button",{onClick:()=>x("info"),className:"px-4 py-2 font-mono text-sm transition-all ".concat("info"===d?"bg-cyber-pink text-black":"text-gray-400 hover:text-white"),children:[(0,r.jsx)(V.Z,{size:14,className:"inline mr-2"}),"INFO"]}),(0,r.jsxs)("button",{onClick:()=>x("created"),className:"px-4 py-2 font-mono text-sm transition-all ".concat("created"===d?"bg-cyber-pink text-black":"text-gray-400 hover:text-white"),children:[(0,r.jsx)(F,{size:14,className:"inline mr-2"}),"CREATED (",A,")"]}),(0,r.jsxs)("button",{onClick:()=>x("favorites"),className:"px-4 py-2 font-mono text-sm transition-all ".concat("favorites"===d?"bg-cyber-pink text-black":"text-gray-400 hover:text-white"),children:[(0,r.jsx)(j,{size:14,className:"inline mr-2"}),"FAVORITES (",M,")"]})]})]}),(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto p-6",children:["info"===d&&(0,r.jsxs)("form",{onSubmit:J,className:"space-y-6 max-w-[760px]",children:[(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-4 text-sm mb-6",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between border-b border-white/5 pb-2",children:[(0,r.jsxs)("span",{className:"text-gray-500 flex items-center gap-2",children:[(0,r.jsx)(G,{size:12})," STATUS"]}),(0,r.jsx)("span",{className:"text-cyber-neon",children:t.status})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between border-b border-white/5 pb-2",children:[(0,r.jsxs)("span",{className:"text-gray-500 flex items-center gap-2",children:[(0,r.jsx)(q,{size:12})," JOINED"]}),(0,r.jsx)("span",{className:"text-gray-300",children:new Date(t.createdAt).toLocaleDateString()})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-xs font-mono text-cyber-pink/80 mb-2 uppercase",children:"Username"}),(0,r.jsx)("input",{type:"text",value:o.username,onChange:e=>i({...o,username:e.target.value}),className:"w-full bg-black/40 border border-cyber-panel p-3 text-white focus:border-cyber-pink focus:outline-none rounded-sm font-mono text-sm"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-xs font-mono text-cyber-pink/80 mb-2 uppercase",children:"Avatar URL"}),(0,r.jsx)("input",{type:"url",value:o.avatarUrl,onChange:e=>i({...o,avatarUrl:e.target.value}),className:"w-full bg-black/40 border border-cyber-panel p-3 text-white focus:border-cyber-pink focus:outline-none rounded-sm font-mono text-sm"})]}),(0,r.jsxs)("div",{className:"flex gap-4",children:[(0,r.jsx)("button",{type:"submit",disabled:l,className:"flex-1 bg-cyber-pink text-black font-bold font-mono py-3 px-6 hover:bg-white transition-all flex items-center justify-center gap-2",children:l?"SAVING...":(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(B.Z,{size:16})," SAVE CHANGES"]})}),(0,r.jsxs)("button",{type:"button",onClick:Y,className:"px-6 border border-red-500 text-red-500 hover:bg-red-500 hover:text-black transition-all font-mono uppercase text-sm flex items-center gap-2",children:[(0,r.jsx)(H.Z,{size:16})," LOGOUT"]})]})]}),"created"===d&&(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-lg font-mono text-white mb-4",children:"MY CREATIONS"}),(0,r.jsxs)("div",{className:"mb-4 flex gap-2",children:[(0,r.jsx)(W,{onUploaded:()=>Z()}),("MANAGER"===t.role||"ADMIN"===t.role)&&(0,r.jsx)(X,{onUploaded:()=>Z(),userRole:t.role})]}),y?(0,r.jsx)("div",{className:"text-center py-10 text-cyber-neon font-mono",children:"LOADING..."}):m.length>0?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:m.map(e=>(0,r.jsx)(N,{material:e,onClick:()=>{},currentUser:t},e.id))}),(0,r.jsxs)("div",{className:"mt-6 flex items-center justify-center gap-4",children:[(0,r.jsx)("button",{onClick:()=>w(e=>Math.max(1,e-1)),className:"px-3 py-2 border border-white/10 text-gray-400 hover:text-white",children:"Prev"}),(0,r.jsxs)("span",{className:"text-xs font-mono text-gray-500",children:["PAGE ",v," / ",Math.max(1,Math.ceil(A/20))]}),(0,r.jsx)("button",{onClick:()=>w(e=>e+1),disabled:!O,className:"px-3 py-2 border border-white/10 text-gray-400 hover:text-white disabled:opacity-50",children:"Next"})]})]}):(0,r.jsxs)("div",{className:"text-center py-20 border border-dashed border-gray-800 rounded",children:[(0,r.jsx)(f,{size:48,className:"mx-auto text-gray-700 mb-4"}),(0,r.jsx)("p",{className:"text-gray-600 font-mono",children:"NO CREATIONS YET"})]})]}),"favorites"===d&&(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-lg font-mono text-white mb-4",children:"MY FAVORITES"}),y?(0,r.jsx)("div",{className:"text-center py-10 text-cyber-neon font-mono",children:"LOADING..."}):h.length>0?(0,r.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:h.map(e=>(0,r.jsx)(N,{material:e,onClick:()=>{},currentUser:t},e.id))}):(0,r.jsxs)("div",{className:"text-center py-20 border border-dashed border-gray-800 rounded",children:[(0,r.jsx)(j,{size:48,className:"mx-auto text-gray-700 mb-4"}),(0,r.jsx)("p",{className:"text-gray-600 font-mono",children:"NO FAVORITES YET"})]}),(0,r.jsxs)("div",{className:"mt-6 flex items-center justify-center gap-4",children:[(0,r.jsx)("button",{onClick:()=>E(e=>Math.max(1,e-1)),className:"px-3 py-2 border border-white/10 text-gray-400 hover:text-white",children:"Prev"}),(0,r.jsxs)("span",{className:"text-xs font-mono text-gray-500",children:["PAGE ",S," / ",Math.max(1,Math.ceil(M/20))]}),(0,r.jsx)("button",{onClick:()=>E(e=>e+1),disabled:!T,className:"px-3 py-2 border border-white/10 text-gray-400 hover:text-white disabled:opacity-50",children:"Next"})]})]})]})]})})},W=e=>{let{onUploaded:t}=e,a=(0,_.p)(),n=s.useRef(null),[o,i]=(0,s.useState)(!1),l=async e=>{var r;let s=null===(r=e.target.files)||void 0===r?void 0:r[0];if(s){if(s.size>3145728){a.error("ZIP size must be ≤ 3MB");return}i(!0);try{await I.D.uploadZip(s,{title:s.name}),a.success("ZIP uploaded"),t()}catch(e){a.error(e.message||"Upload failed")}finally{i(!1),n.current&&(n.current.value="")}}};return(0,r.jsxs)("div",{children:[(0,r.jsx)("input",{ref:n,type:"file",accept:".zip,application/zip",className:"hidden",onChange:l}),(0,r.jsx)("button",{onClick:()=>{var e;return null===(e=n.current)||void 0===e?void 0:e.click()},disabled:o,className:"px-3 py-2 border border-cyber-neon text-cyber-neon hover:bg-cyber-neon hover:text-black transition-colors text-xs font-mono",children:o?"UPLOADING...":"UPLOAD_ZIP"})]})},X=e=>{let{onUploaded:t,userRole:a}=e,n=(0,_.p)(),o=s.useRef(null),[i,l]=(0,s.useState)(!1),c=!("MANAGER"===a||"ADMIN"===a),d=async e=>{var a;let r=null===(a=e.target.files)||void 0===a?void 0:a[0];if(r){l(!0);try{await I.D.uploadVideo(r,{title:r.name}),n.success("Video uploaded"),t()}catch(e){n.error(e.message||"Upload failed")}finally{l(!1),o.current&&(o.current.value="")}}};return(0,r.jsxs)("div",{children:[(0,r.jsx)("input",{ref:o,type:"file",accept:"video/*,.mp4,.webm,.mov",className:"hidden",onChange:d}),(0,r.jsx)("button",{onClick:()=>{var e;if(c){n.error("Manager role required");return}null===(e=o.current)||void 0===e||e.click()},disabled:i,className:"px-3 py-2 border border-cyber-pink text-cyber-pink hover:bg-cyber-pink hover:text-black transition-colors text-xs font-mono",children:i?"UPLOADING...":"UPLOAD_VIDEO"})]})},Y=(0,x.Z)("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);function K(){let[e,t]=(0,s.useState)([]),[a,n]=(0,s.useState)(1),[i,l]=(0,s.useState)(0),[c,d]=(0,s.useState)(!1),[x,m]=(0,s.useState)(null),[h,u]=(0,s.useState)(null),[b,y]=(0,s.useState)(!1),[g,f]=(0,s.useState)(!1),[v,w]=(0,s.useState)("ALL"),[j,k]=(0,s.useState)(""),S=(0,s.useCallback)(async()=>{try{let e="ALL"===v?"ALL":v,r=await I.D.getMaterials(a,20,e,j);t(r.items),l(r.total),d(r.hasNext)}catch(e){console.error("Failed to load materials",e)}},[a,v,j]),E=(0,s.useCallback)(async()=>{m(await I.D.getCurrentUser())},[]);return(0,s.useEffect)(()=>{(async()=>{await E(),await S()})()},[S,E]),(0,r.jsxs)("div",{className:"min-h-screen pb-20",children:[(0,r.jsx)(o(),{children:(0,r.jsx)("title",{children:"NEXUS_MAT.OS"})}),(0,r.jsx)(p,{user:x,onOpenCreate:()=>y(!0),onProfileClick:()=>f(!0),searchQuery:j,onSearch:e=>{k(e),n(1)}}),(0,r.jsxs)("main",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 pt-8",children:[(0,r.jsxs)("div",{className:"flex flex-col md:flex-row md:items-center justify-between mb-12 gap-6",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"text-4xl md:text-5xl font-bold text-white font-mono tracking-tighter mb-2",children:"GRID_ACCESS"}),(0,r.jsxs)("p",{className:"text-gray-500 font-mono text-sm",children:["INDEXING ",i," RESOURCES FROM THE NETWORK"]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-4 bg-cyber-panel/30 p-2 rounded-lg border border-white/5 backdrop-blur-sm",children:[(0,r.jsx)(Y,{size:16,className:"text-cyber-neon ml-2"}),(0,r.jsx)("div",{className:"flex gap-2",children:["ALL","CODE","VIDEO","ASSET_ZIP"].map(e=>(0,r.jsx)("button",{onClick:()=>{w(e),n(1)},className:"px-3 py-1 text-xs font-mono rounded transition-all ".concat(v===e?"bg-cyber-neon text-black font-bold":"text-gray-400 hover:text-white"),children:e},e))}),(0,r.jsx)("div",{className:"w-[1px] h-6 bg-gray-700 mx-2"}),(0,r.jsx)(F,{size:16,className:"text-gray-400"})]})]}),(0,r.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:e.map(e=>(0,r.jsx)(N,{material:e,onClick:e=>u(e),currentUser:x},e.id))}),(0,r.jsxs)("div",{className:"mt-8 flex items-center justify-center gap-4",children:[(0,r.jsx)("button",{onClick:()=>n(e=>Math.max(1,e-1)),className:"px-3 py-2 border border-white/10 text-gray-400 hover:text-white",children:"Prev"}),(0,r.jsxs)("span",{className:"text-xs font-mono text-gray-500",children:["PAGE ",a," / ",Math.max(1,Math.ceil(i/20))]}),(0,r.jsx)("button",{onClick:()=>n(e=>e+1),disabled:!c,className:"px-3 py-2 border border-white/10 text-gray-400 hover:text-white disabled:opacity-50",children:"Next"})]}),0===e.length&&(0,r.jsx)("div",{className:"text-center py-20 border border-dashed border-gray-800 rounded-xl",children:(0,r.jsx)("p",{className:"text-gray-600 font-mono",children:"NO DATA FOUND IN SECTOR."})})]}),h&&(0,r.jsx)(L,{id:h,onClose:()=>u(null),currentUser:x}),b&&(0,r.jsx)(Z,{onClose:()=>y(!1),onSuccess:()=>{y(!1),S()}}),g&&x&&(0,r.jsx)(J,{user:x,onClose:()=>f(!1),onUpdate:E}),(0,r.jsx)("footer",{className:"fixed bottom-0 left-0 w-full h-1 bg-gradient-to-r from-cyber-neon via-purple-600 to-cyber-blue opacity-50"})]})}},3982:function(e,t,a){"use strict";a.d(t,{D:function(){return m},i:function(){return o}});var r=a(3789);let s="NEXUS_DATA_MODE",n=()=>localStorage.getItem(s)||"MOCK",o=e=>{localStorage.setItem(s,e),window.location.reload()},i={id:"u_001",username:"Neo_Architect",avatarUrl:"https://picsum.photos/seed/neo/200/200",role:r.i.CREATOR,status:"ACTIVE",createdAt:new Date(2023,10,15).toISOString(),lastLogin:new Date().toISOString()},l=[i,{id:"u_002",username:"Visual_Drift",avatarUrl:"https://picsum.photos/seed/drift/200/200",role:r.i.CREATOR,status:"ACTIVE",createdAt:new Date(2023,11,1).toISOString(),lastLogin:new Date().toISOString()},{id:"u_003",username:"Poly_Master",avatarUrl:"https://picsum.photos/seed/poly/200/200",role:r.i.USER,status:"FLAGGED",createdAt:new Date(2024,0,10).toISOString(),lastLogin:new Date().toISOString()},{id:"u_004",username:"Script_Kiddie",avatarUrl:"https://picsum.photos/seed/kiddie/200/200",role:r.i.USER,status:"BANNED",createdAt:new Date(2024,1,20).toISOString(),lastLogin:new Date(2024,2,1).toISOString()}],c=[{id:"m_001",title:"Cyberpunk HUD Interface React",description:"A complete React component set for building sci-fi interfaces. Includes glitch effects and holographic transitions.",type:r.x.CODE,codeSnippet:'const CyberButton = ({ children }) => (\n  <button className="border border-neon-500 text-neon-500 hover:bg-neon-500 hover:text-black transition-all duration-300 uppercase tracking-widest px-6 py-2">\n    {children}\n  </button>\n);',language:"tsx",author:i,stats:{views:1204,downloads:450,favorites:89},tags:["react","ui","cyberpunk","animation"],createdAt:new Date(Date.now()-1728e5).toISOString(),comments:[]},{id:"m_002",title:"Neon City Ambience Loop",description:"4K loop of a futuristic city rain scene. Perfect for background assets.",type:r.x.VIDEO,contentUrl:"https://media.w3.org/2010/05/sintel/trailer.mp4",author:l[1],stats:{views:5320,downloads:1200,favorites:432},tags:["video","loop","background","4k"],createdAt:new Date(Date.now()-432e6).toISOString(),comments:[{id:"c_1",content:"The lighting on this is insane!",author:i,createdAt:new Date().toISOString()}]},{id:"m_003",title:"Industrial 3D Assets Pack",description:"Low-poly mechanical parts for game dev. GLB format + Textures.",type:r.x.ASSET_ZIP,contentUrl:"#",author:l[2],stats:{views:800,downloads:120,favorites:45},tags:["3d","blender","game-assets"],createdAt:new Date(Date.now()-864e5).toISOString(),comments:[]}];if(c.length<40){let e=c.length,t=[r.x.CODE,r.x.ASSET_ZIP,r.x.VIDEO];for(let a=e;a<40;a++){let e="m_".concat((a+1).toString().padStart(3,"0")),s=l[a%l.length],n=t[a%t.length],o=new Date(Date.now()-a%10*864e5).toISOString(),i={views:Math.floor(1e3*Math.random()),downloads:Math.floor(200*Math.random()),favorites:Math.floor(50*Math.random())},d={id:e,title:n===r.x.CODE?"Test Code Snippet #".concat(a+1):n===r.x.ASSET_ZIP?"Assets Pack #".concat(a+1):"Demo Video #".concat(a+1),description:"Auto-generated demo material.",type:n,author:s,stats:i,tags:n===r.x.CODE?["test","code"]:n===r.x.ASSET_ZIP?["assets"]:["video"],createdAt:o,comments:[]};n===r.x.CODE?c.push({...d,codeSnippet:"function test".concat(a,"(){return ").concat(a,";}"),language:"ts"}):n===r.x.ASSET_ZIP?c.push({...d,contentUrl:"#"}):c.push({...d,contentUrl:"https://media.w3.org/2010/05/sintel/trailer.mp4"})}}let d={dbHost:"127.0.0.1",dbPort:"3306",dbUser:"root",dbPass:"admin123",dbName:"nexus_db",maintenanceMode:!1,maxUploadMB:3};async function x(e,t){try{let a=await fetch("/api/v1".concat(e),{...t,headers:{"Content-Type":"application/json",...null==t?void 0:t.headers}}),r=await a.json();if(!a.ok)throw Error(r.error||a.statusText||"Request failed");return r.data}catch(e){throw console.error("API Call Failed:",e),e}}let m={getMode:n,setApiMode:o,getCurrentUser:async()=>{if("REAL"===n())try{return await x("/auth/me")}catch(e){return console.log("User not authenticated"),null}return new Promise(e=>setTimeout(()=>e(i),500))},updateUserProfile:async(e,t)=>"REAL"===n()?x("/users/me",{method:"PATCH",body:JSON.stringify(t)}):new Promise(a=>{i.id===e&&(t.username&&(i.username=t.username),t.avatarUrl&&(i.avatarUrl=t.avatarUrl)),setTimeout(()=>a({...i}),800)}),getMaterials:async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20,a=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0,s=new URLSearchParams({page:String(e),limit:String(t)});if(a&&"ALL"!==a&&s.append("type",String(a)),r&&r.trim()&&s.append("q",r.trim()),"REAL"===n())return x("/materials?".concat(s.toString()));let o=a&&"ALL"!==a?c.filter(e=>e.type===a):c;if(r&&r.trim()){let e=r.trim().toLowerCase();o=o.filter(t=>{let a=t.title.toLowerCase().includes(e),r=t.description.toLowerCase().includes(e),s=t.tags.some(t=>t.toLowerCase().includes(e));return a||r||s})}let i=(e-1)*t,l=o.slice(i,i+t),d=o.length,m=e*t<d;return new Promise(a=>setTimeout(()=>a({items:l,total:d,page:e,limit:t,hasNext:m}),400))},getUserMaterials:async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20;if("REAL"===n())return x("/users/me/materials?page=".concat(e,"&limit=").concat(t));let a=c.filter(e=>e.author.id===i.id),r=(e-1)*t,s=a.slice(r,r+t),o=a.length,l=e*t<o;return new Promise(a=>setTimeout(()=>a({items:s,total:o,page:e,limit:t,hasNext:l}),300))},getUserFavorites:async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20;if("REAL"===n())return x("/users/me/favorites?page=".concat(e,"&limit=").concat(t));let a=c.filter(e=>e.stats.favorites>0),r=(e-1)*t,s=a.slice(r,r+t),o=a.length,i=e*t<o;return new Promise(a=>setTimeout(()=>a({items:s,total:o,page:e,limit:t,hasNext:i}),300))},getMaterialById:async e=>"REAL"===n()?x("/materials/".concat(e)):new Promise(t=>{let a=c.find(t=>t.id===e);setTimeout(()=>t(a),400)}),createMaterial:async e=>"REAL"===n()?x("/materials",{method:"POST",body:JSON.stringify(e)}):new Promise(t=>{let a={id:"m_".concat(Date.now()),title:e.title||"Untitled",description:e.description||"",type:e.type||r.x.CODE,codeSnippet:e.codeSnippet,contentUrl:e.contentUrl,language:e.language||"text",author:i,stats:{views:0,downloads:0,favorites:0},tags:e.tags||[],createdAt:new Date().toISOString(),comments:[]};c.unshift(a),setTimeout(()=>t(a),1e3)}),deleteMaterial:async e=>{if("REAL"===n())return await x("/materials/".concat(e),{method:"DELETE"}),!0;let t=c.findIndex(t=>t.id===e);return t>-1&&(c.splice(t,1),!0)},addComment:async(e,t)=>{if("REAL"===n())return x("/materials/".concat(e,"/comments"),{method:"POST",body:JSON.stringify({content:t})});let a=c.find(t=>t.id===e);if(!a)throw Error("Material not found");let r={id:"c_".concat(Date.now()),content:t,author:i,createdAt:new Date().toISOString()};return a.comments.push(r),r},toggleFavorite:async e=>{if("REAL"===n())return(await x("/materials/".concat(e,"/favorite"),{method:"POST"})).favorites;let t=c.find(t=>t.id===e);return t?(t.stats.favorites+=1,t.stats.favorites):0},uploadZip:async(e,t)=>{let a=new FormData;a.append("file",e),(null==t?void 0:t.title)&&a.append("title",t.title),(null==t?void 0:t.description)&&a.append("description",t.description),(null==t?void 0:t.tags)&&a.append("tags",t.tags.join(","));let r=await fetch("/api/v1/materials/upload-zip",{method:"POST",body:a});if(!(r.headers.get("content-type")||"").includes("application/json"))throw Error(await r.text()||"Upload failed (".concat(r.status,")"));let s=await r.json();if(!r.ok||!s.success)throw Error(s.error||"Upload failed (".concat(r.status,")"));return s.data},uploadVideo:async(e,t)=>{let a=new FormData;a.append("file",e),(null==t?void 0:t.title)&&a.append("title",t.title),(null==t?void 0:t.description)&&a.append("description",t.description),(null==t?void 0:t.tags)&&a.append("tags",t.tags.join(","));let r=await fetch("/api/v1/materials/upload-video",{method:"POST",body:a});if(!(r.headers.get("content-type")||"").includes("application/json"))throw Error(await r.text()||"Upload failed (".concat(r.status,")"));let s=await r.json();if(!r.ok||!s.success)throw Error(s.error||"Upload failed (".concat(r.status,")"));return s.data},verifyAdmin:async(e,t)=>new Promise(a=>{setTimeout(()=>{a("admin"===e&&"wx1998WX"===t)},1e3)}),getAllUsers:async()=>"REAL"===n()?x("/admin/users"):new Promise(e=>setTimeout(()=>e(l),600)),updateUserRole:async(e,t)=>{if("REAL"===n())return x("/admin/users/".concat(e,"/role"),{method:"POST",body:JSON.stringify({role:t})});let a=l.find(t=>t.id===e);if(!a)throw Error("User not found");return a.role=t,new Promise(e=>setTimeout(()=>e({...a}),400))},getSystemConfig:async()=>"REAL"===n()?x("/admin/config"):d,updateSystemConfig:async e=>{if("REAL"===n()){await x("/admin/config",{method:"PUT",body:JSON.stringify({maxUploadMB:e.maxUploadMB})});return}return d=e,new Promise(e=>setTimeout(e,1500))},toggleUserStatus:async e=>{if("REAL"===n())return x("/admin/users/".concat(e,"/toggle-status"),{method:"POST"});let t=l.find(t=>t.id===e);if(t)return t.status="ACTIVE"===t.status?"BANNED":"ACTIVE",t}}},3789:function(e,t,a){"use strict";var r,s,n,o;a.d(t,{i:function(){return r},x:function(){return s}}),(n=r||(r={})).USER="USER",n.ADMIN="ADMIN",n.CREATOR="CREATOR",n.MANAGER="MANAGER",(o=s||(s={})).CODE="CODE",o.ASSET_ZIP="ASSET_ZIP",o.VIDEO="VIDEO"}},function(e){e.O(0,[279,605,221,888,774,179],function(){return e(e.s=8312)}),_N_E=e.O()}]);