PageSourceSearch

https://platform.socbyte.ai/_next/static/chunks/1740.9f6cbc2a1b20c290.js

js socbyte.ai collected 2026-10-05 12:41:10 UTC 32,038 bytes, 1 lines download raw bytes

1try{let e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="865a8cfd-81a2-4f81-8ec6-225a04129072",e._sentryDebugIdIdentifier="sentry-dbid-865a8cfd-81a2-4f81-8ec6-225a04129072")}catch(e){}"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1740],{13364:(e,t,l)=>{l.d(t,{r:()=>s});function s(e){if(null==e||"string"==typeof e&&""===e.trim())return"";let t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleString(void 0,{year:"numeric",month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit"})}},38723:(e,t,l)=>{l.d(t,{$m:()=>d,As:()=>o,nD:()=>i,ub:()=>c});var s=l(95155);l(12115);var a=l(89670),r=l(66088),n=l(40980);function i(e){let{...t}=e;return(0,s.jsx)(a.bL,{"data-slot":"accordion",...t,"data-sentry-element":"AccordionPrimitive.Root","data-sentry-component":"Accordion","data-sentry-source-file":"accordion.tsx"})}function o(e){let{className:t,...l}=e;return(0,s.jsx)(a.q7,{"data-slot":"accordion-item",className:(0,n.cn)("border-b last:border-b-0",t),...l,"data-sentry-element":"AccordionPrimitive.Item","data-sentry-component":"AccordionItem","data-sentry-source-file":"accordion.tsx"})}function d(e){let{className:t,children:l,...i}=e;return(0,s.jsx)(a.Y9,{className:"flex","data-sentry-element":"AccordionPrimitive.Header","data-sentry-component":"AccordionTrigger","data-sentry-source-file":"accordion.tsx",children:(0,s.jsxs)(a.l9,{"data-slot":"accordion-trigger",className:(0,n.cn)("focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",t),...i,"data-sentry-element":"AccordionPrimitive.Trigger","data-sentry-source-file":"accordion.tsx",children:[l,(0,s.jsx)(r.A,{className:"text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200","data-sentry-element":"ChevronDownIcon","data-sentry-source-file":"accordion.tsx"})]})})}function c(e){let{className:t,children:l,...r}=e;return(0,s.jsx)(a.UC,{"data-slot":"accordion-content",className:"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm",...r,"data-sentry-element":"AccordionPrimitive.Content","data-sentry-component":"AccordionContent","data-sentry-source-file":"accordion.tsx",children:(0,s.jsx)("div",{className:(0,n.cn)("pt-0 pb-4",t),children:l})})}},51230:(e,t,l)=>{l.d(t,{M:()=>r,w:()=>n});var s=l(65161),a=l(34686);let r=async e=>{try{let{user:t,fieldSearch:l,roleId:r,licenseId:n,licenseIds:i,...o}=e,d=t?(0,a.jN)(t):[e.requestedTenant||""],c=Object.fromEntries(Object.entries(o).filter(e=>{let[,t]=e;return null!=t&&("string"!=typeof t||""!==t.trim())})),u={roleId:r};return d.length>0&&(u.requestedTenant=d),l&&(u.fieldSearch=l),n?u.licenseId=n:i&&i.length>0&&(u.licenseIds=i),(await s.A.post("/user-management/role/permission",u,{params:c})).data}catch(e){var t,l;return{success:!1,message:(null==e||null==(l=e.response)||null==(t=l.data)?void 0:t.message)||"Failed to fetch paginated permissions list"}}},n=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{let{user:t,fieldSearch:l,roleId:r,parentPermissionId:n,...i}=e,o=t?(0,a.jN)(t):[e.requestedTenant||""],d=Object.fromEntries(Object.entries(i).filter(e=>{let[,t]=e;return null!=t&&("string"!=typeof t||""!==t.trim())})),c={roleId:r,parentPermissionId:n};return o.length>0&&(c.requestedTenant=o),l&&(c.fieldSearch=l),(await s.A.post("/user-management/permission/child/list",c,{params:d})).data}catch(e){var t,l;return{success:!1,message:(null==e||null==(l=e.response)||null==(t=l.data)?void 0:t.message)||"Failed to fetch child permissions list"}}}},61740:(e,t,l)=>{l.r(t),l.d(t,{default:()=>F});var s=l(95155),a=l(12115),r=l(61094),n=l(65957),i=l(15007),o=l(87928),d=l(80069),c=l(68249),u=l(70747),m=l(37911),h=l(20363),p=l(12877),v=l(73344),x=l(25475),f=l(64887),g=l(73124),y=l(33936),j=l(8213),b=l(51588),w=l(60285),N=l(33210),S=l(6296),A=l(60002),C=l(3134),I=l(99403),R=l(22980),P=l(51230),O=l(38723),D=l(439);let T=e=>{let{open:t,onOpenChange:l,role:r}=e,[n,i]=(0,a.useState)([]),[o,d]=(0,a.useState)({}),[c,u]=(0,a.useState)(!1),[p,v]=(0,a.useState)(null),{user:x}=(0,R.J)();return(0,a.useEffect)(()=>{(async()=>
1{if(t&&(null==r?void 0:r.id)){u(!0),v(null);try{var e,l,s;let t=await (0,P.M)({user:x,roleId:r.id}),a=null!=(s=null!=(l=null==t||null==(e=t.data)?void 0:e.results)?l:null==t?void 0:t.data)?s:[];i(Array.isArray(a)?a:[]);let n=await Promise.all(a.map(async e=>{try{var t,l,s;let a=await (0,P.w)({user:x,roleId:r.id,parentPermissionId:e.id}),n=null!=(s=null!=(l=null==a||null==(t=a.data)?void 0:t.results)?l:null==a?void 0:a.data)?s:[];return{id:e.id,children:n}}catch(t){return{id:e.id,children:[]}}})),o={};n.forEach(e=>o[e.id]=e.children),d(o)}catch(e){v((null==e?void 0:e.message)||"Failed to load permissions")}finally{u(!1)}}})()},[t,r]),(0,s.jsx)(m.a,{heading:"Role Details",open:t,onOpenChange:l,showClose:!0,"data-sentry-element":"Modal","data-sentry-component":"ViewRoleModal","data-sentry-source-file":"viewRole.tsx",children:r?c?(0,s.jsx)("div",{className:"flex min-h-40 items-center justify-center",children:(0,s.jsx)(S.A,{className:"h-8 w-8 animate-spin text-[var(--primary)]"})}):p?(0,s.jsx)("div",{className:"border-destructive/40 bg-destructive/10 text-destructive rounded-md border p-3",children:p}):(0,s.jsxs)("div",{className:"space-y-5",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{children:r.name||"N/A"}),(0,s.jsx)("p",{className:"text-muted-foreground text-sm",children:r.desc||"No description provided."})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"mb-2 flex items-center gap-2",children:[(0,s.jsx)(D.A,{className:"text-primary h-4 w-4"}),(0,s.jsx)(h.J,{className:"text-foreground text-sm font-semibold",children:"Role Permissions"})]}),0===n.length?(0,s.jsx)("p",{className:"text-muted-foreground bg-secondary/30 rounded-md border p-3 text-sm",children:"No permissions assigned to this role."}):(0,s.jsx)(O.nD,{type:"single",collapsible:!0,className:"w-full space-y-2",children:n.map(e=>{var t;return(0,s.jsxs)(O.As,{value:e.id,className:"border-border/40 bg-secondary/20 rounded-lg border",children:[(0,s.jsx)(O.$m,{className:"px-3 py-2 font-medium capitalize",children:e.name||e.permissionName||"Unnamed Permission"}),(0,s.jsx)(O.ub,{className:"px-4 pb-3",children:(null==(t=o[e.id])?void 0:t.length)?(0,s.jsx)("ul",{className:"text-muted-foreground ml-4 list-disc space-y-1 text-sm",children:o[e.id].map(e=>(0,s.jsx)("li",{className:"capitalize",children:e.name},e.id))}):(0,s.jsx)("p",{className:"text-muted-foreground italic",children:"No sub-permissions"})})]},e.id)})})]})]}):(0,s.jsx)("p",{className:"text-muted-foreground text-sm",children:"No role selected."})})};var k=l(57828),E=l(31376),L=l(13364),M=l(45981);let q=e=>{var t,l;if(!e)return null;for(let s of[null==e?void 0:e.id,null==e?void 0:e.permissionId,null==e?void 0:e.permissionID,null==e?void 0:e.permission_id,null==e?void 0:e.value,null==e||null==(t=e.permission)?void 0:t.id,null==e||null==(l=e.permission)?void 0:l.permissionId,null==e?void 0:e.childId,null==e?void 0:e.childID,null==e?void 0:e.childPermissionId,null==e?void 0:e.childPermissionID])if(null!=s&&""!==s)return String(s);return null},z=e=>e?String(e).replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()):"Unnamed";function F(){var e,t;let{t:l}=(0,M.Jl)("administration"),[O,D]=(0,a.useState)(!1),[F,_]=(0,a.useState)(!1),[V,$]=(0,a.useState)([]),[K,U]=(0,a.useState)(1),[J,B]=(0,a.useState)([]),[H,W]=(0,a.useState)(!1),[Q,Y]=(0,a.useState)(!1),[Z,G]=(0,a.useState)(null),[X,ee]=(0,a.useState)(!1),[et,el]=(0,a.useState)(null),[es,ea]=(0,a.useState)(!1),[er,en]=(0,a.useState)(null),[ei,eo]=(0,a.useState)(""),[ed,ec]=(0,a.useState)(0),[eu,em]=(0,a.useState)(""),{user:eh}=(0,R.J)(),[ep,ev]=(0,a.useState)([]),[ex,ef]=(0,a.useState)(""),[eg,ey]=(0,a.useState)({pageIndex:0,pageSize:10}),[ej,eb]=(0,a.useState)(!0),[ew,eN]=(0,a.useState)(""),[eS,eA]=(0,a.useState)(""),[eC,eI]=(0,a.useState)([]),[eR,eP]=(0,a.useState)(!1),[eO,eD]=(0,a.useState)(null),[eT,ek]=(0,a.useState)({}),eE=(0,a.useMemo)(()=>[{accessorKey:"name",header:e=>{let{column:t}=e;return(0,s.jsx)(y.w,{column:t,title:"Name"})},cell:e=>{let{cell:t}=e;return t.getValue()}},{accessorKey:"tenantName",header:e=>{let{column:t}=e;return(0,s.jsx)(y.w,{column:t,title:"Tenant"})},cell:e=>{let{cell:t}=e;return t.getValue()||"-"}},{accessorKey:"desc",header:e=>{let{column:t}=e;return(0,s.jsx)(y.w,{column:t,title:"Description"})},cell:e=>{let{cell:t}=e;return t.getValue()}},{accessorKey:"createdDate",header:e=>{let{column:t}=e;return(0,s.jsx)(y.w,{column:t,title:"Created At"})},cell:e=>{let{cell:t}=e;return(0,L.r)(t.getValue())||"-"}},{id:"actions",header:()=>(0,s.jsx)("div",{className:"text-center",children:"Actions"}),cell:e=>{var t,a;let{row:o}=e;return(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsxs)(b.rI,{children:[(0,s.jsx)(b.ty,{asChild:!0,children:(0,s.jsx)(u.$,{className:"h-8 w-8 bg-transparent p-0 hover:bg-transparent",children:(0,s.jsx)(w.A,{className:"h-4 w-4"})})}),(0,s.jsxs)(b.SQ,{align:"end",children:[(0,s.jsxs)(b._2,{onClick:()=>{el(o.original),ee(!0)},children:[(0,s.jsx)(r.A,{className:"h-4 w-4 text-[var(--viewIcon)]"})," ",l("View")]}),((null==eh?void 0:eh.tenantType)==="platform"||(null==eh||null==(t=eh.roleObject)?void 0:t.name)==="Admin")&&(0,s.jsxs)(b._2,{onClick:()=>
1{ea(!0),en(o.original),eo(o.original.name||""),em(o.original.desc||""),ek({}),_(!0)},children:[(0,s.jsx)(n.A,{className:"h-4 w-4 text-[var(--editIcon)]"})," ",l("Edit")]}),((null==eh?void 0:eh.tenantType)==="platform"||(null==eh||null==(a=eh.roleObject)?void 0:a.name)==="Admin")&&(0,s.jsxs)(b._2,{onClick:()=>{eD(o.original),eP(!0)},children:[(0,s.jsx)(i.A,{className:"h-4 w-4 text-[var(--deleteIcon)]"})," ",l("Delete")]})]})]})})}}],[l]),eL=(0,a.useCallback)(async()=>{W(!0);try{var e,t,l,s,a,r;let n=await (0,f.O0)({user:eh,page:eg.pageIndex,size:eg.pageSize,search:eS.trim()?eS.trim():void 0}),i=null==n||null==(e=n.data)?void 0:e.results;B(Array.isArray(i)?i:[]);let o=null!=(r=null!=(a=null!=(s=null==n||null==(t=n.data)?void 0:t.totalElements)?s:null==n||null==(l=n.data)?void 0:l.total)?a:null==n?void 0:n.totalElements)?r:0;ec(o)}catch(e){G(e.message)}finally{W(!1)}},[eg.pageIndex,eg.pageSize,eS]);(0,a.useEffect)(()=>{O&&eL()},[O,eL]),(0,a.useEffect)(()=>{F&&ev((null==eh?void 0:eh.licensesObject)||[])},[eh,F]);let eM=(0,a.useMemo)(()=>V.map(e=>e.licenseId),[V]),eq=async e=>{var t,l,s,a,r,n,i,o,d,c,u;if(!e||!(null==eh||null==(t=eh.roleObject)?void 0:t.id))return;let m=ep.find(t=>t.id===e);if(!m)return;let h={id:K,licenseId:m.id,licenseName:m.name,permissionSets:[],permissionsList:[],isLoadingPermissions:!0,nextPermissionSetId:1};$(e=>[...e,h]),U(e=>e+1),ef(""),ek(e=>({...e,license:!1}));try{let t=await (0,P.M)({user:eh,roleId:eh.roleObject.id,licenseId:e}),m=null!=(n=null!=(r=null!=(a=null==t||null==(l=t.data)?void 0:l.results)?a:null==t||null==(s=t.data)?void 0:s.content)?r:null==t?void 0:t.data)?n:[],h=Array.isArray(m)?m:[],p=new Set;if(es&&(null==er?void 0:er.id))try{let t=await (0,P.M)({user:eh,roleId:er.id,licenseId:e}),l=null!=(u=null!=(c=null!=(d=null==t||null==(i=t.data)?void 0:i.results)?d:null==t||null==(o=t.data)?void 0:o.content)?c:null==t?void 0:t.data)?u:[];Array.isArray(l)&&await Promise.all(l.map(async e=>{let t=q(e)||e.id;try{var l,s,a,r,n;let e=await (0,P.w)({user:eh,roleId:er.id,parentPermissionId:t}),i=null!=(n=null!=(r=null!=(a=null==e||null==(l=e.data)?void 0:l.results)?a:null==e||null==(s=e.data)?void 0:s.content)?r:null==e?void 0:e.data)?n:[];Array.isArray(i)&&i.forEach(e=>{let t=null==e?void 0:e.id;t&&p.add(String(t))})}catch(e){console.error("Failed to fetch assigned children",e)}}))}catch(e){console.error("Failed to fetch assigned permissions",e)}let v=await Promise.all(h.map(async(e,t)=>{var l,s,a,r,n,i,o,d,c;let u=q(e)||e.id,m=z(null!=(a=null!=(s=null==e?void 0:e.name)?s:null==e?void 0:e.permissionName)?a:null==e||null==(l=e.permission)?void 0:l.name),h=[],v=[];try{let e=await (0,P.w)({user:eh,roleId:null==eh||null==(r=eh.roleObject)?void 0:r.id,parentPermissionId:u}),t=null!=(c=null!=(d=null!=(o=null==e||null==(n=e.data)?void 0:n.results)?o:null==e||null==(i=e.data)?void 0:i.content)?d:null==e?void 0:e.data)?c:[];h=Array.isArray(t)?t.map(e=>{var t;return{label:z(null==e?void 0:e.name),value:null!=(t=null==e?void 0:e.id)?t:""}}).filter(e=>e.value):[],es&&p.size>0&&(v=h.filter(e=>p.has(String(e.value))).map(e=>e.value))}catch(e){console.error("Failed to fetch children for",u,e)}return{id:t+1,parent:u,parentLabel:m,subs:v,childOptions:h,isLoadingChildren:!1}}));$(e=>e.map(e=>e.id===K?{...e,permissionsList:h,permissionSets:v,nextPermissionSetId:v.length+1,isLoadingPermissions:!1}:e))}catch(e){E.toast.error((null==e?void 0:e.message)||"Failed to fetch permissions for license"),$(e=>e.map(e=>e.id===K?{...e,isLoadingPermissions:!1}:e))}};(0,a.useEffect)(()=>{var e;if(!F||!es||!(null==er?void 0:er.id)||!(null==eh||null==(e=eh.roleObject)?void 0:e.id))return;let t=!1,l=e=>{var t,l,s,a,r;let n=null!=(r=null!=(a=null!=(s=null==e||null==(t=e.data)?void 0:t.results)?s:null==e||null==(l=e.data)?void 0:l.content)?a:null==e?void 0:e.data)?r:[];return Array.isArray(n)?n:[]};return(async()=>{Y(!0),$([]),U(1),ef("");let e=Array.isArray(null==eh?void 0:eh.licensesObject)?eh.licensesObject.map(e=>{var t,l;return{id:String(null!=(t=null==e?void 0:e.id)?t:""),name:String(null!=(l=null==e?void 0:e.name)?l:"")}}):[];if(0===e.length)return void Y(!1);let s=new Set;try{let e=await (0,P.M)({user:eh,roleId:er.id}),t=l(e);Array.isArray(t)&&await Promise.all(t.map(async e=>{let t=q(e)||(null==e?void 0:e.id);if(t)try{let e=await (0,P.w)({user:eh,roleId:er.id,parentPermissionId:String(t)});
1l(e).forEach(e=>{let t=null==e?void 0:e.id;t&&s.add(String(t))})}catch(e){console.error("Failed to fetch assigned children",e)}}))}catch(e){console.error("Failed to fetch assigned permissions",e)}if(t)return;let a=1;for(let r of e){if(t)return;if(!(null==r?void 0:r.id))continue;let e=a++;try{let a=await (0,P.M)({user:eh,roleId:eh.roleObject.id,licenseId:r.id}),n=l(a),i=await Promise.all(n.map(async(e,t)=>{var a,r,n,i;let o=q(e)||(null==e?void 0:e.id),d=z(null!=(n=null!=(r=null==e?void 0:e.name)?r:null==e?void 0:e.permissionName)?n:null==e||null==(a=e.permission)?void 0:a.name),c=[],u=[];try{let e=await (0,P.w)({user:eh,roleId:null==eh||null==(i=eh.roleObject)?void 0:i.id,parentPermissionId:String(o)}),t=l(e);c=Array.isArray(t)?t.map(e=>{var t;return{label:z(null==e?void 0:e.name),value:null!=(t=null==e?void 0:e.id)?t:""}}).filter(e=>e.value):[],s.size>0&&(u=c.filter(e=>s.has(String(e.value))).map(e=>e.value))}catch(e){console.error("Failed to fetch children for",o,e)}return{id:t+1,parent:String(o),parentLabel:d,subs:u,childOptions:c,isLoadingChildren:!1}}));if(t)return;if(!i.some(e=>Array.isArray(e.subs)&&e.subs.length>0))continue;let o={id:e,licenseId:r.id,licenseName:r.name,permissionsList:n,permissionSets:i,nextPermissionSetId:i.length+1,isLoadingPermissions:!1};$(e=>[...e,o])}catch(e){E.toast.error((null==e?void 0:e.message)||"Failed to fetch permissions for license")}}t||(U(a),Y(!1))})().catch(e=>{console.error("Failed to hydrate edit permissions",e),E.toast.error("Failed to load existing role permissions"),Y(!1)}),()=>{t=!0}},[F,es,null==er?void 0:er.id,null==eh||null==(e=eh.roleObject)?void 0:e.id]);let ez=(0,A.N4)({data:J,columns:eE,getCoreRowModel:(0,C.HT)(),getPaginationRowModel:(0,C.kW)(),getSortedRowModel:(0,C.h5)(),onPaginationChange:ey,onSortingChange:eI,manualPagination:!0,pageCount:ed>0?Math.ceil(ed/eg.pageSize):1,meta:{totalRows:ed},state:{pagination:eg,sorting:eC}}),eF=()=>{eo(""),em(""),$([]),U(1),ef(""),ea(!1),en(null),_(!1),Y(!1),ek({})},e_=async()=>{let e=V.flatMap(e=>e.permissionSets.flatMap(e=>e.subs)),t={roleName:!ei.trim(),roleDesc:!eu.trim(),license:0===V.length,permissions:V.length>0&&0===e.length};if(ek(t),Object.values(t).some(Boolean))return void E.toast.error("Please fill in all required fields");let l={name:ei.trim(),desc:eu.trim(),data:e.map(e=>e)};try{let e=await (0,f.rd)({user:eh,payload:l});E.toast.success((null==e?void 0:e.message)||"Role created successfully"),await eL(),eF()}catch(e){E.toast.error((null==e?void 0:e.message)||"Failed to create role")}},eV=async()=>{if(!er)return;let e=V.flatMap(e=>e.permissionSets.flatMap(e=>e.subs)),t={roleName:!ei.trim(),roleDesc:!eu.trim(),license:0===V.length,permissions:V.length>0&&0===e.length};if(ek(t),Object.values(t).some(Boolean))return void E.toast.error("Please fill in all required fields");let l={name:ei.trim(),desc:eu.trim(),data:e.map(e=>e)};try{let e=await (0,f.S0)({roleId:null==er?void 0:er.id,payload:l,requestedTenant:[null==er?void 0:er.tenant]});E.toast.success((null==e?void 0:e.message)||"Role updated successfully"),await eL(),eF()}catch(e){var s,a,r,n;console.error("Failed to update role:",null==e||null==(a=e.errorList)||null==(s=a[0])?void 0:s.message),E.toast.error((null==e||null==(n=e.errorList)||null==(r=n[0])?void 0:r.message)||"Failed to update role")}},e$=()=>{ew.trim()&&(eA(ew),ey(e=>({...e,pageIndex:0})))};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(u.$,{onClick:()=>D(!0),variant:"icon","data-sentry-element":"Button","data-sentry-source-file":"Roles.tsx",children:[(0,s.jsx)(o.A,{className:"text-primary !h-6 !w-6","data-sentry-element":"IconUser","data-sentry-source-file":"Roles.tsx"}),(0,s.jsx)("span",{className:"text-[11px] font-medium text-gray-100",children:l("Roles")})]}),(0,s.jsx)(m.a,{heading:"Roles",open:O,onOpenChange:D,showClose:!0,"data-sentry-element":"Modal","data-sentry-source-file":"Roles.tsx",children:(0,s.jsxs)("div",{className:"space-y-4",children:[((null==eh?void 0:eh.tenantType)==="platform"||(null==eh||null==(t=eh.roleObject)?void 0:t.name)==="Admin")&&(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)(u.$,{onClick:()=>{ea(!1),en(null),eo(""),em(""),$([]),U(1),ef(""),ek({}),_(!0)},children:[(0,s.jsx)(d.A,{className:"!h-6 !w-6 text-white"}),(0,s.jsx)("span",{className:"text-sm font-medium text-gray-100",children:"New Role"})]}),(0,s.jsx)("div",{className:"flex items-center gap-2",children:(0,s.jsxs)("div",{className:"relative flex items-center",children:[(0,s.jsx)(c.A,{className:"text-muted-foreground h-5 w-5 cursor-pointer",onClick:()=>eb(e=>!e)}),(0,s.jsx)("div",{className:"overflow-hidden transition-all duration-500 ease-in-out ".concat(ej?"ml-2 w-80 opacity-100":"w-0 opacity-0"),children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(p.p,{placeholder:"Search roles...",value:ew,onChange:e=>
1{let t=e.target.value,l=!!(null==ew?void 0:ew.trim()),s=!t.trim();eN(t),l&&s&&(eA(""),ey(e=>({...e,pageIndex:0})))},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),e$())},className:"flex-1",autoFocus:ej}),(0,s.jsx)(u.$,{size:"sm",onClick:e$,className:"px-3",title:"Search",disabled:!ew.trim(),children:(0,s.jsx)(c.A,{className:"h-4 w-4"})}),(null==ew?void 0:ew.trim())&&(0,s.jsx)(u.$,{size:"sm",variant:"outline",onClick:()=>{eN(""),eA(""),ey(e=>({...e,pageIndex:0}))},className:"px-3",title:"Clear search",children:(0,s.jsx)(N.A,{className:"h-4 w-4"})})]})})]})})]}),Z?(0,s.jsx)("div",{className:"rounded border border-red-400 bg-red-100 px-4 py-3 text-red-700",children:Z}):H?(0,s.jsx)(j.O,{columnCount:5,rowCount:5,withPagination:!0}):(0,s.jsx)(g.b,{table:ez})]})}),(0,s.jsx)(m.a,{heading:es?"Edit Role":"New Role",open:F,onOpenChange:e=>{e||eF()},showClose:!0,className:"min-w-xl","data-sentry-element":"Modal","data-sentry-source-file":"Roles.tsx",children:(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)(v.D,{label:"Role Name",placeholder:"Enter role name",required:!0,value:ei,onChange:e=>{eo(e.target.value),e.target.value.trim()&&ek(e=>({...e,roleName:!1}))},error:eT.roleName?"Role name is required":void 0,"data-sentry-element":"ValidatedInput","data-sentry-source-file":"Roles.tsx"}),(0,s.jsx)(v.D,{label:"Role Description",placeholder:"Enter role description",required:!0,value:eu,onChange:e=>{em(e.target.value),e.target.value.trim()&&ek(e=>({...e,roleDesc:!1}))},error:eT.roleDesc?"Role description is required":void 0,"data-sentry-element":"ValidatedInput","data-sentry-source-file":"Roles.tsx"}),(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)(h.J,{className:"text-base font-semibold","data-sentry-element":"Label","data-sentry-source-file":"Roles.tsx",children:["Permissions"," ",(0,s.jsx)("span",{className:eT.license?"text-red-400":"text-white",children:"*"})]}),(0,s.jsxs)(x.l6,{value:ex,onValueChange:e=>{e&&eq(e)},"data-sentry-element":"Select","data-sentry-source-file":"Roles.tsx",children:[(0,s.jsx)(x.bq,{className:"w-48","data-sentry-element":"SelectTrigger","data-sentry-source-file":"Roles.tsx",children:(0,s.jsx)(x.yv,{placeholder:"Add License","data-sentry-element":"SelectValue","data-sentry-source-file":"Roles.tsx"})}),(0,s.jsx)(x.gC,{"data-sentry-element":"SelectContent","data-sentry-source-file":"Roles.tsx",children:ep.filter(e=>!eM.includes(e.id)).map(e=>(0,s.jsx)(x.eb,{value:e.id,children:e.name},e.id))})]})]}),(0,s.jsxs)("div",{className:"space-y-6",children:[Q?(0,s.jsx)("div",{className:"flex min-h-40 items-center justify-center",children:(0,s.jsx)(S.A,{className:"h-8 w-8 animate-spin text-[var(--primary)]"})}):V.map(e=>(0,s.jsxs)("div",{className:"border-border rounded-lg border p-4",children:[(0,s.jsxs)("div",{className:"mb-3 flex items-center justify-between",children:[(0,s.jsxs)("h3",{className:"text-primary text-lg font-semibold",children:[e.licenseName,":"]}),(0,s.jsx)(u.$,{size:"sm",variant:"ghost",className:"text-destructive hover:bg-destructive/10",onClick:()=>{var t;return t=e.id,void $(e=>e.filter(e=>e.id!==t))},children:(0,s.jsx)(i.A,{className:"h-4 w-4"})})]}),e.isLoadingPermissions?(0,s.jsx)("div",{className:"flex min-h-24 items-center justify-center",children:(0,s.jsx)(S.A,{className:"h-7 w-7 animate-spin text-[var(--primary)]"})}):0===e.permissionSets.length?(0,s.jsx)("div",{className:"text-muted-foreground py-4 text-center text-sm",children:"No permissions available for this license."}):(0,s.jsx)("div",{className:"space-y-3",children:e.permissionSets.map(t=>(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"w-1/3 min-w-40",children:(0,s.jsx)("span",{className:"text-sm font-medium",children:t.parentLabel})}),(0,s.jsxs)("div",{className:"relative flex-1",children:[(0,s.jsx)(I.K,{disabled:t.isLoadingChildren,value:t.subs,onChange:l=>{var s,a;return s=e.id,a=t.id,void($(e=>e.map(e=>e.id===s?{...e,permissionSets:e.permissionSets.map(e=>e.id===a?{...e,subs:l}:e)}:e)),l.length>0&&ek(e=>({...e,permissions:!1})))},placeholder:t.isLoadingChildren?"Loading...":0===t.childOptions.length?"No sub-permissions available":"Select Sub Permissions...",options:t.childOptions}),t.isLoadingChildren&&(0,s.jsx)(S.A,{className:"absolute top-1/2 right-3 h-4 w-4 -translate-y-1/2 animate-spin text-[var(--primary)]"})]})]},t.id))})]},e.id)),!Q&&0===V.length&&(0,s.jsx)("div",{className:"border-border rounded-lg border border-dashed p-6 text-center",children:es?(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("p",{className:"text-foreground text-sm font-medium",children:"Select a license to modify permissions"}),(0,s.jsx)("p",{className:"text-muted-foreground text-xs",children:"Choose a license from the dropdown above to view and edit its associated permissions for this role."})]}):(0,s.jsx)("p",{className:"text-muted-foreground text-sm",children:"No licenses added yet. Select a license above to add permissions."})})]}),eT.license&&(0,s.jsx)("p",{className:"text-xs text-red-400",children:"At least one license is required"}),eT.permissions&&(0,s.jsx)("p",{className:"text-xs text-red-400",children:"Please select at least one permission"})]}),(0,s.jsx)("div",{className:"flex justify-end",children:(0,s.jsx)(u.$,{onClick:es?eV:e_,disabled:Q,"data-sentry-element":"Button","data-sentry-source-file":"Roles.tsx",children:es?"Update":"Create"})})]})}),(0,s.jsx)(k.A,{open:eR,onOpenChange:eP,title:"Are you sure?",description:'This will permanently delete the "'.concat(null==eO?void 0:eO.name,'" role. Users assigned to this role may lose their related permissions. This action cannot be undone.'),confirmText:"Delete",cancelText:"Cancel",variant:"destructive",onConfirm:async()=>
1{if(eO)try{let e=await (0,f.EO)(eO.id,[eO.tenant]);(null==e?void 0:e.success)?(E.toast.success((null==e?void 0:e.message)||"Role deleted successfully"),eD(null),eP(!1),await eL()):E.toast.error((null==e?void 0:e.message)||"Failed to delete role")}catch(l){var e,t;E.toast.error((null==l||null==(t=l.response)||null==(e=t.data)?void 0:e.message)||(null==l?void 0:l.message)||"Failed to delete role")}},"data-sentry-element":"ConfirmDialog","data-sentry-source-file":"Roles.tsx"}),(0,s.jsx)(T,{open:X,onOpenChange:ee,role:et,"data-sentry-element":"ViewRoleModal","data-sentry-source-file":"Roles.tsx"})]})}},64887:(e,t,l)=>{l.d(t,{EO:()=>i,O0:()=>r,S0:()=>o,rd:()=>n});var s=l(65161),a=l(34686);let r=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{let{user:t,fieldSearch:l,...r}=e,n=t?(0,a.jN)(t):[e.requestedTenant||""],i=Object.fromEntries(Object.entries(r).filter(e=>{let[,t]=e;return null!=t&&("string"!=typeof t||""!==t.trim())})),o={};return n.length>0&&(o.requestedTenant=n),l&&(o.fieldSearch=l),(await s.A.post("/user-management/role/listRoutes",o,{params:i})).data}catch(e){var t,l;return{success:!1,message:(null==e||null==(l=e.response)||null==(t=l.data)?void 0:t.message)||"Failed to fetch roles"}}},n=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{user:t,payload:l,...r}=e,n=t?(0,a.jN)(t):[r.requestedTenant||""];n.length>0&&(l.requestedTenant=n);try{return(await s.A.post("/user-management/role/create",{name:l.name,desc:l.desc,data:l.data,requestedTenant:n})).data}catch(e){var i,o;throw console.error("Error creating role:",(null==(i=e.response)?void 0:i.data)||e.message),(null==(o=e.response)?void 0:o.data)||e}},i=async(e,t)=>{try{return(await s.A.post("/user-management/role/disable",{roleId:e,requestedTenant:null!=t?t:[]})).data}catch(e){var l,a;throw console.error("Error disabling role:",(null==(l=e.response)?void 0:l.data)||e.message),(null==(a=e.response)?void 0:a.data)||e}},o=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{let{user:t,payload:l,roleId:r,requestedTenant:n,...i}=e,o=void 0!==n?Array.isArray(n)?n:[n]:t?(0,a.jN)(t):[i.requestedTenant||""];return o.length>0&&(l.requestedTenant=o),(await s.A.post("/user-management/role/update",{roleId:r,name:l.name,desc:l.desc,data:l.data,requestedTenant:o})).data}catch(e){var t,l;throw console.error("Error creating role:",(null==(t=e.response)?void 0:t.data)||e.message),(null==(l=e.response)?void 0:l.data)||e}}},99403:(e,t,l)=>{l.d(t,{K:()=>m});var s=l(95155),a=l(12115),r=l(96703),n=l(66088),i=l(61878),o=l(9316),d=l(40980),c=l(72226),u=l(12877);function m(e){let{options:t,value:l,onChange:m,placeholder:h="Select...",size:p="default",className:v,disabled:x=!1,emptyMessage:f="No options available"}=e,g=a.useRef(null),[y,j]=a.useState(h),[b,w]=a.useState(!1),[N,S]=a.useState(""),A=a.useRef(null),C=t.length>5;a.useEffect(()=>{if(!C||!b)return;let e=setTimeout(()=>{var e;return null==(e=A.current)?void 0:e.focus()},50);return()=>clearTimeout(e)},[N,b,C]);let I=C&&N?t.filter(e=>e.label.toLowerCase().includes(N.toLowerCase())||e.value.toLowerCase().includes(N.toLowerCase())):t,R=e=>{if("all"===e){let e=t.map(e=>e.value);m(e.every(e=>l.includes(e))?[]:e);return}let s=l.includes(e)?l.filter(t=>t!==e):[...l,e];!t.map(e=>e.value).every(e=>s.includes(e))&&s.includes("all")&&(s=s.filter(e=>"all"!==e)),m(s)};a.useLayoutEffect(()=>{if(!g.current)return;if(x)return void j(h);let e=t.map(e=>e.value);if(e.length>0&&e.every(e=>l.includes(e)))return void j("All");let s=t.filter(e=>l.includes(e.value));if(0===s.length)return void j(h);let a=g.current.offsetWidth-70,r=document.createElement("span");r.style.visibility="hidden",r.style.whiteSpace="nowrap",r.style.fontSize="14px",document.body.appendChild(r);let n=[],i=0;for(let e=0;e<s.length;e++)if(r.innerText=[...n,s[e].label].join(", ")+(e<s.length-1?", ":""),r.offsetWidth<=a)n.push(s[e].label);else{i=s.length-e;break}if(document.body.removeChild(r),i>0){if(0===n.length&&s.length>0)return void(1===s.length?j(s[0].label):j("".concat(s[0].label," ,+").concat(s.length-1," more")));j("".concat(n.join(", ")," ,+").concat(i," more"))}else j(n.join(", "))},[l,t,h,x]);let P=t.map(e=>e.value),O=P.length>0&&P.every(e=>l.includes(e)),D=!x&&0===l.length&&!O;return(0,s.jsxs)(r.bL,{open:!x&&b,onOpenChange:e=>{!x&&(w(e),e||S(""))},"data-sentry-element":"DropdownMenu.Root","data-sentry-component":"MultiSelect","data-sentry-source-file":"multi-select.tsx",children:[(0,s.jsxs)(r.l9,{ref:g,className:(0,d.cn)("w-full rounded-lg border border-[var(--primary)] bg-transparent","px-4 py-2 text-sm transition-all duration-200 ease-in-out","focus:border-[var(--primary)] focus:ring-1 focus:ring-[var(--primary)] focus:outline-none","flex items-center justify-between gap-2 truncate","disabled:cursor-not-allowed disabled:opacity-50","data-[size=default]:h-9 data-[size=sm]:h-8","[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",v),"data-size":p,disabled:x,"data-sentry-element":"DropdownMenu.Trigger","data-sentry-source-file":"multi-select.tsx",children:[(0,s.jsx)("span",{className:(0,d.cn)("truncate",D&&"text-gray-400"),children:y}),(0,s.jsx)(n.A,{className:"size-4 text-[var(--primary)] opacity-50","data-sentry-element":"ChevronDownIcon","data-sentry-source-file":"multi-select.tsx"})]}),(0,s.jsx)(r.ZL,{"data-sentry-element":"DropdownMenu.Portal","data-sentry-source-file":"multi-select.tsx",children:(0,s.jsxs)(r.UC,{align:"start",className:(0,d.cn)("bg-accent z-50 rounded-md border p-1 shadow-md","max-h-64 w-[var(--radix-dropdown-menu-trigger-width)] overflow-hidden"),onKeyDown:C?e=>{"Escape"!==e.key&&e.stopPropagation()}:void 0,"data-sentry-element":"DropdownMenu.Content","data-sentry-source-file":"multi-select.tsx",children:[C&&
1(0,s.jsxs)("div",{className:"relative p-2 pb-1",children:[(0,s.jsx)(i.A,{className:"absolute top-1/2 left-3 size-4 -translate-y-1/2 text-[var(--primary)]"}),(0,s.jsx)(u.p,{ref:A,type:"text",placeholder:"Search...",value:N,onChange:e=>S(e.target.value),autoFocus:!0,className:"h-9 pl-6"})]}),(0,s.jsx)(c.F,{className:(0,d.cn)("relative max-h-[200px] overflow-x-hidden overflow-y-auto px-2","[&::-webkit-scrollbar]:w-1.5","[&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-[var(--primary)]/30","[&::-webkit-scrollbar-thumb:hover]:bg-[var(--primary)]/50","scrollbar-thin scrollbar-thumb-[var(--primary)]/30 scrollbar-track-transparent"),"data-sentry-element":"ScrollArea","data-sentry-source-file":"multi-select.tsx",children:0===t.length?(0,s.jsx)("div",{className:"text-muted-foreground py-4 text-center text-sm",children:f}):0===I.length?(0,s.jsx)("div",{className:"text-muted-foreground py-4 text-center text-sm",children:"No results found"}):I.map(e=>(0,s.jsxs)(r.H_,{checked:l.includes(e.value),onSelect:e=>e.preventDefault(),onCheckedChange:()=>R(e.value),className:(0,d.cn)("relative flex w-full cursor-default items-center rounded-sm px-2 py-1.5 text-sm outline-none","hover:bg-[var(--sidebar-accent)]/30"),children:[(0,s.jsx)("span",{className:"mr-2 flex size-3.5 items-center justify-center",children:(0,s.jsx)(o.S,{id:e.value,checked:l.includes(e.value),onCheckedChange:()=>R(e.value)})}),e.label]},e.value))})]})})]})}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.