import{r as a,d as o,t as r,j as e,H as p,aM as g,f as d,cZ as x,cf as u}from"./vendor-laZsiqLO.js";import{A as f}from"./AdminLayout-Cg-VwQ1I.js";import{S as j}from"./SettingsLayout-nVJO7Ep3.js";import{C as y,a as b,b as w,c as S,d as N}from"./card-BKDXjfy_.js";import{B as C}from"./button-B8f8jW4H.js";import{S as v}from"./switch-52dk8qnh.js";import{L as k}from"./label-BDbCc0wv.js";import"./utils-RgT4yCq8.js";import"./admin-D0dR58a0.js";import"./bootstrap-CBwglqL9.js";/* empty css            */import"./dropdown-menu-CpMN0BZ0.js";import"./sheet-Cp4V1hdh.js";import"./avatar-1RNhlzAH.js";import"./useFlashMessages-CQoLOBuv.js";import"./separator-DMopkgTA.js";function q(){const[c,m]=a.useState(!0),[i,n]=a.useState(!1),[t,l]=a.useState(!0);a.useEffect(()=>{o.get("/api/admin/settings/auth").then(s=>{l(s.data.registration_enabled)}).catch(s=>{console.error(s),r.error("Failed to load settings.")}).finally(()=>m(!1))},[]);const h=async()=>{n(!0);try{const s=await o.post("/api/admin/settings/auth",{registration_enabled:t});r.success(s.data.message||"Settings updated successfully.")}catch(s){console.error(s),r.error("Failed to update settings.")}finally{n(!1)}};return e.jsxs(f,{header:"Settings",children:[e.jsx(p,{title:"Authentication Settings"}),e.jsx(j,{children:e.jsxs(y,{children:[e.jsxs(b,{children:[e.jsxs(w,{className:"flex items-center gap-2",children:[e.jsx(g,{className:"w-5 h-5"})," Registration Control"]}),e.jsx(S,{children:"Manage who can sign up for your application."})]}),e.jsx(N,{className:"space-y-6 pt-4",children:c?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(d,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-row items-center justify-between rounded-lg border p-4 shadow-sm bg-card",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(k,{className:"text-base",children:"Enable Public Registration"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"If disabled, only Admins can create new users via the User Management page."})]}),e.jsx(v,{checked:t,onCheckedChange:l})]}),!t&&e.jsxs("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 text-yellow-800 dark:text-yellow-200 p-4 rounded-md flex items-start gap-3 text-sm border border-yellow-200 dark:border-yellow-800",children:[e.jsx(x,{className:"w-5 h-5 shrink-0"}),e.jsxs("p",{children:[e.jsx("strong",{children:"Warning:"}),' Disabling registration will hide the "Sign Up" button on the homepage and login page. Users attempting to access the register route directly will see a 403 error.']})]}),e.jsx("div",{className:"flex justify-end pt-4",children:e.jsxs(C,{onClick:h,disabled:i,className:"min-w-[150px]",children:[i?e.jsx(d,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(u,{className:"mr-2 h-4 w-4"}),"Save Changes"]})})]})})]})})]})}export{q as default};
