import{a as e}from"./rolldown-runtime-Cyuzqnbw.js";import{a as t,o as n}from"./vendor-motion-COLzAB1Q.js";import{t as r}from"./save-CqAluPeU.js";import{_ as i,c as a,r as o}from"./index-DLFWvoW-.js";import{t as s}from"./input-CQYqSHmc.js";import{t as c}from"./activity-log-BcZldPH3.js";var l=e(n(),1),u=t(),d={site_name:{label:`Site Name`,group:`General`},contact_email:{label:`Contact Email`,group:`General`},instagram_url:{label:`Instagram`,group:`Social Media`},twitter_url:{label:`Twitter / X`,group:`Social Media`},linkedin_url:{label:`LinkedIn`,group:`Social Media`},youtube_url:{label:`YouTube`,group:`Social Media`},vimeo_url:{label:`Vimeo`,group:`Social Media`},seo_title:{label:`SEO Title`,group:`SEO`},seo_description:{label:`SEO Description`,group:`SEO`}},f=()=>{let[e,t]=(0,l.useState)({}),[n,f]=(0,l.useState)(!0),[p,m]=(0,l.useState)(!1);(0,l.useEffect)(()=>{(async()=>{let{data:e,error:n}=await a.from(`site_settings`).select(`*`);if(n)i.error(`Failed to load settings`);else{let n={};(e||[]).forEach(e=>{n[e.key]=e.value||``}),t(n)}f(!1)})()},[]);let h=async()=>{m(!0);let t=Object.entries(e).map(([e,t])=>a.from(`site_settings`).update({value:t,updated_at:new Date().toISOString()}).eq(`key`,e));(await Promise.all(t)).some(e=>e.error)?i.error(`Some settings failed to save`):(i.success(`Settings saved`),c(`settings_updated`,{keys:Object.keys(e)})),m(!1)};if(n)return(0,u.jsx)(`div`,{className:`text-muted-foreground py-20 text-center`,children:`Loading...`});let g=Array.from(new Set(Object.values(d).map(e=>e.group)));return(0,u.jsxs)(`div`,{className:`space-y-6`,children:[(0,u.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`h1`,{className:`text-2xl font-bold text-foreground`,children:`Settings`}),(0,u.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Manage website settings`})]}),(0,u.jsxs)(o,{size:`sm`,onClick:h,disabled:p,children:[(0,u.jsx)(r,{className:`h-4 w-4 mr-2`}),p?`Saving...`:`Save All`]})]}),(0,u.jsx)(`div`,{className:`space-y-8 max-w-2xl`,children:g.map(n=>(0,u.jsxs)(`div`,{className:`rounded-xl border border-border bg-card p-6 space-y-5`,children:[(0,u.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:n}),Object.entries(d).filter(([,e])=>e.group===n).map(([n,r])=>(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground mb-1.5 block`,children:r.label}),(0,u.jsx)(s,{value:e[n]||``,onChange:r=>t({...e,[n]:r.target.value}),placeholder:n.includes(`url`)?`https://`:``})]},n))]},n))}),(0,u.jsxs)(`p`,{className:`text-xs text-muted-foreground max-w-2xl`,children:[`Video settings for the Hero and Showreel sections have been moved to the `,(0,u.jsx)(`strong`,{children:`Page Builder`}),`.`]})]})};export{f as default};