1import{c as fs,G as Ns,J as ws,K as ys,n as _s,r as n,E as bs,s as o,j as e,R as Cs,u as d,C as te,a as ie,b as re,d as ne,N as De,O as Ee,B as u,Q as Te,V as Fe,W as Le,X as Ue,Y as ze,L as w,I as _,Z as Pe,_ as le,$ as Re,g as j,e as oe,U as As,a0 as P,a1 as R,a2 as M,a3 as Me,f as $e,a4 as qe,a5 as Oe,a6 as He,a7 as Be,a8 as Je,a9 as $,aa as Is,ab as ks,m as Ye,ac as Ss,ad as Ke,ae as ce,af as Ge,ag as Ds,F as b,ah as Ve,ai as We,aj as Qe,ak as Xe,al as Ze,am as es,an as ss,ao as as,D as Es}from"./index-DBnK5Ebt.js";import{D as Ts,P as Fs,H as ts}from"./PageHeader-DySwZv8n.js";import{T as Ls,a as Us,b as is,c as C,d as zs,e as A}from"./table-DUNx-voj.js";import{S as Ps}from"./save-qnTkXPh-.js";import{E as Rs}from"./external-link-BzzA0j2g.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const rs=fs("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]),Bs=()=>{const{user:l}=Ns(),{profile:m,loading:ns}=ws(),ls=ys(),{properties:g}=_s(),[q,de]=n.useState([]),[os,O]=n.useState(!0),[cs,I]=n.useState(!1);n.useState(!1);const[k,me]=n.useState(""),[S,xe]=n.useState("");n.useState(""),n.useState(""),n.useState(""),n.useState([]);const[N,H]=n.useState([]),[he,D]=n.useState(!1);n.useState(!1);const[B,E]=n.useState(null),[J,Y]=n.useState(!1),[T,ue]=n.useState(null),[pe,K]=n.useState(null),[F,G]=n.useState(null),[v,ds]=n.useState({}),[ge,V]=n.useState([]),[L,je]=n.useState(""),[y,ve]=n.useState(""),[U,fe]=n.useState(""),[Ne,z]=n.useState(!1),[ms,W]=n.useState(!1),[Q,X]=n.useState(null),[Z,we]=n.useState(!1),[xs]=bs(),ye=xs.get("tour")==="1",hs=n.useMemo(()=>[{id:"demo-1",name:"Sarah Johnson",email:"[email protected]",status:"online",invitation_status:"accepted",user_id:"demo",assigned_properties:g.slice(0,1).map(s=>s.id),avatar_url:void 0},{id:"demo-2",name:"Michael Chen",email:"[email protected]",status:"offline",invitation_status:"accepted",user_id:"demo",assigned_properties:[],avatar_url:void 0}],[g]),ee=ye&&q.length===0?hs:q,us=ye&&q.length===0,se=async()=>{if(!l)return[];const{data:s}=await o.from("account_co_owners").select("owner_user_id").eq("co_owner_user_id",l.id),t=[l.id,...(s||[]).map(a=>a.owner_user_id)];return[...new Set(t)]};n.useEffect(()=>{f(),_e(),ae()},[l]),n.useEffect(()=>{if(!l)return;const s=o.channel("team-agent-status").on("postgres_changes",{event:"UPDATE",schema:"public",table:"agents"},t=>{const a=t.new;de(i=>i.map(r=>r.id===a.id?{...r,status:a.status,invitation_status:a.invitation_status||r.invitation_status}:r))}).subscribe();return()=>{o.removeChannel(s)}},[l]);const _e=async()=>{if(!l)return;const s=await se(),{data:t,error:a}=await o.from("ai_agents").select("id, name, linked_agent_id").in("owner_id",s).not("linked_agent_id","is",null);if(!a&&t){const i={};t.forEach(r=>{r.linked_agent_id&&(i[r.linked_agent_id]=r.name)}),ds(i)}},f=async()=>{if(!l)return;O(!0);const s=await se(),{data:t,error:a}=await o.from("agents").select("*").in("invited_by",s);if(a){console.error("Error fetching agents:",a),O(!1);return}const i=(t==null?void 0:t.map(c=>c.id))||[],{data:r}=await o.from("property_agents").select("agent_id, property_id").in("agent_id",i.length>0?i:["none"]),x=(t||[]).map(c=>{const h=(r==null?void 0:r.filter(p=>p.agent_id===c.id))||[];return{id:c.id,name:c.name,email:c.email,status:c.status,invitation_status:c.invitation_status||"accepted",user_id:c.user_id,assigned_properties:h.map(p=>p.property_id),avatar_url:c.avatar_url}});de(x),O(!1)},be=async(s,t,a)=>{const{data:i}=await o.from("profiles").select("full_name").eq("user_id",l==null?void 0:l.id).maybeSingle(),{data:r,error:x}=await o.functions.invoke("send-agent-invitation",{body:{agentId:s,agentName:t,agentEmail:a,inviterName:(i==null?void 0:i.full_name)||"A team member",appUrl:window.location.origin}});if(x)throw console.error("Error sending invitation:",x),x;return r},ps=async()=>
6{if(!k.trim()||!S.trim()||!l)return;const s=k.trim().toLowerCase(),t=S.trim();D(!0);try{const{data:a}=await o.from("agents").select("id").eq("email",s).eq("invited_by",l.id).maybeSingle();if(a){d.error("This email has already been invited"),D(!1);return}const{data:i}=await o.from("profiles").select("user_id").eq("email",s).maybeSingle(),{data:r,error:x}=await o.from("agents").insert({name:t,email:s,user_id:(i==null?void 0:i.user_id)||crypto.randomUUID(),invited_by:l.id,invitation_status:"pending",status:"offline"}).select().single();if(x){d.error("Failed to invite agent: "+x.message),D(!1);return}if(N.length>0&&r){const c=N.map(h=>({agent_id:r.id,property_id:h}));await o.from("property_agents").insert(c)}try{await be(r.id,t,s),d.success("Invitation sent! They will receive an email to join.")}catch(c){console.error("Failed to send email:",c);const h=c instanceof Error?c.message:String(c);d.error(`Email failed to send: ${h}`)}if(r&&l){let h=N[0]||null;if(!h){const{data:p}=await o.from("properties").select("id").eq("user_id",l.id).limit(1).maybeSingle();h=(p==null?void 0:p.id)||null}h&&await o.from("notification_logs").insert({property_id:h,notification_type:"invitation_sent",channel:"in_app",recipient:"system",recipient_type:"system",status:"sent",visitor_name:t})}I(!1),me(""),xe(""),H([]),f()}catch(a){console.error("Error inviting agent:",a),d.error("Failed to invite agent")}D(!1)},Ce=async s=>{ue(s.id);try{await be(s.id,s.name,s.email),d.success("Invitation resent successfully!")}catch(t){console.error("Failed to resend invitation:",t),d.error("Failed to resend invitation")}ue(null)},gs=async()=>{if(!B)return;Y(!0);const{error:s}=await o.from("agents").delete().eq("id",B);if(s){d.error("Failed to remove agent"),Y(!1);return}d.success("Agent removed"),E(null),Y(!1),f()},Ae=async(s,t,a)=>{a?await o.from("property_agents").delete().eq("agent_id",s).eq("property_id",t):await o.from("property_agents").insert({agent_id:s,property_id:t}),f()},Ie=async(s,t)=>{if(l){K(s);try{const a=t.name.split(".").pop(),r=`avatars/${`human-${s}-${Date.now()}.${a}`}`,{error:x}=await o.storage.from("agent-avatars").upload(r,t,{upsert:!0});if(x){if(x.message.includes("bucket")||x.message.includes("not found")){d.error("Avatar storage not configured. Please contact support."),K(null);return}throw x}const{data:{publicUrl:c}}=o.storage.from("agent-avatars").getPublicUrl(r);await o.from("agents").update({avatar_url:c}).eq("id",s),f(),d.success("Avatar uploaded!")}catch(a){console.error("Error uploading avatar:",a),d.error("Failed to upload avatar")}K(null)}},ke=async s=>{if(l){if(v[s.id]){d.error(`AI persona "${v[s.id]}" is already linked to this agent`);return}G(s.id);try{const{data:t,error:a}=await o.from("ai_agents").insert({name:s.name,avatar_url:s.avatar_url||null,owner_id:l.id,status:"active",linked_agent_id:s.id}).select().single();if(a){d.error("Failed to create AI persona: "+a.message),G(null);return}d.success(`AI persona "${s.name}" created!`),_e()}catch(t){console.error("Error creating AI from agent:",t),d.error("Failed to create AI persona")}G(null)}},ae=async()=>{if(!l)return;const s=await se(),{data:t}=await o.from("account_co_owners").select("id, owner_user_id, co_owner_user_id").in("owner_user_id",s);if(!t||t.length===0){V([]);return}const a=new Set;if(t.forEach(x=>{a.add(x.co_owner_user_id),a.add(x.owner_user_id)}),a.delete(l.id),a.size===0){V([]);return}const{data:i}=await o.from("profiles").select("user_id, email, full_name, avatar_url").in("user_id",Array.from(a)),r=Array.from(a).map(x=>{const c=t.find(p=>p.co_owner_user_id===x||p.owner_user_id===x),h=i==null?void 0:i.find(p=>p.user_id===x);return{id:(c==null?void 0:c.id)||x,user_id:x,email:(h==null?void 0:h.email)||"Unknown",full_name:(h==null?void 0:h.full_name)||null,avatar_url:(h==null?void 0:h.avatar_url)||null}});V(r)},js=async()=>{if(!(!y.trim()||!L.trim()||!U.trim()||!l)){z(!0);try{const{data:s,error:t}=await o.functions.invoke("create-shared-login",{body:{name:L.trim(),email:y.trim().toLowerCase(),password:U}});if(t){d.error("Failed to create shared login: "+t.message),z(!1);return}if(s!=null&&s.error){d.error(s.error),z(!1);return}d.success(`Shared login created! They can sign in with ${y.trim()} and the password you set.`),je(""),ve(""),fe(""),W(!1),ae()}catch(s){console.error("Error creating shared login:",s),d.error("Failed to create shared login")}z(!1)}},vs=async()=>
6{if(!Q)return;we(!0);const{error:s}=await o.from("account_co_owners").delete().eq("id",Q);s?d.error("Failed to remove co-admin"):d.success("Co-admin removed"),X(null),we(!1),ae()},Se=s=>{switch(s){case"pending":return e.jsx(b,{variant:"outline",className:"text-primary border-primary",children:"Pending"});case"accepted":return e.jsx(b,{variant:"outline",className:"text-primary border-primary",children:"Active"});case"revoked":return e.jsx(b,{variant:"outline",className:"text-destructive border-destructive",children:"Revoked"});default:return null}};return e.jsxs(Ts,{children:[e.jsxs("div",{className:"flex-1 flex flex-col min-w-0 overflow-hidden",children:[e.jsxs(Fs,{title:"Team Members",docsLink:"/documentation/team/inviting-agents",tourSection:"team",children:[e.jsx(ts,{size:"icon",onClick:f,children:e.jsx(Cs,{className:"h-4 w-4"})}),e.jsxs(ts,{onClick:()=>{f(),d.success("Changes saved")},children:[e.jsx(Ps,{className:"h-4 w-4 mr-2"}),"Save"]})]}),e.jsx("div",{className:"flex-1 p-2 overflow-hidden",children:e.jsx("div",{className:"h-full overflow-auto scrollbar-hide rounded-lg border border-border/30 bg-background dark:bg-background/50 dark:backdrop-blur-sm p-3 md:p-6",children:e.jsxs("div",{className:"max-w-4xl mx-auto",children:[us&&e.jsxs("div",{className:"mb-4 p-3 rounded-lg bg-primary/5 border border-primary/20 text-sm text-muted-foreground",children:[e.jsx("span",{className:"font-medium text-primary",children:"Tour Mode:"})," Showing sample agents. Your real team will appear here once you invite agents."]}),e.jsxs(te,{"data-tour":"team-table",children:[e.jsx(ie,{className:"space-y-3",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(re,{className:"text-lg",children:"Team Members"}),e.jsx(ne,{className:"text-xs sm:text-sm",children:"Agents can respond to conversations on assigned properties"})]}),e.jsx("div",{className:"flex gap-2 w-full sm:w-auto",children:e.jsxs(De,{open:cs,onOpenChange:I,children:[e.jsx(Ee,{asChild:!0,children:e.jsxs(u,{"data-tour":"invite-agent-btn",size:"sm",className:"flex-1 sm:flex-initial text-xs sm:text-sm",children:[e.jsx(Te,{className:"mr-1.5 h-3.5 w-3.5"}),"Invite Agent"]})}),e.jsxs(Fe,{children:[e.jsxs(Le,{children:[e.jsx(Ue,{className:"text-base",children:"Invite Agent"}),e.jsx(ze,{className:"text-xs",children:"Send an email invitation. The agent will create their own password."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(w,{htmlFor:"agent-name",className:"text-xs",children:"Name"}),e.jsx(_,{id:"agent-name",placeholder:"John Smith",className:"h-8 text-sm",value:S,onChange:s=>xe(s.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(w,{htmlFor:"agent-email",className:"text-xs",children:"Email"}),e.jsxs("div",{className:"relative",children:[e.jsx(Pe,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(_,{id:"agent-email",type:"email",placeholder:"[email protected]",className:"pl-8 h-8 text-sm",value:k,onChange:s=>me(s.target.value)})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(w,{className:"text-xs",children:"Assign to Properties"}),e.jsx("div",{className:"space-y-1.5 max-h-24 overflow-auto border rounded-md p-2",children:g.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No properties available"}):g.map(s=>e.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[e.jsx(le,{className:"h-3.5 w-3.5",checked:N.includes(s.id),onCheckedChange:t=>{H(t?[...N,s.id]:N.filter(a=>a!==s.id))}}),e.jsx("span",{className:"text-xs truncate",children:s.name})]},s.id))})]})]}),e.jsxs(Re,{children:[e.jsx(u,{variant:"outline",size:"sm",onClick:()=>I(!1),children:"Cancel"}),e.jsxs(u,{size:"sm",onClick:ps,disabled:he||!k.trim()||!S.trim(),children:[he&&e.jsx(j,{className:"mr-2 h-3.5 w-3.5 animate-spin"}),"Send Invitation"]})]})]})]})})]})}),e.jsx(oe,{children:os?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(j,{className:"h-8 w-8 animate-spin mx-auto mb-2"}),"Loading agents..."]}):ee.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(As,{className:"h-16 w-16 mx-auto mb-4 opacity-30"}),e.jsx("p",{className:"font-medium text-lg",children:"No agents yet"}),e.jsx("p",{className:"text-sm mb-4",children:"Invite agents to help respond to conversations"}),e.jsxs(u,{onClick:()=>I(!0),children:[e.jsx(Te,{className:"mr-2 h-4 w-4"}),"Invite Your First Agent"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"hidden md:block",children:e.jsxs(Ls,{children:[e.jsx(Us,{children:e.jsxs(is,{children:[e.jsx(C,{children:"Agent"}),e.jsx(C,{children:"Activity"}),e.jsx(C,{children:"Invitation"}),e.jsx(C,{children:"Assigned Properties"}),e.jsx(C,{className:"text-right",children:"Actions"})]})}),e.jsx(zs,{children:ee.map(s=>{var t;return e.jsxs(is,{children:[e.jsx(A,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative group",children:[e.jsxs(P,{className:"h-10 w-10",children:[e.jsx(R,{src:s.avatar_url}),e.jsx(M,{className:"bg-primary/10 text-primary",children:s.name.charAt(0).toUpperCase()})]}),e.jsxs("label",{className:"absolute inset-0 flex items-center justify-center bg-black/50 rounded-full opacity-0 group-hover:opacity-100 cursor-pointer transition-opacity",children:[pe===s.id?e.jsx(j,{className:"h-4 w-4 text-white animate-spin"}):e.jsx(Me,{className:"h-4 w-4 text-white"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:a=>{var r;const i=(r=a.target.files)==null?void 0:r[0];i&&Ie(s.id,i)}})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:s.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.email})]})]})}),e.jsx(A,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:$e("w-2.5 h-2.5 rounded-full",s.status==="online"?"bg-green-500":s.status==="away"?"bg-yellow-500":"bg-muted-foreground
6/40")}),e.jsx("span",{className:"text-sm capitalize text-muted-foreground",children:s.status})]})}),e.jsx(A,{children:Se(s.invitation_status)}),e.jsx(A,{children:e.jsxs(qe,{children:[e.jsx(Oe,{asChild:!0,children:e.jsxs(u,{variant:"outline",size:"sm",className:"h-8",children:[e.jsx(He,{className:"h-3.5 w-3.5 mr-2"}),s.assigned_properties.length===0?"None":s.assigned_properties.length===1?((t=g.find(a=>a.id===s.assigned_properties[0]))==null?void 0:t.name)||"1 property":`${s.assigned_properties.length} properties`,e.jsx(Be,{className:"h-3.5 w-3.5 ml-2"})]})}),e.jsx(Je,{align:"start",className:"w-48",children:g.length===0?e.jsx($,{disabled:!0,children:"No properties available"}):g.map(a=>{const i=s.assigned_properties.includes(a.id);return e.jsxs($,{onClick:()=>Ae(s.id,a.id,i),className:"flex items-center gap-2",children:[e.jsx(le,{checked:i,className:"pointer-events-none"}),e.jsx("span",{className:"truncate",children:a.name})]},a.id)})})]})}),e.jsx(A,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsxs(Is,{children:[e.jsx(ks,{asChild:!0,children:e.jsx(u,{variant:"ghost",size:"icon",onClick:()=>ke(s),disabled:F===s.id||!!v[s.id],className:v[s.id]?"text-primary/50":"text-muted-foreground hover:text-primary",children:F===s.id?e.jsx(j,{className:"h-4 w-4 animate-spin"}):e.jsx(Ye,{className:"h-4 w-4"})})}),e.jsx(Ss,{children:v[s.id]?`AI "${v[s.id]}" linked`:"Create AI Persona"})]}),s.invitation_status==="pending"&&e.jsx(u,{variant:"ghost",size:"icon",onClick:()=>Ce(s),disabled:T===s.id,className:"text-muted-foreground hover:text-foreground",children:T===s.id?e.jsx(j,{className:"h-4 w-4 animate-spin"}):e.jsx(Ke,{className:"h-4 w-4"})}),e.jsx(u,{variant:"ghost",size:"icon",onClick:()=>E(s.id),className:"text-destructive hover:text-destructive hover:bg-destructive/10",children:e.jsx(ce,{className:"h-4 w-4"})})]})})]},s.id)})})]})}),e.jsx("div",{className:"md:hidden space-y-3",children:ee.map(s=>{var t;return e.jsxs("div",{className:"rounded-xl border border-border/50 p-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative group flex-shrink-0",children:[e.jsxs(P,{className:"h-10 w-10",children:[e.jsx(R,{src:s.avatar_url}),e.jsx(M,{className:"bg-primary/10 text-primary text-sm",children:s.name.charAt(0).toUpperCase()})]}),e.jsxs("label",{className:"absolute inset-0 flex items-center justify-center bg-black/50 rounded-full opacity-0 group-hover:opacity-100 cursor-pointer transition-opacity",children:[pe===s.id?e.jsx(j,{className:"h-3.5 w-3.5 text-white animate-spin"}):e.jsx(Me,{className:"h-3.5 w-3.5 text-white"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:a=>{var r;const i=(r=a.target.files)==null?void 0:r[0];i&&Ie(s.id,i)}})]})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:s.name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.email})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:$e("w-2 h-2 rounded-full",s.status==="online"?"bg-green-500":s.status==="away"?"bg-yellow-500":"bg-muted-foreground/40")}),Se(s.invitation_status)]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs(qe,{children:[e.jsx(Oe,{asChild:!0,children:e.jsxs(u,{variant:"outline",size:"sm",className:"h-7 text-xs",children:[e.jsx(He,{className:"h-3 w-3 mr-1.5"}),s.assigned_properties.length===0?"No properties":s.assigned_properties.length===1?((t=g.find(a=>a.id===s.assigned_properties[0]))==null?void 0:t.name)||"1 property":`${s.assigned_properties.length} properties`,e.jsx(Be,{className:"h-3 w-3 ml-1"})]})}),e.jsx(Je,{align:"start",className:"w-48",children:g.length===0?e.jsx($,{disabled:!0,children:"No properties available"}):g.map(a=>{const i=s.assigned_properties.includes(a.id);return e.jsxs($,{onClick:()=>Ae(s.id,a.id,i),className:"flex items-center gap-2",children:[e.jsx(le,{checked:i,className:"pointer-events-none"}),e.jsx("span",{className:"truncate",children:a.name})]},a.id)})})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(u,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>ke(s),disabled:F===s.id||!!v[s.id],children:F===s.id?e.jsx(j,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Ye,{className:"h-3.5 w-3.5 text-muted-foreground"})}),s.invitation_status==="pending"&&e.jsx(u,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>Ce(s),disabled:T===s.id,children:T===s.id?e.jsx(j,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Ke,{className:"h-3.5 w-3.5 text-muted-foreground"})}),e.jsx(u,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>E(s.id),children:e.jsx(ce,{className:"h-3.5 w-3.5"})})]})]})]},s.id)})})]})})]}),e.jsxs(te,{className:"mt-6",children:[e.jsx(ie,{children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs(re,{className:"text-lg flex items-center gap-2",children:[e.jsx(Ge,{className:"h-5 w-5 text-primary"}),"Shared Logins"]}),e.jsx(ne,{className:"text-xs sm:text-sm",children:"Create additional email/password logins that share full access to your account"})]}),e.jsxs(De,{open:ms,onOpenChange:W,children:[e.jsx(Ee,{asChild:!0,children:e.jsxs(u,{size:"sm",variant:"outline",className:"text-xs sm:text-sm",children:[e.jsx(rs,{className:"mr-1.5 h-3.5 w-3.5"}),"Create Login"]})}),e.jsxs(Fe,{children:[e.jsxs(Le,{children:[e.jsx(Ue,{className:"text-base",children:"Create Shared Login"}),e.jsx(ze,{className:"text-xs",children:"Create a new email & password that can sign into your account with full access."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(w,{htmlFor:"co-admin-name",className:"text-xs",children:"Name"}),e.jsx(_,{id:"co-admin-name",placeholder:"Jane Doe",className:"h-8 text-sm",value:L,onChange:s=>je(s.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(w,{htmlFor:"co-admin-email",className:"text-xs",children:"Email"}),e.jsxs("div",{className:"relative",children:[e.jsx(Pe,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(_,{id:"co-admin-email",type:"email",placeholder:"[email protected]",className:"pl-8 h-8 text-sm",value:y,onChange:s=>ve(s.target.value)})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(w,{htmlFor:"co-admin-password",className:"text-xs",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(rs,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(_,{id:"co-admin-password",type:"password",placeholder:"At least 6 characters",className:"pl-8 h-8 text-sm",value:U,onChange:s=>fe(s.target.value)})]})]})]}),e.jsxs(Re,{children:[e.jsx(u,{variant:"outline",size:"sm",onClick:()=>W(!1),children:"Cancel"}),e.jsxs(u,{size:"sm",onClick:js,disabled:Ne||!y.trim()||!L.trim()||U.length<6,children:[Ne&&e.jsx(j,{className:"mr-2 h-3.5 w-3.5 animate-spin"}),"Create Login"]})]})]})]})]})}),e.jsx(oe,{children:ge.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Ge,{className:"h-12 w-12 mx-auto mb-3 opacity-30"}),e.jsx("p",{className:"text-sm",children:"No shared logins yet"}),e.jsx("p",{className:"text-xs mt-1",children:"Create additional logins to share full access to your account"})]}):e.jsx("div",{className:"space-y-3",children:ge.map(s=>e.jsxs("div",{className:"flex items-center justify-between gap-3 p-3 rounded-lg border border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(P,{className:"h-9 w-9",children:[e.jsx(R,{src:s.avatar_url||void 0}),e.jsx(M,{className:"bg-primary/10 text-primary text-sm",children:(s.full_name||s.email).charAt(0).toUpperCase()})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:s.full_name||"Unnamed"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.email})]})]}),e.jsx(u,{variant:"ghost",size:"icon",onClick:()=>X(s.id),className:"text-destructive hover:text-destructive hover:bg-destructive/10",children:e.jsx(ce,{className:"h-4 w-4"})})]},s.id))})})]}),e.jsxs(te,{className:"mt-6",children:[e.jsx(ie,{children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs(re,{className:"text-lg flex items-center gap-2",children:[e.jsx(Ds,{className:"h-5 w-5 text-primary"}),"Account Settings"]}),e.jsx(ne,{className:"text-xs sm:text-sm",children:"Your profile information and account details"})]}),e.jsxs(u,{size:"sm",variant:"outline",className:"text-xs sm:text-sm",onClick:()=>ls("/dashboard/account"),children:[e.jsx(Rs,{className:"mr-1.5 h-3.5 w-3.5"}),"Full Settings"]})]})}),e.jsx(oe,{children:ns?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(j,{className:"h-6 w-6 animate-spin mx-auto mb-2"}),"Loading profile..."]}):e.jsxs("div",{className:"flex flex-col sm:flex-row items-start gap-4",children:[e.jsxs(P,{className:"h-16 w-16 flex-shrink-0",children:[e.jsx(R,{src:(m==null?void 0:m.avatar_url)||void 0}),e.jsx(M,{className:"bg-primary/10 text-primary text-lg",children:((m==null?void 0:m.full_name)||(l==null?void 0:l.email)||"U").charAt(0).toUpperCase()})]}),e.jsxs("div",{className:"flex-1 space-y-2 min-w-0",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:(m==null?void 0:m.full_name)||"No name set"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(m==null?void 0:m.email)||(l==null?void 0:l.email)})]}),(m==null?void 0:m.company_name)&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Company: ",e.jsx("span",{className:"text-foreground",children:m.company_name})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 pt-1",children:[(m==null?void 0:m.two_factor_enabled)&&e.jsx(b,{variant:"outline",className:"text-xs text-primary border-primary",children:"2FA Enabled"}),(m==null?void 0:m.onboarding_complete)&&e.jsx(b,{variant:"outline",className:"text-xs",children:"Onboarding Complete"})]})]})]})})]})]})})})]}),e.jsx(Ve,{open:!!B,onOpenChange:s=>!s&&E(null),children:e.jsxs(We,{children:[e.jsxs(Qe,{children:[e.jsx(Xe,{children:"Remove Agent"}),e.jsx(Ze,{children:"Are you sure you want to remove this agent? They will no longer be able to access conversations."})]}),e.jsxs(es,{children:[e.jsx(ss,{disabled:J,children:"Cancel"}),e.jsx(as,{onClick:gs,disabled:J,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:J?"Removing...":"Remove Agent"})]})]})}),e.jsx(Ve,{open:!!Q,onOpenChange:s=>!s&&X(null),children:e.jsxs(We,{children:[e.jsxs(Qe,{children:[e.jsx(Xe,{children:"Remove Shared Login"}),e.jsx(Ze,{children:"Are you sure? This login will immediately lose access to your properties, conversations, and settings."})]}),e.jsxs(es,{children:[e.jsx(ss,{disabled:Z,children:"Cancel"}),e.jsx(as,{onClick:vs,disabled:Z,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:Z?"Removing...":"Remove Login"})]})]})}),e.jsx(Es,{})]})};export{Bs 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.