import{r as l,j as e,a as r,bH as w,aJ as h,b8 as C,ao as u,bs as k}from"./index-_eM6l4Nf.js";import{C as m}from"./CardLabels-DXqh0OoW.js";const y=(s,o,t)=>!s||s.trim().length===0?!1:!t.find(c=>c.label===s.trim()),M=({value:s,onSave:o,isDisabled:t=!1,isSaving:d=!1,editRestrictionText:c,itemName:a="keywords",options:f=[],isCaseSensitive:p=!1})=>{const[i,x]=l.useState(s),[j,n]=l.useState(!1),b=l.useCallback(async()=>{n(!0),await o(i),n(!1)},[i,o]),g=l.useCallback(()=>{x(s),n(!1)},[s]);return j?e.jsxs(r,{gap:"10px",children:[e.jsx(r,{flex:"1",width:"100%",children:e.jsx(w,{isMulti:!0,value:i,options:f,placeholder:a,variant:"white",onChange:x,noDataMessage:`No ${a} defined`,...p&&{isValidNewOption:y}})}),e.jsxs(r,{gap:"10px",maxHeight:"33px",flex:"0 1 min-content",children:[e.jsx(h,{disabled:d,onClick:g,intent:"secondary",children:"Cancel"}),e.jsx(h,{"data-test":"save-keyword",onClick:b,isLoading:d,children:"Save"})]})]}):e.jsxs(r,{alignItems:"baseline",children:[s!=null&&s.length?e.jsx(m,{flexGrow:1,flexWrap:"wrap",labels:i}):e.jsx(C,{value:`No ${a}`}),e.jsx(u,{disabled:!t,mainText:c??"You have no edit right",children:e.jsx(k,{height:"20px",mt:"-7px",intent:"inline",disabled:t,onClick:()=>n(!0),children:`edit ${a}`})})]})};export{M as K};
