import{r as l,j as e,q as r,bP as g,aJ as h,b9 as w,an as u,bB as k}from"./index-C6OVXshM.js";import{C as m}from"./CardLabels-DQA1ki2o.js";const y=(s,o,t)=>!s||s.trim().length===0?!1:!t.find(c=>c.label===s.trim()),H=({value:s,onSave:o,isDisabled:t=!1,isSaving:d=!1,editRestrictionText:c,itemName:a="keywords",options:f=[],isCaseSensitive:p=!1})=>{const[n,x]=l.useState(s),[j,i]=l.useState(!1),b=l.useCallback(async()=>{i(!0),await o(n),i(!1)},[n,o]),C=l.useCallback(()=>{x(s),i(!1)},[s]);return j?e.jsxs(r,{gap:"10px",children:[e.jsx(r,{flex:"1",width:"100%",children:e.jsx(g,{isMulti:!0,value:n,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:C,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:n}):e.jsx(w,{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:()=>i(!0),children:`edit ${a}`})})]})};export{H as K};
