1import{aa as v,r as x,u as h,j as e,a as j,s as i,J as n}from"./index-CbYUJabt.js";import{u as N}from"./useMutation-V8v4gpXf.js";import{I as w}from"./input-DqkmooFZ.js";import{L as _}from"./label-dsAS461n.js";import{S}from"./switch-D_8c31Hr.js";import{S as k}from"./save-BYFwq8DG.js";import"./index-Ch0VcbCN.js";function E(){const r=v(),[l,p]=x.useState(null),[o,d]=x.useState(!1),{data:c,isLoading:f}=h({queryKey:["site-settings","blog_display_name"],queryFn:async()=>{const{data:s,error:t}=await i.from("site_settings").select("value").eq("key","blog_display_name").maybeSingle();if(t)throw t;return(s==null?void 0:s.value)??"Thinking?"}}),{data:a,isLoading:y}=h({queryKey:["admin-authors-settings"],queryFn:async()=>{const{data:s,error:t}=await i.from("article_authors").select("id, name, title, bio, avatar_url, is_active").order("name");if(t)throw t;return s??[]}}),m=N({mutationFn:async({id:s,is_active:t})=>{const{error:g}=await i.from("article_authors").update({is_active:t}).eq("id",s);if(g)throw g},onSuccess:()=>{r.invalidateQueries({queryKey:["admin-authors-settings"]}),n.success("Author updated")},onError:s=>{n.error(s.message)}}),b=async()=>{const s=l??c??"Thinking?";d(!0);try{const{error:t}=await i.from("site_settings").upsert({key:"blog_display_name",value:s},{onConflict:"key"});if(t)throw t;r.invalidateQueries({queryKey:["site-settings","blog_display_name"]}),n.success("Blog display name updated")}catch(t){n.error(t instanceof Error?t.message:"Failed to save")}finally{d(!1)}},u=l??c??"";return e.jsxs("div",{className:"p-8 max-w-4xl",children:[e.jsxs("div",{className:"mb-12",children:[e.jsx("p",{className:"text-xs uppercase tracking-wider text-muted-foreground mb-2",children:"System"}),e.jsx("h1",{className:"font-display text-4xl",children:"Settings"}),e.jsx("p",{className:"text-lg text-muted-foreground mt-2",children:"Configure system-wide settings for the Content Machine"})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"bg-[hsl(45,30%,96%)] border border-border p-6",children:[e.jsx("h2",{className:"font-display text-xl mb-2",children:"Blog display name"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"The public-facing name shown on the website navigation and blog listing page. Change this to rebrand the blog without touching code."}),e.jsxs("div",{className:"flex items-end gap-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(_,{htmlFor:"blog-name",className:"text-xs text-muted-foreground",children:"Display name"}),e.jsx(w,{id:"blog-name",value:u,onChange:s=>p(s.target.value),placeholder:"e.g. Thinking?",disabled:f})]}),e.jsxs(j,{onClick:b,disabled:o||!u.trim(),size:"sm",children:[e.jsx(k,{className:"h-4 w-4 mr-2"}),o?"Saving...":"Save"]})]})]}),e.jsxs("div",{className:"bg-[hsl(45,30%,96%)] border border-border p-6",children:[e.jsx("h2",{className:"font-display text-xl mb-2",children:"Author pool"}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[(a==null?void 0:a.filter(s=>s.is_active).length)??0," of ",(a==null?void 0:a.length)??0," author",((a==null?void 0:a.length)??0)!==1?"s":""," active in the pool. The system randomly selects an active author for each new article."]}),y?e.jsx("p",{className:"text-muted-foreground",children:"Loadingâ¦"}):a!=null&&a.length?e.jsx("div",{className:"space-y-1",children:a.map(s=>e.jsxs("div",{className:"flex items-center justify-between py-3 px-4 rounded-lg hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.avatar_url?e.jsx("img",{src:s.avatar_url,alt:s.name,className:"w-10 h-10 rounded-full object-cover shrink-0"}):e.jsx("div",{className:"w-10 h-10 rounded-full bg-muted flex items-center justify-center text-xs font-medium text-muted-foreground shrink-0",children:s.name.split(" ").map(t=>t[0]).join("").slice(0,2).toUpperCase()}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:s.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.title}),s.bio&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:s.bio})]})]}),e.jsx(S,{checked:s.is_active,onCheckedChange:t=>m.mutate({id:s.id,is_active:t}),disabled:m.isPending})]},s.id))}):e.jsx("p",{className:"text-muted-foreground",children:"No active authors found."})]})]})]})}export{E 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.