1import{j as e}from"./vendor-ui-core.DP8knyZn.js";import{r as t}from"./vendor-react.BBoGJFYM.js";import{a as r,d as i,s as a,S as n,t as o}from"./index.CdjOtu-m.js";import{R as l,a$ as d,b4 as s,T as c,E as g,f as p,X as u}from"./vendor-icons.BjAWwE8z.js";import"./vendor-supabase.DS-aP8MZ.js";import"./vendor-ui-forms.CjLBxE3d.js";import"./vendor-utils.BlEnRQrd.js";import"./vendor-ui-display.BT2Z6Vpo.js";import"./vendor-query.CfjDb5WU.js";import"./vendor-media.DY6E_qVO.js";import"./vendor-charts.RWeJ_I16.js";import"./vendor-motion.DCvbjL6b.js";const x={dark:{cardBg:"rgba(255,255,255,0.04)",cardBorder:"rgba(16,185,129,0.14)",titleText:"rgba(255,255,255,0.92)",subText:"rgba(255,255,255,0.45)",rowBg:"rgba(255,255,255,0.04)",rowLabelText:"rgba(255,255,255,0.50)",rowValueText:"rgba(255,255,255,0.90)",sectionTitle:"rgba(255,255,255,0.80)",countBadgeBg:"rgba(16,185,129,0.14)",countBadgeText:"#10b981",badgeActiveBg:"rgba(16,185,129,0.18)",badgeActiveText:"#10b981",badgeActiveBorder:"rgba(16,185,129,0.35)",badgeGrayBg:"rgba(255,255,255,0.06)",badgeGrayText:"rgba(255,255,255,0.40)",badgeGrayBorder:"rgba(255,255,255,0.12)",emptyCardBg:"rgba(255,255,255,0.03)",emptyCardBorder:"rgba(255,255,255,0.07)",emptyText:"rgba(255,255,255,0.30)",inputBg:"rgba(255,255,255,0.06)",inputBorder:"rgba(16,185,129,0.20)",inputText:"rgba(255,255,255,0.85)",inputPlaceholder:"rgba(255,255,255,0.28)",divider:"rgba(255,255,255,0.06)",theadText:"rgba(255,255,255,0.45)",rowHoverBg:"rgba(255,255,255,0.03)",btnPrimaryBg:"#10b981",btnPrimaryText:"#fff",btnOutlineBg:"rgba(255,255,255,0.06)",btnOutlineBorder:"rgba(16,185,129,0.20)",btnOutlineText:"rgba(255,255,255,0.70)",btnDangerBg:"rgba(239,68,68,0.12)",btnDangerBorder:"rgba(239,68,68,0.25)",btnDangerText:"#f87171",overlayBg:"rgba(0,0,0,0.60)",modalBg:"#1a1a1a",modalBorder:"rgba(16,185,129,0.18)",labelText:"rgba(255,255,255,0.60)",metaInfoBg:"rgba(255,255,255,0.04)",metaInfoBorder:"rgba(16,185,129,0.10)",metaLabel:"rgba(255,255,255,0.45)",metaValue:"rgba(255,255,255,0.85)"},light:{cardBg:"rgba(16,185,129,0.06)",cardBorder:"rgba(16,185,129,0.22)",titleText:"rgba(255,255,255,0.96)",subText:"rgba(255,255,255,0.60)",rowBg:"rgba(255,255,255,0.08)",rowLabelText:"rgba(255,255,255,0.65)",rowValueText:"rgba(255,255,255,0.95)",sectionTitle:"rgba(255,255,255,0.90)",countBadgeBg:"rgba(16,185,129,0.20)",countBadgeText:"#10b981",badgeActiveBg:"rgba(16,185,129,0.25)",badgeActiveText:"#10b981",badgeActiveBorder:"rgba(16,185,129,0.50)",badgeGrayBg:"rgba(255,255,255,0.10)",badgeGrayText:"rgba(255,255,255,0.55)",badgeGrayBorder:"rgba(255,255,255,0.20)",emptyCardBg:"rgba(255,255,255,0.05)",emptyCardBorder:"rgba(16,185,129,0.15)",emptyText:"rgba(255,255,255,0.45)",inputBg:"rgba(16,185,129,0.12)",inputBorder:"rgba(16,185,129,0.35)",inputText:"rgba(255,255,255,0.90)",inputPlaceholder:"rgba(255,255,255,0.40)",divider:"rgba(16,185,129,0.18)",theadText:"rgba(255,255,255,0.55)",rowHoverBg:"rgba(255,255,255,0.05)",btnPrimaryBg:"#10b981",btnPrimaryText:"#fff",btnOutlineBg:"rgba(16,185,129,0.12)",btnOutlineBorder:"rgba(16,185,129,0.35)",btnOutlineText:"rgba(255,255,255,0.85)",btnDangerBg:"rgba(239,68,68,0.15)",btnDangerBorder:"rgba(239,68,68,0.30)",btnDangerText:"#f87171",overlayBg:"rgba(0,0,0,0.55)",modalBg:"#1f2a24",modalBorder:"rgba(16,185,129,0.25)",labelText:"rgba(255,255,255,0.70)",metaInfoBg:"rgba(255,255,255,0.06)",metaInfoBorder:"rgba(16,185,129,0.14)",metaLabel:"rgba(255,255,255,0.55)",metaValue:"rgba(255,255,255,0.90)"}},b="#10b981";const m=({value:t,onChange:r,placeholder:i,type:a="text",p:n,rightSlot:o})=>e.jsxs("div",{style:{position:"relative"},children:[e.jsx("input",{type:a,value:t,onChange:e=>r(e.target.value),placeholder:i,style:{width:"100%",boxSizing:"border-box",background:n.inputBg,border:`1px solid ${n.inputBorder}`,borderRadius:9,padding:o?"8px 36px 8px 12px":"8px 12px",fontSize:12.5,color:n.inputText,outline:"none"}}),o&&e.jsx("div",{style:{position:"absolute",right:10,top:"50%",transform:"translateY(-50%)",color:n.subText,cursor:"pointer"},children:o})]}),h=({value:t,onChange:r,children:i,p:a})=>e.jsx("select",{value:t,onChange:e=>r(e.target.value),style:{width:"100%",boxSizing:"border-box",background:a.inputBg,border:`1px solid ${a.inputBorder}`,borderRadius:9,padding:"8px 12px",fontSize:12.5,color:a.inputText,outline:"none",cursor:"pointer"},children:i}),f=({children:t,p:r})=>e.jsx("p",{style:{fontSize:11.5,fontWeight:600,color:r.labelText,margin:"0 0 5px"},children:t}),y=({onClick:t,disabled:r,children:i,p:a})=>e.jsx("button",{onClick:t,disabled:r,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6,width:"100%",padding:"9px 16px",borderRadius:9,background:r?"rgba(16,185,129,0.4)":a.btnPrimaryBg,border:"none",color:a.btnPrimaryText,fontSize:13,fontWeight:700,cursor:r?"not-allowed":"pointer",transition:"background 150ms"},children:i}),j=({onClick:t,disabled:r,children:i,p:a,small:n})=>e.jsx("button",{onClick:t,disabled:r,style:{display:"inline-flex",alignItems:"center",gap:6,padding:n?"5px 10px":"7px 14px",borderRadius:8,background:a.btnOutlineBg,border:`1px solid ${a.btnOutlineBorder}`,color:r?"rgba(255,255,255,0.25)":a.btnOutlineText,fontSize:12,fontWeight:600,cursor:r?"not-allowed":"pointer",transition:"background 150ms"},children:i}),v=({onClick:t,disabled:r,danger:i,children:a,p:n})=>e.jsx("button",{onClick:t,disabled:r,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:28,height:28,borderRadius:7,border:"none",background:i?n.btnDangerBg:"transparent",color:i?n.btnDangerText:n.rowLabelText,cursor:r?"not-allowed":"pointer"},children:a}),B=({open:t,onClose:r,title:i,children:a,p:n})=>t?e.jsx("div",{style:{position:"fixed",inset:0,zIndex:1e3,background:n.overlayBg,display:"flex",alignItems:"center",justifyContent:"center"},onClick:e=>{e.target===e.currentTarget&&r()},children:e.jsxs("div",{style:{background:n.modalBg,border:`1px solid ${n.modalBorder}`,borderRadius:16,padding:"22px 24px",width:"100%",maxWidth:400,margin:"0 16px",boxShadow:"0 24px 64px rgba(0,0,0,0.5)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:18},children:[e.jsx("h3",{style:{fontSize:15,fontWeight:700,color:n.titleText,margin:0},children:i}),e.jsx("button",{onClick:r,style:{background:"none",border:"none",color:n.subText,cursor:"pointer",padding:2},children:e.jsx(u,{style:{width:16,height:16}})})]}),a]})}):null,T=({open:t,onClose:r,onConfirm:i,title:a,description:n,p:o})=>t?e.jsx("div",{style:{position:"fixed",inset:0,zIndex:1001,background:o.overlayBg,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("div",{style:{background:o.modalBg,border:`1px solid ${o.modalBorder}`,borderRadius:16,padding:"22px 24px",width:"100%",maxWidth:360,margin:"0 16px"},children:[e.jsx("h3",{style:{fontSize:15,fontWeight:700,color:o.titleText,margin:"0 0 8px"},children:a}),e.jsx("p",{style:{fontSize:12.5,color:o.subText,margin:"0 0 20px"},children:n}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx(j,{onClick:r,p:o,children:"Cancel"}),e.jsx("button",{onClick:i,style:{padding:"7px 16px",borderRadius:8,fontSize:12,fontWeight:700,background:o.btnDangerBg,border:`1px solid ${o.btnDangerBorder}`,color:o.btnDangerText,cursor:"pointer"},children:"Remove"})]})]})}):null,w=()=>{r();const{corporateId:u,role:w}=i(),C=function(){const e=t.useCallback(()=>
1{if("undefined"!=typeof document){const e=document.documentElement.getAttribute("data-theme")??document.documentElement.getAttribute("class")??"";if(e.includes("light"))return"light";if(e.includes("dark"))return"dark"}return"undefined"!=typeof window&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark"},[]),[r,i]=t.useState(e);return t.useEffect(()=>{const t=new MutationObserver(()=>i(e()));return t.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]}),()=>t.disconnect()},[e]),r}(),S=x[C],[_,k]=t.useState(null),[z,A]=t.useState([]),[R,I]=t.useState(!0),[M,W]=t.useState(!1),[E,D]=t.useState(!1),[$,L]=t.useState(!1),[P,O]=t.useState(null),[q,G]=t.useState(!1),[F,N]=t.useState(null),[V,H]=t.useState(null),[U,J]=t.useState(""),[X,Y]=t.useState(""),[K,Q]=t.useState(""),[Z,ee]=t.useState(""),[te,re]=t.useState(!1),[ie,ae]=t.useState(""),[ne,oe]=t.useState(""),[le,de]=t.useState(""),[se,ce]=t.useState("recruiter");t.useEffect(()=>{u&&ge()},[u]);const ge=async()=>{if(!u)return;I(!0);const[e,t]=await Promise.all([a.from("corporates").select("name, contact_email, contact_name, city, state, max_users").eq("id",u).single(),a.from("corporate_members").select("*").eq("corporate_id",u).order("created_at")]);k(e.data||null);const r=t.data||[],i=r.map(e=>e.user_id).filter(Boolean);if(i.length>0){const{data:e}=await a.from("profiles").select("user_id, full_name, email").in("user_id",i),t={},n={};(e||[]).forEach(e=>{e.full_name&&(t[e.user_id]=e.full_name),e.email&&(n[e.user_id]=e.email)}),r.forEach(e=>{e.full_name=t[e.user_id],e.email=n[e.user_id]})}const n=r.filter(e=>"admin"===e.role).sort((e,t)=>new Date(e.created_at||0).getTime()-new Date(t.created_at||0).getTime()),o=n.length>0?n[0].id:null;r.forEach(e=>{e.is_main_admin=e.id===o}),A(r),I(!1)},pe=_?[{label:"Company Name",value:_.name},{label:"Contact Email",value:_.contact_email},{label:"Contact Name",value:_.contact_name||"â"},{label:"Location",value:[_.city,_.state].filter(Boolean).join(", ")||"â"}]:[];return e.jsxs(e.Fragment,{children:[e.jsx(n,{title:"Settings | Corporate Portal",description:"Corporate settings and team management."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0,width:"100%"},children:[e.jsxs("div",{style:{marginBottom:18},children:[e.jsxs("h1",{style:{fontSize:17,fontWeight:800,color:"rgba(255,255,255,0.92)",margin:0,letterSpacing:"-0.3px"},children:["Profile"," ",e.jsx("span",{style:{color:b,fontWeight:700},children:" Management"})]}),e.jsx("p",{style:{fontSize:11.5,color:"rgba(255,255,255,0.40)",marginTop:2,marginBottom:0},children:"Manage organization profile and team members."})]}),e.jsx("div",{style:{height:1,background:S.divider,marginBottom:20}}),e.jsxs("section",{style:{marginBottom:20},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:14},children:e.jsx("h2",{style:{fontSize:14,fontWeight:700,color:S.sectionTitle,margin:0},children:"Organization Profile"})}),e.jsx("div",{style:{background:S.cardBg,border:`1px solid ${S.cardBorder}`,borderRadius:14,padding:"16px 20px"},children:R||!_?e.jsx("p",{style:{fontSize:12,color:S.subText,margin:0},children:"Loading..."}):e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:10},children:pe.map(({label:t,value:r})=>e.jsxs("div",{style:{background:S.metaInfoBg,border:`1px solid ${S.metaInfoBorder}`,borderRadius:9,padding:"10px 12px"},children:[e.jsx("p",{style:{fontSize:10.5,color:S.metaLabel,margin:"0 0 3px",fontWeight:600},children:t}),e.jsx("p",{style:{fontSize:12.5,color:S.metaValue,margin:0,fontWeight:500},children:r})]},t))})})]}),e.jsx("div",{style:{height:1,background:S.divider,marginBottom:20}}),e.jsxs("section",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,marginBottom:14,flexWrap:"wrap"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("h2",{style:{fontSize:14,fontWeight:700,color:S.sectionTitle,margin:0},children:"Team Members"}),!R&&e.jsxs("span",{style:{fontSize:10,fontWeight:700,padding:"1px 8px",borderRadius:20,background:S.countBadgeBg,color:S.countBadgeText},children:[z.length,(null==_?void 0:_.max_users)?` / ${_.max_users}`:""]})]}),e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[e.jsxs(j,{onClick:ge,disabled:R,p:S,small:!0,children:[e.jsx(l,{style:{width:12,height:12}})," Refresh"]}),"corporate_admin"===w&&e.jsxs("button",{onClick:()=>W(!0),style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 12px",borderRadius:8,background:b,border:"none",color:"#fff",fontSize:12,fontWeight:700,cursor:"pointer"},children:[e.jsx(d,{style:{width:13,height:13}})," Add Member"]})]})]}),0!==z.length||R?e.jsx("div",{style:{background:S.cardBg,border:`1px solid ${S.cardBorder}`,borderRadius:14,overflow:"hidden"},children:e.jsx("div",{style:{overflowX:"auto"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[e.jsx("thead",{children:e.jsx("tr",{children:["Name","Email","Role","Status",..."corporate_admin"===w?["Actions"]:[]].map((t,r)=>e.jsx("th",{style:{textAlign:r>=3?"center":"left",padding:"10px 14px",fontSize:10.5,fontWeight:700,color:S.theadText,borderBottom:`1px solid ${S.divider}`,whiteSpace:"nowrap"},children:t},t))})}),e.jsx("tbody",{children:z.map(t=>e.jsxs("tr",{style:{borderBottom:`1px solid ${S.divider}`},onMouseEnter:e=>e.currentTarget.style.background=S.rowHoverBg,onMouseLeave:e=>e.currentTarget.style.background="transparent",children:[e.jsx("td",{style:{padding:"9px 14px",color:S.rowValueText,fontWeight:500},children:t.full_name||"Unnamed User"}),e.jsx("td",{style:{padding:"9px 14px",color:S.rowLabelText},children:t.email||"â"}),e.jsx("td",{style:{padding:"9px 14px",color:S.rowLabelText,textTransform:"capitalize"},children:t.role}),e.jsx("td",{style:{padding:"9px 14px",textAlign:"center"},children:e.jsx("span",{style:{display:"inline-flex",alignItems:"center",fontSize:10,fontWeight:700,padding:"2px 8px",borderRadius:6,background:"active"===t.status?S.badgeActiveBg:S.badgeGrayBg,color:"active"===t.status?S.badgeActiveText:S.badgeGrayText,border:`1px solid ${"active"===t.status?S.badgeActiveBorder:S.badgeGrayBorder}`},children:t.status||"inactive"})}),"corporate_admin"===w&&e.jsx("td",{style:{padding:"9px 14px",textAlign:"center"},children:t.is_main_admin?e.jsx("span",{style:{fontSize:10.5,color:S.rowLabelText},children:"Main Admin"}):e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:4},children:[e.jsx(v,{onClick:()=>(e=>{H(e),J(e.full_name||""),Y(e.role),Q(e.department||""),ee(e.designation||"")})(t),p:S,children:e.jsx(s,{style:{width:13,height:13}})}),e.jsx(v,{onClick:()=>{N(t),G(!0)},disabled:P===t.id,danger:!0,p:S,children:e.jsx(c,{style:{width:13,height:13}})})]})})]},t.id))})]})})}):e.jsx("div",{style:{background:S.emptyCardBg,border:`1px solid ${S.emptyCardBorder}`,borderRadius:12,padding:"24px 16px",textAlign:"center",color:S.emptyText,fontSize:12.5},children:"No team members yet."})]}),e.jsx("div",{style:{height:16}})]}),e.jsx(B,{open:M,onClose:()=>W(!1),title:"Add Team Member",p:S,children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[e.jsxs("div",{children:[e.jsx(f,{p:S,children:"Full Name *"}),e.jsx(m,{value:ne,onChange:oe,placeholder:"Jane Smith",p:S})]}),e.jsxs("div",{children:[e.jsx(f,{p:S,children:"Email *"}),e.jsx(m,{value:ie,onChange:ae,placeholder:"[email protected]",p:S})]}),e.jsxs("div",{children:[e.jsx(f,{p:S,children:"Password *"}),e.jsx(m,{type:$?"text":"password",value:le,onChange:de,placeholder:"Min 6 characters",p:S,rightSlot:e.jsx("span",{onClick:()=>L(!$),children:$?e.jsx(g,{style:{width:14,height:14}}):e.jsx(p,{style:{width:14,height:14}})})})]}),e.jsxs("div",{children:[e.jsx(f,{p:S,children:"Role *"}),e.jsxs(h,{value:se,onChange:ce,p:S,children:[e.jsx("option",{value:"recruiter",children:"Recruiter"}),e.jsx("option",{value:"admin",children:"Admin"})]})]}),e.jsx(y,{onClick:async()=>{var e,t,r;if(!(ne.trim()&&ie.trim()&&le.trim()&&se&&u))return void o({title:"All fields are required",variant:"destructive"});if(le.trim().length<6)return void o({title:"Password too short",description:"Min 6 characters.",variant:"destructive"});const i=(null==_?void 0:_.max_users)||50;if(z.length>=i)o({title:"Limit reached",description:`Max ${i} members. Contact admin.`,variant:"destructive"});else{D(!0);try{const i=await a.functions.invoke("corporate-create-admin",{body:{email:ie.trim().toLowerCase(),full_name:ne.trim(),password:le,corporate_id:u,member_role:se}});if(i.error||(null==(e=i.data)?void 0:e.error))throw new Error((null==(t=i.data)?void 0:t.error)||(null==(r=i.error)?void 0:r.message)||"Failed");o({title:"Team member added!"}),ae(""),oe(""),de(""),ce("recruiter"),W(!1),ge()}catch(n){o({title:"Error",description:n.message,variant:"destructive"})}D(!1)}},disabled:E||!(ne.trim()&&ie.trim()&&le.trim().length>=6&&se),p:S,children:E?"Adding...":"Add Team Member"})]})}),e.jsx(B,{open:!!V,onClose:()=>H(null),title:"Edit Team Member",p:S,children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[e.jsxs("div",{children:[e.jsx(f,{p:S,children:"Full Name"}),e.jsx(m,{value:U,onChange:J,placeholder:"Member name",p:S})]}),e.jsxs("div",{children:[e.jsx(f,{p:S,children:"Role"}),e.jsxs(h,{value:X,onChange:Y,p:S,children:[e.jsx("option",{value:"recruiter",children:"Recruiter"}),e.jsx("option",{value:"admin",children:"Admin"})]})]}),e.jsxs("div",{children:[e.jsx(f,{p:S,children:"Department"}),e.jsx(m,{value:K,onChange:Q,placeholder:"e.g. Engineering",p:S})]}),e.jsxs("div",{children:[e.jsx(f,{p:S,children:"Designation"}),e.jsx(m,{value:Z,onChange:ee,placeholder:"e.g. HR Manager",p:S})]}),e.jsx(y,{onClick:async()=>
1{if(!V||!u)return;re(!0);const{error:e}=await a.from("corporate_members").update({role:X,department:K||null,designation:Z||null}).eq("id",V.id).eq("corporate_id",u);e?o({title:"Error",description:"Failed to update member",variant:"destructive"}):(U.trim()&&U!==V.full_name&&await a.from("profiles").update({full_name:U.trim()}).eq("user_id",V.user_id),X!==V.role&&await a.from("user_roles").update({role:"admin"===X?"corporate_admin":"recruiter"}).eq("user_id",V.user_id),o({title:"Member updated"}),H(null),ge()),re(!1)},disabled:te,p:S,children:te?"Saving...":"Save Changes"})]})}),e.jsx(T,{open:q,onClose:()=>{G(!1),N(null)},onConfirm:async()=>{if(!u||!F)return;O(F.id);const{error:e,data:t}=await a.from("corporate_members").delete().eq("id",F.id).eq("corporate_id",u).select();e||!t||0===t.length?o({title:"Error",description:(null==e?void 0:e.message)||"Could not delete member.",variant:"destructive"}):(o({title:"Member removed"}),ge()),O(null),G(!1),N(null)},title:"Remove Team Member",description:`Are you sure you want to remove ${(null==F?void 0:F.full_name)||"this member"}? This cannot be undone.`,p:S})]})};export{w as default};
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.