(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4650],{68523:function(e,n,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/settings/regulations",function(){return t(66773)}])},66773:function(e,n,t){"use strict";t.r(n),t.d(n,{default:function(){return q}});var i=t(24246),s=t(91922),l=t(79894),o=t.n(l),a=t(16134),r=t(77213),c=t(77830),d=t(58754),u=t(64781),h=t(98784),g=t.n(h),m=t(86677),x=t(27378),p=t(812),j=t(58452),C=t(26917),v=t(46628),f=t(26089),y=t(31883),w=t(61524),_=t(67991),S=t(12282),k=e=>{let{regulations:n,isOpen:t,onClose:l,selected:o,onChange:a}=e,[r,c]=(0,x.useState)(o),{allSelected:d,handleToggleAll:u,handleToggleSelection:h}=(0,_.QZ)({items:n,selected:r,onChange:c}),g=r.length,m=n[0].continent;return(0,i.jsxs)(s.u_l,{size:"2xl",isOpen:t,onClose:l,isCentered:!0,children:[(0,i.jsx)(s.ZAr,{}),(0,i.jsxs)(s.hzk,{"data-testid":"regulation-modal",children:[(0,i.jsx)(S.h4,{title:"Select regulations"}),(0,i.jsxs)(s.fef,{p:6,maxHeight:"70vh",overflowY:"auto",children:[(0,i.jsx)(S.x$,{title:m,allSelected:d,onToggleAll:u,numSelected:g}),(0,i.jsx)(s.MIq,{columns:3,spacing:6,paddingInline:4,children:n.map(e=>(0,i.jsx)(s.XZJ,{size:"sm",colorScheme:"complimentary",isChecked:r.includes(e.id),onChange:()=>h(e.id),"data-testid":"".concat(e.name,"-checkbox"),children:e.name},e.id))})]}),(0,i.jsx)(S.$_,{onApply:()=>{a(r),l()},onClose:l})]})]})},O=e=>{let{title:n,items:t,selected:l,onChange:o}=e,a=(0,s.qY0)();return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(w.ZP,{title:n,items:t,selected:l,onChange:o,numSelected:l.length,indeterminate:[],onViewMore:t.length>w.I_?a.onOpen:void 0}),(0,i.jsx)(k,{regulations:t,isOpen:a.isOpen,onClose:a.onClose,selected:l,onChange:o},"regulation-modal-selected-".concat(l.length))]})},Z=t(85759);let b=(e,n)=>{var t;return null===(t=e.name)||void 0===t?void 0:t.toLocaleLowerCase().includes(n.toLocaleLowerCase())};var N=e=>{var n;let{data:t}=e,l=(0,s.pmc)(),o=(0,s.qY0)(),[a,r]=(0,x.useState)(null!==(n=t.regulations)&&void 0!==n?n:[]),[d,h]=(0,x.useState)(""),[w,{isLoading:_}]=(0,u.WA)(),S=(0,x.useMemo)(()=>{var e,n;let i=null!==(n=null===(e=t.regulations)||void 0===e?void 0:e.filter(e=>b(e,d)))&&void 0!==n?n:[];return(0,Z.F7)(i)},[t.regulations,d]),k=!g().isEqual(a,t.regulations),N=(0,m.useRouter)(),q=()=>{N.push(c.r5).then(()=>{l.closeAll()})},E=async()=>{let e=await w({regulations:a.map(e=>({id:e.id,selected:e.selected})),locations:[]});(0,y.D4)(e)?l((0,v.Vo)((0,p.e$)(e.error))):l((0,v.t5)((0,i.jsxs)(s.xvT,{display:"inline",children:["Fides has automatically associated the relevant locations with your regulation choices.",(0,i.jsx)(f.Z,{onClick:q,children:"View locations here."})]})))},L=e=>{r(a.map(n=>{let t=e.find(e=>e.id===n.id);return null!=t?t:n}))};return(0,i.jsxs)(s.gCW,{alignItems:"start",spacing:4,children:[(0,i.jsx)(s.xuv,{maxWidth:"510px",width:"100%",children:(0,i.jsx)(C.Z,{onChange:h,placeholder:"Search",value:d,onClear:()=>h("")})}),(0,i.jsx)(s.MIq,{columns:{base:1,md:2,xl:3},spacing:6,width:"100%",children:Object.entries(S).map(e=>{let[n,t]=e,s=a.filter(e=>t.find(n=>n.id===e.id)&&e.selected).map(e=>e.id);return(0,i.jsx)(O,{title:n,items:t,selected:s,onChange:e=>{L(t.map(n=>e.includes(n.id)?{...n,selected:!0}:{...n,selected:!1}))}},n)})}),(0,i.jsx)(j.Z,{isOpen:o.isOpen,onClose:o.onClose,onConfirm:()=>{E(),o.onClose()},title:"Location updates",message:"Modifications in your regulation settings may also affect your location settings to simplify management. You can override any Fides-initiated changes directly in the location settings.",isCentered:!0,icon:(0,i.jsx)(s.aNP,{color:"orange"})}),k&&(0,i.jsx)(s.wpx,{type:"primary",onClick:o.onOpen,loading:_,"data-testid":"save-btn",children:"Save"})]})},q=()=>{let{isLoading:e}=(0,u.QM)(),n=(0,a.C)(u.P8);return(0,i.jsx)(r.Z,{title:"Regulations",children:(0,i.jsxs)(s.xuv,{"data-testid":"regulation-management",children:[(0,i.jsx)(d.Z,{heading:"Regulations"}),(0,i.jsxs)(s.xvT,{pb:6,fontSize:"sm",maxWidth:"600px",children:["Select the regulations that apply to your organizations compliance requirements. The selections you make here will automatically update your location selections."," ",(0,i.jsx)(s.rUS,{as:o(),href:c.r5,color:"complimentary.500",children:"You can view your location settings here."})]}),(0,i.jsx)(s.xuv,{children:e?(0,i.jsx)(s.$jN,{}):(0,i.jsx)(N,{data:n})})]})})}}},function(e){e.O(0,[8033,5835,2888,9774,179],function(){return e(e.s=68523)}),_N_E=e.O()}]);