1import{j as e}from"./vendor-ui.BwPBmVwt.js";import{j as G,u as X,r as l}from"./vendor-react.kR8tqwKZ.js";import{d,f as B,p as U}from"./vendor-utils.D2q0l15H.js";import{e as J,p as K,l as Q,q as H,r as W,B as j,X as P,D as I,f as L,h as $,i as D,m as A,j as O,t as Y,v as Z,w as ee,x as se,y as ae,z as re,A as te,C as ne,G as ie}from"./index.86ltQqcV.js";import{I as z}from"./input.Bn8hRSEL.js";import{L as F}from"./label.BLlGNrU0.js";import{T as le}from"./textarea.CzIuFU26.js";import{S as k,a as M,b as R,c as E,d as _}from"./select.DEFUaHfV.js";import{L as V}from"./loader-circle.PPp0m7l9.js";import{A as ce}from"./arrow-left.COB2K-vb.js";import{I as oe}from"./info.oSrbbhNg.js";import{U as de}from"./users.BboaRFUh.js";import{M as xe}from"./mail.DbDdjDWF.js";import{A as me}from"./activity.dmW5sXDt.js";import{T as he}from"./triangle-alert.DiFS_pz6.js";import"./vendor-three.C5-HLXBy.js";import"./chevron-down.8Oyg22r0.js";import"./check.Qs6HOoRX.js";import"./chevron-up.B4ORgOxs.js";const ue=[{id:"info",label:"ì ë³´",icon:e.jsx(oe,{className:"h-4 w-4"})},{id:"members",label:"멤ë²",icon:e.jsx(de,{className:"h-4 w-4"})},{id:"invite",label:"ì´ë",icon:e.jsx(xe,{className:"h-4 w-4"})},{id:"logs",label:"íë ë¡ê·¸",icon:e.jsx(me,{className:"h-4 w-4"})},{id:"danger",label:"ìí ìì",icon:e.jsx(he,{className:"h-4 w-4"})}],C={owner:"Owner",editor:"í¸ì§ì",viewer:"ë·°ì´"},fe={"team.create":()=>"í ìì±","member.invite":a=>`${a.email??""}ë ì´ë`,"member.join":a=>`${a.name??a.email??""}ë í©ë¥`,"member.role_change":a=>`${a.name??a.email??""}ë ìí ë³ê²½: ${C[a.old_role]??a.old_role} â ${C[a.new_role]??a.new_role}`,"member.remove":a=>`${a.name??a.email??""}ë ì ê±°`,"project.create":a=>`íë¡ì í¸ ìì±: ${a.project_name??""}`,"project.update":a=>`íë¡ì í¸ ìì : ${a.project_name??""}
1`,"project.delete":a=>`íë¡ì í¸ ìì : ${a.project_name??""}`,"project.import":a=>`íë¡ì í¸ ê°ì ¸ì¤ê¸°: ${a.project_name??""}`,"team.transfer_owner":a=>`Owner ìì: ${a.old_owner??""} â ${a.new_owner??""}`,"team.dissolve":()=>"í í´ì²´"};function je(a){const n=fe[a.action];return n?n(a.metadata):a.action}function Ve(){const{teamId:a}=G(),n=X(),{user:y}=J(),[c,p]=l.useState("info"),[i,t]=l.useState(null),[x,g]=l.useState([]),[N,h]=l.useState([]),[f,u]=l.useState([]),[w,S]=l.useState(!0),b=x.find(o=>o.user_id===y?.id)?.role??null,s=b==="owner",m=b==="owner"||b==="editor",r=l.useCallback(async()=>{if(a){S(!0);try{const[o,q]=await Promise.all([K(a),Q(a)]);t(o),g(q)}catch(o){d.error("í ì ë³´ ë¡ë ì¤í¨"),console.error(o)}finally{S(!1)}}},[a]);if(l.useEffect(()=>{r()},[r]),l.useEffect(()=>{c==="invite"&&a&&H(a).then(h).catch(o=>{d.error("ì´ë ëª©ë¡ ë¡ë ì¤í¨"),console.error(o)}),c==="logs"&&a&&m&&W(a).then(u).catch(o=>{d.error("íë ë¡ê·¸ ë¡ë ì¤í¨"),console.error(o)})},[c,a,m]),w)return e.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center",style:{paddingTop:"72px"},children:e.jsx(V,{className:"h-6 w-6 animate-spin text-gray-400"})});if(!i)return e.jsxs("div",{className:"min-h-screen bg-white flex flex-col items-center justify-center gap-4",style:{paddingTop:"72px"},children:[e.jsx("p",{className:"text-gray-500",children:"íì ì°¾ì ì ììµëë¤."}),e.jsx(j,{variant:"outline",onClick:()=>n("/pro/library"),children:"ë¼ì´ë¸ë¬ë¦¬ë¡ ëìê°ê¸°"})]});const v=ue.filter(o=>o.id==="danger"?!0:o.id==="logs"?m:!0);return e.jsx("div",{className:"min-h-screen bg-white",style:{paddingTop:"72px"},children:e.jsxs("div",{className:"max-w-4xl mx-auto px-6 py-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsx(j,{variant:"ghost",size:"icon",onClick:()=>n("/pro/library"),className:"h-8 w-8",children:e.jsx(ce,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-gray-900",children:i.name}),e.jsx("p",{className:"text-sm text-gray-500",children:"í ì¤ì "})]})]}),e.jsxs("div",{className:"flex gap-6",children:[e.jsx("nav",{className:"w-44 shrink-0 space-y-1",children:v.map(o=>e.jsxs("button",{className:`w-full flex items-center gap-2 px-3 py-2 rounded-md text-sm transition-colors cursor-pointer ${c===o.id?"bg-blue-50 text-blue-700 font-medium":"text-gray-600 hover:bg-gray-100"} ${o.id==="danger"?c===o.id?"":"text-red-600 hover:bg-red-50":""}`,onClick:()=>p(o.id),children:[o.icon,o.label]},o.id))}),e.jsxs("div",{className:"flex-1 min-w-0",children:[c==="info"&&e.jsx(pe,{team:i,isOwner:s,onUpdated:o=>t(o)}),c==="members"&&e.jsx(ge,{teamId:i.id,members:x,currentUserId:y?.id??"",isOwner:s,onMembersChanged:g}),c==="invite"&&e.jsx(ye,{teamId:i.id,invitations:N,isOwner:s,onInvitationsChanged:h}),c==="logs"&&e.jsx(ve,{logs:f}),c==="danger"&&e.jsx(Ne,{team:i,isOwner:s,onDissolved:()=>n("/pro/library"),onLeft:()=>n("/pro/library")})]})]})]})})}function pe({team:a,isOwner:n,onUpdated:y}){const[c,p]=l.useState(a.name),[i,t]=l.useState(a.description??""),[x,g]=l.useState(!1),N=async h=>{h.preventDefault();const f=c.trim();if(f){g(!0);try{await Z(a.id,f,i.trim()),y({...a,name:f,description:i.trim()||null}),d.success("í ì ë³´ê° ì ì¥ëììµëë¤")}catch(u){d.error("ì ì¥ì ì¤í¨íìµëë¤"),console.error(u)}finally{g(!1)}}};return e.jsxs("div",{className:"space-y-6",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-900",children:"í ì ë³´"}),e.jsxs("form",{onSubmit:N,className:"space-y-4 max-w-md",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(F,{htmlFor:"info-name",children:"í ì´ë¦"}),e.jsx(z,{id:"info-name",value:c,onChange:h=>p(h.target.value),maxLength:50,disabled:!n})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(F,{htmlFor:"info-desc",children:"ì¤ëª
"}),e.jsx(le,{id:"info-desc",value:i,onChange:h=>t(h.target.value),rows:3,disabled:!n})]}),n&&e.jsx(j,{type:"submit",disabled:!c.trim()||x,className:"bg-gray-900 text-white hover:bg-gray-800",children:x?"ì ì¥ ì¤...":"ì ì¥"})]})]})}function ge({teamId:a,members:n,currentUserId:y,isOwner:c,onMembersChanged:p}){const[i,t]=l.useState(null),[x,g]=l.useState(!1),[N,h]=l.useState(null),[f,u]=l.useState(null),w=async(s,m)=>{u(s.id);try{await ee(s.id,m),p(n.map(r=>r.id===s.id?{...r,role:m}:r)),d.success("ìí ì´ ë³ê²½ëììµëë¤")}catch(r){d.error("ìí ë³ê²½ì ì¤í¨íìµëë¤"),console.error(r)}finally{u(null)}},S=async s=>{h(s.id);try{await se(s.id),p(n.filter(m=>
1m.id!==s.id)),d.success(`${s.user_email??"멤ë²"}를 íìì ì ê±°íìµëë¤`)}catch(m){d.error("ë©¤ë² ì ê±°ì ì¤í¨íìµëë¤"),console.error(m)}finally{h(null)}},T=async()=>{if(i){g(!0);try{await ae(a,i),d.success("Owner ê¶íì´ ììëììµëë¤"),p(n.map(s=>s.user_id===y?{...s,role:"editor"}:s.user_id===i?{...s,role:"owner"}:s)),t(null)}catch(s){d.error("Owner ììì ì¤í¨íìµëë¤"),console.error(s)}finally{g(!1)}}},b=n.filter(s=>s.role!=="owner");return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-900",children:["ë©¤ë² (",n.length,"ëª
)"]}),e.jsx("div",{className:"border rounded-lg divide-y",children:n.map(s=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-gray-900 truncate",children:s.user_email??s.user_id}),e.jsxs("p",{className:"text-xs text-gray-400 mt-0.5",children:["ê°ì
ì¼: ",B(U(s.joined_at),"yyyy.MM.dd")]})]}),e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full font-medium ${s.role==="owner"?"bg-blue-100 text-blue-700":s.role==="editor"?"bg-green-100 text-green-700":"bg-gray-100 text-gray-600"}`,children:C[s.role]}),c&&s.user_id===y&&s.role==="owner"&&e.jsx(j,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>t(b[0]?.user_id??null),disabled:b.length===0,children:"Owner ìì"}),c&&s.user_id!==y&&s.role!=="owner"&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs(k,{value:s.role,onValueChange:m=>w(s,m),disabled:f===s.id,children:[e.jsx(M,{className:"h-7 w-24 text-xs",children:e.jsx(R,{})}),e.jsxs(E,{children:[e.jsx(_,{value:"editor",children:"í¸ì§ì"}),e.jsx(_,{value:"viewer",children:"ë·°ì´"})]})]}),e.jsx(j,{variant:"ghost",size:"icon",className:"h-7 w-7 text-red-500 hover:bg-red-50",onClick:()=>S(s),disabled:N===s.id,children:N===s.id?e.jsx(V,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(P,{className:"h-3.5 w-3.5"})})]})]},s.id))}),e.jsx(I,{open:i!=null&&typeof i=="string"&&i!=="",onOpenChange:s=>{s||t(null)},children:e.jsxs(L,{className:"max-w-sm",children:[e.jsxs($,{children:[e.jsx(D,{children:"Owner ìì"}),e.jsx(A,{children:"ì Owner를 ì ííì¸ì. ìì í íì¬ ê³ì ì editorë¡ ë³ê²½ë©ëë¤."})]}),e.jsxs(k,{value:i??"",onValueChange:t,children:[e.jsx(M,{children:e.jsx(R,{placeholder:"ë©¤ë² ì í"})}),e.jsx(E,{children:b.map(s=>e.jsxs(_,{value:s.user_id,children:[s.user_email??s.user_id," (",C[s.role],")"]},s.user_id))})]}),e.jsxs(O,{children:[e.jsx(j,{variant:"outline",onClick:()=>t(null),children:"ì·¨ì"}),e.jsx(j,{className:"bg-gray-900 text-white hover:bg-gray-800",onClick:T,disabled:!i||x,children:x?"ì²ë¦¬ ì¤...":"ìì"})]})]})})]})}function ye({teamId:a,invitations:n,isOwner:y,onInvitationsChanged:c}){const[p,i]=l.useState(""),[t,x]=l.useState("not_found"),[g,N]=l.useState("viewer"),[h,f]=l.useState(!1),u=l.useRef(null);l.useEffect(()=>{const r=p.trim();if(!r){x("not_found");return}return x("searching"),u.current&&clearTimeout(u.current),u.current=setTimeout(async()=>{try{const v=await Y(r);x(v??"not_found")}catch(v){console.error(v),x("not_found")}},300),()=>{u.current&&clearTimeout(u.current)}},[p]);const w=typeof t=="object"&&t!==null?n.some(r=>r.invited_email===t.email&&r.status==="pending"):!1,S=typeof t=="object"&&t!==null&&!w,T=async()=>{if(!(!S||typeof t!="object"||t===null)){f(!0);try{await re(a,t.email,g),d.success(`${t.email}ëìê² ì´ë를 ë³´ëìµëë¤`),i(""),x("not_found");const r=await H(a);c(r)}catch(r){const v=r instanceof Error?r.message:"ì´ëì ì¤í¨íìµëë¤";d.error(v),console.error(r)}finally{f(!1)}}},b=async r=>{try{await te(r),c(n.map(v=>v.id===r?{...v,status:"cancelled"}:v)),d.success("ì´ë를 ì·¨ìíìµëë¤")}catch(v){d.error("ì´ë ì·¨ìì ì¤í¨íìµëë¤"),console.error(v)}},s={pending:"ë기 ì¤",accepted:"ìë½",rejected:"ê±°ì ",expired:"ë§ë£",cancelled:"ì·¨ìë¨"},m={pending:"text-amber-700 bg-amber-50",accepted:"text-green-700 bg-green-50",rejected:"text-red-700 bg-red-50",expired:"text-gray-500 bg-gray-100",cancelled:"text-gray-400 bg-gray-100"};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-900",children:"ë©¤ë² ì´ë"}),y?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(z,{placeholder:"ì´ë©ì¼ 주ì ì
ë ¥",value:p,onChange:r=>i(r.target.value),className:"flex-1"}),e.jsxs(k,{value:g,onValueChange:r=>N(r),children:[e.jsx(M,{className:"w-28",children:e.jsx(R,{})}),e.jsxs(E,{children:[e.jsx(_,{value:"editor",children:"í¸ì§ì"}),e.jsx(_,{value:"viewer",children:"ë·°ì´"})]})]}),e.jsx(j,{onClick:T,disabled:!S||h,className:"bg-gray-900 text-white hover:bg-gray-800",children:h?"ì ì¡ ì¤...":"ì´ë"})]}),p.trim()&&e.jsxs("div",{className:"text-sm",children:[t==="searching"&&e.jsxs("span",{className:"text-gray-400 flex items-center gap-1",children:[e.jsx(V,{className:"h-3.5 w-3.5 animate-spin"}),"ê²ì ì¤..."]}),t==="not_found"&&e.jsx("span",{className:"text-red-600",children:"íì ê°ì
ë ì´ë©ì¼ë§ ì´ë ê°ë¥í©ëë¤"}),typeof t=="object"&&t!==null&&w&&e.jsx("span",{className:"text-amber-600",children:"ì´ë¯¸ ì´ë를 ë³´ë¸ ì´ë©ì¼ì
ëë¤"}),typeof t=="object"&&t!==null&&!w&&e.jsxs("span",{className:"text-green-600",children:[t.name?`${t.name} (${t.email})`:t.email," â ì´ë ê°ë¥"]})]})]}):e.jsx("p",{className:"text-sm text-gray-500",children:"ì´ëë Ownerë§ ë³´ë¼ ì ììµëë¤."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-700",children:"ë³´ë¸ ì´ë"}),n.length===0?e.jsx("p",{className:"text-sm text-gray-400",children:"ë³´ë¸ ì´ëê° ììµëë¤"}):e.jsx("div",{className:"border rounded-lg divide-y",children:n.map(r=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-900 truncate",children:r.invited_email}),e.jsxs("p",{className:"text-xs text-gray-400 mt-0.5",children:["ë§ë£: ",B(U(r.expires_at),"yyyy.MM.dd")," ·"," ",C[r.proposed_role]]})]}),e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full font-medium ${m[r.status]??"text-gray-500"}`,children:s[r.status]??r.status}),y&&r.status==="pending"&&e.jsx(j,{variant:"ghost",size:"icon",className:"h-7 w-7 text-gray-400 hover:text-red-500",onClick:()=>b(r.id),children:e.jsx(P,{className:"h-3.5 w-3.5"})})]},r.id))})]})]})}function ve({logs:a}){return e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-900",children:"íë ë¡ê·¸ (ìµê·¼ 100ê±´)"}),a.length===0?e.jsx("p",{className:"text-sm text-gray-400",children:"íë 기ë¡ì´ ììµëë¤"}):e.jsx("div",{className:"border rounded-lg divide-y",children:a.map(n=>e.jsxs("div",{className:"flex items-start gap-3 px-4 py-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-900",children:je(n)}),e.jsx("p",{className:"text-xs text-gray-400 mt-0.5",children:n.actor_email??n.actor_id})]}),e.jsx("span",{className:"text-xs text-gray-400 whitespace-nowrap",children:B(U(n.created_at),"Mì dì¼ HH:mm")}
1)]},n.id))})]})}function Ne({team:a,isOwner:n,onDissolved:y,onLeft:c}){const[p,i]=l.useState(!1),[t,x]=l.useState(""),[g,N]=l.useState(!1),[h,f]=l.useState(!1),[u,w]=l.useState(!1),S=t.trim()===a.name,T=async()=>{if(S){N(!0);try{await ie(a.id),d.success(`í "${a.name}"ì´ í´ì²´ëììµëë¤`),y()}catch(s){const m=s instanceof Error?s.message:"í í´ì²´ì ì¤í¨íìµëë¤";d.error(m),console.error(s)}finally{N(!1)}}},b=async()=>{w(!0);try{await ne(a.id),d.success(`í "${a.name}"ìì íí´íìµëë¤`),c()}catch(s){const m=s instanceof Error?s.message:"í íí´ì ì¤í¨íìµëë¤";d.error(m),console.error(s)}finally{w(!1),f(!1)}};return n?e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-base font-semibold text-red-600",children:"ìí ìì"}),e.jsxs("div",{className:"border border-red-200 rounded-lg p-5 space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900",children:"í í´ì²´"}),e.jsxs("p",{className:"text-sm text-gray-500 mt-1",children:["íì í´ì²´íë©´ 모ë í íë¡ì í¸, 멤ë², í´ëê° ì구 ìì ë©ëë¤. ì´ ìì
ì ëë릴 ì ììµëë¤.",e.jsx("br",{}),e.jsx("span",{className:"text-amber-700",children:"Ownerì¸ ê²½ì° íí´íë ¤ë©´ 먼ì ë¤ë¥¸ 멤ë²ìê² Owner를 ììíì¸ì (ë©¤ë² í)."})]})]}),e.jsx(j,{variant:"outline",className:"border-red-300 text-red-600 hover:bg-red-50",onClick:()=>i(!0),children:"í í´ì²´"})]}),e.jsx(I,{open:p,onOpenChange:s=>{s||(i(!1),x(""))},children:e.jsxs(L,{className:"max-w-sm",children:[e.jsxs($,{children:[e.jsx(D,{children:"í í´ì²´ íì¸"}),e.jsxs(A,{children:["ì´ ìì
ì ëë릴 ì ììµëë¤. ê³ìíë ¤ë©´ í ì´ë¦"," ",e.jsx("span",{className:"font-mono font-semibold text-gray-900",children:a.name}),"ì ì
ë ¥íì¸ì."]})]}),e.jsx(z,{placeholder:a.name,value:t,onChange:s=>x(s.target.value)}),e.jsxs(O,{children:[e.jsx(j,{variant:"outline",onClick:()=>{i(!1),x("")},children:"ì·¨ì"}),e.jsx(j,{className:"bg-red-600 text-white hover:bg-red-700",disabled:!S||g,onClick:T,children:g?"í´ì²´ ì¤...":"í í´ì²´"})]})]})})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-base font-semibold text-red-600",children:"ìí ìì"}),e.jsxs("div",{className:"border border-red-200 rounded-lg p-5 space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900",children:"í íí´"}),e.jsxs("p",{className:"text-sm text-gray-500 mt-1",children:["íìì íí´íë©´ í íë¡ì í¸ì í´ëì ë ì´ì ì ê·¼í ì ììµëë¤.",e.jsx("br",{}),"íì íë¡ì í¸, í´ë, ë¤ë¥¸ 멤ë²ìê²ë ìí¥ì´ ììµëë¤."]})]}),e.jsx(j,{variant:"outline",className:"border-red-300 text-red-600 hover:bg-red-50",onClick:()=>f(!0),children:"í íí´"})]}),e.jsx(I,{open:h,onOpenChange:s=>!s&&f(!1),children:e.jsxs(L,{className:"max-w-sm",children:[e.jsxs($,{children:[e.jsx(D,{children:"í íí´ íì¸"}),e.jsxs(A,{children:[e.jsx("strong",{children:a.name})," íìì íí´íìê² ìµëê¹?",e.jsx("br",{}),"í íë¡ì í¸ì í´ëì ë ì´ì ì ê·¼í ì ììµëë¤."]})]}),e.jsxs(O,{children:[e.jsx(j,{variant:"outline",onClick:()=>f(!1),disabled:u,children:"ì·¨ì"}),e.jsx(j,{className:"bg-red-600 text-white hover:bg-red-700",disabled:u,onClick:b,children:u?"íí´ ì¤...":"íí´"})]})]})})]})}export{Ve 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.