PageSourceSearch

https://southernfm.com.au/assets/MediaLibraryTab-KyJTYjiR.js

js southernfm.com.au collected 2026-10-02 07:50:57 UTC 36,908 bytes, 9 lines download raw bytes

1import{q as yt,r as m,j as e,ar as Ze,y as C,as as Qe,au as jt,ac as kt,av as et,aw as tt,ax as Nt,at as vt,ay as Ct,aN as $t,s as w,ab as k,ai as De,B as y,aH as St,f as _t,h as Ft,D as Me,c as Te,d as Oe,e as Le,aO as Ie,E as He,aP as we,W as ye}from"./index-BvsqCpEz.js";import{I as Bt}from"./input-BedoGODD.js";import{H as Rt,T as I,C as je,A as Ut,a as At,b as Pt,c as zt,d as Et,e as Dt,f as Mt,g as Tt,F as Ke}from"./MemberDashboard-Cs5Sf23a.js";import{B as H}from"./badge-BI94o_1V.js";import{C as Ot}from"./checkbox-DVEqSMus.js";import{v as Lt,u as Ge}from"./upload-rules-DzRXK9g4.js";import{p as Je}from"./prepare-image-upload-Bby_BZou.js";import{F as Ve,T as It}from"./trash-Cq_XHo20.js";import{S as Ht}from"./sparkles-C7PiRczy.js";import{C as X}from"./chevron-right-CPI6eVSm.js";import{a as ke}from"./index-5yHiP4fM.js";import{L as Kt}from"./layout-grid-BVHYlI4g.js";import{L as Gt}from"./list-D2ETVdUl.js";import{R as Jt}from"./refresh-cw-Dooswkp8.js";import{U as Vt}from"./upload-B6sNIh33.js";import{D as Wt}from"./download-0HDG1NIG.js";import{f as Y}from"./format-Dogvratb.js";import"./use-auth-4OwtEfAA.js";import"./wind-DW6YfAyS.js";import"./arrow-left-DasGo8Zs.js";import"./calendar-BX6XEece.js";import"./user-DLmK3dAG.js";import"./check-B97Uezjq.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const qt=yt("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]),Xt=Nt,Yt=vt,Zt=Ct,st=m.forwardRef(({className:o,...x},u)=>e.jsx(Ze,{className:C("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",o),...x,ref:u}));st.displayName=Ze.displayName;const Qt=$t("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4  border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),at=m.forwardRef(({side:o="right",className:x,children:u,...N},g)=>e.jsxs(Zt,{children:[e.jsx(st,{}),e.jsxs(Qe,{ref:g,className:C(Qt({side:o}),x),...N,children:[u,e.jsxs(jt,{className:"absolute right-4 top-4 roun
6ded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-secondary hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[e.jsx(kt,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));at.displayName=Qe.displayName;const es=m.forwardRef(({className:o,...x},u)=>e.jsx(et,{ref:u,className:C("text-lg font-semibold text-foreground",o),...x}));es.displayName=et.displayName;const ts=m.forwardRef(({className:o,...x},u)=>e.jsx(tt,{ref:u,className:C("text-sm text-muted-foreground",o),...x}));ts.displayName=tt.displayName;const D=[{id:"post-images",label:"Post Images",description:"Post & podcast cover art",public:!0},{id:"show-images",label:"Show Images",description:"Show artwork and icons",public:!0},{id:"sponsor-logos",label:"Sponsor Logos",description:"Sponsor logos",public:!0},{id:"site-photos",label:"Site Photos",description:"Page headers & galleries",public:!0},{id:"kb-media",label:"Knowledge Base",description:"KB attachments and images",public:!0},{id:"resource-files",label:"Resources",description:"Downloadable member resources (marketing assets, etc.)",public:!0},{id:"policy-documents",label:"Policy Documents",description:"Policy PDFs",public:!1}],K="media-trash",Ne="_trash/",We=o=>o==="__unassigned"?"Unassigned":o.replace(/^\/+/,"").split(/[-_/]/g).filter(Boolean).map(x=>x.charAt(0).toUpperCase()+x.slice(1)).join(" ")||o,ve=(o,x)=>o&&o.startsWith("image/")||/\.(png|jpe?g|gif|webp|svg|avif)$/i.test(x||""),qe=(o,x)=>o==="application/pdf"||/\.pdf$/i.test(x||""),ne=o=>o==null?"-":o<1024?`${o} B`:o<1024*1024?`${(o/1024).toFixed(1)} KB`:`${(o/1024/1024).toFixed(1)} MB`,ss=o=>o.trim().replace(/[^\w.\-]+/g,"-").replace(/-+/g,"-"),Xe=async()=>{const o=[],x=(d,_,...le)=>{const U=le.filter(P=>P!=null).map(P=>typeof P=="string"?P:JSON.stringify(P)).join(`
7`);U&&o.push({label:d,url:_,haystack:U})},[u,N,g,S,v,$,B]=await Promise.all([w.from("posts").select("id,title,slug,content,excerpt,featured_image,tracklist,chapters,audio_tracks"),w.from("shows").select("id,name,slug,description,image_url,icon_url,coming_up,social_links,presenters"),w.from("sponsors").select("id,name,logo_url,website_url"),w.from("site_photos").select("id,label,page,image_url,alt"),w.rpc("get_kb_pages"),w.from("page_content").select("page,content"),w.from("announcements").select("id,title,content,images")]);return(u.data||[]).forEach(d=>x(`Post: ${d.title}`,`/post/${d.slug}`,d.content,d.excerpt,d.featured_image,d.tracklist,d.chapters,d.audio_tracks)),(N.data||[]).forEach(d=>x(`Show: ${d.name}`,`/show/${d.slug}`,d.description,d.image_url,d.icon_url,d.coming_up,d.social_links,d.presenters)),(g.data||[]).forEach(d=>x(`Sponsor: ${d.name}`,"/member#tab=sponsors",d.logo_url,d.website_url)),(S.data||[]).forEach(d=>x(`Site photo: ${d.label}${d.page?` (${d.page})`:""}`,d.page?`/${d.page.replace(/^\//,"")}`:"/member#tab=page-content",d.image_url,d.alt)),(v.data||[]).forEach(d=>x(`KB page: ${d.title}`,`/member#tab=kb&kb=${d.slug}`,d.icon,d.cover_url,d.content,d.content_text,d.draft_content)),($.data||[]).forEach(d=>x(`Page content: ${d.page}`,`/${d.page.replace(/^\//,"")}`,d.content)),(B.data||[]).forEach(d=>x(`Noticeboard: ${d.title}`,"/member#tab=hub",d.content,d.images)),o},Ye=(o,x)=>{const u=encodeURIComponent(o),N=[o,u],g=o.split("/").pop()||o;g!==o&&N.push(g,encodeURIComponent(g));const S=[],v=new Set;for(const $ of x)if(N.some(B=>$.haystack.includes(B))){const B=`${$.label}|${$.url||""}`;v.has(B)||(v.add(B),S.push({label:$.label,url:$.url}))}return S},Ce=1e3,re=async(o,x="")=>{const u=[];let N=0;for(;;){const{data:g,error:S}=await w.storage.from(o).list(x||void 0,{limit:Ce,offset:N,sortBy:{column:"name",order:"asc"}});if(S||!g||g.length===0)break;for(const v of g){const $=x?`${x}/${v.name}`:v.name;if(!v.id&&!v.metadata){const d=await re(o,$);u.push(...d)}else u.push({key:$,item:v})}if(g.length<Ce)break;N+=Ce}return u},$s=()=>{const[o,x]=m.useState(D[0].id),[u,N]=m.useState("bucket"),[g,S]=m.useState(""),[v,$]=m.useState([]),[B,d]=m.useState(!1),[_,le]=m.useState(""),[U,P]=m.useState("date"),[ie,$e]=m.useState("grid"),[T,oe]=m.useState(null),[Z,z]=m.useState(new Set),[h,ce]=m.useState(null);m.useState(null),m.useState("");const[nt,R]=m.useState(!1),[b,A]=m.useState(null),[rt,Se]=m.useState(null),[lt,G]=m.useState(null),[de,Q]=m.useState(!1),[J,_e]=m.useState(null),[M,ee]=m.useState(null),[te,it]=m.useState({}),se=m.useRef(null),Fe=m.useMemo(()=>D.find(t=>
7t.id===o),[o]),Be=T||[];m.useEffect(()=>{let t=!1;if(!T)return(async()=>{const a=await Xe();t||oe(a)})(),()=>{t=!0}},[T]),m.useEffect(()=>{let t=!1;if(!J)return(async()=>{const[a,n]=await Promise.all([w.from("page_content").select("page,content"),w.from("site_photos").select("page,image_url,alt,label")]),s=[];(a.data||[]).forEach(r=>{r.page&&s.push({page:r.page,text:JSON.stringify(r.content??"")})}),(n.data||[]).forEach(r=>{r.page&&s.push({page:r.page,text:`${r.image_url||""}
8${r.alt||""}
9${r.label||""}`})}),t||_e(s)})(),()=>{t=!0}},[J]);const ue=m.useCallback(async()=>{d(!0),z(new Set);const{data:t,error:a}=await w.storage.from(o).list(g||void 0,{limit:1e3,sortBy:{column:"updated_at",order:"desc"}});a?(k.error(`Failed to list files: ${a.message}`),$([])):$((t||[]).filter(n=>n.name!==Ne.replace(/\/$/,""))),d(!1)},[o,g]);m.useEffect(()=>{S(""),N("bucket"),ee(null)},[o]),m.useEffect(()=>{u==="bucket"&&ue()},[ue,u]);const Re=m.useCallback(async(t,a)=>{if(a.length===0)return;const n=a.filter(c=>!te[`${t}|${c}`]);if(n.length===0)return;const{data:s,error:r}=await w.rpc("get_storage_uploaders",{_bucket:t,_paths:n});if(r||!s)return;const l=Array.from(new Set(s.map(c=>c.owner_id).filter(Boolean)));let i={};if(l.length>0){const{data:c}=await w.rpc("get_public_profiles",{_user_ids:l});c==null||c.forEach(p=>{p.user_id&&(i[p.user_id]=p.display_name||"")})}it(c=>{const p={...c};return s.forEach(f=>{const F=`${t}|${f.path}`,E=f.owner_id&&i[f.owner_id]||f.owner_email||(f.owner_id?"Unknown user":null);p[F]={uploaderId:f.owner_id??null,uploaderName:E,uploadedAt:f.created_at??void 0}}),p})},[te]);m.useEffect(()=>{if(u!=="bucket"||v.length===0)return;const t=v.filter(a=>!!a.id||!!a.metadata).map(a=>g?`${g}/${a.name}`:a.name);Re(o,t)},[v,o,g,u,Re]);const Ue=m.useMemo(()=>{const t=v.map(s=>{var p,f;const r=!s.id&&!s.metadata,l=g?`${g}/${s.name}`:s.name,{data:i}=w.storage.from(o).getPublicUrl(l),c=te[`${o}|${l}`];return{key:l,bucket:o,name:s.name,isFolder:r,size:(p=s.metadata)==null?void 0:p.size,mimetype:(f=s.metadata)==null?void 0:f.mimetype,updatedAt:s.updated_at||s.created_at||void 0,publicUrl:i.publicUrl,usedBy:r?[]:Ye(l,Be),uploadedAt:c==null?void 0:c.uploadedAt,uploaderId:(c==null?void 0:c.uploaderId)??null,uploaderName:(c==null?void 0:c.uploaderName)??null}});if(o==="site-photos"&&!g&&J){const s=r=>{const l=[r,encodeURIComponent(r)],i=new Set;for(const c of J)l.some(p=>c.text.includes(p))&&i.add(c.page);return Array.from(i)};if(M){const r=t.filter(i=>{if(i.isFolder)return!1;const c=s(i.name);return M==="__unassigned"?c.length===0:c.includes(M)}),l=_?r.filter(i=>i.name.toLowerCase().includes(_.toLowerCase())):r;return l.sort((i,c)=>U==="name"?i.name.localeCompare(c.name):U==="size"?(c.size||0)-(i.size||0):(c.updatedAt||"").localeCompare(i.updatedAt||"")),l}else{const r=new Map;for(const p of t){if(p.isFolder)continue;const f=s(p.name);f.length===0?r.set("__unassigned",(r.get("__unassigned")||0)+1):f.forEach(F=>r.set(F,(r.get(F)||0)+1))}const l=Array.from(r.entries()).sort((p,f)=>p[0]==="__unassigned"?1:f[0]==="__unassigned"?-1:p[0].localeCompare(f[0])).map(([p,f])=>({key:`__page__/${p}`,bucket:o,name:We(p),isFolder:!0,publicUrl:"",usedBy:[],pageFolder:p,pageCount:f})),i=t.filter(p=>p.isFolder),c=[...l,...i];return _?c.filter(p=>p.name.toLowerCase().includes(_.toLowerCase())):c}}const n=_?t.filter(s=>s.name.toLowerCase().includes(_.toLowerCase())):t;return n.sort((s,r)=>s.isFolder!==r.isFolder?s.isFolder?-1:1:U==="name"?s.name.localeCompare(r.name):U==="size"?(r.size||0)-(s.size||0):(r.updatedAt||"").localeCompare(s.updatedAt||"")),n},[v,g,o,_,U,Be,J,M,te]),Ae=m.useRef(()=>{}),V=m.useCallback((t=!1)=>{t&&(oe(null),_e(null)),Ae.current()},[]),me=t=>{t.pageFolder?ee(t.pageFolder):S(t.key)},ot=async t=>{if(!t||t.length===0)return;R(!0);let a=0;for(const n of Array.from(t)){const s=Lt(o,n);if(s){k.error(`${n.name} rejected`,{description:s});continue}const r=ss(n.name),l=g?`${g}/${r}`:r,i=await Je(n),{error:c}=await w.storage.from(o).upload(l,i,{cacheControl:"3600",upsert:!1,contentType:i.type||void 0});c?k.error(`${n.name} failed`,{description:Ge(o,c,n)}):a++}a&&k.success(`Uploaded ${a} file${a>
91?"s":""}`),R(!1),se.current&&(se.current.value=""),V()},ct=async t=>{R(!0);let a=0;for(const n of t){const s=Date.now(),r=n.key.replace(/\//g,"__"),l=`${n.bucket}/${s}__${r}`,{error:i}=await w.storage.from(n.bucket).copy(n.key,l,{destinationBucket:K});if(i){k.error(`${n.name}: ${i.message}`);continue}const{error:c}=await w.storage.from(n.bucket).remove([n.key]);if(c){k.error(`${n.name}: ${c.message}`);continue}a++}a&&k.success(`Moved ${a} file${a>1?"s":""} to Recycle Bin`),R(!1),A(null),z(new Set),G(null),V(!0)},dt=async t=>{R(!0);const a=new Map;for(const s of t){const r=a.get(s.bucket)||[];r.push(s.key),a.set(s.bucket,r)}let n=0;for(const[s,r]of a){const{error:l}=await w.storage.from(s).remove(r);l?k.error(`Delete failed (${s}): ${l.message}`):n+=r.length}n&&k.success(`Permanently deleted ${n} file${n>1?"s":""}`),R(!1),A(null),z(new Set),G(null),V(!0)},pe=async t=>{const a=t.key.indexOf("/");if(a===-1){k.error("Cannot parse trash entry");return}const n=t.key.slice(0,a),s=t.key.slice(a+1),r=s.indexOf("__");if(r===-1){k.error("Cannot parse trash entry");return}const l=s.slice(r+2).replace(/__/g,"/");R(!0);const{data:i,error:c}=await w.storage.from(K).download(t.key);if(c||!i){k.error(`Restore failed: ${(c==null?void 0:c.message)||"could not read file"}`),R(!1);return}const{error:p}=await w.storage.from(n).upload(l,i,{cacheControl:"3600",upsert:!0,contentType:t.mimetype||i.type||void 0});if(p){k.error("Restore failed",{description:Ge(n,p)}),R(!1);return}const{error:f}=await w.storage.from(K).remove([t.key]);f?k.error(`Trash cleanup failed: ${f.message}`):k.success(`Restored to ${n}/${l}`),R(!1),G(null),V(!0)},he=async t=>{const a=D.find(s=>s.id===t.bucket);let n=t.publicUrl;if(a&&!a.public){const{data:s,error:r}=await w.storage.from(t.bucket).createSignedUrl(t.key,604800);if(r||!s){k.error(`Could not create link: ${(r==null?void 0:r.message)||"unknown"}`);return}n=s.signedUrl}try{await navigator.clipboard.writeText(n),k.success(a!=null&&a.public?"Public link copied":"Signed link copied (valid 7 days)")}catch{window.prompt("Copy this link:",n)}},fe=m.useCallback(async()=>{Q(!0),Se(null);const t=T||await Xe();T||oe(t);const n=(await Promise.all(D.map(async s=>(await re(s.id)).filter(({key:l})=>!l.startsWith(Ne)).map(({key:l,item:i})=>{var p,f;const{data:c}=w.storage.from(s.id).getPublicUrl(l);return{key:l,bucket:s.id,name:l.split("/").pop()||l,isFolder:!1,size:(p=i.metadata)==null?void 0:p.size,mimetype:(f=i.metadata)==null?void 0:f.mimetype,updatedAt:i.updated_at||i.created_at||void 0,publicUrl:c.publicUrl,usedBy:Ye(l,t)}})))).flat().filter(s=>s.usedBy.length===0).sort((s,r)=>(r.size||0)-(s.size||0));Se(n),Q(!1)},[T]),xe=m.useCallback(async()=>{Q(!0),G(null);const t=D.map(s=>s.id),n=(await Promise.all(t.map(async s=>(await re(K,s)).map(({key:l,item:i})=>{var F,E;const c=l.slice(s.length+1),p=c.indexOf("__"),f=p===-1?c:c.slice(p+2).replace(/__/g,"/");return{key:l,bucket:K,name:f,isFolder:!1,size:(F=i.metadata)==null?void 0:F.size,mimetype:(E=i.metadata)==null?void 0:E.mimetype,updatedAt:i.updated_at||i.created_at||void 0,publicUrl:"",usedBy:[]}})))).flat().sort((s,r)=>(r.updatedAt||"").localeCompare(s.updatedAt||""));if(n.length){const s=n.map(i=>i.key),{data:r}=await w.storage.from(K).createSignedUrls(s,60*60),l=new Map;(r||[]).forEach(i=>{i!=null&&i.path&&(i!=null&&i.signedUrl)&&l.set(i.path,i.signedUrl)}),n.forEach(i=>{i.publicUrl=l.get(i.key)||""})}G(n),Q(!1)},[]);Ae.current=()=>{u==="trash"?xe():u==="audit"?fe():ue()},m.useEffect(()=>{u==="audit"&&fe(),u==="trash"&&xe()},[u,fe,xe]);const ge=t=>{z(a=>{const n=new Set(a);return n.has(t)?n.delete(t):n.add(t),n})},W=Ue.filter(t=>Z.has(t.key)&&!t.isFolder),ut=["post-images","show-images","sponsor-logos","site-photos","kb-media","resource-files"],[mt,ae]=m.useState(!1),[j,O]=m.useState(null),pt=async t=>{for(let a=0;a<2;a++)try{const{data:n,error:s}=await w.storage.from(t.bucket).download(t.key);if(s||!n)continue;const r=t.key.split("/").pop()||"photo.jpg",l=new File([n],r,{type:n.type||"image/jpeg"}),i=await Je(l);if(i===l)return"skipped";const{error:c}=await w.storage.from(t.bucket).upload(t.key,i,{upsert:!0,contentType:"image/jpeg"});if(!c)return"fixed"}catch{}return"error"},Pe=async()=>{O({total:0,done:0,fixed:0,skipped:0,errors:0,failedKeys:[],running:!0});const t=[];for(const f of ut){const F=await re(f);for(const{key:E}of F)/\.jpe?g$/i.test(E)&&!E.startsWith(Ne)&&t.push({bucket:f,key:E})}O({total:t.length,done:0,fixed:0,skipped:0,errors:0,failedKeys:[],running:!0});let a=0,n=0,s=0,r=0;const l=[];let i=0;const c=4,p=async()=>{for(;i<t.length;){const f=t[i++],F=await pt(f);F==="fixed"?a++:F==="skipped"?n++:(s++,l.push(`${f.bucket}/${f.key}`)),r++,O({total:t.length,done:r,fixed:a,skipped:n,errors:s,failedKeys:[...l],running:!0})}};await Promise.all(Array.from({length:c},p)),O({total:t.length,done:r,fixed:a,skipped:n,errors:s,failedKeys:l,running:!1}),s>0?k.error(`HDR backfill finished with ${s} failure${s>1?"s":""}`,{description:`${a} fixed, ${n} skipped. See the dialog for which files failed (each was retried once).`}):k.success(`HDR backfill complete: ${a} fixed, ${n} skipped`)},[ht,q]=m.useState(!1),ze=e.jsxs("div",{className:"p-2 space-y-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase text-muted-foreground px-2 mb-1",children:"Buckets"}),e.jsx("div",{className:"space-y-0.5",children:D.map(t=>e.jsxs("button",{onClick:()=>{x(t.id),N("bucket"),q(!1)},className:C("w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-sm text-left transition-colors",o===t.id&&u==="bucket"?"bg-primary/10 text-primary font-medium":"hover:bg-muted"),children:[e.jsx(Ve,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate",children:t.label})]},t.id))})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase text-muted-foreground px-2 mb-1",children:"Maintenance"}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs("button",{onClick:()=>{N("audit"),q(!1)},className:C("w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-sm text-left",u==="audit"?"bg-primary/10 text-primary font-medium":"hover:bg-muted"),children:[e.jsx(De,{className:"h-4 w-4"})," Unused Files"]}),e.jsxs("button",{onClick:()=>{N("trash"),q(!1)},className:C("w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-sm text-left",u==="trash"?"bg-primary/10 text-primary font-medium":"hover:bg-muted"),children:[e.jsx(It,{className:"h-4 w-4"})," Recycle Bin"]}),e.jsxs("button",{onClick:()=>{ae(!0),q(!1)},className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-sm text-left hover:bg-muted",children:[e.jsx(Ht,{className:"h-4 w-4"})," Fix HDR Photos"]})]})]})]}),ft=e.jsx("aside",{className:"hidden lg:block w-56 shrink-0 border-r bg-muted/30",children:ze}),xt=e.jsxs("div",{className:"flex items-center gap-1 text-sm flex-wrap",children:[e.jsx("button",{className:"flex items-center gap-1 px-2 py-1 rounded-md hover:bg-muted text-muted-foreground",onClick:()=>{N("bucket"),S(""),ee(null)},children:e.jsx(Rt,{className:"h-3.5 w-3.5"})}),e.jsx(X,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("button",{className:C("px-2 py-1 rounded-md hover:bg-muted font-medium",!g&&!M&&u==="bucket"&&"bg-muted"),onClick:()=>{N("bucket"),S(""),ee(null)},children:Fe.label}),u==="bucket"&&M&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(X,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"px-2 py-1 rounded-md bg-muted font-medium",children:We(M)})]}),u==="bucket"&&g&&g.split("/").map((t,a,n)=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(X,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("button",{className:"px-2 py-1 rounded-md hover:bg-muted",onClick:()=>S(n.slice(0,a+1).join("/")),children:t})]},a)),u==="trash"&&e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"px-2 py-1 font-medium",children:"Recycle Bin"})]}),u==="audit"&&e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"px-2 py-1 font-medium",children:"Unused Files"})]})]}),gt=(t,a)=>{var l;
9const n=Z.has(t.key),s=ve(t.mimetype,t.name),r=qe(t.mimetype,t.name);return e.jsxs("div",{className:C("group relative bg-card border rounded-lg overflow-hidden transition-all",n?"ring-2 ring-primary":"hover:shadow-md hover:border-primary/30"),children:[!t.isFolder&&e.jsx("input",{type:"checkbox",checked:n,onChange:()=>ge(t.key),className:"absolute top-2 left-2 z-10 h-4 w-4 rounded",onClick:i=>i.stopPropagation()}),e.jsx("button",{className:"w-full aspect-square bg-muted flex items-center justify-center overflow-hidden",onClick:()=>t.isFolder?me(t):ge(t.key),title:t.isFolder?"Open folder":n?"Deselect":"Select",children:t.isFolder?e.jsx(Ke,{className:"h-10 w-10 text-muted-foreground"}):s?e.jsx("img",{src:t.publicUrl,alt:t.name,loading:"lazy",className:"w-full h-full object-cover pointer-events-none"}):r?e.jsx(ye,{className:"h-10 w-10 text-destructive"}):e.jsx(ye,{className:"h-10 w-10 text-muted-foreground"})}),e.jsxs("div",{className:"p-2 space-y-1 cursor-pointer hover:bg-muted/40",onClick:()=>t.isFolder?me(t):ce(t),title:t.isFolder?"Open folder":"Open preview",children:[e.jsx("div",{className:"text-xs font-medium truncate",title:t.name,children:t.name}),t.isFolder&&t.pageCount!==void 0&&e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[t.pageCount," file",t.pageCount===1?"":"s"]}),t.bucket!==o&&e.jsxs("div",{className:"text-[10px] text-muted-foreground truncate",title:t.bucket,children:[e.jsx(Ve,{className:"h-2.5 w-2.5 inline mr-0.5"}),((l=D.find(i=>i.id===t.bucket))==null?void 0:l.label)||t.bucket]}),!t.isFolder&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-[10px] text-muted-foreground flex items-center justify-between gap-1",children:[e.jsx("span",{children:ne(t.size)}),(t.uploadedAt||t.updatedAt)&&e.jsx("span",{children:Y(new Date(t.uploadedAt||t.updatedAt),"d MMM yy")})]}),t.uploaderName&&e.jsxs("div",{className:"text-[10px] text-muted-foreground truncate",title:`Uploaded by ${t.uploaderName}${t.uploadedAt?` on ${Y(new Date(t.uploadedAt),"d MMM yyyy, HH:mm")}`:""}`,children:["by ",t.uploaderName]}),!(a!=null&&a.trash)&&e.jsxs("div",{className:"flex items-center justify-between gap-1",children:[t.usedBy.length>0?e.jsxs(H,{variant:"secondary",className:"text-[10px] h-5 whitespace-nowrap shrink-0",children:["Used ×",t.usedBy.length]}):e.jsx(H,{variant:"outline",className:"text-[10px] h-5 whitespace-nowrap shrink-0 text-muted-foreground",children:"Unused"}),e.jsxs("div",{className:"flex -mr-1",onClick:i=>i.stopPropagation(),children:[e.jsx(y,{size:"icon",variant:"ghost",className:"h-7 w-7 shrink-0",onClick:()=>he(t),title:"Copy link",children:e.jsx(je,{className:"h-3.5 w-3.5"})}),e.jsx(y,{size:"icon",variant:"ghost",className:"h-7 w-7 shrink-0 text-destructive",onClick:()=>A({rows:[t],permanent:!1}),title:"Move to Recycle Bin",children:e.jsx(I,{className:"h-3.5 w-3.5"})})]})]}),(a==null?void 0:a.trash)&&e.jsxs("div",{className:"flex items-center justify-end gap-1",onClick:i=>i.stopPropagation(),children:[e.jsx(y,{size:"icon",variant:"ghost",className:"h-7 w-7",onClick:()=>pe(t),title:"Restore",children:e.jsx(ke,{className:"h-3.5 w-3.5"})}),e.jsx(y,{size:"icon",variant:"ghost",className:"h-7 w-7 text-destructive",onClick:()=>A({rows:[t],permanent:!0}),title:"Delete permanently",children:e.jsx(I,{className:"h-3.5 w-3.5"})})]})]})]})]},t.key)},bt=(t,a)=>{var r;const n=Z.has(t.key),s=ve(t.mimetype,t.name);return e.jsxs("div",{className:C("flex items-center gap-3 px-3 py-1.5 border-b last:border-b-0 hover:bg-muted/40 text-sm",n&&"bg-primary/5"),children:[!t.isFolder&&e.jsx("input",{type:"checkbox",checked:n,onChange:()=>ge(t.key),className:"h-4 w-4 rounded"}),t.isFolder&&e.jsx("div",{className:"w-4"}),e.jsxs("button",{className:"flex items-center gap-2 flex-1 min-w-0 text-left",onClick:()=>t.isFolder?me(t):ce(t),children:[e.jsx("div",{className:"h-8 w-8 rounded bg-muted flex items-center justify-center overflow-hidden shrink-0",children:t.isFolder?e.jsx(Ke,{className:"h-4 w-4 text-muted-foreground"}):s?e.jsx("img",{src:t.publicUrl,alt:t.name,loading:"lazy",className:"w-full h-full object-cover"}):e.jsx(ye,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"truncate",children:t.name}),t.isFolder&&t.pageCount!==void 0&&e.jsx(H,{variant:"outline",className:"text-[10px] whitespace-nowrap shrink-0",children:t.pageCount}),t.bucket!==o&&e.jsx(H,{variant:"outline",className:"text-[10px] whitespace-nowrap shrink-0",children:((r=D.find(l=>l.id===t.bucket))==null?void 0:r.label)||t.bucket})]}),!(a!=null&&a.trash)&&(t.isFolder?e.jsx("span",{className:"hidden md:inline text-xs text-muted-foreground w-20 text-right",children:"-"}):t.usedBy.length>0?e.jsxs(H,{variant:"secondary",className:"hidden md:inline-flex text-[10px] whitespace-nowrap shrink-0",children:["Used ×",t.usedBy.length]}):e.jsx(H,{variant:"outline",className:"hidden md:inline-flex text-[10px] whitespace-nowrap shrink-0 text-muted-foreground",children:"Unused"})),e.jsx("span",{className:"text-xs text-muted-foreground w-32 text-right truncate hidden md:inline",title:t.uploaderName?`Uploaded by ${t.uploaderName}`:"",children:t.isFolder?"":t.uploaderName||"-"}),e.jsx("span",{className:"hidden md:inline text-xs text-muted-foreground w-20 text-right tabular-nums",children:t.isFolder?"-":ne(t.size)}),e.jsx("span",{className:"hidden md:inline text-xs text-muted-foreground w-24 text-right",children:t.uploadedAt?Y(new Date(t.uploadedAt),"d MMM yy"):t.updatedAt?Y(new Date(t.updatedAt),"d MMM yy"):"-"}),!t.isFolder&&e.jsx("div",{className:"flex",children:a!=null&&a.trash?e.jsxs(e.Fragment,{children:[e.jsx(y,{size:"icon",variant:"ghost",className:"h-7 w-7",onClick:()=>pe(t),title:"Restore",children:e.jsx(ke,{className:"h-3.5 w-3.5"})}),e.jsx(y,{size:"icon",variant:"ghost",className:"h-7 w-7 text-destructive",onClick:()=>A({rows:[t],permanent:!0}),title:"Delete permanently",children:e.jsx(I,{className:"h-3.5 w-3.5"})})]}):e.jsxs(e.Fragment,{children:[e.jsx(y,{size:"icon",variant:"ghost",className:"h-7 w-7",onClick:()=>he(t),title:"Copy link",children:e.jsx(je,{className:"h-3.5 w-3.5"})}),e.jsx(y,{size:"icon",variant:"ghost",className:"h-7 w-7 text-destructive",onClick:()=>A({rows:[t],permanent:!1}),title:"Move to Recycle Bin",children:e.jsx(I,{className:"h-3.5 w-3.5"})})]})})]},t.key)},be=u==="trash"?lt||[]:u==="audit"?rt||[]:Ue,L=u==="bucket"?be:_?be.filter(t=>t.name.toLowerCase().includes(_.toLowerCase())):be,Ee=L.filter(t=>!t.isFolder).length,wt=L.reduce((t,a)=>t+(a.size||0),0);return e.jsxs("div",{className:"flex border rounded-xl overflow-hidden bg-card min-h-[600px]",children:[ft,e.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[e.jsxs("div",{className:"border-b",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b",children:[e.jsxs(Xt,{open:ht,onOpenChange:q,children:[e.jsx(Yt,{asChild:!0,children:e.jsx(y,{variant:"outline",size:"icon",className:"h-8 w-8 lg:hidden shrink-0",title:"Browse buckets",children:e.jsx(St,{className:"h-4 w-4"})})}),e.jsx(at,{side:"left",className:"w-64 p-0",children:ze})]}),e.jsx("div",{className:"min-w-0 flex-1 overflow-x-auto",children:xt})]}),(()=>{const t=L.filter(l=>!l.isFolder),a=t.length>0&&t.every(l=>Z.has(l.key)),n=W.length>0,s=t.length>0,r=n?u==="audit"?"bg-amber-500/10":"bg-primary/5":"";return e.jsxs("div",{className:C("flex items-center gap-2 flex-wrap px-3 py-2 transition-colors",r),children:[s&&e.jsxs("div",{className:"flex items-center gap-2 pr-2 mr-1 border-r min-h-[2rem]",children:[e.jsx(Ot,{checked:a,onCheckedChange:()=>{z(a?new Set:new Set(t.map(l=>l.key)))},"aria-label":"Select all"}),e.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:n?`${W.length} / ${t.length}`:`${t.length}`}),n&&e.jsxs(e.Fragment,{children:[e.jsx(y,{size:"sm",variant:"ghost",className:"h-8",onClick:()=>z(new Set),children:"Clear"}),u==="trash"?e.jsxs(e.Fragment,{children:[e.jsxs(y,{size:"sm",variant:"outline",className:"h-8",onClick:async()=>{for(const l of W)await pe(l);z(new Set)},children:[e.jsx(ke,{className:"h-3.5 w-3.5"})," Restore"]}),e.jsxs(y,{size:"sm",variant:"destructive",className:"h-8",onClick:()=>A({rows:W,permanent:!0}),children:[e.jsx(I,{className:"h-3.5 w-3.5"})," Delete"]})]}):e.jsxs(y,{size:"sm",variant:"destructive",className:"h-8",onClick:()=>A({rows:W,permanent:!1}),children:[e.jsx(I,{className:"h-3.5 w-3.5"})," Move to bin"]})]})]}),e.jsxs("div",{className:"relative flex-1 min-w-[140px]",children:[e.jsx(_t,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}
9),e.jsx(Bt,{placeholder:"Search…",value:_,onChange:l=>le(l.target.value),className:"pl-8 h-8 w-full"})]}),e.jsxs(y,{variant:"outline",size:"sm",className:"h-8",onClick:()=>{P(l=>l==="date"?"name":l==="name"?"size":"date")},title:"Sort",children:[e.jsx(qt,{className:"h-3.5 w-3.5"})," ",U]}),e.jsxs("div",{className:"flex rounded-md border h-8",children:[e.jsx("button",{onClick:()=>$e("grid"),className:C("px-2",ie==="grid"?"bg-muted":""),title:"Grid",children:e.jsx(Kt,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>$e("list"),className:C("px-2 border-l",ie==="list"?"bg-muted":""),title:"List",children:e.jsx(Gt,{className:"h-3.5 w-3.5"})})]}),e.jsx(y,{variant:"outline",size:"sm",className:"h-8",onClick:()=>V(!0),title:"Refresh",children:e.jsx(Jt,{className:C("h-3.5 w-3.5",(B||de)&&"animate-spin")})}),u==="bucket"&&e.jsxs(y,{size:"sm",className:"h-8",onClick:()=>{var l;return(l=se.current)==null?void 0:l.click()},disabled:nt,children:[e.jsx(Vt,{className:"h-3.5 w-3.5"})," Upload"]}),e.jsx("input",{ref:se,type:"file",multiple:!0,className:"hidden",onChange:l=>ot(l.target.files)})]})})()]}),u==="audit"&&e.jsxs("div",{className:"px-4 py-3 bg-amber-500/10 border-b text-sm text-amber-900 dark:text-amber-200 flex items-start gap-2",children:[e.jsx(De,{className:"h-4 w-4 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold",children:"Unused file audit - all buckets"}),e.jsx("div",{className:"text-xs opacity-80",children:"Files below have no detected references in posts, shows, sponsors, page content, knowledge base, announcements, or site photos. Always double-check before deleting - embedded/dynamic references may not always be detected."})]})]}),e.jsx("div",{className:"flex-1 overflow-auto p-3",children:B||de?e.jsxs("div",{className:"flex items-center justify-center py-20 text-muted-foreground",children:[e.jsx(Ft,{className:"h-5 w-5 animate-spin mr-2"})," ",de?"Scanning…":"Loading…"]}):L.length===0?e.jsx("div",{className:"text-center py-20 text-muted-foreground border border-dashed rounded-xl",children:u==="trash"?"Recycle Bin is empty":u==="audit"?"No unused files detected 🎉":"No files in this folder"}):ie==="grid"?e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5 gap-3",children:L.map(t=>gt(t,{trash:u==="trash",audit:u==="audit"}))}):e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 bg-muted/50 border-b text-[10px] uppercase font-semibold text-muted-foreground",children:[e.jsx("div",{className:"w-4"}),e.jsx("div",{className:"flex-1",children:"Name"}),u!=="trash"&&e.jsx("div",{className:"hidden md:block w-[72px] text-right",children:"Status"}),e.jsx("div",{className:"hidden md:block w-20 text-right",children:"Size"}),e.jsx("div",{className:"hidden md:block w-24 text-right",children:"Modified"}),e.jsx("div",{className:"w-[108px]"})]}),L.map(t=>bt(t,{trash:u==="trash"}))]})}),e.jsxs("div",{className:"border-t bg-muted/30 px-3 py-1.5 text-[11px] text-muted-foreground flex items-center justify-between",children:[e.jsxs("span",{children:[Ee," item",Ee!==1?"s":""," · ",ne(wt)]}),u==="bucket"&&e.jsx("span",{children:Fe.public?"Public bucket":"Private bucket"})]})]}),e.jsx(Me,{open:!!h,onOpenChange:t=>!t&&ce(null),children:e.jsxs(Te,{className:"max-w-3xl",children:[e.jsxs(Oe,{children:[e.jsx(Le,{className:"truncate",children:h==null?void 0:h.name}),e.jsxs(Ie,{children:[ne(h==null?void 0:h.size)," · ",(h==null?void 0:h.mimetype)||"unknown",h!=null&&h.usedBy.length?` · used by ${h.usedBy.length} item${h.usedBy.length>1?"s":""}`:" · not referenced"]})]}),h&&e.jsxs("div",{className:"space-y-3",children:[ve(h.mimetype,h.name)?e.jsx("img",{src:h.publicUrl,alt:h.name,className:"max-h-[60vh] mx-auto rounded-lg"}):qe(h.mimetype,h.name)?e.jsx("iframe",{src:h.publicUrl,className:"w-full h-[60vh] rounded-lg border",title:h.name}):e.jsx("div",{className:"text-center text-muted-foreground py-10",children:"No inline preview available."}),h.usedBy.length>0&&e.jsxs("div",{className:"text-xs bg-muted/50 rounded-lg p-3 space-y-1",children:[e.jsx("div",{className:"font-semibold",children:"Referenced by:"}),e.jsx("ul",{className:"space-y-1",children:h.usedBy.map((t,a)=>e.jsxs("li",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"truncate",children:t.label}),t.url&&e.jsxs("a",{href:t.url,target:"_blank",rel:"noreferrer",className:"text-primary hover:underline flex items-center gap-1 shrink-0",children:["Open ",e.jsx(He,{className:"h-3 w-3"})]})]},a))})]}),e.jsxs("div",{className:"text-xs bg-muted/30 rounded-lg p-3 space-y-0.5",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Uploaded by:"})," ",e.jsx("span",{className:"font-medium",children:h.uploaderName||"Unknown"})]}),h.uploadedAt&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Uploaded:"})," ",Y(new Date(h.uploadedAt),"d MMM yyyy 'at' HH:mm")]})]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground font-mono break-all",children:[h.bucket,"/",h.key]})]}),e.jsx(we,{className:"gap-2 sm:gap-2",children:h&&e.jsxs(e.Fragment,{children:[e.jsxs(y,{variant:"outline",onClick:()=>he(h),children:[e.jsx(je,{className:"h-4 w-4"})," Copy link"]}),e.jsx(y,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:h.publicUrl,download:!0,target:"_blank",rel:"noreferrer",children:[e.jsx(Wt,{className:"h-4 w-4"})," Download"]})}),e.jsx(y,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:h.publicUrl,target:"_blank",rel:"noreferrer",children:[e.jsx(He,{className:"h-4 w-4"})," Open"]})})]})})]})}),e.jsx(Ut,{open:!!b,onOpenChange:t=>!t&&A(null),children:e.jsxs(At,{children:[e.jsxs(Pt,{children:[e.jsx(zt,{children:b!=null&&b.permanent?`Permanently delete ${b.rows.length} file${b.rows.length>
91?"s":""}?`:`Move ${b==null?void 0:b.rows.length} file${((b==null?void 0:b.rows.length)||0)>1?"s":""} to Recycle Bin?`}),e.jsx(Et,{asChild:!0,children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{children:b!=null&&b.permanent?"This cannot be undone.":"You can restore files later from the Recycle Bin."}),(b==null?void 0:b.rows.some(t=>t.usedBy.length>0))&&e.jsxs("div",{className:"bg-destructive/10 text-destructive rounded-md p-2 text-xs",children:[e.jsx("div",{className:"font-semibold mb-1",children:"Some files are currently in use:"}),e.jsx("ul",{className:"list-disc list-inside",children:b.rows.flatMap(t=>t.usedBy.map((a,n)=>e.jsx("li",{children:a.label},`${t.key}-${n}`)))})]})]})})]}),e.jsxs(Dt,{children:[e.jsx(Mt,{children:"Cancel"}),e.jsx(Tt,{onClick:()=>b&&(b.permanent?dt(b.rows):ct(b.rows)),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:b!=null&&b.permanent?"Delete permanently":"Move to bin"})]})]})}),e.jsx(Me,{open:mt,onOpenChange:t=>{j!=null&&j.running||(ae(t),t||O(null))},children:e.jsxs(Te,{children:[e.jsxs(Oe,{children:[e.jsx(Le,{children:"Fix HDR Photos"}),e.jsx(Ie,{children:`Re-encodes every JPEG already in storage (across all photo buckets) to 
9strip the HDR "gain map" recent iPhones attach to photos - the thing that makes them look oversaturated or glowing next to everything else on the site. Safe to run more than once; files that don't need it are left as-is.`})]}),j?e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:j.running?j.total>0?`Processing ${j.done} / ${j.total}… (${j.fixed} fixed, ${j.errors} failed so far)`:"Finding JPEGs across buckets…":`Done — ${j.fixed} fixed, ${j.skipped} skipped, ${j.errors} failed (each retried once before counting as failed).`}),e.jsx("div",{className:"h-2 rounded-full bg-muted overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${j.total?j.done/j.total*100:0}%`}})}),!j.running&&j.failedKeys.length>0&&e.jsxs("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 p-2 max-h-32 overflow-y-auto",children:[e.jsx("div",{className:"text-xs font-semibold text-destructive mb-1",children:"Failed files"}),j.failedKeys.map(t=>e.jsx("div",{className:"text-xs text-muted-foreground font-mono truncate",children:t},t))]}),!j.running&&e.jsxs(we,{children:[e.jsx(y,{variant:"outline",onClick:()=>{ae(!1),O(null)},children:"Close"}),e.jsx(y,{onClick:Pe,children:j.errors>0?"Run again (will retry failures too)":"Run again"})]})]}):e.jsxs(we,{children:[e.jsx(y,{variant:"outline",onClick:()=>ae(!1),children:"Cancel"}),e.jsx(y,{onClick:Pe,children:"Start"})]})]})})]})};export{$s 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.