1/*! For license information please see 5287.01de372a.chunk.js.LICENSE.txt */ 2(self.webpackChunkknowledge_base_saas=self.webpackChunkknowledge_base_saas||[]).push([[5287],{15003(e,s,t){"use strict";t.d(s,{A:()=>x});var a=t(89379),r=t(53986),n=t(65043),i=t(98139),l=t.n(i),c=t(66630),o=t(70579);const d=["size","fullWidth","loading","leadingIcon","trailingIcon","className","disabled","children","type"],m={sm:"py-2 px-3 text-body-sm font-medium",md:"py-2 px-4 text-body-md font-medium",lg:"py-3 px-4 text-body-md font-medium"},x=(0,n.forwardRef)(function(e,s){let t=e.size,n=void 0===t?"md":t,i=e.fullWidth,x=void 0!==i&&i,g=e.loading,h=void 0!==g&&g,p=e.leadingIcon,u=e.trailingIcon,y=e.className,f=e.disabled,b=e.children,v=e.type,j=void 0===v?"button":v,N=(0,r.A)(e,d);const w=Boolean(h),k=w?(0,o.jsx)(c.y$,{size:"sm",className:"shrink-0","aria-hidden":!0}):p;return(0,o.jsxs)("button",(0,a.A)((0,a.A)({ref:s,type:j,disabled:f||w,className:l()("inline-flex items-center justify-center font-medium bg-brand hover:bg-brand-hover text-brand-on rounded-brand-md focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-focus-ring disabled:opacity-50 disabled:cursor-not-allowed transition-colors",m[n]||m.md,x&&"w-full justify-center",(k||u)&&"gap-2",y)},N),{},{children:[k,b,u]}))})},95287(e,s,t){"use strict";t.r(s),t.d(s,{default:()=>W});var a=t(89379),r=t(5544),n=t(65043),i=t(77819),l=t(26533),c=t(95264),o=t(36210),d=t(9463),m=t(72313),x=t(35087),g=t(94965),h=t(35327),p=t(35746),u=t(42489),y=t(51884),f=t(7118),b=t(66630),v=t(15003),j=t(47081),N=t(96060),w=t(47874),k=t(92339),A=t(1862),z=t(70579);const W=()=>{(0,w.Zp)(),(0,w.zy)();const e=(0,n.useState)({emails:"",role:"viewer",message:"",selectedWorkspaces:[]}),s=(0,r.A)(e,2),t=s[0],W=s[1],E=(0,n.useState)([]),S=(0,r.A)(E,2),C=S[0],M=S[1],I=(0,n.useState)([]),O=(0,r.A)(I,2),P=O[0],L=O[1],D=(0,n.useState)([]),F=(0,r.A)(D,2),T=F[0],U=F[1],q=(0,n.useState)(!1),R=(0,r.A)(q,2),_=R[0],H=R[1],Q=(0,n.useState)(""),V=(0,r.A)(Q,2),B=V[0],G=V[1],Y=(0,n.useState)(!1),$=(0,r.A)(Y,2),Z=$[0],J=$[1],K=(0,n.useState)("invite"),X=(0,r.A)(K,2),ee=X[0],se=X[1],te=(0,n.useState)(!0),ae=(0,r.A)(te,2),re=ae[0],ne=ae[1],ie=(0,n.useState)(null),le=(0,r.A)(ie,2),ce=le[0],oe=le[1],de=(0,n.useState)(null),me=(0,r.A)(de,2),xe=me[0],ge=me[1],he=(0,n.useState)(!1),pe=(0,r.A)(he,2),ue=pe[0],ye=pe[1],fe={viewer:{name:"Viewer",description:"Can view all documents in the knowledge base",icon:x.A,color:"text-blue-600 bg-blue-50"},editor:{name:"Editor",description:"Can view and edit existing documents",icon:l.A,color:"text-green-600 bg-green-50"},admin:{name:"Admin",description:"Full access including adding/removing users",icon:u.A,color:"text-purple-600 bg-purple-50"}},be=e=>{if(!e||"Unknown"===e)return"Unknown";try{const s=new Date(e);if(isNaN(s.getTime()))return e;const t=String(s.getMonth()+1).padStart(2,"0"),a=String(s.getDate()).padStart(2,"0"),r=String(s.getFullYear()).slice(-2);return"".concat(t,"/").concat(a,"/").concat(r)}catch(ce){return console.error("Error formatting date:",ce),e}},ve=async()=>{try{oe(null);let t=(0,j.getSelectedOrganizationId)(),a=null;if(!t)try{var e;a=await(0,j.getUserOrganizationData)(null),null!==(e=a)&&void 0!==e&&e.id&&((0,j.t6)(a.id),t=a.id)}catch(s){console.warn("Could not resolve default organization:",s)}if(!t)return oe("No organization selected. Please select an organization first."),ye(!1),void ne(!1);if(a||(a=await(0,j.getUserOrganizationData)(t)),!a)return oe("Unable to load organization data. Please try again."),ye(!1),void ne(!1);const r=a.role;if(ge(r),"admin"!==r)return oe("You do not have permission to invite users. Only administrators can invite users to the organization."),ye(!1),void ne(!1);ye(!0)}catch(t){console.error("Error checking permissions:",t),oe("Failed to verify permissions. Please try again."),ye(!1),ne(!1)}};(0,n.useEffect)(()=>{ve();const e=()=>{ve()};return window.addEventListener("organizationChanged",e),()=>window.removeEventListener("organizationChanged",e)},[]),(0,n.useEffect)(()=>{const e=async()=>{if(ue)try{ne(!0);const t=(0,j.getSelectedOrganizationId)();(0,A.gg)("Fetching workspaces for organization:",t);let r=!1;if(t)try{const s=await(0,j.getUserOrganizationData)(t);if((0,A.gg)("Organization data:",s),s){const e=await(0,j.getWorkspaces)();if((0,A.gg)("Fetched ".concat(e.length," total workspaces from getWorkspaces()")),e&&0!==e.length){const t=e.filter(e=>{const t=e.organizationId===s.id;
2return t||(0,A.gg)("Workspace ".concat(e.name," (").concat(e.id,") has organizationId ").concat(e.organizationId,", expected ").concat(s.id)),t});(0,A.gg)("Filtered to ".concat(t.length," workspaces for organization ").concat(s.name)),0===t.length&&e.length>0?((0,A.gg)("No workspaces matched organization filter, showing all workspaces"),U(e.map(e=>(0,a.A)((0,a.A)({},e),{},{organizationName:e.organizationName||s.name||"Unknown Organization"})))):U(t.map(e=>(0,a.A)((0,a.A)({},e),{},{organizationName:s.name}))),r=!0}else{(0,A.gg)("getWorkspaces() returned empty array, trying loadWorkspacesWithOrgNames as fallback");const e=await(0,j.PT)();(0,A.gg)("Loaded ".concat(e.length," workspaces via loadWorkspacesWithOrgNames fallback")),U(e),r=!0}}else{(0,A.gg)("No organization data found, falling back to direct getWorkspaces()");try{const e=await(0,j.getWorkspaces)();e&&e.length>0&&((0,A.gg)("Loaded ".concat(e.length," workspaces directly via getWorkspaces()")),U(e),r=!0)}catch(e){(0,A.gg)("Direct getWorkspaces() failed, trying loadWorkspacesWithOrgNames")}if(!r){const e=await(0,j.PT)();(0,A.gg)("Loaded ".concat(e.length," workspaces via fallback")),U(e),r=!0}}}catch(ce){console.error("Error loading organization workspaces:",ce),(0,A.gg)("Error in organization workspace loading:",ce),ce.message&&ce.message.includes("not a member")&&((0,A.gg)("User is not a member of selected organization, clearing it from localStorage"),(0,j.t6)(null));try{const e=await(0,j.getWorkspaces)();e&&e.length>0&&((0,A.gg)("Loaded ".concat(e.length," workspaces directly via getWorkspaces() after error")),U(e),r=!0)}catch(e){(0,A.gg)("Direct getWorkspaces() failed after error, trying loadWorkspacesWithOrgNames")}if(!r)try{const e=await(0,j.PT)();(0,A.gg)("Loaded ".concat(e.length," workspaces via error fallback")),U(e),r=!0}catch(s){console.error("All workspace loading methods failed:",s),(0,A.gg)("All workspace loading methods failed, setting empty array"),U([])}}else{try{const e=await(0,j.getWorkspaces)();e&&e.length>0&&((0,A.gg)("Loaded ".concat(e.length," workspaces directly via getWorkspaces()")),U(e),r=!0)}catch(e){(0,A.gg)("Direct getWorkspaces() failed, trying loadWorkspacesWithOrgNames")}if(!r){(0,A.gg)("No selected organization, using loadWorkspacesWithOrgNames");const e=await(0,j.PT)();(0,A.gg)("Loaded ".concat(e.length," workspaces without organization filter")),U(e)}}const n=await(0,j.fP)(t);(0,A.gg)("Raw encrypted users from API:",n);const i=await(async e=>{try{const n=[];for(const i of e)try{const e=(0,a.A)({},i),r=i.id,l=i.name&&"string"===typeof i.name&&(0,N.NQ)(i.name)||i.email&&"string"===typeof i.email&&(0,N.NQ)(i.email);let c=null;if(r&&l)try{c=await(0,N.k5)(r)}catch(s){console.error("\u274c Could not derive key for member:",r,s)}if(c){if(i.name&&"string"===typeof i.name&&(0,N.NQ)(i.name)){(0,A.gg)("\ud83d\udd13 Attempting to decrypt name:",i.name.substring(0,20)+"...");try{const s=await(0,N.PV)(i.name,c);s&&s!==i.name?(e.name=(0,N.pM)(s),(0,A.gg)("\u2705 Name decrypted:",e.name)):(0,A.gg)("\u26a0\ufe0f Name decryption returned same value or null")}catch(t){console.error("\u274c Error decrypting name:",t)}}else i.name&&(0,A.gg)("\u2139\ufe0f Name does not look encrypted, keeping as-is:",i.name);if(i.email&&"string"===typeof i.email&&(0,N.NQ)(i.email)){(0,A.gg)("\ud83d\udd13 Attempting to decrypt email:",i.email.substring(0,20)+"...");try{const s=await(0,N.PV)(i.email,c);s&&s!==i.email?(e.email=(0,N.pM)(s),(0,A.gg)("\u2705 Email decrypted:",e.email)):(0,A.gg)("\u26a0\ufe0f Email decryption returned same value or null")}catch(t){console.error("\u274c Error decrypting email:",t)}}else i.email&&(0,A.gg)("\u2139\ufe0f Email does not look encrypted, keeping as-is:",i.email)}else l&&(r||console.warn("\u26a0\ufe0f Encrypted member field but no member id; skipping decrypt"));if(e.name&&"string"===typeof e.name&&(e.name=(0,N.pM)(e.name)),e.email&&"string"===typeof e.email&&(e.email=(0,N.pM)(e.email)),e.name&&!(0,N.NQ)(e.name)){const s=e.name.split(" ");e.avatar=s.length>1?s[0][0]+s[1][0]:s[0][0],e.avatar=e.avatar.toUpperCase()}else e.email&&!(0,N.NQ)(e.email)&&(e.avatar=e.email.substring(0,2).toUpperCase());n.push(e)}catch(r){console.error("\u274c Error processing user data:",r),n.push(i)}return(0,A.gg)("\u2705 Decryption complete. Decrypted users:",n),n}catch(ce){return console.error("\u274c Error in decryptUserData:",ce),e}})(n);if((0,A.gg)("Decrypted users:",i),L(i),"invite"===ee){const e=await(0,j.Gb)(t);M(e)}ne(!1),oe(null)}catch(t){console.error("Error fetching data:",t),oe("Error loading data: ".concat(t.message)),ne(!1)}};e();const s=()=>{e()};return window.addEventListener("organizationChanged",s),()=>window.removeEventListener("organizationChanged",s)},[ee,ue]);return ue||re?(0,z.jsx)(z.Fragment,{children:(0,z.jsxs)("div",{className:"min-h-screen bg-gray-50",children:[(0,z.jsx)("div",{className:"bg-white border-b border-gray-200",children:(0,z.jsx)("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:(0,z.jsxs)("div",{className:"flex items-center h-16 gap-3",children:[(0,z.jsxs)(w.N_,{to:"/",className:"flex items-center text-gray-600 hover:text-gray-900 flex-shrink-0",children:[(0,z.jsx)(d.A,{className:"h-5 w-5 mr-1"}),(0,z.jsx)("span",{className:"hidden sm:inline",children:"Back"})]}),(0,z.jsx)("h1",{className:"text-lg sm:text-xl font-semibold text-gray-900 whitespace-nowrap",children:"Manage Team Access"})]})})}),(0,z.jsxs)("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8",children:[ce&&(0,z.jsx)("div",{className:"mb-6 bg-red-50 border-l-4 border-red-500 p-4",children:(0,z.jsxs)("div",{className:"flex items-start",children:[(0,z.jsx)(i.A,{className:"h-5 w-5 text-red-500 mr-2 mt-0.5"}),(0,z.jsx)("p",{className:"text-sm text-red-700",children:ce})]})}),(0,z.jsx)("div",{className:"border-b border-gray-200 mb-8",children:(0,z.jsxs)("nav",{className:"-mb-px flex space-x-8",children:[(0,z.jsx)("button",{onClick:()=>se("invite"),className:"pb-4 px-1 border-b-2 font-medium text-sm ".concat("invite"===ee?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300"),children:(0,z.jsxs)("div",{className:"flex items-center",children:[(0,z.jsx)(y.A,{className:"h-5 w-5 mr-2"}),"Invite Team"]})}),(0,z.jsx)("button",{onClick:()=>se("users"),className:"pb-4 px-1 border-b-2 font-medium text-sm ".concat("users"===ee?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300"),children:(0,z.jsxs)("div",{className:"flex items-center",children:[(0,z.jsx)(f.A,{className:"h-5 w-5 mr-2"}),"Active Users (",P.length,")"]})})]})}),re&&(0,z.jsx)("div",{className:"flex justify-center my-8",children:(0,z.jsx)(b.y$,{size:"md",className:"text-blue-500"})}),!re&&"invite"===ee&&(0,z.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8",children:[(0,z.jsxs)("div",{className:"lg:col-span-2",children:[(0,z.jsxs)("div",{className:"bg-white rounded-lg shadow-sm p-6",children:[(0,z.jsx)("h2",{className:"text-lg font-medium text-gray-900 mb-6",children:"Invite Team Members"}),(0,z.jsxs)("div",{className:"mb-6 rounded-lg border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-950",children:[(0,z.jsx)("p",{className:"font-medium",children:"Adds people to your organization"}),(0,z.jsxs)("p",{className:"mt-1 text-amber-900",children:["Recipients join your team and can switch to your organization in their profile menu. To share a single workspace with someone who keeps their own organization, open that workspace and use"," ",(0,z.jsx)("strong",{children:"Worksp
2ace Access"})," from the workspace menu instead."]})]}),(0,z.jsx)("form",{onSubmit:async e=>{e.preventDefault(),H(!0),oe(null);try{const e=t.emails.split(/[,\n]/).map(e=>e.trim()).filter(e=>e);if(0===e.length)throw new Error("Please enter at least one valid email address");if(0===t.selectedWorkspaces.length)throw new Error("Please select at least one workspace");const s=T.find(e=>e.id===t.selectedWorkspaces[0]);if(!s||!s.organizationId)throw new Error("Could not determine organization");const a=s.organizationId,r=await(0,j.nL)(e,t.role,t.message,t.selectedWorkspaces,a);M(e=>[...r,...e]),W({emails:"",role:"viewer",message:"",selectedWorkspaces:[]}),k.Ay.success("Successfully sent ".concat(e.length," invitation(s) for ").concat(t.selectedWorkspaces.length," workspace(s)"))}catch(s){console.error("Error sending invitations:",s),oe("Failed to send invitations: ".concat(s.message))}finally{H(!1)}},children:(0,z.jsxs)("div",{className:"space-y-6",children:[(0,z.jsxs)("div",{children:[(0,z.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Email Addresses"}),(0,z.jsx)("textarea",{value:t.emails,onChange:e=>W((0,a.A)((0,a.A)({},t),{},{emails:e.target.value})),rows:4,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-1 focus:ring-blue-500",placeholder:"Enter email addresses separated by commas or new lines\ne.g., [email protected], [email protected]",required:!0}),(0,z.jsx)("p",{className:"mt-1 text-sm text-gray-500",children:"Separate multiple emails with commas or new lines"})]}),(0,z.jsxs)("div",{children:[(0,z.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,z.jsx)("label",{className:"block text-sm font-medium text-gray-700",children:"Select Workspaces"}),(0,z.jsxs)("div",{className:"flex space-x-2",children:[(0,z.jsx)("button",{type:"button",onClick:()=>{W(e=>(0,a.A)((0,a.A)({},e),{},{selectedWorkspaces:T.map(e=>e.id)}))},className:"text-xs text-blue-600 hover:text-blue-700",children:"Select All"}),(0,z.jsx)("span",{className:"text-xs text-gray-400",children:"|"}),(0,z.jsx)("button",{type:"button",onClick:()=>{W(e=>(0,a.A)((0,a.A)({},e),{},{selectedWorkspaces:[]}))},className:"text-xs text-gray-600 hover:text-gray-700",children:"Clear All"})]})]}),(0,z.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 max-h-48 overflow-y-auto border border-gray-200 rounded-md p-3",children:0===T.length?(0,z.jsxs)("div",{className:"col-span-2 text-center text-gray-500 py-4",children:[(0,z.jsx)(g.A,{className:"h-8 w-8 mx-auto mb-2 text-gray-400"}),(0,z.jsx)("p",{className:"text-sm",children:"No workspaces found"})]}):T.map(e=>(0,z.jsx)("div",{className:"relative rounded-lg border p-3 cursor-pointer transition-colors ".concat(t.selectedWorkspaces.includes(e.id)?"border-blue-500 bg-blue-50":"border-gray-200 hover:border-gray-300"),onClick:()=>{return s=e.id,void W(e=>(0,a.A)((0,a.A)({},e),{},{selectedWorkspaces:e.selectedWorkspaces.includes(s)?e.selectedWorkspaces.filter(e=>e!==s):[...e.selectedWorkspaces,s]}));var s},children:(0,z.jsxs)("div",{className:"flex items-start",children:[(0,z.jsx)("div",{className:"flex-shrink-0",children:(0,z.jsx)("div",{className:"rounded-lg p-2 bg-gray-100",children:(0,z.jsx)(c.A,{className:"h-4 w-4 text-gray-600"})})}),(0,z.jsxs)("div",{className:"ml-3 flex-1 min-w-0",children:[(0,z.jsx)("h4",{className:"text-sm font-medium text-gray-900 truncate",children:e.name}),(0,z.jsx)("p",{className:"text-xs text-gray-500 mt-1",children:e.organizationName}),void 0!==e.documentsCount&&(0,z.jsxs)("p",{className:"text-xs text-gray-400",children:[e.documentsCount," documents"]})]}),t.selectedWorkspaces.includes(e.id)&&(0,z.jsx)(o.A,{className:"h-4 w-4 text-blue-600 absolute top-3 right-3"})]})},e.id))}),(0,z.jsxs)("p",{className:"mt-1 text-sm text-gray-500",children:["Selected: ",t.selectedWorkspaces.length," workspace(s)"]})]}),(0,z.jsxs)("div",{children:[(0,z.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-3",children:"Access Level"}),(0,z.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:Object.entries(fe).map(e=>{let s=(0,r.A)(e,2),n=s[0],i=s[1];const l=i.icon;return(0,z.jsx)("div",{className:"relative rounded-lg border p-4 cursor-pointer ".concat(t.role===n?"border-blue-500 bg-blue-50":"border-gray-200 hover:border-gray-300"),onClick:()=>W((0,a.A)((0,a.A)({},t),{},{role:n})),children:(0,z.jsxs)("div",{className:"flex items-start",children:[(0,z.jsx)("div",{className:"rounded-lg p-2 ".concat(i.color),children:(0,z.jsx)(l,{className:"h-5 w-5"})}),(0,z.jsxs)("div",{className:"ml-3 flex-1",children:[(0,z.jsx)("h3",{className:"text-sm font-medium text-gray-900",children:i.name}),(0,z.jsx)("p",{className:"text-sm text-gray-500 mt-1",children:i.description})]}),t.role===n&&(0,z.jsx)(o.A,{className:"h-5 w-5 text-blue-600 absolute top-4 right-4"})]})},n)})})]}),(0,z.jsxs)("div",{children:[(0,z.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Personal Message (Optional)"}),(0,z.jsx)("textarea",{value:t.message,onChange:e=>W((0,a.A)((0,a.A)({},t),{},{message:e.target.value})),rows:3,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-1 focus:ring-blue-500",placeholder:"Add a personal message to the invitation email..."})]}),(0,z.jsx)("div",{className:"flex items-center justify-between",children:(0,z.jsx)(v.A,{type:"submit",disabled:_||!t.emails||0===t.selectedWorkspaces.length,loading:_,leadingIcon:(0,z.jsx)(p.A,{className:"h-4 w-4"}),size:"md",className:"flex items-center px-6 py-2 rounded-md text-sm disabled:!opacity-100 disabled:!bg-gray-400 disabled:!cursor-not-allowed",children:_?"Sending...":"Send Invitations"})})]})})]}),C.length>0&&(0,z.jsxs)("div",{className:"bg-white rounded-lg shadow-sm p-6 mt-6",children:[(0,z.jsx)("h2",{className:"text-lg font-medium text-gray-900 mb-4",children:"Pending Invitations"}),(0,z.jsx)("div",{className:"space-y-3",children:C.map(e=>(0,z.jsxs)("div",{className:"flex items-center justify-between p-3 bg-gray-50 rounded-lg",children:[(0,z.jsxs)("div",{className:"flex items-center",children:[(0,z.jsx)(h.A,{className:"h-5 w-5 text-gray-400 mr-3"}),(0,z.jsxs)("div",{children:[(0,z.jsx)("p",{className:"text-sm font-medium text-gray-900",children:e.email}),(0,z.jsxs)("p",{className:"text-xs text-gray-500",children:[fe[e.role].name," \u2022 Invited ",be(e.invitedAt)]}),e.workspaces&&e.workspaces.length>0&&(0,z.jsxs)("p",{className:"text-xs text-gray-400",children:[e.workspaces.length," workspace(s)"]})]})]}),(0,z.jsxs)("div",{className:"flex items-center space-x-2",children:["expired"===e.status&&(0,z.jsx)("span",{className:"text-xs text-red-600 bg-red-50 px-2 py-1 rounded-full",children:"Expired"}),(0,z.jsx)("button",{onClick:()=>(async e=>{try{ne(!0),oe(null),await(0,j.Il)(e),M(s=>s.filter(s=>s.id!==e)),ne(!1)}catch(s){console.error("Error canceling invitation:",s),oe("Failed to cancel invitation: ".concat(s.message)),ne(!1)}})(e.id),className:"text-sm text-red-600 hover:text-red-700",children:"Cancel"})]})]},e.id))})]})]}),(0,z.jsxs)("div",{className:"lg:col-span-1",children:[(0,z.jsxs)("div",{className:"bg-white rounded-lg shadow-sm p-6",children:[(0,z.jsx)("h3",{className:"text-lg font-medium text-gray-900 mb-4",children:"Share Invite Link"}),(0,z.jsx)("p",{className:"text-sm text-gray-600 mb-4",children:"Generate a link that can be shared with multiple team members"}),0===t.selectedWorkspaces.length&&(0,z.jsx)("div",{className:"mb-4 p-3 bg-amber-50 border border-amber-200 rounded-md",children:(0,z.jsx)("p",{className:"text-sm text-amber-700",children:"Please select at least one workspace to generate an invite link"})}),B?(0,z.jsxs)("div",{className:"space-y-4",children:[(0,z.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,z.jsx)("input",{type:"text",value:B,readOnly:!0,className:"flex-1 px-3 py-2 text-sm border border-gray-300 rounded-md bg-gray-50"}),(0,z.jsx)("button",{onClick:async()=>{try{await navigator.clipboard.writeText(B),J(!0),setTimeout(()=>J(!1),2e3)}catch(e){console.error("Failed to copy:",e),oe("Failed to copy to clipboard. Please try again.")}},className:"px-3 py-2 text-sm bg-blue-600 text-white rounded-md hover:bg-blue-700",children:Z?(0,z.jsx)(o.A,{className:"h-4 w-4"}):(0,z.jsx)(m.A,{className:"h-4 w-4"})})]}),Z&&(0,z.jsx)("p",{className:"text-sm text-green-600",children:"Link copied to clipboard!"}),(0,z.jsxs)("div",{className:"text-xs text-gray-500",children:[(0,z.jsx)("p",{children:"This link will expire in 7 days"}),(0,z.jsxs)("p",{children:["Default role: ",fe[t.role].name]}),(0,z.jsxs)("p",{children:["Workspaces: ",t.selectedWorkspaces.length," selected"]})]}),(0,z.jsx)("button",{onClick:()=>G(""),className:"text-sm text-gray-600 hover:text-gray-700",children:"Generate new link"})]}):(0,z.jsx)("button",{onClick:async()=>{try{if(ne(!0),oe(null),0===t.selectedWorkspaces.length)throw new Error("Please select at least one workspace");const e=await(0,j.Rp)(t.role,t.selectedWorkspaces);G(e.url),ne(!1)}catch(e){console.error("Error generating invite link:",e),oe("Failed to generate invite link: ".concat(e.message)),ne(!1)}},disabled:0===t.selectedWorkspaces.length,className:"w-full px-4 py-2 rounded-md transition-colors ".concat(0===t.selectedWorkspaces.length?"bg-gray-100 text-gray-400 cursor-not-allowed":"bg-gray-100 text-gray-700 hover:bg-gray-200"),children:"Generate Invite Link"})]}),(0,z.jsxs)("div",{className:"bg-white rounded-lg shadow-sm p-6 mt-6",children:[(0,z.jsx)("h3",{className:"text-lg font-medium text-gray-900 mb-4",children:"Team Overview"}),(0,z.jsxs)("div",{className:"space-y-4",children:[(0,z.jsxs)("div",{className:"flex justify-between items-center",children:[(0,z.jsx)("span",{className:"text-sm text-gray-600",children:"Active Users"}),(0,z.jsx)("span",{className:"text-sm font-medium text-gray-900",children:P.length})]}),(0,z.jsxs)("div",{className:"flex justify-between items-center",children:[(0,z.jsx)("span",{className:"text-sm text-gray-600",children:"Pending Invites"}),(0,z.jsx)("span",{className:"text-sm font-medium text-gray-900",children:C.filter(e=>"pending"===e.status).length})]}),(0,z.jsxs)("div",{className:"flex justify-between items-center",children:[(0,z.jsx)("span",{className:"text-sm text-gray-600",children:"Worksp
2aces"}),(0,z.jsx)("span",{className:"text-sm font-medium text-gray-900",children:T.length})]}),(0,z.jsxs)("div",{className:"border-t border-gray-200 pt-4",children:[(0,z.jsx)("h4",{className:"text-sm font-medium text-gray-900 mb-2",children:"By Role"}),Object.entries(fe).map(e=>{let s=(0,r.A)(e,2),t=s[0],a=s[1];const n=P.filter(e=>e.role===t).length;return(0,z.jsxs)("div",{className:"flex justify-between items-center mb-1",children:[(0,z.jsx)("span",{className:"text-sm text-gray-600",children:a.name}),(0,z.jsx)("span",{className:"text-sm font-medium text-gray-900",children:n})]},t)})]})]})]})]})]}),!re&&"users"===ee&&(0,z.jsxs)("div",{className:"bg-white rounded-lg shadow-sm",children:[(0,z.jsx)("div",{className:"px-6 py-4 border-b border-gray-200",children:(0,z.jsx)("h2",{className:"text-lg font-medium text-gray-900",children:"Active Team Members"})}),(0,z.jsx)("div",{className:"overflow-x-auto",children:0===P.length?(0,z.jsx)("div",{className:"p-6 text-center text-gray-500",children:"No active users found. Invite your team members to get started."}):(0,z.jsxs)("table",{className:"min-w-full divide-y divide-gray-200",children:[(0,z.jsx)("thead",{className:"bg-gray-50",children:(0,z.jsxs)("tr",{children:[(0,z.jsx)("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"User"}),(0,z.jsx)("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Role"}),(0,z.jsx)("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Workspaces"}),(0,z.jsx)("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Added"}),(0,z.jsx)("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Last Active"}),(0,z.jsx)("th",{scope:"col",className:"px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Actions"})]})}),(0,z.jsx)("tbody",{className:"bg-white divide-y divide-gray-200",children:P.map(e=>(0,z.jsxs)("tr",{children:[(0,z.jsx)("td",{className:"px-6 py-4 whitespace-nowrap",children:(0,z.jsxs)("div",{className:"flex items-center",children:[(0,z.jsx)("div",{className:"flex-shrink-0 h-10 w-10",children:(0,z.jsx)("div",{className:"h-10 w-10 rounded-full bg-blue-500 flex items-center justify-center text-white font-medium",children:e.avatar||"?"})}),(0,z.jsxs)("div",{className:"ml-4",children:[(0,z.jsx)("div",{className:"text-sm font-medium text-gray-900",children:e.name||"Encrypted Name"}),(0,z.jsx)("div",{className:"text-sm text-gray-500",children:e.email||"Encrypted Email"})]})]})}),(0,z.jsx)("td",{className:"px-6 py-4 whitespace-nowrap",children:(0,z.jsx)("select",{value:e.role,onChange:s=>(async(e,s)=>{try{ne(!0),oe(null),await(0,j.v_)(e,s),L(t=>t.map(t=>t.id===e?(0,a.A)((0,a.A)({},t),{},{role:s}):t)),ne(!1)}catch(t){console.error("Error updating user role:",t),oe("Failed to update user role: ".concat(t.message)),ne(!1)}})(e.id,s.target.value),className:"text-sm border border-gray-300 rounded-md px-2 py-1",disabled:"[email protected]"===e.email,children:Object.entries(fe).map(e=>{let s=(0,r.A)(e,2),t=s[0],a=s[1];return(0,z.jsx)("option",{value:t,children:a.name},t)})})}),(0,z.jsx)("td",{className:"px-6 py-4 whitespace-nowrap",children:(0,z.jsx)("div",{className:"text-sm text-gray-900",children:e.workspaces?(0,z.jsxs)("div",{className:"flex flex-wrap gap-1",children:[e.workspaces.slice(0,2).map(e=>(0,z.jsx)("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-gray-100 text-gray-800",children:e.name},e.id)),e.workspaces.length>2&&(0,z.jsxs)("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-gray-100 text-gray-800",children:["+",e.workspaces.length-2," more"]})]}):(0,z.jsx)("span",{className:"text-gray-500",children:"No workspaces"})})}),(0,z.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:be(e.addedAt)}),(0,z.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:be(e.lastActive)}),(0,z.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium",children:"[email protected]"!==e.email&&(0,z.jsx)("button",{onClick:()=>(async e=>{if(window.confirm("Are you sure you want to remove this user?"))try{ne(!0),oe(null),await(0,j.a1)(e),L(s=>
2s.filter(s=>s.id!==e)),ne(!1)}catch(s){console.error("Error removing user:",s),oe("Failed to remove user: ".concat(s.message)),ne(!1)}})(e.id),className:"text-red-600 hover:text-red-900",children:"Remove"})})]},e.id))})]})})]})]})]})}):(0,z.jsx)(z.Fragment,{children:(0,z.jsxs)("div",{className:"min-h-screen bg-gray-50",children:[(0,z.jsx)("div",{className:"bg-white border-b border-gray-200",children:(0,z.jsx)("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:(0,z.jsxs)("div",{className:"flex items-center h-16 gap-3",children:[(0,z.jsxs)(w.N_,{to:"/",className:"flex items-center text-gray-600 hover:text-gray-900 flex-shrink-0",children:[(0,z.jsx)(d.A,{className:"h-5 w-5 mr-1"}),(0,z.jsx)("span",{className:"hidden sm:inline",children:"Back"})]}),(0,z.jsx)("h1",{className:"text-lg sm:text-xl font-semibold text-gray-900 whitespace-nowrap",children:"Manage Team Access"})]})})}),(0,z.jsx)("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8",children:(0,z.jsx)("div",{className:"bg-red-50 border-l-4 border-red-500 p-6 rounded-md",children:(0,z.jsxs)("div",{className:"flex items-start",children:[(0,z.jsx)(i.A,{className:"h-6 w-6 text-red-500 mr-3 mt-0.5"}),(0,z.jsxs)("div",{children:[(0,z.jsx)("h3",{className:"text-lg font-medium text-red-800 mb-2",children:"Access Denied"}),(0,z.jsx)("p",{className:"text-sm text-red-700 mb-4",children:ce||"You do not have permission to access this page. Only administrators can invite users to the organization."}),(0,z.jsxs)("p",{className:"text-sm text-red-600",children:["Your current role: ",(0,z.jsx)("span",{className:"font-semibold capitalize",children:xe||"Unknown"})]}),(0,z.jsx)("p",{className:"text-sm text-red-600 mt-2",children:"If you need to invite users, please switch to an organization where you have administrator privileges."})]})]})})})]})})}},95264(e,s,t){"use strict";t.d(s,{A:()=>a});const a=(0,t(77784).A)("building",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["path",{d:"M9 22v-4h6v4",key:"r93iot"}],["path",{d:"M8 6h.01",key:"1dz90k"}],["path",{d:"M16 6h.01",key:"1x0f13"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M8 14h.01",key:"6423bh"}]])},36210(e,s,t){"use strict";t.d(s,{A:()=>a});const a=(0,t(77784).A)("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]])},9463(e,s,t){"use strict";t.d(s,{A:()=>a});const a=(0,t(77784).A)("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]])},77819(e,s,t){"use strict";t.d(s,{A:()=>a});const a=(0,t(77784).A)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]])},72313(e,s,t){"use strict";t.d(s,{A:()=>a});const a=(0,t(77784).A)("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]])},35087(e,s,t){"use strict";t.d(s,{A:()=>a});const a=(0,t(77784).A)("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]])},94965(e,s,t){"use strict";t.d(s,{A:()=>a});const a=(0,t(77784).A)("folder-open",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]])},35327(e,s,t){"use strict";t.d(s,{A:()=>a});const a=(0,t(77784).A)("mail",[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]])},35746(e,s,t){"use strict";t.d(s,{A:()=>a});const a=(0,t(77784).A)("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]])},42489(e,s,t){"use strict";t.d(s,{A:()=>a});const a=(0,t(77784).A)("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",ke
2y:"oel41y"}]])},26533(e,s,t){"use strict";t.d(s,{A:()=>a});const a=(0,t(77784).A)("square-pen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]])},51884(e,s,t){"use strict";t.d(s,{A:()=>a});const a=(0,t(77784).A)("user-plus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]])},7118(e,s,t){"use strict";t.d(s,{A:()=>a});const a=(0,t(77784).A)("users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]])},98139(e,s){var t;!function(){"use strict";var a={}.hasOwnProperty;function r(){for(var e="",s=0;s<arguments.length;s++){var t=arguments[s];t&&(e=i(e,n(t)))}return e}function n(e){if("string"===typeof e||"number"===typeof e)return e;if("object"!==typeof e)return"";if(Array.isArray(e))return r.apply(null,e);if(e.toString!==Object.prototype.toString&&!e.toString.toString().includes("[native code]"))return e.toString();var s="";for(var t in e)a.call(e,t)&&e[t]&&(s=i(s,t));return s}function i(e,s){return s?e?e+" "+s:e+s:e}e.exports?(r.default=r,e.exports=r):void 0===(t=function(){return r}.apply(s,[]))||(e.exports=t)}()}}]); 3//# sourceMappingURL=5287.01de372a.chunk.js.map
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.