import{j as t,ej as v,aw as S,R as i,b8 as C,az as w,cD as d,E as b,a9 as u,df as c}from"./app-BgLa5dit.js";import{D as N}from"./C4BcftDO.chunk.js";import{T as g}from"./lZO4aq5x.chunk.js";import{O as k,S as m,a as P,b as O}from"./BPPr_ng0.chunk.js";import{C as f}from"./c3I67AiW.chunk.js";const h=v(),T={name:h.accessor(e=>e,{id:"name",header:"",cell:e=>{const a=e.getValue();return t.jsxs("div",{className:"d-flex flex-column gap-2",children:[a.displayName,m[a.name]&&t.jsx("div",{className:"alert alert-danger mb-0",children:m[a.name]})]})},size:400}),value:h.accessor(e=>e,{id:"Value",header:"",cell:e=>{const a=e.getValue();return t.jsx(k,{settingName:a.name})}})};function K(e){const a=(e.filterKind===void 0||e.filterKind===null?e.data:e.data.filter(o=>o.kind===e.filterKind)).slice().sort((o,r)=>o.displayName.localeCompare(r.displayName)),s={...f,header:"d-none",row:e.rowClassname||f.row};return t.jsx(g,{data:a,columns:Object.values(T),theme:s})}const x="edit-customer-options";function V(e,a=[]){return!a||a.length===0?e:a.reduce((s,o)=>{switch(o.name){case c.Developer:return e;case c.SalesSupport:return{...s,...O.reduce((r,n)=>(e[n]&&(r[n]=e[n]),r),{})};case c.Support:return{...s,...P.reduce((r,n)=>(e[n]&&(r[n]=e[n]),r),{})};default:return s}},{})}function F(e){const a=S(),[s,o]=i.useState(""),r=i.useMemo(()=>{const l=Object.values(V(e.settings,e.userGroups??[]));if(!s)return l;const j=s.toLowerCase();return l.filter(y=>y.displayName.toLowerCase().includes(j))},[e.settings,e.userGroups,s]),n=C(),p=()=>n.unlock(x);return i.useEffect(()=>{a.dirty&&n.lock({id:x,title:"Are you sure you want to leave?",text:"The options you are currently editing will not be saved."}),a.dirty||p()},[a.dirty]),t.jsxs(w,{className:"d-flex flex-column gap-3",children:[t.jsx("div",{className:"d-flex justify-content-end",children:t.jsx(d,{variant:"dark",disabled:!a.dirty,onClick:()=>e.setShowPopup(!0),children:"Update options"})}),t.jsxs(N,{heading:e.title,children:[t.jsx("div",{className:"p-3",children:t.jsx("input",{type:"text",className:"form-control",placeholder:"Search by name...",value:s,onChange:l=>o(l.target.value)})}),t.jsx(K,{data:r,filterKind:e.filterKind,rowClassname:e.rowClassname})]}),t.jsx("div",{className:"d-flex justify-content-end",children:t.jsx(d,{variant:"dark",disabled:!a.dirty,onClick:()=>e.setShowPopup(!0),children:"Update options"})}),t.jsx("div",{children:e.showPopup&&t.jsxs(b,{title:"Update options",closePopup:()=>e.setShowPopup(!1),children:[t.jsx("p",{className:"m-0 pb-3",children:"Are you sure you want to save your changes?"}),t.jsxs(u,{children:[t.jsx(u.Cancel,{onClick:()=>e.setShowPopup(!1)}),t.jsx(u.Submit,{showSpinner:e.showSpinner,variant:"dark",text:"Update options",onClick:()=>e.onSubmit(a.values)})]})]})})]})}export{F as O};
//# sourceMappingURL=BZQd390p.chunk.js.map
