1import{r as n,j as e}from"./index-D4Zr5rY9.js";import{u as h}from"./createServerFn-BCL2_wWo.js";import{t as l}from"./index-UHvcT41n.js";import{a as S,f as C,R as D}from"./releases.functions-bFO8c3Pk.js";import{C as i,B as f}from"./badge-koYFi_fK.js";import{B as u}from"./button-ByIKbqS9.js";import{S as M}from"./shield-check-CCh4aFMd.js";import{L as g}from"./loader-circle-BEX-qcGY.js";import{c as N}from"./createLucideIcon-CTnQt_Aq.js";import{E as j}from"./external-link-DAKDitxf.js";import"./utils-BwZV9EMO.js";import"./clsx-B-dksMZM.js";const R=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],_=N("triangle-alert",R);const A=[["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.72",key:"ul74o6"}],["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"}]],L=N("wand-sparkles",A);function y(r){return r?r.match(/^(\d{4})-(\d{2})-(\d{2})$/)?new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric",timeZone:"UTC"}).format(new Date(`${r}T00:00:00Z`)):r:"â"}function P(){const r=h(S),c=h(C),[d,o]=n.useState(!1),[t,v]=n.useState(null),[m,x]=n.useState({}),[b,p]=n.useState({}),k=async()=>{o(!0);try{const s=await r();v(s),p({}),l.success(`Checked ${s.total} releases â ${s.mismatches.length} mismatched, ${s.unverified.length} unverified`)}catch(s){l.error(s instanceof Error?s.message:"Audit failed")}finally{o(!1)}},w=async s=>{x(a=>({...a,[s.id]:!0}));try{await c({data:{id:s.id,date:s.spotifyDate}}),p(a=>({...a,[s.id]:s.spotifyDate})),l.success(`Updated "${s.title}" â ${s.spotifyDate}`)}catch(a){l.error(a instanceof Error?a.message:"Update failed")}finally{x(a=>({...a,[s.id]:!1}))}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 flex-wrap",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-semibold flex items-center gap-2",children:[e.jsx(M,{className:"h-6 w-6 text-gold"})," Release Date Audit"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Compares each release's stored date against the date visible on its Spotify page."})]}),e.jsxs(u,{onClick:k,disabled:d,className:"gap-2",children:[d?e.jsx(g,{className:"h-4 w-4 animate-spin"}):e.jsx(D,{className:"h-4 w-4"}),d?"Auditingâ¦":t?"Re-run audit":"Run audit"]})]}),!t&&!d&&e.jsx(i,{className:"p-8 text-center text-sm text-muted-foreground",children:'Click "Run audit" to scrape each Spotify page and compare dates. This may take a minute.'}),t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[e.jsxs(i,{className:"p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:"Checked"}),e.jsx("div",{className:"text-2xl font-semibold mt-1",children:t.total})]}),e.jsxs(i,{className:"p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:"Mismatched"}),e.jsx("div",{className:"text-2xl font-semibold mt-1 text-amber-500",children:t.mismatches.length})]}),e.jsxs(i,{className:"p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:"Unverified"}),e.jsx("div",{className:"text-2xl font-semibold mt-1",children:t.unverified.length})]})]}),e.jsxs(i,{className:"p-0 overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-border flex items-center gap-2",children:[e.jsx(_,{className:"h-4 w-4 text-amber-500"}),e.jsx("h2",{className:"font-medium",children:"Mismatches"})]}),t.mismatches.length===0?e.jsx("div",{className:"p-6 text-sm text-muted-foreground",children:"All stored dates match the Spotify pages. ð"}):e.jsx("div",{className:"divide-y divide-border",children:t.mismatches.map(s=>{const a=b[s.id];return e.jsxs("div",{className:"p-4 flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-[200px]",children:[e.jsxs("div",{className:"font-medium flex items-center gap-2",children:[s.title,s.release_type&&e.jsx(f,{variant:"secondary",className:"uppercase text-[10px]",children:s.release_type})]}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Stored: ",e.jsx("span",{className:"text-foreground",children:y(a??s.storedDate)})," · ","Spotify:"," ",e.jsx("span",{className:"text-amber-500 font-medium",children:y(s.spotifyDate)})]})]}),e.jsxs("a",{href:s.spotify_url,target:"_blank",rel:"noreferrer",className:"text-xs text-muted-foreground hover:text-gold flex items-center gap-1",children:["Open ",e.jsx(j,{className:"h-3 w-3"})]}),a===s.spotifyDate?e.jsx(f,{className:"bg-emerald-600/20 text-emerald-400 border-emerald-600/30",children:"Fixed"}):e.jsxs(u,{size:"sm",variant:"secondary",disabled:m[s.id],onClick:()=>w(s),className:"gap-1",children:[m[s.id]?e.jsx(g,{className:"h-3 w-3 animate-spin"}):e.jsx(L,{className:"h-3 w-3"}),"Use Spotify date"]})]},s.id)})})]}),t.unverified.length>0&&e.jsxs(i,{className:"p-0 overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-border",children:[e.jsx("h2",{className:"font-medium",children:"Unverified"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Couldn't read a date from these Spotify pages."})]}),e.jsx("div",{className:"divide-y divide-border",children:t.unverified.map(s=>e.jsxs("div",{className:"px-4 py-3 text-sm flex items-center justify-between gap-3",children:[e.jsx("span",{children:s.title}),e.jsxs("a",{href:`https://open.spotify.com/album/${s.spotify_id}`,target:"_blank",rel:"noreferrer",className:"text-xs text-muted-foreground hover:text-gold flex items-center gap-1",children:["Open ",e.jsx(j,{className:"h-3 w-3"})]})]},s.id))})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Last checked ",new Date(t.checkedAt).toLocaleStr
1ing()]})]})]})}export{P as component};
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.