import{j as e}from"./radix-ui-nu4wz29m.js";import{r as k}from"./react-vendor-Bjx91N7w.js";import{t as R}from"./notifications-B4_o8bcr.js";import{B as E,e as a,c as z,bc as S,X as B}from"./index-CcGVqYOy.js";import{aX as L,L as m,au as P,o as T,R as X}from"./icons-DzKUh8vG.js";function F({title:c,pathLabel:x,loading:t,parseWarning:r,readWarning:i,value:s,dirty:n,readOnly:f=!1,saving:h,saveDisabled:j,onChange:p,onSave:u,onRefresh:b,onDiscard:l,language:v="json",exactText:N=!1,loadingLabel:g="Loading settings.json...",parseWarningLabel:w="Parse warning",ownershipNotice:d}){const[C,o]=k.useState(!1),y=async()=>{s&&(await navigator.clipboard.writeText(s),o(!0),R.success(B.t("commonToast.settingsCopied")),window.setTimeout(()=>o(!1),1500))};return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"p-4 border-b bg-background flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h2",{className:"font-semibold flex items-center gap-2",children:[e.jsx(L,{className:"h-4 w-4 text-primary"}),c,n&&e.jsx(E,{variant:"secondary",className:"text-[10px]",children:"Unsaved"})]}),e.jsx("p",{className:"text-xs text-muted-foreground font-mono truncate",children:x})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(a,{size:"sm",onClick:u,disabled:j,children:[h?e.jsx(m,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(P,{className:"h-4 w-4 mr-1"}),"Save"]}),l?e.jsx(a,{variant:"outline",size:"sm",onClick:l,disabled:!n||t,children:"Discard"}):null,e.jsxs(a,{variant:"outline",size:"sm",onClick:y,disabled:!s,children:[e.jsx(T,{className:"h-4 w-4 mr-1"}),C?"Copied":"Copy"]}),e.jsx(a,{variant:"outline",size:"sm",onClick:b,"aria-label":"Refresh raw config",children:e.jsx(X,{className:z("h-4 w-4",t?"animate-spin":"")})})]})]}),e.jsx("div",{className:"flex-1 overflow-auto",children:t?e.jsxs("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:[e.jsx(m,{className:"h-5 w-5 animate-spin mr-2"}),g]}):e.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[d&&e.jsx("div",{className:"mx-4 mt-4",children:d}),r&&e.jsxs("div",{className:"mx-4 mt-4 rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-800 dark:bg-amber-950/20 dark:text-amber-300",children:[w,": ",r]}),i&&e.jsxs("div",{className:"mx-4 mt-4 rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:["Read-only: ",i]}),e.jsx("div",{className:"min-h-0 flex-1 p-4 pt-3",children:e.jsx("div",{className:"h-full rounded-md border overflow-hidden bg-background",children:e.jsx(S,{value:s,onChange:p,language:v,readonly:f,exactText:N,minHeight:"100%",heightMode:"fill-parent"})})})]})})]})}const A=F;export{F as R,A as a};
