import{i as s}from"./_virtual___federation_fn_import-DB-0B1B_.js";import{j as e}from"./jsx-runtime-u17CrQMm.js";import{c as p}from"./clsx-B-dksMZM.js";import{F as j,as as b}from"./index-KpBDpTrU.js";import{l as h}from"./error-formatter-B41KnHG1.js";import{E as v}from"./enum-info-form-DBuiSsqs.js";import{u as g}from"./use-enum-form-BxerQuZY.js";const{Button:f,Dialog:E,DialogClose:y,DialogContent:D,DialogFooter:C,DialogHeader:S,DialogTitle:F,DialogTrigger:N,useControlledState:w}=await s("@baseplate-dev/ui-components");function I({enumKey:a,open:t,onOpenChange:r,trigger:i}){const[l,n]=w(t,r,!1),{form:{control:c,reset:d},onSubmit:m,defaultValues:o,isSavingDefinition:u}=g({enumKey:a,onSubmitSuccess(){n(!1)}});return e.jsxs(E,{open:l,onOpenChange:x=>{n(x),x||d(o)},children:[i&&e.jsx(N,{render:i}),e.jsx(D,{"aria-describedby":void 0,children:e.jsxs("form",{onSubmit:m,className:"space-y-4",children:[e.jsx(S,{children:e.jsx(F,{children:"Edit Enum Info"})}),e.jsx(v,{control:c}),e.jsxs(C,{children:[e.jsx(y,{render:e.jsx(f,{variant:"secondary"}),children:"Cancel"}),e.jsx(f,{type:"submit",disabled:u,children:"Save"})]})]})})]})}const{FeatureUtils:B,modelEnumEntityType:k}=await s("@baseplate-dev/project-builder-lib"),{useProjectDefinition:T}=await s("@baseplate-dev/project-builder-lib/web"),{Button:O,useConfirmDialog:R}=await s("@baseplate-dev/ui-components"),{useNavigate:z}=await s("@tanstack/react-router");function P({className:a,enumDefinition:t}){const{definition:r,saveDefinitionWithFeedbackSync:i,isSavingDefinition:l}=T(),n=z(),{requestConfirm:c}=R(),d=m=>{i(o=>{o.enums=o.enums?.filter(u=>u.id!==m)},{onSuccess:()=>{n({to:"/data/enums"}).catch(h)}})};return e.jsxs("div",{className:p("flex items-center justify-between",a),children:[e.jsxs("div",{children:[e.jsx(I,{enumKey:k.keyFromId(t.id),trigger:e.jsxs("button",{className:"group flex items-center space-x-2 hover:cursor-pointer",type:"button",title:"Edit Enum Info",children:[e.jsx("h1",{children:t.name}),e.jsx(j,{className:"invisible size-4 group-hover:visible"})]})}),t.featureRef&&e.jsx("div",{className:"text-xs text-muted-foreground",children:B.getFeatureById(r,t.featureRef)?.name})]}),e.jsx("div",{className:"flex gap-8",children:e.jsxs(O,{variant:"outline",size:"icon",onClick:()=>{c({title:"Confirm delete",content:`Are you sure you want to delete ${t.name}?`,buttonConfirmVariant:"destructive",buttonConfirmText:"Delete",onConfirm:()=>{d(t.id)}})},disabled:l,children:[e.jsx(b,{className:"text-destructive"}),e.jsx("div",{className:"sr-only",children:"Delete Enum"})]})})]})}export{P as E};
//# sourceMappingURL=enum-header-bar-JA_rn2Ha.js.map
