import{jsx as e,jsxs as t}from"react/jsx-runtime";import{B as u}from"./button-BvFBRYHq.js";import{D as x,a as N,b as S,c as D,d as w,e as C}from"./dialog-BfGkTFdF.js";import{I}from"./input-qMvM9qch.js";import{Loader2 as k}from"lucide-react";import{useState as d,useEffect as F}from"react";import"@radix-ui/react-slot";import"class-variance-authority";import"./utils-CMbmcP35.js";import"clsx";import"tailwind-merge";import"@radix-ui/react-dialog";function z({open:n,onOpenChange:s,serverDir:o,initialGs01Maps:i,availableMaps:g,onSave:f}){const[c,m]=d(o),[a,l]=d(i),[p,h]=d(!1);F(()=>{m(o),l(i)},[o,i,n]);const v=async()=>{h(!0);try{await f(c,a),s(!1)}catch{}finally{h(!1)}};return e(x,{open:n,onOpenChange:s,children:t(N,{children:[t(S,{children:[e(D,{children:"Server Control Settings"}),e(w,{children:"Configure core settings for server management."})]}),t("div",{className:"space-y-4 py-2",children:[t("div",{className:"space-y-2",children:[e("label",{htmlFor:"server_dir",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Server Directory Path"}),e(I,{id:"server_dir",placeholder:"/home",value:c,onChange:r=>m(r.target.value)}),e("p",{className:"text-xs text-muted-foreground",children:"Absolute path to the game server root directory (e.g., /home, /opt/server)."})]}),t("div",{className:"space-y-2",children:[e("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Map Instances (gs01)"}),e("div",{className:"border rounded-md h-48 overflow-y-auto p-2 space-y-2 bg-muted/20",children:g.map(r=>t("div",{className:"flex items-center space-x-2",children:[e("input",{type:"checkbox",id:`map-${r.id}`,className:"h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary",checked:a.includes(r.id),onChange:y=>{y.target.checked?l([...a,r.id]):l(a.filter(b=>b!==r.id))}}),t("label",{htmlFor:`map-${r.id}`,className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 cursor-pointer w-full",children:[e("span",{className:"font-semibold text-primary",children:r.id}),r.name&&t("span",{className:"text-muted-foreground ml-2",children:[" - ",r.name]})]})]},r.id))}),e("p",{className:"text-xs text-muted-foreground",children:"Select maps to be loaded by the gs01 process."})]})]}),t(C,{children:[e(u,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),t(u,{onClick:v,disabled:p,children:[p&&e(k,{className:"mr-2 h-4 w-4 animate-spin"}),"Save Changes"]})]})]})})}export{z as ServerControlSettings};
