1 line
32 KiB
JavaScript

(()=>{var e={};e.id=146,e.ids=[146],e.modules={72934:e=>{"use strict";e.exports=require("next/dist/client/components/action-async-storage.external.js")},54580:e=>{"use strict";e.exports=require("next/dist/client/components/request-async-storage.external.js")},45869:e=>{"use strict";e.exports=require("next/dist/client/components/static-generation-async-storage.external.js")},20399:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},27790:e=>{"use strict";e.exports=require("assert")},78893:e=>{"use strict";e.exports=require("buffer")},84770:e=>{"use strict";e.exports=require("crypto")},17702:e=>{"use strict";e.exports=require("events")},32615:e=>{"use strict";e.exports=require("http")},35240:e=>{"use strict";e.exports=require("https")},55315:e=>{"use strict";e.exports=require("path")},86624:e=>{"use strict";e.exports=require("querystring")},17360:e=>{"use strict";e.exports=require("url")},21764:e=>{"use strict";e.exports=require("util")},71568:e=>{"use strict";e.exports=require("zlib")},33830:(e,t,s)=>{"use strict";s.r(t),s.d(t,{GlobalError:()=>l.a,__next_app__:()=>h,originalPathname:()=>u,pages:()=>c,routeModule:()=>m,tree:()=>o}),s(88179),s(49446),s(40656),s(40509),s(70546);var a=s(30170),r=s(45002),i=s(83876),l=s.n(i),n=s(66299),d={};for(let e in n)0>["default","tree","pages","GlobalError","originalPathname","__next_app__","routeModule"].indexOf(e)&&(d[e]=()=>n[e]);s.d(t,d);let o=["",{children:["admin",{children:["uploads",{children:["__PAGE__",{},{page:[()=>Promise.resolve().then(s.bind(s,88179)),"/home/Nicholai/Documents/Dev/united_v03/united-tattoo/united-tattoo/app/admin/uploads/page.tsx"]}]},{}]},{layout:[()=>Promise.resolve().then(s.bind(s,49446)),"/home/Nicholai/Documents/Dev/united_v03/united-tattoo/united-tattoo/app/admin/layout.tsx"],metadata:{icon:[async e=>(await Promise.resolve().then(s.bind(s,57481))).default(e)],apple:[],openGraph:[],twitter:[],manifest:void 0}}]},{layout:[()=>Promise.resolve().then(s.bind(s,40656)),"/home/Nicholai/Documents/Dev/united_v03/united-tattoo/united-tattoo/app/layout.tsx"],error:[()=>Promise.resolve().then(s.bind(s,40509)),"/home/Nicholai/Documents/Dev/united_v03/united-tattoo/united-tattoo/app/error.tsx"],"not-found":[()=>Promise.resolve().then(s.bind(s,70546)),"/home/Nicholai/Documents/Dev/united_v03/united-tattoo/united-tattoo/app/not-found.tsx"],metadata:{icon:[async e=>(await Promise.resolve().then(s.bind(s,57481))).default(e)],apple:[],openGraph:[],twitter:[],manifest:void 0}}],c=["/home/Nicholai/Documents/Dev/united_v03/united-tattoo/united-tattoo/app/admin/uploads/page.tsx"],u="/admin/uploads/page",h={require:s,loadChunk:()=>Promise.resolve()},m=new a.AppPageRouteModule({definition:{kind:r.x.APP_PAGE,page:"/admin/uploads/page",pathname:"/admin/uploads",bundlePath:"",filename:"",appPaths:[]},userland:{loaderTree:o}})},77208:(e,t,s)=>{Promise.resolve().then(s.bind(s,66789)),Promise.resolve().then(s.bind(s,60985))},60782:(e,t,s)=>{"use strict";s.d(t,{SV:()=>c});var a=s(97247),r=s(28964),i=s.n(r),l=s(27757),n=s(58053),d=s(35921),o=s(28339);class c extends i().Component{constructor(e){super(e),this.handleRetry=()=>{this.setState({hasError:!1,error:void 0,errorInfo:void 0})},this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error("Error caught by boundary:",e,t),console.error("Production error:",{error:e.message,stack:e.stack,componentStack:t.componentStack}),this.setState({hasError:!0,error:e,errorInfo:t})}render(){if(this.state.hasError){let{fallback:e}=this.props;return e&&this.state.error?a.jsx(e,{error:this.state.error,retry:this.handleRetry}):(0,a.jsxs)(l.Zb,{className:"max-w-lg mx-auto mt-8",children:[a.jsx(l.Ol,{children:(0,a.jsxs)(l.ll,{className:"flex items-center gap-2 text-destructive",children:[a.jsx(d.Z,{className:"h-5 w-5"}),"Something went wrong"]})}),(0,a.jsxs)(l.aY,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-muted-foreground",children:"An unexpected error occurred. Please try refreshing the page or contact support if the problem persists."}),!1,(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsxs)(n.z,{onClick:this.handleRetry,variant:"outline",size:"sm",children:[a.jsx(o.Z,{className:"h-4 w-4 mr-2"}),"Try Again"]}),a.jsx(n.z,{onClick:()=>window.location.reload(),size:"sm",children:"Refresh Page"})]})]})]})}return this.props.children}}},66789:(e,t,s)=>{"use strict";s.d(t,{FileManager:()=>T});var a=s(97247),r=s(28964),i=s(27757),l=s(58053),n=s(70170),d=s(22394),o=s(98969),c=s(91207),u=s(6274),h=s(10906),m=s(10283),x=s(60985),p=s(60782),f=s(26323);let g=(0,f.Z)("Folder",[["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"}]]);var j=s(70405);let y=(0,f.Z)("Video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]),v=(0,f.Z)("Music",[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]]),N=(0,f.Z)("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]),k=(0,f.Z)("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]),b=(0,f.Z)("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]),w=(0,f.Z)("HardDrive",[["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"}]]),z=(0,f.Z)("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]),M=(0,f.Z)("FolderPlus",[["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"}]]);var C=s(99219);let S=(0,f.Z)("Move",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]]),Z=(0,f.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"}]]);var F=s(33841),D=s(37013);let P=(0,f.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"}]]),_=(0,f.Z)("List",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]]);var q=s(19389),E=s(44597);function T(){let[e,t]=(0,r.useState)([]),[s,f]=(0,r.useState)(null),[T,O]=(0,r.useState)(!0),[V,$]=(0,r.useState)("grid"),[A,L]=(0,r.useState)(""),[R,U]=(0,r.useState)(new Set),[I,B]=(0,r.useState)("/"),[H,Y]=(0,r.useState)(!1),[W,G]=(0,r.useState)(!1),[K,X]=(0,r.useState)(""),{toast:J}=(0,h.pm)(),{uploadFiles:Q,isUploading:ee,progress:et}=(0,m.FL)({maxFiles:50,maxSize:10485760,allowedTypes:["image/*","video/*","audio/*","application/pdf","text/*"]}),es=async()=>{try{let e=await fetch(`/api/files?path=${encodeURIComponent(I)}`);if(!e.ok)throw Error("Failed to load files");let s=await e.json();t(s)}catch(e){J({title:"Error",description:"Failed to load files",variant:"destructive"})}},ea=async()=>{try{let e=await fetch("/api/files/stats");if(!e.ok)throw Error("Failed to load stats");let t=await e.json();f(t)}catch(e){console.error("Failed to load stats:",e)}finally{O(!1)}},er=async e=>{try{let t=Array.from(e);await Q(t,{keyPrefix:I.replace("/","")}),await es(),await ea(),Y(!1),J({title:"Success",description:`Uploaded ${t.length} files successfully`})}catch(e){J({title:"Error",description:"Failed to upload files",variant:"destructive"})}},ei=async()=>{if(K.trim())try{if(!(await fetch("/api/files/folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:K,path:I})})).ok)throw Error("Failed to create folder");await es(),G(!1),X(""),J({title:"Success",description:"Folder created successfully"})}catch(e){J({title:"Error",description:"Failed to create folder",variant:"destructive"})}},el=async()=>{try{if(!(await fetch("/api/files/bulk-delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fileIds:Array.from(R)})})).ok)throw Error("Failed to delete files");await es(),await ea(),U(new Set),J({title:"Success",description:`Deleted ${R.size} items successfully`})}catch(e){J({title:"Error",description:"Failed to delete files",variant:"destructive"})}},en=e=>{let t=new Set(R);t.has(e)?t.delete(e):t.add(e),U(t)},ed=e=>"folder"===e.type?a.jsx(g,{className:"h-4 w-4"}):e.mimeType?.startsWith("image/")?a.jsx(j.Z,{className:"h-4 w-4"}):e.mimeType?.startsWith("video/")?a.jsx(y,{className:"h-4 w-4"}):e.mimeType?.startsWith("audio/")?a.jsx(v,{className:"h-4 w-4"}):e.mimeType?.includes("pdf")?a.jsx(N,{className:"h-4 w-4"}):e.mimeType?.includes("zip")||e.mimeType?.includes("archive")?a.jsx(k,{className:"h-4 w-4"}):a.jsx(b,{className:"h-4 w-4"}),eo=e=>{if(0===e)return"0 Bytes";let t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(2))+" "+["Bytes","KB","MB","GB"][t]},ec=e.filter(e=>e.name.toLowerCase().includes(A.toLowerCase())),eu=I.split("/").filter(Boolean);return T?a.jsx(x.LoadingSpinner,{}):a.jsx(p.SV,{children:(0,a.jsxs)("div",{className:"space-y-6",children:[s&&(0,a.jsxs)("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[(0,a.jsxs)(i.Zb,{children:[(0,a.jsxs)(i.Ol,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[a.jsx(i.ll,{className:"text-sm font-medium",children:"Total Files"}),a.jsx(b,{className:"h-4 w-4 text-muted-foreground"})]}),(0,a.jsxs)(i.aY,{children:[a.jsx("div",{className:"text-2xl font-bold",children:s.totalFiles}),(0,a.jsxs)("p",{className:"text-xs text-muted-foreground",children:["+",s.recentUploads," this week"]})]})]}),(0,a.jsxs)(i.Zb,{children:[(0,a.jsxs)(i.Ol,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[a.jsx(i.ll,{className:"text-sm font-medium",children:"Storage Used"}),a.jsx(w,{className:"h-4 w-4 text-muted-foreground"})]}),(0,a.jsxs)(i.aY,{children:[a.jsx("div",{className:"text-2xl font-bold",children:s.storageUsed}),a.jsx("p",{className:"text-xs text-muted-foreground",children:"R2 storage usage"})]})]}),(0,a.jsxs)(i.Zb,{children:[(0,a.jsxs)(i.Ol,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[a.jsx(i.ll,{className:"text-sm font-medium",children:"Images"}),a.jsx(j.Z,{className:"h-4 w-4 text-muted-foreground"})]}),(0,a.jsxs)(i.aY,{children:[a.jsx("div",{className:"text-2xl font-bold",children:s.fileTypes.image||0}),a.jsx("p",{className:"text-xs text-muted-foreground",children:"Image files"})]})]}),(0,a.jsxs)(i.Zb,{children:[(0,a.jsxs)(i.Ol,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[a.jsx(i.ll,{className:"text-sm font-medium",children:"Documents"}),a.jsx(N,{className:"h-4 w-4 text-muted-foreground"})]}),(0,a.jsxs)(i.aY,{children:[a.jsx("div",{className:"text-2xl font-bold",children:s.fileTypes.document||0}),a.jsx("p",{className:"text-xs text-muted-foreground",children:"Document files"})]})]})]}),(0,a.jsxs)(i.Zb,{children:[(0,a.jsxs)(i.Ol,{children:[a.jsx(i.ll,{children:"File Manager"}),a.jsx(i.SZ,{children:"Manage your uploaded files and organize your storage."})]}),(0,a.jsxs)(i.aY,{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-2 text-sm text-muted-foreground",children:[a.jsx(l.z,{variant:"ghost",size:"sm",onClick:()=>B("/"),className:"h-auto p-1",children:"Home"}),eu.map((e,t)=>(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[a.jsx("span",{children:"/"}),a.jsx(l.z,{variant:"ghost",size:"sm",onClick:()=>B("/"+eu.slice(0,t+1).join("/")),className:"h-auto p-1",children:e})]},t))]}),(0,a.jsxs)("div",{className:"flex flex-col gap-4 md:flex-row md:items-center md:justify-between",children:[(0,a.jsxs)("div",{className:"flex flex-1 items-center space-x-2",children:[a.jsx(z,{className:"h-4 w-4 text-muted-foreground"}),a.jsx(n.I,{placeholder:"Search files...",value:A,onChange:e=>L(e.target.value),className:"max-w-sm"})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsxs)(o.Vq,{open:W,onOpenChange:G,children:[a.jsx(o.hg,{asChild:!0,children:(0,a.jsxs)(l.z,{variant:"outline",size:"sm",children:[a.jsx(M,{className:"mr-2 h-4 w-4"}),"New Folder"]})}),(0,a.jsxs)(o.cZ,{children:[(0,a.jsxs)(o.fK,{children:[a.jsx(o.$N,{children:"Create New Folder"}),a.jsx(o.Be,{children:"Enter a name for the new folder."})]}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[a.jsx(d._,{htmlFor:"folderName",children:"Folder Name"}),a.jsx(n.I,{id:"folderName",value:K,onChange:e=>X(e.target.value),placeholder:"Enter folder name"})]}),(0,a.jsxs)("div",{className:"flex justify-end space-x-2",children:[a.jsx(l.z,{variant:"outline",onClick:()=>G(!1),children:"Cancel"}),a.jsx(l.z,{onClick:ei,children:"Create"})]})]})]})]}),(0,a.jsxs)(o.Vq,{open:H,onOpenChange:Y,children:[a.jsx(o.hg,{asChild:!0,children:(0,a.jsxs)(l.z,{children:[a.jsx(C.Z,{className:"mr-2 h-4 w-4"}),"Upload Files"]})}),(0,a.jsxs)(o.cZ,{children:[(0,a.jsxs)(o.fK,{children:[a.jsx(o.$N,{children:"Upload Files"}),a.jsx(o.Be,{children:"Select files to upload to the current directory."})]}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[a.jsx(d._,{htmlFor:"files",children:"Select Files"}),a.jsx(n.I,{id:"files",type:"file",multiple:!0,onChange:e=>e.target.files&&er(e.target.files),disabled:ee})]}),ee&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"text-sm text-muted-foreground",children:["Uploading... ",et.length>0?Math.round(et[0].progress||0):0,"%"]}),a.jsx("div",{className:"w-full bg-secondary rounded-full h-2",children:a.jsx("div",{className:"bg-primary h-2 rounded-full transition-all duration-300",style:{width:`${et.length>0&&et[0].progress||0}%`}})})]})]})]})]})]})]}),R.size>0&&(0,a.jsxs)("div",{className:"flex items-center justify-between p-3 bg-muted rounded-lg",children:[(0,a.jsxs)("span",{className:"text-sm font-medium",children:[R.size," item(s) selected"]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsxs)(l.z,{variant:"outline",size:"sm",children:[a.jsx(S,{className:"mr-2 h-4 w-4"}),"Move"]}),(0,a.jsxs)(l.z,{variant:"outline",size:"sm",children:[a.jsx(Z,{className:"mr-2 h-4 w-4"}),"Copy"]}),(0,a.jsxs)(c.aR,{children:[a.jsx(c.vW,{asChild:!0,children:(0,a.jsxs)(l.z,{variant:"destructive",size:"sm",children:[a.jsx(F.Z,{className:"mr-2 h-4 w-4"}),"Delete"]})}),(0,a.jsxs)(c._T,{children:[(0,a.jsxs)(c.fY,{children:[a.jsx(c.f$,{children:"Delete Files"}),(0,a.jsxs)(c.yT,{children:["Are you sure you want to delete ",R.size," selected items? This action cannot be undone."]})]}),(0,a.jsxs)(c.xo,{children:[a.jsx(c.le,{children:"Cancel"}),a.jsx(c.OL,{onClick:el,children:"Delete"})]})]})]}),(0,a.jsxs)(l.z,{variant:"outline",size:"sm",onClick:()=>U(new Set),children:[a.jsx(D.Z,{className:"mr-2 h-4 w-4"}),"Clear"]})]})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[a.jsx("span",{className:"text-sm font-medium",children:"View:"}),(0,a.jsxs)("div",{className:"flex items-center border rounded-md",children:[a.jsx(l.z,{variant:"grid"===V?"default":"ghost",size:"sm",onClick:()=>$("grid"),className:"rounded-r-none",children:a.jsx(P,{className:"h-4 w-4"})}),a.jsx(l.z,{variant:"list"===V?"default":"ghost",size:"sm",onClick:()=>$("list"),className:"rounded-none",children:a.jsx(_,{className:"h-4 w-4"})}),a.jsx(l.z,{variant:"tree"===V?"default":"ghost",size:"sm",onClick:()=>$("tree"),className:"rounded-l-none",children:a.jsx(g,{className:"h-4 w-4"})})]})]}),(0,a.jsxs)("span",{className:"text-sm text-muted-foreground",children:[ec.length," items"]})]})]})]}),(0,a.jsxs)("div",{className:"space-y-4",children:["grid"===V?a.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:ec.map(e=>(0,a.jsxs)(i.Zb,{className:"overflow-hidden cursor-pointer hover:shadow-md transition-shadow",children:[(0,a.jsxs)("div",{className:"relative aspect-square bg-muted flex items-center justify-center",children:["file"===e.type&&e.mimeType?.startsWith("image/")&&e.url?a.jsx(E.default,{src:e.url,alt:e.name,fill:!0,className:"object-cover"}):a.jsx("div",{className:"text-muted-foreground",children:ed(e)}),a.jsx("div",{className:"absolute top-2 left-2",children:a.jsx(u.X,{checked:R.has(e.id),onCheckedChange:()=>en(e.id),className:"bg-background"})}),a.jsx("div",{className:"absolute top-2 right-2",children:a.jsx(l.z,{size:"sm",variant:"secondary",className:"h-8 w-8 p-0",children:a.jsx(q.Z,{className:"h-4 w-4"})})})]}),a.jsx(i.aY,{className:"p-4",children:(0,a.jsxs)("div",{className:"space-y-2",children:[a.jsx("h4",{className:"font-semibold truncate",children:e.name}),(0,a.jsxs)("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[a.jsx("span",{children:"file"===e.type&&e.size?eo(e.size):"Folder"}),a.jsx("span",{children:new Date(e.createdAt).toLocaleDateString()})]})]})})]},e.id))}):a.jsx("div",{className:"space-y-2",children:ec.map(e=>a.jsx(i.Zb,{children:a.jsx(i.aY,{className:"p-4",children:(0,a.jsxs)("div",{className:"flex items-center space-x-4",children:[a.jsx(u.X,{checked:R.has(e.id),onCheckedChange:()=>en(e.id)}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[ed(e),a.jsx("span",{className:"font-medium",children:e.name})]}),a.jsx("div",{className:"flex-1"}),(0,a.jsxs)("div",{className:"flex items-center space-x-4 text-sm text-muted-foreground",children:[a.jsx("span",{children:"file"===e.type&&e.size?eo(e.size):"Folder"}),a.jsx("span",{children:new Date(e.createdAt).toLocaleDateString()}),a.jsx(l.z,{size:"sm",variant:"ghost",className:"h-8 w-8 p-0",children:a.jsx(q.Z,{className:"h-4 w-4"})})]})]})})},e.id))}),0===ec.length&&a.jsx(i.Zb,{children:(0,a.jsxs)(i.aY,{className:"flex flex-col items-center justify-center py-12",children:[a.jsx(g,{className:"h-12 w-12 text-muted-foreground mb-4"}),a.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No files found"}),a.jsx("p",{className:"text-muted-foreground text-center mb-4",children:A?"Try adjusting your search terms":"This directory is empty. Upload some files to get started."}),!A&&(0,a.jsxs)(l.z,{onClick:()=>Y(!0),children:[a.jsx(C.Z,{className:"mr-2 h-4 w-4"}),"Upload Files"]})]})})]})]})})}},91207:(e,t,s)=>{"use strict";s.d(t,{OL:()=>f,_T:()=>u,aR:()=>n,f$:()=>x,fY:()=>h,le:()=>g,vW:()=>d,xo:()=>m,yT:()=>p});var a=s(97247);s(28964);var r=s(28980),i=s(25008),l=s(58053);function n({...e}){return a.jsx(r.fC,{"data-slot":"alert-dialog",...e})}function d({...e}){return a.jsx(r.xz,{"data-slot":"alert-dialog-trigger",...e})}function o({...e}){return a.jsx(r.h_,{"data-slot":"alert-dialog-portal",...e})}function c({className:e,...t}){return a.jsx(r.aV,{"data-slot":"alert-dialog-overlay",className:(0,i.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function u({className:e,...t}){return(0,a.jsxs)(o,{children:[a.jsx(c,{}),a.jsx(r.VY,{"data-slot":"alert-dialog-content",className:(0,i.cn)("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),...t})]})}function h({className:e,...t}){return a.jsx("div",{"data-slot":"alert-dialog-header",className:(0,i.cn)("flex flex-col gap-2 text-center sm:text-left",e),...t})}function m({className:e,...t}){return a.jsx("div",{"data-slot":"alert-dialog-footer",className:(0,i.cn)("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function x({className:e,...t}){return a.jsx(r.Dx,{"data-slot":"alert-dialog-title",className:(0,i.cn)("text-lg font-semibold",e),...t})}function p({className:e,...t}){return a.jsx(r.dk,{"data-slot":"alert-dialog-description",className:(0,i.cn)("text-muted-foreground text-sm",e),...t})}function f({className:e,...t}){return a.jsx(r.aU,{className:(0,i.cn)((0,l.d)(),e),...t})}function g({className:e,...t}){return a.jsx(r.$j,{className:(0,i.cn)((0,l.d)({variant:"outline"}),e),...t})}},6274:(e,t,s)=>{"use strict";s.d(t,{X:()=>n});var a=s(97247),r=s(37830),i=s(48799),l=s(25008);function n({className:e,...t}){return a.jsx(r.fC,{"data-slot":"checkbox",className:(0,l.cn)("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:a.jsx(r.z$,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:a.jsx(i.Z,{className:"size-3.5"})})})}},98969:(e,t,s)=>{"use strict";s.d(t,{$N:()=>x,Be:()=>p,Vq:()=>n,cN:()=>m,cZ:()=>u,fK:()=>h,hg:()=>d});var a=s(97247),r=s(50400),i=s(37013),l=s(25008);function n({...e}){return a.jsx(r.fC,{"data-slot":"dialog",...e})}function d({...e}){return a.jsx(r.xz,{"data-slot":"dialog-trigger",...e})}function o({...e}){return a.jsx(r.h_,{"data-slot":"dialog-portal",...e})}function c({className:e,...t}){return a.jsx(r.aV,{"data-slot":"dialog-overlay",className:(0,l.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function u({className:e,children:t,showCloseButton:s=!0,...n}){return(0,a.jsxs)(o,{"data-slot":"dialog-portal",children:[a.jsx(c,{}),(0,a.jsxs)(r.VY,{"data-slot":"dialog-content",className:(0,l.cn)("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),...n,children:[t,s&&(0,a.jsxs)(r.x8,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[a.jsx(i.Z,{}),a.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function h({className:e,...t}){return a.jsx("div",{"data-slot":"dialog-header",className:(0,l.cn)("flex flex-col gap-2 text-center sm:text-left",e),...t})}function m({className:e,...t}){return a.jsx("div",{"data-slot":"dialog-footer",className:(0,l.cn)("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function x({className:e,...t}){return a.jsx(r.Dx,{"data-slot":"dialog-title",className:(0,l.cn)("text-lg leading-none font-semibold",e),...t})}function p({className:e,...t}){return a.jsx(r.dk,{"data-slot":"dialog-description",className:(0,l.cn)("text-muted-foreground text-sm",e),...t})}},10283:(e,t,s)=>{"use strict";s.d(t,{FL:()=>r});var a=s(28964);function r(e={}){let[t,s]=(0,a.useState)([]),[r,i]=(0,a.useState)(!1),[l,n]=(0,a.useState)(null),{maxFiles:d=10,maxSize:o=10485760,allowedTypes:c=["image/jpeg","image/png","image/webp","image/gif"],onProgress:u,onComplete:h,onError:m}=e,x=(0,a.useCallback)(e=>{let t=[],s=[];if(e.length>d)return s.push(`Maximum ${d} files allowed`),{valid:t,errors:s};for(let a of e){if(a.size>o){s.push(`${a.name}: File size exceeds ${Math.round(o/1024/1024)}MB limit`);continue}if(!c.includes(a.type)){s.push(`${a.name}: File type ${a.type} not allowed`);continue}t.push(a)}return{valid:t,errors:s}},[d,o,c]),p=(0,a.useCallback)(async(e,t)=>{let a=`${Date.now()}-${Math.random().toString(36).substring(2)}`,r={id:a,filename:e.name,progress:0,status:"uploading"};s(e=>[...e,r]),n(null);try{let r=setInterval(()=>{s(e=>e.map(e=>e.id===a&&e.progress<90?{...e,progress:Math.min(90,e.progress+20*Math.random())}:e))},200),i=new FormData;i.append("file",e),t&&i.append("key",t);let l=await fetch("/api/upload",{method:"POST",body:i});clearInterval(r);let n=await l.json();if(n.success)return s(e=>e.map(e=>e.id===a?{...e,progress:100,status:"complete",url:n.url}:e)),n;return s(e=>e.map(e=>e.id===a?{...e,status:"error",error:n.error}:e)),{success:!1,error:n.error||"Upload failed"}}catch(t){let e=t instanceof Error?t.message:"Upload failed";return s(t=>t.map(t=>t.id===a?{...t,status:"error",error:e}:t)),{success:!1,error:e}}},[]);return{uploadFiles:(0,a.useCallback)(async(e,s)=>{i(!0),n(null);try{let{valid:a,errors:r}=x(e);if(r.length>0){let e=r.join(", ");n(e),m?.(e);return}if(0===a.length){n("No valid files to upload"),m?.("No valid files to upload");return}let i=[];for(let e of a){let t=s?.keyPrefix?`${s.keyPrefix}/${Date.now()}-${e.name}`:void 0,a=await p(e,t);i.push(a)}let l=i.filter(e=>e.success).map(e=>({filename:a.find(t=>i.indexOf(e)===a.indexOf(t))?.name||"",url:e.url||"",key:e.key||"",size:a.find(t=>i.indexOf(e)===a.indexOf(t))?.size||0,mimeType:a.find(t=>i.indexOf(e)===a.indexOf(t))?.type||""})),d=i.map((e,t)=>({result:e,file:a[t]})).filter(({result:e})=>!e.success).map(({result:e,file:t})=>({filename:t.name,error:e.error||"Upload failed"})),o={successful:l,failed:d,total:a.length};h?.(o);let c=[...t];u?.(c)}catch(t){let e=t instanceof Error?t.message:"Upload failed";n(e),m?.(e)}finally{i(!1)}},[t,x,p,u,h,m]),uploadSingleFile:p,progress:t,isUploading:r,error:l,clearProgress:(0,a.useCallback)(()=>{s([]),n(null)},[]),removeFile:(0,a.useCallback)(e=>{s(t=>t.filter(t=>t.id!==e))},[])}}},48799:(e,t,s)=>{"use strict";s.d(t,{Z:()=>a});let a=(0,s(26323).Z)("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]])},19389:(e,t,s)=>{"use strict";s.d(t,{Z:()=>a});let a=(0,s(26323).Z)("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]])},70405:(e,t,s)=>{"use strict";s.d(t,{Z:()=>a});let a=(0,s(26323).Z)("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]])},99219:(e,t,s)=>{"use strict";s.d(t,{Z:()=>a});let a=(0,s(26323).Z)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},37013:(e,t,s)=>{"use strict";s.d(t,{Z:()=>a});let a=(0,s(26323).Z)("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},88179:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>d,metadata:()=>n});var a=s(72051),r=s(26269);let i=(0,s(45347).createProxy)(String.raw`/home/Nicholai/Documents/Dev/united_v03/united-tattoo/united-tattoo/components/admin/file-manager.tsx#FileManager`);var l=s(15487);let n={title:"File Manager | United Tattoo Admin",description:"Manage uploaded files and storage"};function d(){return(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{children:[a.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"File Manager"}),a.jsx("p",{className:"text-muted-foreground",children:"Manage uploaded files, organize storage, and monitor usage."})]}),a.jsx(r.Suspense,{fallback:a.jsx(l.TK,{}),children:a.jsx(i,{})})]})}},37830:(e,t,s)=>{"use strict";s.d(t,{fC:()=>N,z$:()=>b});var a=s(28964),r=s(93191),i=s(20732),l=s(70319),n=s(28469),d=s(45298),o=s(30255),c=s(67264),u=s(22251),h=s(97247),m="Checkbox",[x,p]=(0,i.b)(m),[f,g]=x(m);function j(e){let{__scopeCheckbox:t,checked:s,children:r,defaultChecked:i,disabled:l,form:d,name:o,onCheckedChange:c,required:u,value:x="on",internal_do_not_use_render:p}=e,[g,j]=(0,n.T)({prop:s,defaultProp:i??!1,onChange:c,caller:m}),[y,v]=a.useState(null),[N,k]=a.useState(null),b=a.useRef(!1),w=!y||!!d||!!y.closest("form"),z={checked:g,disabled:l,setChecked:j,control:y,setControl:v,name:o,form:d,value:x,hasConsumerStoppedPropagationRef:b,required:u,defaultChecked:!M(i)&&i,isFormControl:w,bubbleInput:N,setBubbleInput:k};return(0,h.jsx)(f,{scope:t,...z,children:"function"==typeof p?p(z):r})}var y="CheckboxTrigger",v=a.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:s,...i},n)=>{let{control:d,value:o,disabled:c,checked:m,required:x,setControl:p,setChecked:f,hasConsumerStoppedPropagationRef:j,isFormControl:v,bubbleInput:N}=g(y,e),k=(0,r.e)(n,p),b=a.useRef(m);return a.useEffect(()=>{let e=d?.form;if(e){let t=()=>f(b.current);return e.addEventListener("reset",t),()=>e.removeEventListener("reset",t)}},[d,f]),(0,h.jsx)(u.WV.button,{type:"button",role:"checkbox","aria-checked":M(m)?"mixed":m,"aria-required":x,"data-state":C(m),"data-disabled":c?"":void 0,disabled:c,value:o,...i,ref:k,onKeyDown:(0,l.Mj)(t,e=>{"Enter"===e.key&&e.preventDefault()}),onClick:(0,l.Mj)(s,e=>{f(e=>!!M(e)||!e),N&&v&&(j.current=e.isPropagationStopped(),j.current||e.stopPropagation())})})});v.displayName=y;var N=a.forwardRef((e,t)=>{let{__scopeCheckbox:s,name:a,checked:r,defaultChecked:i,required:l,disabled:n,value:d,onCheckedChange:o,form:c,...u}=e;return(0,h.jsx)(j,{__scopeCheckbox:s,checked:r,defaultChecked:i,disabled:n,required:l,onCheckedChange:o,name:a,form:c,value:d,internal_do_not_use_render:({isFormControl:e})=>(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(v,{...u,ref:t,__scopeCheckbox:s}),e&&(0,h.jsx)(z,{__scopeCheckbox:s})]})})});N.displayName=m;var k="CheckboxIndicator",b=a.forwardRef((e,t)=>{let{__scopeCheckbox:s,forceMount:a,...r}=e,i=g(k,s);return(0,h.jsx)(c.z,{present:a||M(i.checked)||!0===i.checked,children:(0,h.jsx)(u.WV.span,{"data-state":C(i.checked),"data-disabled":i.disabled?"":void 0,...r,ref:t,style:{pointerEvents:"none",...e.style}})})});b.displayName=k;var w="CheckboxBubbleInput",z=a.forwardRef(({__scopeCheckbox:e,...t},s)=>{let{control:i,hasConsumerStoppedPropagationRef:l,checked:n,defaultChecked:c,required:m,disabled:x,name:p,value:f,form:j,bubbleInput:y,setBubbleInput:v}=g(w,e),N=(0,r.e)(s,v),k=(0,d.D)(n),b=(0,o.t)(i);a.useEffect(()=>{if(!y)return;let e=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"checked").set,t=!l.current;if(k!==n&&e){let s=new Event("click",{bubbles:t});y.indeterminate=M(n),e.call(y,!M(n)&&n),y.dispatchEvent(s)}},[y,k,n,l]);let z=a.useRef(!M(n)&&n);return(0,h.jsx)(u.WV.input,{type:"checkbox","aria-hidden":!0,defaultChecked:c??z.current,required:m,disabled:x,name:p,value:f,form:j,...t,tabIndex:-1,ref:N,style:{...t.style,...b,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});function M(e){return"indeterminate"===e}function C(e){return M(e)?"indeterminate":e?"checked":"unchecked"}z.displayName=w},30255:(e,t,s)=>{"use strict";s.d(t,{t:()=>i});var a=s(28964),r=s(9537);function i(e){let[t,s]=a.useState(void 0);return(0,r.b)(()=>{if(e){s({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{let a,r;if(!Array.isArray(t)||!t.length)return;let i=t[0];if("borderBoxSize"in i){let e=i.borderBoxSize,t=Array.isArray(e)?e[0]:e;a=t.inlineSize,r=t.blockSize}else a=e.offsetWidth,r=e.offsetHeight;s({width:a,height:r})});return t.observe(e,{box:"border-box"}),()=>t.unobserve(e)}s(void 0)},[e]),t}}};var t=require("../../../webpack-runtime.js");t.C(e);var s=e=>t(t.s=e),a=t.X(0,[9379,3670,1488,1511,4080,4128,6082,2092,6887,921,5314,4106,5593,8673],()=>s(33830));module.exports=a})();