import{wt as e}from"./mui-B6lh3XSP.js";import{l as t,u as n}from"./IconButton-BEBOUWhl.js";import{t as r}from"./Container-CHg71Wor.js";import{i,n as a,r as o}from"./ExpandMore-BvigPYWL.js";import{t as s}from"./TextField-DOdnjCrL.js";import{t as c}from"./Skeleton-C-luRk4q.js";import{t as l}from"./Typography-DfQXhGTT.js";import{n as u}from"./MenuItem-HQNtf0LG.js";import{en as d,mt as f,pt as p,w as m,yt as h}from"./index-KVuxnkWj.js";import{t as g}from"./useSettingsStyles-X3caKosH.js";var _=e(),v=({children:e,endpoint:v,item:y,setItem:b,defaultItem:x,validate:S,onItemSaved:C,menu:w,breadcrumbs:T})=>{let E=t(),{classes:D}=g(),O=h(),{id:k}=n();p(async({signal:e})=>{y||b(k?await(await m(`/api/${v}/${k}`,{signal:e})).json():x||{})},[k,y,x,v,b]);let A=f(async()=>{let e=`/api/${v}`;k&&(e+=`/${k}`);let t=await m(e,{method:k?`PUT`:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(y)});C&&C(await t.json()),E(-1)});return(0,_.jsx)(u,{menu:w,breadcrumbs:T,children:(0,_.jsxs)(r,{maxWidth:`xs`,className:D.container,children:[y?e:(0,_.jsxs)(i,{defaultExpanded:!0,children:[(0,_.jsx)(a,{children:(0,_.jsx)(l,{variant:`subtitle1`,children:(0,_.jsx)(c,{width:`10em`})})}),(0,_.jsx)(o,{children:[...[,,,]].map((e,t)=>(0,_.jsx)(c,{width:`100%`,children:(0,_.jsx)(s,{})},-t))})]}),(0,_.jsxs)(`div`,{className:D.buttons,children:[(0,_.jsx)(d,{color:`primary`,variant:`outlined`,onClick:()=>E(-1),disabled:!y,children:O(`sharedCancel`)}),(0,_.jsx)(d,{color:`primary`,variant:`contained`,onClick:A,disabled:!y||!S(),children:O(`sharedSave`)})]})]})})};export{v as t};