1import{j as e}from"./vendor-data-Z5doMMu-.js";import{r as c}from"./vendor-react-zNM0AU50.js";import{U as ze,a5 as $e,s as We,e as Ge,K as He,z as u,X as V,n as qe,r as mt,H as ht,$ as ut,ag as Ke,a as Xe,ah as gt,c as Je,ai as pt,d as be,aa as bt,T as Me,E as ne,g as Qe,A as ft,h as jt,a8 as Ce,aj as Le,O as yt,ak as Nt,al as wt,Y as vt}from"./vendor-ui-CW5bJ11U.js";import{s as fe,d as g,u as St}from"./index-D1K3lVhu.js";import{u as z,k as E,y as ie,D as je,G as ye,E as Ne,z as se,l as $,j as kt,q as W,x as J,w as F,m as _,A as R,H as Ct}from"./vendor-firebase-Da9KY1q_.js";import"./vendor-charts-08G1rM8P.js";const At=["ìê°ì¡±êµì¡ 1주차","ìê°ì¡±êµì¡ 2주차","ìê°ì¡±êµì¡ 3주차","ìê°ì¡±êµì¡ 4주차","ì±ê²½ê³µë¶ ì
문","ì¸ë¡êµì¡"],Dt=["첫방문","ì 기ì¬ë°©","í¹ë³ì¬ë°©","ì íì¬ë°©"],Mt=["ì¥ë
ë¶","ì²ë
ë¶","ì¤ê³ ë±ë¶","êµííêµ"],v="newMembers";function oe(s){const l={};for(const[r,d]of Object.entries(s))d!==void 0&&(l[r]=d);return l}const q={async getAll(){const s=W($(g,v),J("registeredAt","desc"));return(await _(s)).docs.map(r=>({id:r.id,...r.data()}))},async getByYear(s){const l=new Date(s,0,1),r=new Date(s,11,31,23,59,59),d=W($(g,v),F("registeredAt",">=",l),F("registeredAt","<=",r),J("registeredAt","desc"));return(await _(d)).docs.map(p=>({id:p.id,...p.data()}))},async getByStatus(s){const l=W($(g,v),F("status","==",s),J("registeredAt","desc"));return(await _(l)).docs.map(d=>({id:d.id,...d.data()}))},async getById(s){const l=await kt(E(g,v,s));return l.exists()?{id:l.id,...l.data()}:null},async create(s,l){let r=[];if(l&&l.length>0)for(const p of l){const S=je(fe,`newMembers/${Date.now()}_${p.name}`);await ye(S,p);const x=await Ne(S);r.push(x)}const d=oe({...s,photoUrl:r[0]||s.photoUrl||"",photoUrls:r.length>0?r:s.photoUrls||[],status:s.status||"ì ê·",isPublic:s.isPublic!==!1,createdAt:R(),updatedAt:R()});return(await se($(g,v),d)).id},async update(s,l,r){const d={...oe(l),updatedAt:R()};if(r&&r.length>0){const j=[];for(const S of r){const x=je(fe,`newMembers/${Date.now()}_${S.name}`);await ye(x,S);const b=await Ne(x);j.push(b)}const p=l.photoUrls||[];d.photoUrls=[...p,...j],d.photoUrl=d.photoUrls[0]||""}await z(E(g,v,s),d)},async delete(s){await ie(E(g,v,s))},async updateStatus(s,l){await z(E(g,v,s),{status:l,updatedAt:R()})},getPhotoUrls(s){return s.photoUrls&&s.photoUrls.length>0?s.photoUrls:s.photoUrl?[s.photoUrl]:[]}},he={async getAll(s){const l=$(g,v,s,"education");return(await _(l)).docs.map(d=>({id:d.id,...d.data()}))},async initCourses(s){if((await this.getAll(s)).length>0)return;const r=Ct(g);for(const d of At){const j=E($(g,v,s,"education"));r.set(j,{courseName:d,isCompleted:!1,createdAt:R()})}await r.commit()},async toggleCourse(s,l,r){const d=E(g,v,s,"education",l);await z(d,{isCompleted:r,completedAt:r?R():null})},async addCourse(s,l){return(await se($(g,v,s,"education"),{...oe(l),createdAt:R()})).id},async deleteCourse(s,l){await ie(E(g,v,s,"education",l))}},Ae={async getAll(s){const l=$(g,v,s,"visits"),r=W(l,J("visitDate","desc"));return(await _(r)).docs.map(j=>({id:j.id,...j.data()}))},async add(s,l){return(await se($(g,v,s,"visits"),{...oe(l),createdAt:R()})).id},async update(s,l,r){await z(E(g,v,s,"visits",l),oe(r))},async delete(s,l){await ie(E(g,v,s,"visits",l))}},Ye={async assign(s,l,r){await z(E(g,v,s),{mentorId:l,mentorName:r,updatedAt:R()})},async unassign(s){await z(E(g,v,s),{mentorId:null,mentorName:null,updatedAt:R()})},async getUnassigned(){return(await q.getAll()).filter(l=>!l.mentorId&&l.status!=="ì ì°©ìë£"&&l.status!=="ì´í")}
1,async getByMentor(s){const l=W($(g,v),F("mentorId","==",s));return(await _(l)).docs.map(d=>({id:d.id,...d.data()}))}},$t={async getPromotionCandidates(){const s=W($(g,v),F("status","==","ì ì°©ìë£"));return(await _(s)).docs.map(r=>({id:r.id,...r.data()})).filter(r=>!r.promotedToMemberId)},async promoteToMember(s,l){const r=await se($(g,"members"),{...l,member_classification:"ìê°ì¡±",source:"new_member_promotion",sourceNewMemberId:s,createdAt:R(),updatedAt:R()});return await z(E(g,v,s),{promotedToMemberId:r.id,updatedAt:R()}),r.id}},Ut={async getStats(){var S;const s=await q.getAll(),l={ì ê·:0,êµì¡ì¤:0,ì ì°©ì¤:0,ì ì°©ìë£:0,ì´í:0},r={};for(const x of s){const b=x.status||"ì ê·";l[b]=(l[b]||0)+1;const I=(S=x.registeredAt)!=null&&S.toDate?x.registeredAt.toDate():x.registeredAt?new Date(x.registeredAt):null;if(I){const w=I.getFullYear();r[w]=(r[w]||0)+1}}const d=s.length-l.ì ê·,j=d>0?Math.round(l.ì ì°©ìë£/d*100):0,p=s.filter(x=>!x.mentorId&&x.status!=="ì ì°©ìë£"&&x.status!=="ì´í").length;return{total:s.length,byStatus:l,byYear:r,settlementRate:j,educationCompletionRate:0,noMentorCount:p}}},Pt={ì ê·:"bg-blue-100 text-blue-700",êµì¡ì¤:"bg-yellow-100 text-yellow-700",ì ì°©ì¤:"bg-emerald-100 text-emerald-700",ì ì°©ìë£:"bg-green-100 text-green-700",ì´í:"bg-red-100 text-red-700"},Tt={ì ê·:"bg-blue-500",êµì¡ì¤:"bg-yellow-500",ì ì°©ì¤:"bg-emerald-500",ì ì°©ìë£:"bg-green-500",ì´í:"bg-red-500"};function Rt(){const[s,l]=c.useState(null),[r,d]=c.useState(!0);c.useEffect(()=>{j()},[]);const j=async()=>{try{const x=await Ut.getStats();l(x)}catch(x){console.error("íµê³ ë¡ë ì¤í¨:",x)}finally{d(!1)}};if(r)return e.jsx("div",{className:"flex justify-center py-20",children:e.jsx("div",{className:"animate-spin rounded-full h-10 w-10 border-b-2 border-blue-600"})});if(!s)return e.jsx("div",{className:"text-center py-10 text-gray-400",children:"íµê³ ë°ì´í°ë¥¼ ë¶ë¬ì¬ ì ììµëë¤."});const p=Object.entries(s.byYear).sort(([x],[b])=>Number(b)-Number(x)),S=Math.max(...Object.values(s.byYear),1);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsx(ue,{icon:ze,label:"ì ì²´ ìê°ì¡±",value:s.total,color:"blue"}),e.jsx(ue,{icon:$e,label:"ì ì°© ìë£",value:s.byStatus.ì ì°©ìë£,color:"green"}),e.jsx(ue,{icon:We,label:"ì ì°©ë¥ ",value:`${s.settlementRate}%`,color:"emerald"}),e.jsx(ue,{icon:Ge,label:"ë´ë¹ì 미배ì ",value:s.noMentorCount,color:"orange",alert:s.noMentorCount>0})]}),e.jsxs("div",{className:"bg-white rounded-xl border p-5 shadow-sm",children:[e.jsxs("h3",{className:"font-bold text-gray-900 mb-4 flex items-center gap-2",children:[e.jsx(He,{className:"w-5 h-5 text-blue-600"})," ìíë³ ë¶í¬"]}),e.jsx("div",{className:"space-y-3",children:Object.entries(s.byStatus).map(([x,b])=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:`px-2.5 py-1 rounded-full text-xs font-medium w-20 text-center ${Pt[x]}`,children:x}),e.jsx("div",{className:"flex-1 bg-gray-100 rounded-full h-6 overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all duration-500 flex items-center justify-end pr-2 ${Tt[x]}`,style:{width:`${s.total>0?b/s.total*100:0}%`,minWidth:b>0?"32px":"0"},children:b>0&&e.jsx("span",{className:"text-white text-xs font-bold",children:b})})}),e.jsxs("span",{className:"text-sm text-gray-500 w-10 text-right",children:[b,"ëª
"]})]},x))})]}),e.jsxs("div",{className:"bg-white rounded-xl border p-5 shadow-sm",children:[e.jsxs("h3",{className:"font-bold text-gray-900 mb-4 flex items-center gap-2",children:[e.jsx(We,{className:"w-5 h-5 text-emerald-600"})," ë
ëë³ ìê°ì¡± ì"]}),p.length===0?e.jsx("p",{className:"text-gray-400 text-sm",children:"ë°ì´í°ê° ììµëë¤."}):e.jsx("div",{className:"space-y-2",children:p.map(([x,b])=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-sm font-medium text-gray-700 w-14",children:[x,"ë
"]}),e.jsx("div",{className:"flex-1 bg-gray-100 rounded-full h-7 overflow-hidden",children:e.jsx("div",{className:"h-full bg-blue-600 rounded-full transition-all duration-500 flex items-center justify-end pr-2",style:{width:`${b/S*100}%`,minWidth:"40px"},children:e.jsxs("span",{className:"text-white text-xs font-bold",children:[b,"ëª
"]})})})]},x))})]})]})}function ue({icon:s,label:l,value:r,color:d,alert:j}){const p={blue:"bg-blue-50 text-blue-600",green:"bg-green-50 text-green-600",emerald:"bg-emerald-50 text-emerald-600",orange:"bg-orange-50 text-orange-600"};return e.jsxs("div",{className:`bg-white rounded-xl border p-4 shadow-sm ${j?"ring-2 ring-orange-300":""}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("div",{className:`w-9 h-9 rounded-lg ${p[d]} flex items-center justify-center`,children:e.jsx(s,{className:"w-4.5 h-4.5"})}),j&&e.jsx("span",{className:"w-2 h-2 bg-orange-500 rounded-full animate-pulse"})]}),e.jsx("p",{className:"text-2xl font-bold text-gray-900 tabular-nums",children:r}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:l})]})}const Et=["ì ê·","êµì¡ì¤","ì ì°©ì¤","ì ì°©ìë£","ì´í"],Be=["1ë¨ê³-첫방문","2ë¨ê³-êµì¡","3ë¨ê³-ì그룹","4ë¨ê³-ë´ì¬","5ë¨ê³-ì ì°©ìë£"],Ve={ì ê·:"bg-blue-100 text-blue-700 border-blue-200",êµì¡ì¤:"bg-yellow-100 text-yellow-700 border-yellow-200",ì ì°©ì¤:"bg-emerald-100 text-emerald-700 border-emerald-200",ì ì°©ìë£:"bg-green-100 text-green-700 border-green-200",ì´í:"bg-red-100 text-red-700 border-red-200"};function It({member:s,onClose:l,onUpdate:r}){const[d,j]=c.useState("info"),[p,S]=c.useState([]),[x,b]=c.useState([]),[I,w]=c.useState(!1),[o,C]=c.useState(0),[T,Y]=c.useState(!1),[D,U]=c.useState({visitDate:new Date().toISOString().slice(0,10),visitor:"",type:"ì 기ì¬ë°©",content:"",followUpRequired:!1}),M=q.getPhotoUrls(s);c.useEffect(()=>{d==="education"&&G(),d==="visit"&&B()},[d]);const G=async()=>{w(!0);try{let a=await he.getAll(s.id);a.length===0&&(await he.initCourses(s.id),a=await he.getAll(s.id)),S(a)}catch(a){console.error(a),u.error("êµì¡ ë°ì´í° ë¡ë ì¤í¨")}finally{w(!1)}},B=async()=>{w(!0);try{const a=await Ae.getAll(s.id);b(a)}catch(a){console.error(a),u.error("ì¬ë°© ê¸°ë¡ ë¡ë ì¤í¨")}finally{w(!1)}},H=async a=>{try{await he.toggleCourse(s.id,a.id,!a.isCompleted),S(O=>O.map(L=>L.id===a.id?{...L,isCompleted:!L.isCompleted}:L)),u.success(a.isCompleted?"ì´ì ì·¨ì":"ì´ì ìë£")}catch{u.error("ì
ë°ì´í¸ ì¤í¨")}},k=async a=>{try{await q.updateStatus(s.id,a),u.success(`ìí: ${a}`),r()}catch{u.error("ìí ë³ê²½ ì¤í¨")}},i=async a=>{try{await q.update(s.id,{settlementStage:a}
1),u.success(`ì ì°© ë¨ê³: ${a}`),r()}catch{u.error("ë¨ê³ ë³ê²½ ì¤í¨")}},P=async()=>{if(!D.visitor.trim()||!D.content.trim()){u.error("방문ìì ë´ì©ì ì
ë ¥íì¸ì.");return}try{await Ae.add(s.id,D),u.success("ì¬ë°© ê¸°ë¡ ì¶ê°"),Y(!1),U({visitDate:new Date().toISOString().slice(0,10),visitor:"",type:"ì 기ì¬ë°©",content:"",followUpRequired:!1}),B()}catch{u.error("ì¬ë°© ê¸°ë¡ ì¶ê° ì¤í¨")}},y=async a=>{if(confirm("ì´ ì¬ë°© 기ë¡ì ìì íìê² ìµëê¹?"))try{await Ae.delete(s.id,a),u.success("ìì ìë£"),B()}catch{u.error("ìì ì¤í¨")}},Q=a=>{if(!a)return"-";const O=a.toDate?a.toDate():new Date(a);return`${O.getFullYear()}.${O.getMonth()+1}.${O.getDate()}`},Z=[{key:"info",label:"기본ì ë³´",icon:qe},{key:"education",label:"êµì¡ê³¼ì ",icon:mt},{key:"visit",label:"ì¬ë°©ê¸°ë¡",icon:ht},{key:"settlement",label:"ì ì°©íí©",icon:ut}];return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:l,children:e.jsxs("div",{className:"bg-white rounded-xl w-full max-w-2xl mx-4 shadow-2xl max-h-[90vh] overflow-hidden flex flex-col",onClick:a=>a.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b bg-slate-50",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-gray-200 overflow-hidden flex-shrink-0",children:M[0]?e.jsx("img",{src:M[0],alt:s.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-2xl text-gray-400",children:"ð¤"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold text-lg text-gray-900",children:s.name||"(ì´ë¦ ìì)"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsxs("span",{className:"text-xs text-gray-500",children:[Q(s.registeredAt)," ë±ë¡"]}),s.department&&e.jsx("span",{className:"px-1.5 py-0.5 bg-blue-50 text-blue-600 text-[10px] rounded",children:s.department}),e.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium border ${Ve[s.status||"ì ê·"]}`,children:s.status||"ì ê·"})]})]})]}),e.jsx("button",{onClick:l,className:"p-1.5 hover:bg-gray-100 rounded-lg",children:e.jsx(V,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"flex border-b bg-gray-50",children:Z.map(a=>e.jsxs("button",{onClick:()=>j(a.key),className:`flex-1 flex items-center justify-center gap-1.5 py-3 text-sm font-medium transition-colors ${d===a.key?"text-blue-600 border-b-2 border-blue-600 bg-white":"text-gray-500 hover:text-gray-700"}`,children:[e.jsx(a.icon,{className:"w-4 h-4"}),a.label]},a.key))}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[d==="info"&&e.jsxs("div",{className:"space-y-4",children:[M.length>0&&e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"aspect-[4/3] bg-gray-100 rounded-lg overflow-hidden",children:e.jsx("img",{src:M[o],alt:s.name,className:"w-full h-full object-contain"})}),M.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>C(a=>(a-1+M.length)%M.length),className:"absolute left-2 top-1/2 -translate-y-1/2 p-1.5 bg-black/40 hover:bg-black/60 text-white rounded-full",children:e.jsx(Ke,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>C(a=>(a+1)%M.length),className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 bg-black/40 hover:bg-black/60 text-white rounded-full",children:e.jsx(Xe,{className:"w-4 h-4"})}),e.jsxs("div",{className:"absolute bottom-2 left-1/2 -translate-x-1/2 bg-black/50 text-white text-xs px-2 py-0.5 rounded-full",children:[o+1," / ",M.length]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(ge,{icon:qe,label:"ì´ë¦",value:s.name||"-"}),e.jsx(ge,{icon:gt,label:"ì°ë½ì²",value:s.phone||"-"}),e.jsx(ge,{icon:Je,label:"ë±ë¡ì¼",value:Q(s.registeredAt)}),e.jsx(ge,{icon:pt,label:"ë¶ì",value:s.department||"-"})]}),s.welcomeMessage&&e.jsxs("div",{className:"bg-gray-50 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs font-semibold text-gray-500 mb-1",children:"ë±ë¡ ì ë³´"}),e.jsx("p",{className:"text-sm text-gray-700 whitespace-pre-line",children:s.welcomeMessage})]}),s.mentorName&&e.jsxs("div",{className:"bg-blue-50 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs font-semibold text-blue-600 mb-1",children:"ë´ë¹ì"}),e.jsx("p",{className:"text-sm text-blue-800",children:s.mentorName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-gray-500 mb-2",children:"ìí ë³ê²½"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Et.map(a=>e.jsx("button",{onClick:()=>k(a),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-all ${s.status===a||!s.status&&a==="ì ê·"?Ve[a]+" ring-2 ring-offset-1 ring-blue-400":"bg-gray-50 text-gray-500 border-gray-200 hover:bg-gray-100"}`,children:a},a))})]})]}),d==="education"&&e.jsx("div",{className:"space-y-3",children:I?e.jsx("div",{className:"flex justify-center py-10",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"})}):p.length===0?e.jsx("p",{className:"text-center py-10 text-gray-400",children:"êµì¡ ê³¼ì ì´ ììµëë¤."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-blue-50 rounded-lg p-3 mb-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium text-blue-700",children:"ì´ì íí©"}),e.jsxs("span",{className:"text-sm font-bold text-blue-800",children:[p.filter(a=>a.isCompleted).length," / ",p.length]})]}),e.jsx("div",{className:"mt-2 bg-blue-200 rounded-full h-2 overflow-hidden",children:e.jsx("div",{className:"h-full bg-blue-600 rounded-full transition-all",style:{width:`${p.filter(a=>a.isCompleted).length/p.length*100}%`}})})]}),p.map(a=>e.jsxs("button",{onClick:()=>H(a),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-all ${a.isCompleted?"bg-green-50 border-green-200":"bg-white border-gray-200 hover:bg-gray-50"}`,children:[e.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center flex-shrink-0 ${a.isCompleted?"bg-green-500":"border-2 border-gray-300"}`,children:a.isCompleted&&e.jsx(be,{className:"w-3.5 h-3.5 text-white"})}),e.jsx("span",{className:`text-sm ${a.isCompleted?"text-green-700 line-through":"text-gray-700"}`,children:a.courseName})]},a.id))]})}),d==="visit"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("button",{onClick:()=>Y(!0),className:"w-full flex items-center justify-center gap-1.5 py-2 border-2 border-dashed border-gray-300 rounded-lg text-sm text-gray-500 hover:border-blue-400 hover:text-blue-500",children:[e.jsx(bt,{className:"w-4 h-4"})," ì¬ë°© ê¸°ë¡ ì¶ê°"]}),T&&e.jsxs("div",{className:"bg-gray-50 rounded-lg p-4 space-y-3 border",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-gray-600 mb-1",children:"방문ì¼"}),e.jsx("input",{type:"date",value:D.visitDate,onChange:a=>U({...D,visitDate:a.target.value}),className:"w-full px-3 py-1.5 border rounded-lg text-sm"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-gray-600 mb-1",children:"ì í"}
1),e.jsx("select",{value:D.type,onChange:a=>U({...D,type:a.target.value}),className:"w-full px-3 py-1.5 border rounded-lg text-sm",children:Dt.map(a=>e.jsx("option",{value:a,children:a},a))})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-gray-600 mb-1",children:"방문ì"}),e.jsx("input",{value:D.visitor,onChange:a=>U({...D,visitor:a.target.value}),className:"w-full px-3 py-1.5 border rounded-lg text-sm",placeholder:"방문ì ì´ë¦"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-gray-600 mb-1",children:"ë´ì©"}),e.jsx("textarea",{value:D.content,onChange:a=>U({...D,content:a.target.value}),className:"w-full px-3 py-1.5 border rounded-lg text-sm",rows:3,placeholder:"ì¬ë°© ë´ì©ì 기ë¡íì¸ì"})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:D.followUpRequired,onChange:a=>U({...D,followUpRequired:a.target.checked}),className:"rounded"}),e.jsx("span",{className:"text-sm text-gray-600",children:"íì ì¡°ì¹ íì"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>Y(!1),className:"flex-1 px-3 py-1.5 border rounded-lg text-sm hover:bg-gray-50",children:"ì·¨ì"}),e.jsx("button",{onClick:P,className:"flex-1 px-3 py-1.5 bg-blue-600 text-white rounded-lg text-sm hover:bg-blue-700",children:"ì ì¥"})]})]}),I?e.jsx("div",{className:"flex justify-center py-10",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"})}):x.length===0?e.jsx("p",{className:"text-center py-10 text-gray-400 text-sm",children:"ì¬ë°© 기ë¡ì´ ììµëë¤."}):x.map(a=>e.jsxs("div",{className:"bg-white border rounded-lg p-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"px-2 py-0.5 bg-gray-100 text-gray-600 text-[10px] rounded-full",children:a.type}),e.jsx("span",{className:"text-sm font-medium text-gray-700",children:a.visitDate})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[a.followUpRequired&&!a.followUpDone&&e.jsx("span",{className:"px-1.5 py-0.5 bg-orange-100 text-orange-600 text-[10px] rounded-full",children:"íìì¡°ì¹"}),e.jsx("button",{onClick:()=>y(a.id),className:"p-1 hover:bg-red-50 rounded text-red-400 hover:text-red-600",children:e.jsx(Me,{className:"w-3.5 h-3.5"})})]})]}),e.jsxs("p",{className:"text-xs text-gray-500 mb-1",children:["방문ì: ",a.visitor]}),e.jsx("p",{className:"text-sm text-gray-700 whitespace-pre-line",children:a.content})]},a.id))]}),d==="settlement"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-gray-500 mb-3",children:"ì ì°© ë¨ê³"}),e.jsx("div",{className:"space-y-2",children:Be.map((a,O)=>{const L=s.settlementStage||"1ë¨ê³-첫방문",ae=Be.indexOf(L),ee=O<=ae,le=O===ae;return e.jsxs("button",{onClick:()=>i(a),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-all ${le?"bg-blue-50 border-blue-300 ring-2 ring-blue-200":ee?"bg-green-50 border-green-200":"bg-gray-50 border-gray-200 hover:bg-gray-100"}`,children:[e.jsx("div",{className:`w-7 h-7 rounded-full flex items-center justify-center flex-shrink-0 text-xs font-bold ${ee?"bg-green-500 text-white":"bg-gray-200 text-gray-500"}`,children:ee?e.jsx(be,{className:"w-4 h-4"}):O+1}),e.jsx("span",{className:`text-sm font-medium ${le?"text-blue-700":ee?"text-green-700":"text-gray-500"}`,children:a}),le&&e.jsx("span",{className:"ml-auto text-[10px] text-blue-500 font-medium",children:"íì¬"})]},a)})})]}),e.jsxs("div",{className:"bg-gray-50 rounded-lg p-4 space-y-2",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-700",children:"ì ì°© ìì½"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[e.jsx("div",{className:"text-gray-500",children:"íì¬ ìí"}),e.jsx("div",{className:"font-medium",children:s.status||"ì ê·"}
1),e.jsx("div",{className:"text-gray-500",children:"ì ì°© ë¨ê³"}),e.jsx("div",{className:"font-medium",children:s.settlementStage||"1ë¨ê³-첫방문"}),e.jsx("div",{className:"text-gray-500",children:"ë´ë¹ì"}),e.jsx("div",{className:"font-medium",children:s.mentorName||"미배ì "}),s.promotedToMemberId&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-gray-500",children:"êµì ì°ë"}),e.jsx("div",{className:"font-medium text-green-600",children:"ìë£"})]})]})]})]})]})]})})}function ge({icon:s,label:l,value:r}){return e.jsxs("div",{className:"flex items-center gap-2 py-2",children:[e.jsx(s,{className:"w-4 h-4 text-gray-400 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-gray-400",children:l}),e.jsx("p",{className:"text-sm text-gray-700",children:r})]})]})}function Ot(){const[s,l]=c.useState([]),[r,d]=c.useState([]),[j,p]=c.useState(!0),[S,x]=c.useState(!1),[b,I]=c.useState(null),[w,o]=c.useState(""),[C,T]=c.useState([]),[Y,D]=c.useState(!1);c.useEffect(()=>{U()},[]);const U=async()=>{p(!0);try{const P=(await q.getAll()).filter(y=>y.status!=="ì ì°©ìë£"&&y.status!=="ì´í");l(P.filter(y=>!y.mentorId)),d(P.filter(y=>y.mentorId))}catch(i){console.error(i),u.error("ë°ì´í° ë¡ë ì¤í¨")}finally{p(!1)}},M=async()=>{if(!(w.trim().length<1)){D(!0);try{const i=W($(g,"members"),F("name",">=",w.trim()),F("name","<=",w.trim()+""),J("name")),P=await _(i);T(P.docs.map(y=>({id:y.id,name:y.data().name,phone:y.data().phone||y.data().mobile||""})))}catch{try{const i=W($(g,"users"),F("name",">=",w.trim()),F("name","<=",w.trim()+"")),P=await _(i);T(P.docs.map(y=>({id:y.id,name:y.data().name||y.data().displayName||"",phone:y.data().phone||""})))}catch{T([])}}finally{D(!1)}}},G=async(i,P)=>{if(b)try{await Ye.assign(b.id,i,P),u.success(`${b.name}ìê² ${P} ë°°ì ìë£`),x(!1),I(null),o(""),T([]),U()}catch{u.error("ë°°ì ì¤í¨")}},B=async i=>{if(confirm(`${i.name}ì ë´ë¹ì ${i.mentorName}ì(를) í´ì íìê² ìµëê¹?`))try{await Ye.unassign(i.id),u.success("ë´ë¹ì í´ì ìë£"),U()}catch{u.error("í´ì ì¤í¨")}},H=i=>{I(i),o(""),T([]),x(!0)},k=i=>{if(!i)return"-";const P=i.toDate?i.toDate():new Date(i);return`${P.getFullYear()}.${P.getMonth()+1}.${P.getDate()}`};return j?e.jsx("div",{className:"flex justify-center py-20",children:e.jsx("div",{className:"animate-spin rounded-full h-10 w-10 border-b-2 border-blue-600"})}):e.jsxs("div",{className:"space-y-6",children:[s.length>0&&e.jsxs("div",{className:"bg-orange-50 border border-orange-200 rounded-xl p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Ge,{className:"w-5 h-5 text-orange-500"}),e.jsxs("h3",{className:"font-bold text-orange-800",children:["ë´ë¹ì 미배ì (",s.length,"ëª
)"]})]}),e.jsx("div",{className:"space-y-2",children:s.map(i=>e.jsxs("div",{className:"flex items-center justify-between bg-white rounded-lg p-3 border border-orange-100",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-gray-200 overflow-hidden flex-shrink-0",children:i.photoUrl?e.jsx("img",{src:i.photoUrl,alt:i.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-sm text-gray-400",children:"ð¤"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-900",children:i.name||"(ì´ë¦ ìì)"}),e.jsxs("p",{className:"text-xs text-gray-400",children:[k(i.registeredAt)," · ",i.department||"-"]})]})]}),e.jsxs("button",{onClick:()=>H(i),className:"flex items-center gap-1 px-3 py-1.5 bg-blue-600 text-white rounded-lg text-xs font-medium hover:bg-blue-700",children:[e.jsx(ne,{className:"w-3.5 h-3.5"})," ë°°ì "]})]},i.id))})]}),e.jsxs("div",{className:"bg-white rounded-xl border p-4 shadow-sm",children:[e.jsxs("h3",{className:"font-bold text-gray-900 mb-3 flex items-center gap-2",children:[e.jsx(ze,{className:"w-5 h-5 text-blue-600"})," ë´ë¹ì ë°°ì íí© (",r.length,"ëª
)"]}),r.length===0?e.jsx("p",{className:"text-center py-8 text-gray-400 text-sm",children:"ë°°ì ë ìê°ì¡±ì´ ììµëë¤."}):e.jsx("div",{className:"space-y-2",children:r.map(i=>e.jsxs("div",{className:"flex items-center justify-between bg-gray-50 rounded-lg p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-gray-200 overflow-hidden flex-shrink-0",children:i.photoUrl?e.jsx("img",{src:i.photoUrl,alt:i.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-sm text-gray-400",children:"ð¤"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-900",children:i.name||"(ì´ë¦ ìì)"}),e.jsx("p",{className:"text-xs text-gray-400",children:k(i.registeredAt)})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"px-2 py-1 bg-blue-50 text-blue-700 text-xs rounded-full font-medium",children:i.mentorName}),e.jsx("button",{onClick:()=>B(i),className:"p-1 hover:bg-red-50 rounded text-red-400 hover:text-red-600",title:"ë´ë¹ì í´ì ",children:e.jsx(V,{className:"w-4 h-4"})})]})]},i.id))})]}),S&&b&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>x(!1),children:e.jsxs("div",{className:"bg-white rounded-xl p-6 w-full max-w-md mx-4 shadow-2xl",onClick:i=>i.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"font-bold text-lg",children:"ë´ë¹ì ë°°ì "}),e.jsx("button",{onClick:()=>x(!1),className:"p-1 hover:bg-gray-100 rounded",children:e.jsx(V,{className:"w-5 h-5"})})]}),e.jsxs("p",{className:"text-sm text-gray-600 mb-4",children:[e.jsx("span",{className:"font-semibold",children:b.name}),"ìê² ë´ë¹ì를 ë°°ì í©ëë¤."]}),e.jsxs("div",{className:"flex gap-2 mb-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Qe,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{value:w,onChange:i=>o(i.target.value),onKeyDown:i=>i.key==="Enter"&&M(),placeholder:"êµì¸ ì´ë¦ ê²ì",className:"w-full pl-9 pr-3 py-2 border rounded-lg text-sm"})]}),e.jsx("button",{onClick:M,className:"px-4 py-2 bg-blue-600 text-white rounded-lg text-sm hover:bg-blue-700",children:"ê²ì"})]}),Y&&e.jsx("p",{className:"text-sm text-gray-400 text-center py-3",children:"ê²ì ì¤..."}),C.length>0&&e.jsx("div",{className:"max-h-60 overflow-y-auto border rounded-lg divide-y",children:C.map(i=>e.jsxs("button",{onClick:()=>G(i.id,i.name),className:"w-full flex items-center justify-between px-3 py-2.5 hover:bg-blue-50 text-left",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-900",children:i.name}),i.phone&&e.jsx("p",{className:"text-xs text-gray-400",children:i.phone})]}),e.jsx("span",{className:"text-xs text-blue-600",children:"ì í"})]},i.id))}),!Y&&w&&C.length===0&&e.jsxs("div",{className:"text-center py-4",children:[e.jsx("p",{className:"text-sm text-gray-400 mb-2",children:"ê²ì ê²°ê
1³¼ê° ììµëë¤."}),e.jsxs("button",{onClick:()=>G("manual_"+Date.now(),w.trim()),className:"text-sm text-blue-600 hover:underline",children:['"',w.trim(),'" ì´ë¦ì¼ë¡ ì§ì ë°°ì ']})]})]})})]})}function Ft(){const[s,l]=c.useState([]),[r,d]=c.useState([]),[j,p]=c.useState(!0),[S,x]=c.useState(null);c.useEffect(()=>{b()},[]);const b=async()=>{p(!0);try{const o=await q.getAll();l(o.filter(C=>C.status==="ì ì°©ìë£"&&!C.promotedToMemberId)),d(o.filter(C=>C.promotedToMemberId))}catch(o){console.error(o),u.error("ë°ì´í° ë¡ë ì¤í¨")}finally{p(!1)}},I=async o=>{var C;if(confirm(`"${o.name}"ì(를) êµì ë¶ì ë±ë¡íìê² ìµëê¹?`)){x(o.id);try{const T=(C=o.registeredAt)!=null&&C.toDate?o.registeredAt.toDate():o.registeredAt?new Date(o.registeredAt):new Date;await $t.promoteToMember(o.id,{name:o.name,phone:o.phone||"",department:o.department||"",registration_date:T.toISOString().slice(0,10),member_classification:"ìê°ì¡±",status:"íë",memo:`ìê°ì¡±ë¶ìì ì´ì (${T.getFullYear()}ë
ë±ë¡)`}),u.success(`${o.name} êµì ë¶ ë±ë¡ ìë£`),b()}catch(T){console.error(T),u.error("êµì ë±ë¡ ì¤í¨")}finally{x(null)}}},w=o=>{if(!o)return"-";const C=o.toDate?o.toDate():new Date(o);return`${C.getFullYear()}.${C.getMonth()+1}.${C.getDate()}`};return j?e.jsx("div",{className:"flex justify-center py-20",children:e.jsx("div",{className:"animate-spin rounded-full h-10 w-10 border-b-2 border-blue-600"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"bg-blue-50 border border-blue-200 rounded-xl p-4",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(ft,{className:"w-5 h-5 text-blue-500 flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-blue-800",children:"êµì ë¶ ì°ë ìë´"}),e.jsx("p",{className:"text-xs text-blue-600 mt-1",children:'"ì ì°©ìë£" ìíì¸ ìê°ì¡±ì êµì ë¶(members)ì ë±ë¡í©ëë¤. ë±ë¡ íìë ìê°ì¡± 기ë¡ì ì ì§ë©ëë¤.'})]})]})}),e.jsxs("div",{className:"bg-white rounded-xl border p-4 shadow-sm",children:[e.jsxs("h3",{className:"font-bold text-gray-900 mb-3 flex items-center gap-2",children:[e.jsx($e,{className:"w-5 h-5 text-emerald-600"}),"êµì ë±ë¡ ë기 (",s.length,"ëª
)"]}),s.length===0?e.jsx("p",{className:"text-center py-8 text-gray-400 text-sm",children:"ì ì°©ìë£ ìíì´ë©´ì êµì 미ë±ë¡ì¸ ìê°ì¡±ì´ ììµëë¤."}):e.jsx("div",{className:"space-y-2",children:s.map(o=>e.jsxs("div",{className:"flex items-center justify-between bg-emerald-50 rounded-lg p-3 border border-emerald-100",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-gray-200 overflow-hidden flex-shrink-0",children:o.photoUrl?e.jsx("img",{src:o.photoUrl,alt:o.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-lg text-gray-400",children:"ð¤"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-gray-900",children:o.name}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx("span",{className:"text-xs text-gray-400",children:w(o.registeredAt)}),o.department&&e.jsxs("span",{className:"text-xs text-gray-400",children:["· ",o.department]}),o.mentorName&&e.jsxs("span",{className:"text-xs text-blue-500",children:["ë´ë¹: ",o.mentorName]})]})]})]}),e.jsx("button",{onClick:()=>I(o),disabled:S===o.id,className:"flex items-center gap-1.5 px-4 py-2 bg-emerald-600 text-white rounded-lg text-sm font-medium hover:bg-emerald-700 disabled:opacity-50",children:S===o.id?e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}):e.jsxs(e.Fragment,{children:[e.jsx(jt,{className:"w-4 h-4"})," êµì ë±ë¡"]})})]},o.id))})]}),r.length>0&&e.jsxs("div",{className:"bg-white rounded-xl border p-4 shadow-sm",children:[e.jsxs("h3",{className:"font-bold text-gray-900 mb-3 flex items-center gap-2",children:[e.jsx(be,{className:"w-5 h-5 text-green-600"}),"êµì ë±ë¡ ìë£ (",r.length,"ëª
)"]}),e.jsx("div",{className:"space-y-1.5",children:r.map(o=>e.jsxs("div",{className:"flex items-center justify-between bg-gray-50 rounded-lg px-3 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(be,{className:"w-4 h-4 text-green-500"}),e.jsx("span",{className:"text-sm text-gray-700",children:o.name}),e.jsx("span",{className:"text-xs text-gray-400",children:w(o.registeredAt)})]}),e.jsx("span",{className:"text-[10px] text-green-600 bg-green-50 px-2 py-0.5 rounded-full",children:"ë±ë¡ìë£"})]},o.id))})]})]})}const De=Mt,pe="newMembers",_t={ì ê·:"bg-blue-100 text-blue-700",êµì¡ì¤:"bg-yellow-100 text-yellow-700",ì ì°©ì¤:"bg-emerald-100 text-emerald-700",ì ì°©ìë£:"bg-green-100 text-green-700",ì´í:"bg-red-100 text-red-700"};function zt(){const{user:s}=St(),[l,r]=c.useState("members"),[d,j]=c.useState([]),[p,S]=c.useState(!0),[x,b]=c.useState(""),[I,w]=c.useState(""),[o,C]=c.useState(""),[T,Y]=c.useState(()=>{const t=new Date;return`${t.getFullYear()}
1-${String(t.getMonth()+1).padStart(2,"0")}`}),[D,U]=c.useState(!1),[M,G]=c.useState(null),[B,H]=c.useState(null),[k,i]=c.useState({name:"",phone:"",department:"ì¥ë ë¶",welcomeMessage:"",registeredAt:new Date().toISOString().slice(0,10)}),[P,y]=c.useState([]),[Q,Z]=c.useState([]),[a,O]=c.useState(!1),L=c.useRef(null),[ae,ee]=c.useState([]),[le,re]=c.useState(!1),[K,we]=c.useState({title:"",content:""}),[X,ve]=c.useState([]),[Ue,Se]=c.useState([]),[Pe,Te]=c.useState(!1),Re=c.useRef(null),[te,ce]=c.useState(null),[de,xe]=c.useState(0);c.useEffect(()=>{l==="members"&&me(),l==="welcome"&&ke()},[T,l]);const me=async()=>{S(!0);try{const[t,n]=T.split("-").map(Number),m=new Date(t,n-1,1),h=new Date(t,n,0,23,59,59),N=W($(g,pe),F("registeredAt",">=",m),F("registeredAt","<=",h),J("registeredAt","desc")),f=await _(N);j(f.docs.map(A=>({id:A.id,...A.data()})))}catch(t){console.error("ìê°ì¡± ë¡ë ì¤í¨:",t),u.error("ë°ì´í° ë¡ë ì¤í¨")}finally{S(!1)}},Ze=()=>{G(null),i({name:"",phone:"",department:"ì¥ë ë¶",welcomeMessage:"",registeredAt:new Date().toISOString().slice(0,10)}),y([]),Z([]),U(!0)},et=t=>{G(t);let n=new Date().toISOString().slice(0,10);t.registeredAt&&(n=(t.registeredAt.toDate?t.registeredAt.toDate():new Date(t.registeredAt)).toISOString().slice(0,10)),i({name:t.name||"",phone:t.phone||"",department:t.department||"ì¥ë ë¶",welcomeMessage:t.welcomeMessage||"",registeredAt:n}),y([]);const m=q.getPhotoUrls(t);Z(m),U(!0)},tt=t=>{const n=Array.from(t.target.files||[]);n.length!==0&&(y(m=>[...m,...n]),n.forEach(m=>{const h=new FileReader;h.onload=N=>Z(f=>{var A;return[...f,(A=N.target)==null?void 0:A.result]}),h.readAsDataURL(m)}))},st=t=>{y(n=>n.filter((m,h)=>h!==t)),Z(n=>n.filter((m,h)=>h!==t))},at=async()=>{if(!k.registeredAt){u.error("ë±ë¡ì¼ì ì íí´ì£¼ì¸ì.");return}O(!0);try{const t=[];if(M){const m=q.getPhotoUrls(M);for(const h of Q)h.startsWith("http")&&m.includes(h)&&t.push(h)}for(const m of P){const h=je(fe,`newMembers/${Date.now()}_${m.name}`);await ye(h,m);const N=await Ne(h);t.push(N)}const n={name:k.name.trim(),phone:k.phone.trim(),department:k.department,welcomeMessage:k.welcomeMessage.trim(),registeredAt:new Date(k.registeredAt),photoUrl:t[0]||"",photoUrls:t,isPublic:!0,updatedAt:R()};M?(await z(E(g,pe,M.id),n),u.success("ìì ëììµëë¤.")):(n.createdAt=R(),n.status="ì ê·",await se($(g,pe),n),u.success("ìê°ì¡±ì´ ë±ë¡ëììµëë¤.")),U(!1),me()}catch(t){console.error("ì ì¥ ì¤í¨:",t),u.error("ì ì¥ ì¤ ì¤ë¥ê° ë°ìíìµëë¤.")}finally{O(!1)}},lt=async t=>{if(confirm(`"${t.name}" ìê°ì¡± ì 보를 ìì íìê² ìµëê¹?`))try{await ie(E(g,pe,t.id)),u.success("ìì ëììµëë¤."),me()}catch{u.error("ìì ì¤í¨")}},ke=async()=>{try{const t=W($(g,"communications"),F("type","==","welcome_party"),J("timestamp","desc")),n=await _(t),m=[];n.forEach(h=>{var f;const N=h.data();((f=N.files)==null?void 0:f.length)>0&&m.push({id:h.id,content:N.content,files:N.files,authorName:N.authorName,timestamp:N.timestamp})}),ee(m)}catch(t){console.error("íìí ì¬ì§ ë¡ë ì¤í¨:",t)}},rt=()=>{we({title:`${new Date().getMonth()+1}ì ìê°ì¡± íìí`,content:""}),ve([]),Se([]),re(!0)},nt=t=>{const n=Array.from(t.target.files||[]);n.length!==0&&(ve(m=>[...m,...n]),n.forEach(m=>{const h=new FileReader;h.onload=N=>Se(f=>{var A;return[...f,(A=N.target)==null?void 0:A.result]}),h.readAsDataURL(m)}))},it=t=>{ve(n=>n.filter((m,h)=>h!==t)),Se(n=>n.filter((m,h)=>h!==t))},ot=async()=>{if(!K.title.trim()){u.error("ì 목ì ì ë ¥í´ì£¼ì¸ì.");return}if(X.length===0){u.error("ì¬ì§ì ì íí´ì£¼ì¸ì.");return}Te(!0);try{const t=[];for(let n=0;n<X.length;n++){const m=X[n],h=je(fe,`communications/welcome_${Date.now()}_${n}_${m.name}`);await ye(h,m);const N=await Ne(h);t.push({name:m.name,url:N,type:m.type||"image/jpeg"})}await se($(g,"communications"),{content:`ìê°ì¡± íìí | ${K.title.trim()} 2${K.content.trim()}`,files:t,type:"welcome_party",authorName:"ê´ë¦¬ì",authorId:(s==null?void 0:s.uid)||null,timestamp:R(),likes:[],comments:[]}),u.success(`${X.length}ì¥ì ì¬ì§ì´ ì ë¡ëëììµëë¤.`),re(!1),ke()}catch(t){console.error("íìí ì¬ì§ ì ë¡ë ì¤í¨:",t),u.error("ì ë¡ë ì
2¤ ì¤ë¥ê° ë°ìíìµëë¤.")}finally{Te(!1)}},ct=async t=>{if(confirm("ì´ íìí ì¬ì§ì ìì íìê² ìµëê¹?"))try{await ie(E(g,"communications",t.id)),u.success("ìì ëììµëë¤."),ke(),(te==null?void 0:te.id)===t.id&&ce(null)}catch{u.error("ìì ì¤í¨")}},dt=t=>{if(!t)return"-";const n=t.toDate?t.toDate():new Date(t);return`${n.getFullYear()}.${n.getMonth()+1}.${n.getDate()}`},Ee=d.filter(t=>{var n;return!(x&&!((n=t.name)!=null&&n.includes(x))||I&&t.department!==I||o&&(t.status||"ì ê·")!==o)}),xt=[{key:"members",label:"ìê°ì¡± ê´ë¦¬",icon:ne},{key:"dashboard",label:"ëìë³´ë",icon:He},{key:"welcome",label:"íìí ì¬ì§",icon:Le},{key:"mentor",label:"ë´ë¹ì ë°°ì ",icon:yt},{key:"promotion",label:"êµì ì°ë",icon:$e}];return e.jsxs("div",{className:"space-y-4 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-900 flex items-center gap-2",children:[e.jsx(ne,{className:"w-6 h-6 text-blue-600"})," ìê°ì¡±ë¶"]}),e.jsx("p",{className:"text-sm text-gray-500 mt-0.5",children:"ìê°ì¡± ë±ë¡, êµì¡, ì ì°© ê´ë¦¬"})]}),l==="members"&&e.jsxs("button",{onClick:Ze,className:"inline-flex items-center gap-1.5 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 text-sm font-medium shadow-sm",children:[e.jsx(ne,{className:"w-4 h-4"})," ìê°ì¡± ë±ë¡"]}),l==="welcome"&&e.jsxs("button",{onClick:rt,className:"inline-flex items-center gap-1.5 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 text-sm font-medium shadow-sm",children:[e.jsx(Ce,{className:"w-4 h-4"})," ì¬ì§ ì¬ë¦¬ê¸°"]})]}),e.jsx("div",{className:"bg-white rounded-xl border shadow-sm overflow-x-auto",children:e.jsx("div",{className:"flex min-w-max",children:xt.map(t=>e.jsxs("button",{onClick:()=>r(t.key),className:`flex items-center gap-1.5 px-5 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${l===t.key?"text-blue-600 border-blue-600 bg-blue-50/50":"text-gray-500 border-transparent hover:text-gray-700 hover:bg-gray-50"}`,children:[e.jsx(t.icon,{className:"w-4 h-4"}),t.label]},t.key))})}),l==="members"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[e.jsxs("div",{className:"bg-white rounded-xl border p-4 shadow-sm",children:[e.jsx("p",{className:"text-xs text-gray-500",children:"ì´ë² ë¬ ìê°ì¡±"}),e.jsxs("p",{className:"text-2xl font-bold text-blue-600 mt-1",children:[d.length,"ëª
"]})]}),De.map(t=>{const n=d.filter(m=>m.department===t).length;return n>0?e.jsxs("div",{className:"bg-white rounded-xl border p-4 shadow-sm",children:[e.jsx("p",{className:"text-xs text-gray-500",children:t}),e.jsxs("p",{className:"text-2xl font-bold text-gray-800 mt-1",children:[n,"ëª
"]})]},t):null})]}),e.jsx("div",{className:"bg-white rounded-xl border p-4 shadow-sm",children:e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Je,{className:"w-4 h-4 text-gray-400"}),e.jsx("input",{type:"month",value:T,onChange:t=>Y(t.target.value),className:"px-3 py-1.5 border rounded-lg text-sm"})]}),e.jsxs("div",{className:"relative flex-1 min-w-[180px]",children:[e.jsx(Qe,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{value:x,onChange:t=>b(t.target.value),placeholder:"ì´ë¦ ê²ì",className:"w-full pl-9 pr-3 py-1.5 border rounded-lg text-sm"})]}),e.jsxs("select",{value:I,onChange:t=>w(t.target.value),className:"px-3 py-1.5 border rounded-lg text-sm",children:[e.jsx("option",{value:"",children:"ë¶ì ì ì²´"}),De.map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsxs("select",{value:o,onChange:t=>C(t.target.value),className:"px-3 py-1.5 border rounded-lg text-sm",children:[e.jsx("option",{value:"",children:"ìí ì ì²´"}),e.jsx("option",{value:"ì ê·",children:"ì ê·"}),e.jsx("option",{value:"êµì¡ì¤",children:"êµì¡ì¤"}),e.jsx("option",{value:"ì ì°©ì¤",children:"ì ì°©ì¤"}),e.jsx("option",{value:"ì ì°©ìë£",children:"ì ì°©ìë£"}),e.jsx("option",{value:"ì´í",children:"ì´í"})]})]})}),p?e.jsx("div",{className:"flex justify-center py-20",children:e.jsx("div",{className:"animate-spin rounded-full h-10 w-10 border-b-2 border-blue-600"})}):Ee.length===0?e.jsxs("div",{className:"bg-white rounded-xl border p-12 text-center shadow-sm",children:[e.jsx(ne,{className:"w-12 h-12 text-gray-300 mx-auto mb-3"}),e.jsx("p",{className:"text-gray-400",children:"ë±ë¡ë ìê°ì¡±ì´ ììµëë¤."})]}):e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 ga
2p-4",children:Ee.map(t=>{const n=q.getPhotoUrls(t),m=t.status||"ì ê·";return e.jsxs("div",{className:"bg-white rounded-xl border shadow-sm overflow-hidden hover:shadow-md transition-shadow group",children:[e.jsxs("div",{className:"aspect-[3/4] bg-gray-100 flex items-center justify-center overflow-hidden relative cursor-pointer",onClick:()=>H(t),children:[n[0]?e.jsx("img",{src:n[0],alt:t.name,className:"w-full h-full object-contain"}):e.jsx("span",{className:"text-5xl text-gray-300",children:"ð¤"}),n.length>1&&e.jsxs("span",{className:"absolute top-2 right-2 bg-black/50 text-white text-[10px] px-1.5 py-0.5 rounded",children:["+",n.length-1]}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/10 transition-colors flex items-center justify-center",children:e.jsx(Nt,{className:"w-6 h-6 text-white opacity-0 group-hover:opacity-80 transition-opacity"})})]}),e.jsxs("div",{className:"p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"font-semibold text-gray-900 text-sm truncate",children:t.name||"(ì´ë¦ ìì)"}),e.jsx("span",{className:`px-1.5 py-0.5 rounded-full text-[10px] font-medium ${_t[m]}`,children:m})]}),e.jsx("div",{className:"text-xs text-gray-400 mt-0.5",children:dt(t.registeredAt)}),t.department&&e.jsx("span",{className:"inline-block mt-1 px-2 py-0.5 bg-blue-50 text-blue-700 text-[11px] rounded-full",children:t.department}),t.mentorName&&e.jsxs("div",{className:"text-[10px] text-blue-600 mt-1",children:["ë´ë¹: ",t.mentorName]}),e.jsxs("div",{className:"flex gap-1.5 mt-2 pt-2 border-t",children:[e.jsxs("button",{onClick:h=>{h.stopPropagation(),et(t)},className:"flex-1 flex items-center justify-center gap-1 px-2 py-1 text-xs text-blue-600 bg-blue-50 rounded hover:bg-blue-100",children:[e.jsx(wt,{className:"w-3 h-3"})," ìì "]}),e.jsxs("button",{onClick:h=>{h.stopPropagation(),lt(t)},className:"flex-1 flex items-center justify-center gap-1 px-2 py-1 text-xs text-red-600 bg-red-50 rounded hover:bg-red-100",children:[e.jsx(Me,{className:"w-3 h-3"})," ìì "]})]})]})]},t.id)})})]}),l==="dashboard"&&e.jsx(Rt,{}),l==="welcome"&&e.jsx(e.Fragment,{children:ae.length===0?e.jsxs("div",{className:"bg-white rounded-xl border p-10 text-center shadow-sm",children:[e.jsx(vt,{className:"w-10 h-10 text-gray-300 mx-auto mb-2"}),e.jsx("p",{className:"text-gray-400 text-sm",children:"íìí ì¬ì§ì´ ììµëë¤."})]}):e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-4",children:ae.map(t=>{var A,Ie,Oe;const n=t.files.filter(Fe=>{var _e;return Fe.type==="image"||((_e=Fe.type)==null?void 0:_e.startsWith("image/"))}),m=n[0],h=((Ie=(A=t.content)==null?void 0:A.split(` 3`)[0])==null?void 0:Ie.replace("ìê°ì¡± íìí | ",""))||"íìí",N=(Oe=t.timestamp)!=null&&Oe.toDate?t.timestamp.toDate():t.timestamp?new Date(t.timestamp):null,f=N?`${N.getFullYear()}.${N.getMonth()+1}.${N.getDate()}`:"";return e.jsxs("div",{className:"bg-white rounded-xl border shadow-sm overflow-hidden hover:shadow-md transition-shadow group",children:[e.jsxs("div",{className:"aspect-video bg-gray-100 overflow-hidden relative cursor-pointer",onClick:()=>{ce(t),xe(0)},children:[m?e.jsx("img",{src:m.url,alt:h,className:"w-full h-full object-cover group-hover:scale-105 transition-transform"}):e.jsx("div",{className:"flex items-center justify-center h-full text-3xl text-gray-300",children:"ð·"}),e.jsxs("span",{className:"absolute bottom-2 right-2 bg-black/60 text-white text-xs px-2 py-0.5 rounded",children:["ð· ",n.length,"ì¥"]})]}),e.jsxs("div",{className:"p-3",children:[e.jsx("div",{className:"font-semibold text-gray-900 text-sm truncate",children:h}),e.jsx("div",{className:"text-xs text-gray-400 mt-0.5",children:f}),e.jsxs("button",{onClick:()=>ct(t),className:"mt-2 flex items-center gap-1 px-2 py-1 text-xs text-red-600 bg-red-50 rounded hover:bg-red-100 w-full justify-center",children:[e.jsx(Me,{className:"w-3 h-3"})," ìì "]})]})]},t.id)})})}),l==="mentor"&&e.jsx(Ot,{}),l==="promotion"&&e.jsx(Ft,{}),B&&e.jsx(It,{member:B,onClose:()=>H(null),onUpdate:()=>{me(),H(null)}}),D&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>U(!1),children:e.jsxs("div",{className:"bg-white rounded-xl p-6 w-full max-w-md mx-4 shadow-2xl max-h-[90vh] overflow-y-auto",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between mb-5",children:[e.jsx("h3",{className:"text-lg font-bold",children:M?"ìê°ì¡± ìì ":"ìê°ì¡± ë±ë¡"}),e.jsx("button",{onClick:()=>U(!1),className:"p-1 hover:bg-gray-100 rounded",children:e.jsx(V,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-gray-600 mb-1.5",children:"ì¬ì§ (ë³µì ê°ë¥)"}
3),e.jsx("input",{ref:L,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:tt}),e.jsxs("button",{onClick:()=>{var t;return(t=L.current)==null?void 0:t.click()},className:"inline-flex items-center gap-1.5 px-4 py-2 border-2 border-dashed border-gray-300 rounded-lg text-sm text-gray-500 hover:border-blue-400 hover:text-blue-500 w-full justify-center",children:[e.jsx(Ce,{className:"w-4 h-4"})," í´ë¦íì¬ ì¬ì§ ì¶ê°"]}),Q.length>0&&e.jsx("div",{className:"mt-3 grid grid-cols-4 gap-2",children:Q.map((t,n)=>e.jsxs("div",{className:"relative aspect-square rounded-lg overflow-hidden border bg-gray-50",children:[e.jsx("img",{src:t,alt:`미리보기 ${n+1}`,className:"w-full h-full object-cover"}),e.jsx("button",{onClick:()=>st(n),className:"absolute top-0.5 right-0.5 w-5 h-5 bg-black/60 text-white rounded-full flex items-center justify-center text-xs hover:bg-red-500",children:e.jsx(V,{className:"w-3 h-3"})}),n===0&&e.jsx("span",{className:"absolute bottom-0.5 left-0.5 bg-blue-500 text-white text-[8px] px-1 rounded",children:"ëí"})]},n))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-gray-600 mb-1",children:"ì´ë¦"}),e.jsx("input",{value:k.name,onChange:t=>i({...k,name:t.target.value}),className:"w-full px-3 py-2 border rounded-lg text-sm",placeholder:"ì´ë¦"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-gray-600 mb-1",children:"ì°ë½ì²"}),e.jsx("input",{value:k.phone,onChange:t=>i({...k,phone:t.target.value}),className:"w-full px-3 py-2 border rounded-lg text-sm",placeholder:"010-0000-0000"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-gray-600 mb-1",children:"ë±ë¡ì¼ *"}),e.jsx("input",{type:"date",value:k.registeredAt,onChange:t=>i({...k,registeredAt:t.target.value}),className:"w-full px-3 py-2 border rounded-lg text-sm"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-gray-600 mb-1",children:"ìì ë¶ì"}),e.jsx("select",{value:k.department,onChange:t=>i({...k,department:t.target.value}),className:"w-full px-3 py-2 border rounded-lg text-sm",children:De.map(t=>e.jsx("option",{value:t,children:t},t))})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-gray-600 mb-1",children:"ë±ë¡ ì ë³´"}),e.jsx("textarea",{value:k.welcomeMessage,onChange:t=>i({...k,welcomeMessage:t.target.value}),className:"w-full px-3 py-2 border rounded-lg text-sm",rows:3,placeholder:"êµêµ¬, 구ì, ì êµí ë± ë±ë¡ ì 보를 ì
ë ¥íì¸ì"})]})]}),e.jsxs("div",{className:"flex gap-2 mt-6",children:[e.jsx("button",{onClick:()=>U(!1),className:"flex-1 px-4 py-2 border rounded-lg text-sm hover:bg-gray-50",children:"ì·¨ì"}),e.jsx("button",{onClick:at,disabled:a,className:"flex-1 px-4 py-2 bg-blue-600 text-white rounded-lg text-sm hover:bg-blue-700 disabled:opacity-50",children:a?"ì ì¥ ì¤...":"ì ì¥"})]})]})}),le&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>re(!1),children:e.jsxs("div",{className:"bg-white rounded-xl p-6 w-full max-w-lg mx-4 shadow-2xl max-h-[90vh] overflow-y-auto",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between mb-5",children:[e.jsxs("h3",{className:"text-lg font-bold flex items-center gap-2",children:[e.jsx(Le,{className:"w-5 h-5 text-blue-600"})," íìí ì¬ì§ ì¬ë¦¬ê¸°"]}),e.jsx("button",{onClick:()=>re(!1),className:"p-1 hover:bg-gray-100 rounded",children:e.jsx(V,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-gray-600 mb-1",children:"ì 목 *"}),e.jsx("input",{value:K.title,onChange:t=>we({...K,title:t.target.value}),className:"w-full px-3 py-2 border rounded-lg text-sm",placeholder:"ì: 2ì ìê°ì¡± íìí"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-gray-600 mb-1",children:"ë´ì©"}),e.jsx("textarea",{value:K.content,onChange:t=>we({...K,content:t.target.value}),className:"w-full px-3 py-2 border rounded-lg text-sm",rows:2,placeholder:"íìí ë´ì©ì ê°ë¨í ì ì´ì£¼ì¸ì"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-gray-600 mb-1.5",children:"ì¬ì§ ì í (ë³µì ê°ë¥) *"}),e.jsx("input",{ref:Re,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:nt}),e.jsxs("button",{onClick:()=>{var t;return(t=Re.current)==null?void 0:t.click()},className:"inline-flex items-center gap-1.5 px-4 py-2 border-2 border-dashed border-gray-300 rounded-lg text-sm text-gray-500 hover:border-blue-400 hover:text-blue-500
3w-full justify-center",children:[e.jsx(Ce,{className:"w-4 h-4"})," í´ë¦íì¬ ì¬ì§ ì¶ê°"]}),Ue.length>0&&e.jsx("div",{className:"mt-3 grid grid-cols-3 gap-2",children:Ue.map((t,n)=>e.jsxs("div",{className:"relative aspect-square rounded-lg overflow-hidden border bg-gray-50",children:[e.jsx("img",{src:t,alt:`미리보기 ${n+1}`,className:"w-full h-full object-cover"}),e.jsx("button",{onClick:()=>it(n),className:"absolute top-1 right-1 w-5 h-5 bg-black/60 text-white rounded-full flex items-center justify-center text-xs hover:bg-red-500",children:e.jsx(V,{className:"w-3 h-3"})})]},n))}),X.length>0&&e.jsxs("p",{className:"text-xs text-gray-500 mt-2",children:[X.length,"ì¥ ì íë¨"]})]})]}),e.jsxs("div",{className:"flex gap-2 mt-6",children:[e.jsx("button",{onClick:()=>re(!1),className:"flex-1 px-4 py-2 border rounded-lg text-sm hover:bg-gray-50",children:"ì·¨ì"}),e.jsx("button",{onClick:ot,disabled:Pe,className:"flex-1 px-4 py-2 bg-blue-600 text-white rounded-lg text-sm hover:bg-blue-700 disabled:opacity-50",children:Pe?"ì ë¡ë ì¤...":`ì¬ë¦¬ê¸° (${X.length}ì¥)`})]})]})}),te&&(()=>{var m,h,N;const t=te.files.filter(f=>{var A;return f.type==="image"||((A=f.type)==null?void 0:A.startsWith("image/"))}),n=((h=(m=te.content)==null?void 0:m.split(` 4`)[0])==null?void 0:h.replace("ìê°ì¡± íìí | ",""))||"íìí";return e.jsxs("div",{className:"fixed inset-0 z-[60] bg-black/90 flex flex-col",onClick:()=>ce(null),children:[e.jsxs("div",{className:"flex items-center justify-between p-4 text-white",onClick:f=>f.stopPropagation(),children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold text-lg",children:n}),e.jsxs("p",{className:"text-sm text-white/70",children:[de+1," / ",t.length]})]}),e.jsx("button",{onClick:()=>ce(null),className:"p-2 hover:bg-white/10 rounded-full",children:e.jsx(V,{className:"w-6 h-6"})})]}),e.jsxs("div",{className:"flex-1 flex items-center justify-center relative",onClick:f=>f.stopPropagation(),children:[t.length>1&&e.jsx("button",{onClick:()=>xe(f=>(f-1+t.length)%t.length),className:"absolute left-2 z-10 p-2 bg-white/20 hover:bg-white/30 rounded-full text-white",children:e.jsx(Ke,{className:"w-6 h-6"})}),e.jsx("img",{src:(N=t[de])==null?void 0:N.url,alt:`ì¬ì§ ${de+1}`,className:"max-w-full max-h-[70vh] object-contain rounded-lg"}),t.length>1&&e.jsx("button",{onClick:()=>xe(f=>(f+1)%t.length),className:"absolute right-2 z-10 p-2 bg-white/20 hover:bg-white/30 rounded-full text-white",children:e.jsx(Xe,{className:"w-6 h-6"})})]}),t.length>1&&e.jsx("div",{className:"flex justify-center gap-2 p-4 overflow-x-auto",onClick:f=>f.stopPropagation(),children:t.map((f,A)=>e.jsx("button",{onClick:()=>xe(A),className:`w-16 h-16 rounded-lg overflow-hidden border-2 flex-shrink-0 transition-all ${A===de?"border-white scale-110":"border-transparent opacity-60 hover:opacity-100"}`,children:e.jsx("img",{src:f.url,alt:`ì¸ë¤ì¼ ${A+1}`,className:"w-full h-full object-cover"})},A))})]})})()]})}export{zt as NewMemberManagementPage};
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.