1import{ac as J,j as e,B as g,L as U,al as A}from"./index-7EFAMiCM.js";import{r as l}from"./react-vendor-CLLiSyAr.js";import{u as Y}from"./useQuery-YnBH_RC_.js";import{supabase as N}from"./client-CwZBWhtm.js";import{I as Z}from"./input-DbiZ3okp.js";import{B as $}from"./index-CW7pmUFz.js";import{s as ee}from"./adminStatusColors-DJ4H2IDV.js";import{S as se,a as te,b as ae,c as re,d as le}from"./sheet-C1xLKuHw.js";import{T as ie,a as ne,b as Q,c as i,d as de,e as n}from"./table-DhsQqT8z.js";import{S as v,a as w,b,c as S,d as o}from"./select-WPGqPjFg.js";import{L as oe}from"./LeadEmailDialog-BrJH47TV.js";import{M as E}from"./mail-vmf_WrCR.js";import{S as ce}from"./search-CM0j1jVs.js";import{M as me}from"./music-4-D2LlgOu5.js";import{C as xe}from"./circle-check-BCLDE0My.js";import{C as ue}from"./circle-x-Qdgav1cO.js";import{D as he}from"./download-CibaYfLE.js";import"./supabase-92svyh75.js";import"./index-DGrZF4cN.js";import"./Combination-CAYDltsY.js";import"./index-D3syr9tN.js";import"./label-B_3h-K02.js";import"./textarea-mRRP17X5.js";import"./checkbox-COa1Hi9u.js";import"./emailTemplates-BbdjW3BI.js";import"./plus-BsBAu_WA.js";import"./eye-iF2sgEuA.js";import"./send-ZdxigJJz.js";const y=[{value:"new",label:"New"},{value:"in_review",label:"In Review"},{value:"approved",label:"Approved"},{value:"rejected",label:"Rejected"}],V=r=>{var x;return((x=y.find(_=>_.value===r))==null?void 0:x.label)??"New"},z=r=>new Date(r).toLocaleDateString(void 0,{day:"numeric",month:"short",year:"numeric"}),pe=r=>({artist_id:r.id,email:r.email,first_name:r.artist_name,artist_name:r.artist_name,track_name:r.track_name,genre:r.genre,business_name:r.artist_name}),He=()=>{const r=J(),[x,_]=l.useState(""),[p,H]=l.useState("all"),[j,K]=l.useState("all"),[a,C]=l.useState(null),[k,q]=l.useState(null),[O,D]=l.useState(!1),[L,B]=l.useState(null),[c,u]=l.useState(null),{data:f,isLoading:P,error:I}=Y({queryKey:["admin-artist-applications"],queryFn:async()=>{const{data:s,error:t}=await N.from("artist_ai_signups").select("*").order("created_at",{ascending:!1});if(t)throw t;return s??[]}}),T=x.trim().toLowerCase(),h=l.useMemo(()=>{let s=f??[];return p==="with"&&(s=s.filter(t=>!!t.sample_path)),p==="without"&&(s=s.filter(t=>!t.sample_path)),j!=="all"&&(s=s.filter(t=>t.status===j)),T?s.filter(t=>[t.artist_name,t.email,t.track_name,t.genre].filter(Boolean).some(m=>m.toLowerCase().includes(T))):s},[f,T,p,j]),M=async(s,t)=>{B(s.id);const{error:m}=await N.from("artist_ai_signups").update({status:t}).eq("id",s.id);if(B(null),m){A({title:"Couldn't update status",description:m.message,variant:"destructive"});return}C(d=>d&&d.id===s.id?{...d,status:t}:d),await r.invalidateQueries({queryKey:["admin-artist-applications"]}),A({title:`Marked as ${V(t)}`})},G=async(s,t)=>{var d;const m=new Date().toISOString().slice(0,10);for(const R of s){const X=[(d=R.notes)==null?void 0:d.trim(),`${m} â Emailed: ${t}`].filter(Boolean).join(` 2`),{error:F}=await N.from("artist_ai_signups").update({notes:X}).eq("id",R.id);if(F){A({title:"Couldn't log the email",description:F.message,variant:"destructive"});break}}await r.invalidateQueries({queryKey:["admin-artist-applications"]})},W=async s=>{if(C(s),q(null),!s.sample_path)return;D(!0);const{data:t}=await N.storage.from("artist-submissions").createSignedUrl(s.sample_path,60*60);q((t==null?void 0:t.signedUrl)??null),D(!1)};return e.jsxs("div",{className:"px-6 py-8 md:px-10 md:py-10",children:[e.jsxs("header",{className:"mb-8 flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-display uppercase tracking-tight text-2xl md:text-3xl text-foreground",children:"Artist Applications"}),e.jsxs("p",{className:"text-muted-foreground font-body text-sm mt-1",children:["Submissions from the AI music artists page. ",f?`${f.length} total.`:""]})]}),e.jsxs(g,{variant:"outline",className:"rounded-full",disabled:h.length===0,onClick:()=>u(h),children:[e.jsx(E,{className:"h-4 w-4 mr-2"}),"Email ",h.length||""]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mb-6",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ce,{className:"absolute left-3.5 to
2p-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none"}),e.jsx(Z,{value:x,onChange:s=>_(s.target.value),placeholder:"Search artist, email, track or genre...",className:"pl-10"})]}),e.jsxs(v,{value:p,onValueChange:s=>H(s),children:[e.jsx(w,{className:"sm:w-52",children:e.jsx(b,{})}),e.jsxs(S,{children:[e.jsx(o,{value:"all",children:"All applications"}),e.jsx(o,{value:"with",children:"With sample"}),e.jsx(o,{value:"without",children:"No sample"})]})]}),e.jsxs(v,{value:j,onValueChange:s=>K(s),children:[e.jsx(w,{className:"sm:w-44",children:e.jsx(b,{})}),e.jsxs(S,{children:[e.jsx(o,{value:"all",children:"All statuses"}),y.map(s=>e.jsx(o,{value:s.value,children:s.label},s.value))]})]})]}),e.jsx("div",{className:"rounded-2xl border border-border bg-card overflow-hidden",children:P?e.jsx("div",{className:"p-10 flex justify-center",children:e.jsx(U,{className:"h-5 w-5 animate-spin text-warm-amber"})}):I?e.jsxs("p",{className:"p-8 text-sm font-body text-muted-foreground",children:["Couldn't load applications. ",I.message]}):h.length===0?e.jsx("p",{className:"p-8 text-sm font-body text-muted-foreground",children:"No applications match your filters."}):e.jsxs(ie,{children:[e.jsx(ne,{children:e.jsxs(Q,{children:[e.jsx(i,{children:"Artist"}),e.jsx(i,{className:"hidden md:table-cell",children:"Track"}),e.jsx(i,{className:"hidden lg:table-cell",children:"Genre"}),e.jsx(i,{children:"Sample"}),e.jsx(i,{className:"hidden sm:table-cell",children:"Rights"}),e.jsx(i,{children:"Status"}),e.jsx(i,{className:"text-right",children:"Received"}),e.jsx(i,{className:"w-10"})]})}),e.jsx(de,{children:h.map(s=>e.jsxs(Q,{onClick:()=>void W(s),className:"cursor-pointer",children:[e.jsxs(n,{children:[e.jsx("span",{className:"block font-body font-semibold text-foreground",children:s.artist_name||"â"}),e.jsx("span",{className:"block text-xs text-muted-foreground",children:s.email})]}),e.jsx(n,{className:"hidden md:table-cell text-sm",children:s.track_name||"â"}),e.jsx(n,{className:"hidden lg:table-cell text-sm",children:s.genre||"â"}),e.jsx(n,{children:s.sample_path?e.jsxs($,{variant:"secondary",className:"gap-1",children:[e.jsx(me,{className:"h-3 w-3"})," MP3"]}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"None"})}),e.jsx(n,{className:"hidden sm:table-cell",children:s.rights_confirmed?e.jsx(xe,{className:"h-4 w-4 text-verified"}):e.jsx(ue,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs(n,{onClick:t=>t.stopPropagation(),children:[e.jsx($,{variant:"outline",className:`mb-1.5 block w-fit ${ee(s.status)}`,children:V(s.status)}),e.jsxs(v,{value:s.status,onValueChange:t=>void M(s,t),disabled:L===s.id,children:[e.jsx(w,{className:"h-9 w-[132px] text-sm",children:e.jsx(b,{})}),e.jsx(S,{children:y.map(t=>e.jsx(o,{value:t.value,children:t.label},t.value))})]})]}),e.jsx(n,{className:"text-right text-sm text-muted-foreground whitespace-nowrap",children:z(s.created_at)}),e.jsx(n,{className:"text-right",children:e.jsx(g,{variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":`Email ${s.artist_name||s.email}`,onClick:t=>{t.stopPropagation(),u([s])},children:e.jsx(E,{className:"h-4 w-4"})})})]},s.id))})]})}),e.jsx(se,{open:!!a,onOpenChange:s=>!s&&C(null),children:e.jsx(te,{className:"w-full sm:max-w-lg overflow-y-auto",children:a&&e.jsxs(e.Fragment,{children:[e.jsxs(ae,{children:[e.jsx(re,{className:"font-display uppercase",children:a.artist_name||"Untitled artist"}),e.jsxs(le,{children:[a.email," · ",z(a.created_at)]})]}),e.jsxs("div",{className:"mt-6 space-y-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs uppercase tracking-wider text-muted-foreground mb-2",children:"Status"}),e.jsxs(v,{value:a.status,onValueChange:s=>void M(a,s),disabled:L===a.id,children:[e.jsx(w,{className:"w-full sm:w-56",children:e.jsx(b,{})}),e.jsx(S,{children:y.map(s=>e.jsx(o,{value:s.value,children:s.label},s.value))})]}),e.jsxs(g,{size:"sm",className:"rounded-full mt-3",onClick:()=>u([a]),children:[e.jsx(E,{className:"h-3.5 w-3.5 mr-1.5"}),"Email this artist"]})]}),e.jsxs("dl",{className:"grid grid-cols-2 gap-4 text-sm font-body",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted-foreground text-xs uppercase tracking-wider",children:"Track"}),e.jsx("dd",{className:"text-foreground",children:a.track_name||"â"})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted-foreground text-xs uppercase tracking-wider",children:"Genre"}),e.jsx("dd",{className:"text-foreground",children:a.genre||"â"})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted-foreground text-xs uppercase tracking-wider",children:"Rights"}),e.jsx("dd",{className:"text-foreground",children:a.rights_confirmed?"Confirmed":"Not confirmed"})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted-foreground text-xs uppercase tracking-wider",children:"Source"}),e.jsx("dd",{className:"text-foreground",children:a.source||"â"})]})]}),a.notes&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs uppercase tracking-wider text-muted-foreground mb-1.5",children:"Message"}),e.jsx("p",{className:"text-sm font-body text-foreground whitespace-pre-wrap rounded-xl bg-muted/50 p-4",children:a.notes})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs uppercase tracking-wider text-muted-foreground mb-2",children:"Sample"}),a.sample_path?O?e.jsx(U,{className:"h-4 w-4 animate-spin text-warm-amber"}):k?e.jsxs("div",{className:"space-y-3",children:[e.jsx("audio",{controls:!0,src:k,className:"w-full"}),e.jsx("a",{href:k,download:!0,children:e.jsxs(g,{variant:"outline",size:"sm",className:"rounded-full",children:[e.jsx(he,{className:"h-3.5 w-3.5 mr-2"}),"Download"]})})]}):e.jsx("p",{className:"text-sm font-body text-muted-foreground",children:"Couldn't load this file."}):e.jsx("p",{className:"text-sm font-body text-muted-foreground",children:"No sample uploaded."})]})]})]})})}),e.jsx(oe,{open:!!c,onOpenChange:s=>!s&&u(null),audience:"artist",recipients:(c??[]).map(pe),onSent:({markEmailed:s,subject:t})=>{s&&(c!=null&&c.length)&&G(c,t),u(null)}})]})};export{He 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.