1import{j as e}from"./vendor-data-Z5doMMu-.js";import{r as b,b as ce,h as de}from"./vendor-react-zNM0AU50.js";import{m as $}from"./index-D1K3lVhu.js";import{z as F,ad as ee,f as se,X as z,A as ue,g as te,E as me,a7 as w,n as pe,a8 as xe,ae as he,T as ae,aa as J,H as Y,i as ge,af as be}from"./vendor-ui-CW5bJ11U.js";import{u as W}from"./userService-CE4aI1A4.js";import{C as Z}from"./financeConstants-CXKUiVP8.js";import{s as je}from"./storageService-HxVmCucr.js";import{v as H}from"./visitService-DcwGr2oo.js";import{G as ve,C as fe,M as ye,P as Ne,A as _e,c as we,d as Ce,a as Se,g as Ie,b as Ee,e as Re,W as Te,E as ke,f as Me,K as Ae,h as Pe,i as De,S as Oe,j as $e,k as Le,B as Ve,F as Ue,l as Fe}from"./positions-BjtHy0zm.js";import"./vendor-firebase-Da9KY1q_.js";import"./vendor-charts-08G1rM8P.js";function Be({memberId:u,memberName:j}){const[i,v]=b.useState(!0),[I,C]=b.useState(!1),[g,d]=b.useState(null),[N,S]=b.useState("");b.useEffect(()=>{let p=!0;return(async()=>{try{const y=await W.getUserByMemberId(u);if(!p)return;d(y),y&&S(y.assignedDepartmentId||"")}catch{}finally{p&&v(!1)}})(),()=>{p=!1}},[u]);const a=!!(g!=null&&g.assignedDepartmentId);async function R(){if(!g)return;if(!N){F.error("ë´ë¹ ë¶ì를 ì ííì¸ì");return}const p=Z.find(y=>y.id===N);C(!0);try{const y=(g.roles||[]).filter(P=>P!=="dept_head");await W.updateUser(g.uid,{assignedDepartmentId:N,assignedDepartmentName:(p==null?void 0:p.name)||"",customPermissions:{...g.customPermissions||{},deptLedger:!0},roles:y}),d({...g,assignedDepartmentId:N,assignedDepartmentName:(p==null?void 0:p.name)||"",customPermissions:{...g.customPermissions||{},deptLedger:!0},roles:y}),F.success(`${p==null?void 0:p.name} ë¶ìíê³ ì§ì ìë£`)}catch{F.error("ì§ì ì ì¤í¨íìµëë¤")}finally{C(!1)}}async function m(){if(g){C(!0);try{const p=(g.roles||[]).filter(y=>y!=="dept_head");await W.updateUser(g.uid,{assignedDepartmentId:null,assignedDepartmentName:null,customPermissions:{...g.customPermissions||{},deptLedger:!1},roles:p}),d({...g,assignedDepartmentId:void 0,assignedDepartmentName:void 0,roles:p}),S(""),F.success("íê³ ì§ì ì í´ì íìµëë¤")}catch{F.error("í´ì ì ì¤í¨íìµëë¤")}finally{C(!1)}}}return e.jsxs("div",{className:"border border-gray-200 rounded-lg p-4 bg-gray-50",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-800",children:"ë¶ì íê³ ì§ì "}),a&&e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full bg-blue-100 text-blue-700",children:[g==null?void 0:g.assignedDepartmentName," · ë¶ìíê³"]})]}),i?e.jsx("p",{className:"text-sm text-gray-400",children:"ë¶ë¬ì¤ë ì¤â¦"}):g?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("select",{value:N,onChange:p=>S(p.target.value),className:"w-full px-3 py-2 border border-gray-200 rounded-lg text-sm bg-white",children:[e.jsx("option",{value:"",children:"ë´ë¹ ë¶ì ì í"}),Z.map(p=>e.jsx("option",{value:p.id,children:p.level&&p.level>1?`â ${p.name}`:p.name},p.id))]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:R,disabled:I,className:"px-4 py-2 bg-blue-600 text-white rounded-lg text-sm font-medium hover:bg-blue-700 disabled:opacity-50",children:a?"ë³ê²½ ì ì¥":"ì§ì "}),a&&e.jsx("button",{type:"button",onClick:m,disabled:I,className:"px-4 py-2 text-rose-600 border border-rose-200 rounded-lg text-sm hover:bg-rose-50 disabled:opacity-50",children:"í´ì "})]}),e.jsx("p",{className:"text-xs text-gray-400",children:"ìí ì ì ì§ëë©° ë´ë¹ë¶ì ì ê·¼ ê¶í(deptLedger)ë§ ë¶ì¬ë©ëë¤. íê³ë ì´ ë¶ìì ìì
ì§ì¶Â·ìì°ì ì²ë§ ë³¼ ì ììµëë¤. ë´ë¹ì¥ë¡(ë¶ì¥)ë êµì ë¶ì ë´ë¹ ë¶ì ì§ì ì¼ë¡ ê´ë¦¬ë©ëë¤."})]}):e.jsxs("p",{className:"text-sm text-gray-500",children:["ì´ êµì¸ì ì±(êµì¸ì첩) ê³ì ì´ ìì´ íê³ ì§ì ì í ì ììµëë¤.",j?` (${j})`:""," ì± ê°ì
í ì§ì íì¸ì."]})]})}function He({relations:u,onChange:j}){const[i,v]=b.useState("search"),[I,C]=b.useState("ë°°ì°ì"),[g,d]=b.useState(""),[N,S]=b.useState([]),[a,R]=b.useState(""),[m,p]=b.useState(null),[y,P]=b.useState([]);b.useEffect(()=>{L()},[]);async function L(){try{const r=await $.getMembers();P(r)}catch(r){console.error("êµì¸ ëª©ë¡ ë¡ë ì¤í¨:",r)}}b.useEffect(()=>{if(i!=="search"||!g.trim()){S([]);return}const r=y.filter(h=>h.name.includes(g.trim())).slice(0,10);S(r)},[g,y,i]);function V(r){v(r),d(""),S([]),R(""),p(null)}function q(r){p(r),d(""),S([])}function k(){let r=null;if(i==="search"){if(!m){alert("êµì¸ì ì íí´ì£¼ì¸ì.");return}r={memberId:m.id,relativeId:m.id,relativeName:m.name,relationType:I}}else if(i==="manual"){if(!a.trim()){alert("ì´ë¦ì ì
ë ¥í´ì£¼ì¸ì.");return}r={relativeName:a.trim(),relationType:I,isExternal:!0}}else i==="none"&&(r={relativeName:"ìì",relationType:I,isNone:!0});
1if(r){const h=u.find(E=>r.memberId&&E.memberId?E.memberId===r.memberId:r.isExternal||E.isExternal?E.relativeName===r.relativeName:!1);if(h){alert(`ì´ë¯¸ ë±ë¡ë ê°ì¡±ì ëë¤. 2기존: ${h.relativeName} (${h.relationType}) 3ìë¡ ì¶ê°íë ¤ë: ${r.relativeName} (${r.relationType})`);return}j([...u,r]),p(null),R(""),d("")}}function U(r){if(confirm("ì´ ê´ê³ë¥¼ ìì íìê² ìµëê¹?")){const h=u.filter((E,G)=>G!==r);j(h)}}function A(r){if(r===0)return;const h=[...u],E=h[r];h[r]=h[r-1],h[r-1]=E,j(h)}function D(r){if(r===u.length-1)return;const h=[...u],E=h[r];h[r]=h[r+1],h[r+1]=E,j(h)}return e.jsxs("div",{className:"space-y-4",children:[u.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"ë±ë¡ë ê°ì¡± ê´ê³"}),u.map((r,h)=>e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-gray-50 rounded-lg border",children:[e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("button",{type:"button",onClick:()=>A(h),disabled:h===0,className:`p-0.5 rounded ${h===0?"text-gray-300 cursor-not-allowed":"text-gray-500 hover:text-blue-600 hover:bg-blue-50"}`,title:"ìë¡ ì´ë",children:e.jsx(ee,{className:"w-4 h-4"})}),e.jsx("button",{type:"button",onClick:()=>D(h),disabled:h===u.length-1,className:`p-0.5 rounded ${h===u.length-1?"text-gray-300 cursor-not-allowed":"text-gray-500 hover:text-blue-600 hover:bg-blue-50"}`,title:"ìëë¡ ì´ë",children:e.jsx(se,{className:"w-4 h-4"})})]}),e.jsx("span",{className:"font-medium",children:r.relativeName}),e.jsxs("span",{className:"text-sm text-gray-500",children:["(",r.relationType,")"]}),r.memberId&&e.jsx("span",{className:"text-xs text-blue-600 bg-blue-50 px-2 py-1 rounded",children:"êµì ë¶ ì°ê²°ë¨"}),r.isExternal&&e.jsx("span",{className:"text-xs text-orange-600 bg-orange-50 px-2 py-1 rounded",children:"ì¸ë¶ ê°ì¡±"}),e.jsx("button",{type:"button",onClick:()=>U(h),className:"ml-auto text-red-500 hover:text-red-700",children:e.jsx(z,{className:"w-4 h-4"})})]},h))]}),e.jsxs("div",{className:"p-4 bg-blue-50 border border-blue-200 rounded-lg space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"text-sm font-semibold text-blue-900",children:"ê°ì¡± ì¶ê°"}),e.jsx("div",{className:"flex gap-1 text-xs",children:e.jsxs("button",{type:"button",onClick:()=>alert(`ð¡ êµì ë¶ì ë±ë¡ë êµì¸ì ì ííë©´ 5ë ê°ê³ë를 ìì±í ì ììµëë¤. 4 5ð êµì ë¶ ê²ì: êµì¸ ì´ë¦ì¼ë¡ ê²ì 6âï¸ ì§ì ì ë ¥: êµì ë¶ì ìë ê°ì¡± ì ë ¥ 7â ìì: í´ë¹ ê´ê³ê° ììì íì`),className:"text-blue-600 hover:text-blue-800 flex items-center gap-1",children:[e.jsx(ue,{className:"w-3 h-3"}),"ëìë§"]})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"ê´ê³"}),e.jsxs("select",{value:I,onChange:r=>C(r.target.value),className:"w-full px-3 py-2 border border-gray-300 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:"ìë "}),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:"ì¤ë¹ "}),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:"ì¡°ë¶"}),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:"ìë (ì¹)"}),e.jsx("option",{value:"ìë (ì¸)",children:"ìë (ì¸)"}),e.jsx("option",{value:"기í",children:"기í"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-2",children:"ì ë ¥ ë°©ì"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>V("search"),className:`flex-1 px-3 py-2 text-sm rounded-lg border font-medium ${i==="search"?"border-blue-500 bg-blue-500 text-white":"border-gray-300 bg-white text-gray-700 hover:bg-gray-50"}`,children:"ð êµì ë¶ ê²ì"}),e.jsx("button",{type:"button",onClick:()=>V("manual"),className:`flex-1 px-3 py-2 text-sm rounded-lg border font-medium ${i==="manual"?"border-blue-500 bg-blue-500 text-white":"border-gray-300 bg-white text-gray-700 hover:bg-gray-50"}`,children:"âï¸ ì§ì ì ë ¥"}),e.jsx("button",{type:"button",onClick:()=>V("none"),className:`flex-1 px-3 py-2 text-sm rounded-lg border font-medium ${i==="none"?"border-blue-500 bg-blue-500 text-white":"border-gray-300 bg-white text-gray-700 hover:bg-gray-50"}`,children:"â ìì"})]})]}),i==="search"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"relative",children:[e.jsx(te,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{type:"text",value:g,onChange:r=>d(r.target.value),placeholder:"ì´ë¦ì ì ë ¥íë©´ ìëì¼ë¡ ê²ìë©ëë¤",className:"w-full pl-10 pr-3 py-2 border border-gray-300 rounded-lg text-sm"})]}),N.length>0&&e.jsx("div",{className:"absolute z-50 w-full mt-1 bg-white border border-gray-300 rounded-lg shadow-lg max-h-60 overflow-y-auto",children:N.map(r=>e.jsxs("button",{type:"button",onClick:()=>q(r),className:"w-full p-3 hover:bg-blue-50 text-left border-b last:border-b-0 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:r.name}),e.jsxs("div",{className:"text-xs text-gray-500",children:[r.detailed_position||r.position||"ì±ë"," |",r.age&&` ${r.age}ì¸`,r.district&&` | ${r.district}`]})]}),e.jsx(me,{className:"w-4 h-4 text-gray-400"})]},r.id))})]}),m&&e.jsxs("div",{className:"p-2 bg-green-50 border border-green-200 rounded-lg flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm",children:["ì íë¨: ",e.jsx("strong",{children:m.name})]}),e.jsx("button",{type:"button",onClick:()=>p(null),className:"text-red-500 hover:text-red-700",children:e.jsx(z,{className:"w-4 h-4"})})]}),e.jsx("div",{className:"text-xs text-gray-600",children:"ð¡ êµì ë¶ì ë±ë¡ë êµ
7ì¸ì ì ííë©´ ëì¤ì ê°ê³ë를 ìì±í ì ììµëë¤"})]}),i==="manual"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("input",{type:"text",value:a,onChange:r=>R(r.target.value),placeholder:"ì´ë¦ì ì
ë ¥íì¸ì (ì: í길ë)",className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm"}),e.jsx("div",{className:"text-xs text-orange-600",children:"â ï¸ êµì ë¶ì ë±ë¡ëì§ ìì ê°ì¡±ì
ëë¤. ê°ê³ëìë íìëì§ ììµëë¤."})]}),i==="none"&&e.jsx("div",{className:"p-3 bg-gray-100 rounded-lg text-sm text-gray-600",children:"ì´ ê´ê³ì í´ë¹íë ê°ì¡±ì´ ììì 기ë¡í©ëë¤."}),e.jsx("button",{type:"button",onClick:k,className:"w-full px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 font-medium",children:"ì¶ê°"})]})]})}function as({member:u,mode:j}){var K,Q;const i=ce(),{id:v}=de(),[I,C]=b.useState(!1),[g,d]=b.useState(null),[N,S]=b.useState((u==null?void 0:u.photo_url)||""),[a,R]=b.useState(u),[m,p]=b.useState([]),[y,P]=b.useState(!1),[L,V]=b.useState(!1),[q,k]=b.useState(!1),[U,A]=b.useState(null);b.useEffect(()=>{j==="edit"&&v&&(G(v),D(v))},[j,v]);async function D(s){try{P(!0);const l=await H.getMemberVisits(s);p(l)}catch(l){console.error("ì¬ë°© ê¸°ë¡ ì¡°í ì¤í¨:",l)}finally{P(!1)}}async function r(s){if(v)try{await H.addVisit(s),w.success("ì¬ë°© 기ë¡ì´ ì¶ê°ëììµëë¤"),D(v),k(!1)}catch(l){console.error("ì¬ë°© ê¸°ë¡ ì¶ê° ì¤í¨:",l),w.error("ì¬ë°© ê¸°ë¡ ì¶ê°ì ì¤í¨íìµëë¤")}}async function h(s,l){if(v)try{await H.updateVisit(s,l),w.success("ì¬ë°© 기ë¡ì´ ìì ëììµëë¤"),D(v),A(null),k(!1)}catch(o){console.error("ì¬ë°© ê¸°ë¡ ìì ì¤í¨:",o),w.error("ì¬ë°© ê¸°ë¡ ìì ì ì¤í¨íìµëë¤")}}async function E(s){if(v&&confirm("ì´ ì¬ë°© 기ë¡ì ìì íìê² ìµëê¹?"))try{await H.deleteVisit(s),w.success("ì¬ë°© 기ë¡ì´ ìì ëììµëë¤"),D(v)}catch(l){console.error("ì¬ë°© ê¸°ë¡ ìì ì¤í¨:",l),w.error("ì¬ë°© ê¸°ë¡ ìì ì ì¤í¨íìµëë¤")}}async function G(s){try{C(!0);const l=await $.getMember(s);l?(R(l),S(l.photo_url||"")):(w.error("êµì¸ ì 보를 ì°¾ì ì ììµëë¤"),i("/members"))}catch(l){console.error("êµì¸ ì ë³´ ë¡ë ì¤í¨:",l),w.error("êµì¸ ì 보를 ë¶ë¬ì¤ëë° ì¤í¨íìµëë¤"),i("/members")}finally{C(!1)}}const[t,n]=b.useState({name:"",member_classification:"ìëì¶ìì±ë",position:"ì±ë",gender:"ë¨",registration_date:new Date().toISOString().split("T")[0],calendar_type:"ìë ¥",spiritual_maturity:"1ë¨ê³",family_structure:"ì¼ë°",care_type:"í´ë¹ìì",status:"íë",relations:[],roles:[],service_assignments:[],elder_departments:[]});b.useEffect(()=>{a&&n(s=>({...s,name:a.name||"",member_classification:a.member_classification||"ìëì¶ìì±ë",position:a.position||"ì±ë",position_order:a.position_order,detailed_position:a.detailed_position||"",detailed_position_order:a.detailed_position_order,father_id:a.father_id||"",mother_id:a.mother_id||"",birth_date:a.birth_date||"",age:a.age,gender:a.gender||"ë¨",registration_date:a.registration_date||new Date().toISOString().split("T")[0],mobile_phone:a.mobile_phone||"",phone:a.phone||"",email:a.email||"",address_city:a.address_city||"",address_district:a.address_district||"",address_dong:a.address_dong||"",address_bunji:a.address_bunji||"",address_postal:a.address_postal||"",address_full:a.address_full||"",spouse:a.spouse||"",children:a.children,relations:a.relations||[],introducer:a.introducer||"",baptism_date:a.baptism_date||"",confirmation_date:a.confirmation_date||"",calendar_type:a.calendar_type||"ìë ¥",spiritual_maturity:a.spiritual_maturity||"1ë¨ê³",family_structure:a.family_structure||"ì¼ë°",care_type:a.care_type||"í´ë¹ìì",parish:a.parish||"",region:a.region||"",district:a.district||"",district_role:a.district_role||"",evangelism_group:a.evangelism_group||"",evangelism_position:a.evangelism_position||"",deacon_association_position:a.deacon_association_position||"",kwonsa_association_position:a.kwonsa_association_position||"",attendance_rate:a.attendance_rate,last_contact:a.last_contact||"",status:a.status||"íë",member_number:a.member_number||"",occupation:a.occupation||"",blood_type:a.blood_type||"",position_appointment_date:a.position_appointment_date||"",ministry:a.ministry||"",talents:a.talents||"",medical_info:a.medical_info||"",pastoral_notes:a.pastoral_notes||"",roles:a.roles||[],service_assignments:a.service_assignments||[],elder_departments:a.elder_departments||[]}))},[a]);function le(s){var x;const l=(x=s.target.files)==null?void 0:x[0];if(!l)return;if(l.size>5*1024*1024){w.error("íì¼ í¬ê¸°ë 5MB ì´íì¬ì¼ í©ëë¤");return}d(l);const o=new FileReader;o.onloadend=()=>{S(o.result)},o.readAsDataURL(l)}function re(s,l){return{ë°°ì°ì:"ë°°ì°ì",ë¶:l==="ë¨"?"ìë¤":l==="ì¬"?"ë¸":"ìë
",모:l==="ë¨"?"ìë¤":l==="ì¬"?"ë¸":"ìë
",ìë¤:t.gender==="ë¨"?"ë¶":"모",ë¸:t.gender==="ë¨"?"ë¶":"모",ìë
:t.gender==="ë¨"?"ë¶":"모"}[s]||null}async function ne(s,l,o){try{console.log("ð ìë°©í¥ ê´ê³ ì
ë°ì´í¸ ìì",{memberId:s,memberName:o,relationsCount:l.length});const x=l.filter(f=>f.memberId&&!f.isNone&&!f.isExternal);console.log("ð ì
ë°ì´í¸ ëì ê´ê³:",x.length);for(const f of x)if(f.memberId)try{console.log(`ð ìëë°© ì¡°í ì¤: ${f.memberId}`);const _=await $.getMember(f.memberId);if(!_){console.warn(`íìì ì°¾ì ì ììµëë¤: ${f.memberId}`);continue}const M=re(f.relationType,_.gender);if(!M){console.warn(`ìë°©í¥ ê´ê³ íì
ì ê³ì°í ì ììµëë¤: ${f.relationType}`);continue}const B=_.relations||[];if(B.some(O=>O.memberId===s))console.log(`â¹ï¸ ${_.name}ìê² ì´ë¯¸ ê´ê³ê° ì¡´ì¬í¨`);else{const O={memberId:s,relativeId:s,relativeName:o||"ì´ë¦ìì",relationType:M},oe=[...B,O];console.log(`ð ${_.name}ìê² ìë°©í¥ ê´ê³ ì¶ê° ìë:`,O),await $.updateMember(f.memberId,{relations:oe}),console.log(`â
${_.name}ìê² ìë°©í¥ ê´ê³ ì¶ê° ìë£: ${o}(${M})`)}}catch(_){console.error(`â ${f.relativeName}(${f.memberId}) ê´ê³ ì
ë°ì´í¸ ì¤í¨:`,_)}console.log("â
ìë°©í¥ ê´ê³ ì
ë°ì´í¸ ìë£")}catch(x){console.error("â ìë°©í¥ ê´ê³ ì
ë°ì´í¸ ì¤í¨:",x),w.error("ê°ì¡± ê´ê³ ìë°©í¥ ì
ë°ì´í¸ì ì¤í¨íìµëë¤. ìëì¼ë¡ íì¸í´ì£¼ì¸ì.")}}async function ie(s){if(s.preventDefault(),!t.name){w.error("ì´ë¦ì íì í목ì
ëë¤");return}try{C(!0);let l=a==null?void 0:a.photo_url;if(g){const M=(a==null?void 0:a.id)||`temp_${Date.now()}`;l=await je.uploadMemberPhoto(M,g)}const o=t.relations?t.relations.filter((M,B,X)=>B===X.findIndex(O=>O.memberId===M.memberId)):[];let x=t.address_full||"";t.address_bunji&&(x.includes(t.address_bunji)||(x=x?x+" "+t.address_bunji:t.address_bunji));const f={...t,address_full:x,relations:o,photo_url:l};let _;if(j==="create")_=(await $.createMember(f)).id,w.success("êµì¸ì´ ë±ë¡ëììµëë¤");else if(a)await $.updateMember(a.id,f),_=a.id,w.success("êµì¸ ì ë³´ê° ìì ëììµëë¤");else throw new Error("Invalid state");t.relations&&t.relations.length>0&&await ne(_,t.relations,t.name||""),j==="create"&&i(`/members/${_}/edit`,{replace:!0})}catch(l){console.error("ì ì¥ ì¤í¨:",l),w.error("ì ì¥ì ì¤í¨íìµëë¤")}finally{C(!1)}}return e.jsxs("form",{onSubmit:ie,className:"space-y-4 animate-fade-in",children:[e.jsx("div",{className:"relative overflow-hidden bg-white border border-gray-200 rounded-2xl p-6 shadow-sm",children:e.jsxs("div",{className:"relative flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"relative",children:[N?e.jsx("img",{src:N,alt:"미리보기",className:"w-20 h-20 rounded-2xl object-cover border-4 border-gray-100 shadow-sm",onError:()=>S("")}):e.jsx("div",{className:"w-20 h-20 rounded-2xl bg-blue-50 flex flex-col items-center justify-center border-4 border-gray-100",children:e.jsx(pe,{className:"w-8 h-8 text-blue-600"})}),e.jsxs("label",{className:"absolute -bottom-2 -right-2 cursor-pointer",children:[e.jsx("input",{type:"file",accept:"image/*",onChange:le,className:"hidden"}),e.jsx("div",{className:"w-8 h-8 bg-blue-600 rounded-full flex items-center justify-center shadow-sm hover:scale-110 transition-transform",children:e.jsx(xe,{className:"w-4 h-4 text-white"})})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-3 mb-1",children:e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:j==="create"?"êµì¸ ë±ë¡":"êµì¸ ì ë³´ ìì "})}),e.jsx("p",{className:"text-gray-500 text-sm",children:j==="create"?"ìë¡ì´ êµì¸ì ë±ë¡í©ëë¤":`${t.name||""} êµì¸ì ì 보를 ìì í©ëë¤`})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>i(-1),className:"flex items-center gap-2 px-4 py-2.5 bg-white border border-gray-300 text-gray-700 rounded-xl hover:bg-gray-50 transition-all text-sm font-medium",children:[e.jsx(z,{className:"w-4 h-4"}),"ì·¨ì"]}),e.jsxs("button",{type:"submit",disabled:I,className:"flex items-center gap-2 px-5 py-2.5 bg-blue-600 text-white rounded-xl hover:bg-blue-700 transition-all text-sm font-semibold shadow-sm disabled:opacity-50",children:[e.jsx(he,{className:"w-4 h-4"}),I?"ì ì¥ ì¤...":"ì ì¥"]})]})]})}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs(T,{title:"기본 ì ë³´",children:[e.jsx(c,{label:"ì´ë¦",required:!0,children:e.jsx("input",{type:"text",value:t.name,onChange:s=>n({...t,name:s.target.value}),className:"compact-input",placeholder:"í길ë"})}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(c,{label:"ì±ë³",children:e.jsx("select",{value:t.gender,onCh
7ange:s=>n({...t,gender:s.target.value}),className:"compact-input",children:ve.map(s=>e.jsx("option",{value:s,children:s},s))})}),e.jsx(c,{label:"ëì´",children:e.jsx("input",{type:"number",value:t.age||"",onChange:s=>n({...t,age:parseInt(s.target.value)||void 0}),className:"compact-input",placeholder:"35"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(c,{label:"ìë
ìì¼",children:e.jsx("input",{type:"date",value:t.birth_date,onChange:s=>n({...t,birth_date:s.target.value}),className:"compact-input"})}),e.jsx(c,{label:"ì/ìë ¥",children:e.jsx("select",{value:t.calendar_type,onChange:s=>n({...t,calendar_type:s.target.value}),className:"compact-input",children:fe.map(s=>e.jsx("option",{value:s,children:s},s))})})]}),e.jsx(c,{label:"ë±ë¡ì¼",children:e.jsx("input",{type:"date",value:t.registration_date,onChange:s=>n({...t,registration_date:s.target.value}),className:"compact-input"})}),e.jsx(c,{label:"ì¸ëì",children:e.jsx("input",{type:"text",value:t.introducer,onChange:s=>n({...t,introducer:s.target.value}),className:"compact-input",placeholder:"êµíë¡ ì¸ëí ì¬ë"})})]}),e.jsxs(T,{title:"ì°ë½ì²",children:[e.jsx(c,{label:"í¸ëí°",children:e.jsx("input",{type:"tel",value:t.mobile_phone,onChange:s=>n({...t,mobile_phone:s.target.value}),className:"compact-input",placeholder:"010-1234-5678"})}),e.jsx(c,{label:"ì íë²í¸",children:e.jsx("input",{type:"tel",value:t.phone,onChange:s=>n({...t,phone:s.target.value}),className:"compact-input",placeholder:"02-1234-5678"})}),e.jsx(c,{label:"ì´ë©ì¼",children:e.jsx("input",{type:"email",value:t.email,onChange:s=>n({...t,email:s.target.value}),className:"compact-input",placeholder:"[email protected]"})})]}),e.jsxs(T,{title:"주ì",children:[e.jsx("div",{className:"flex gap-2 mb-2",children:e.jsxs("button",{type:"button",onClick:()=>{var l;const s=()=>{new window.daum.Postcode({oncomplete:o=>{const x=o.roadAddress||o.jibunAddress||"";n(f=>({...f,address_city:o.sido||"",address_district:o.sigungu||"",address_dong:o.bname||"",address_postal:o.zonecode||"",address_full:x,address_bunji:""}))}}).open()};if((l=window.daum)!=null&&l.Postcode)s();else{const o=document.createElement("script");o.src="https://t1.daumcdn.net/mapjsapi/bundle/postcode/prod/postcode.v2.js",o.onload=()=>s(),o.onerror=()=>w.error("주ì ê²ì ìë¹ì¤ë¥¼ ë¶ë¬ì¬ ì ììµëë¤."),document.head.appendChild(o)}},className:"flex items-center gap-1 px-3 py-1.5 bg-blue-500 text-white text-sm rounded hover:bg-blue-600",children:[e.jsx(te,{size:14}),"주ì ê²ì"]})}),e.jsx(c,{label:"ëë¡ëª
주ì",children:e.jsx("input",{type:"text",value:t.address_full,onChange:s=>n({...t,address_full:s.target.value}),className:"compact-input",placeholder:"주ì ê²ì ëë ì§ì ì
ë ¥"})}),e.jsx(c,{label:"ìì¸ì£¼ì",children:e.jsx("input",{type:"text",value:t.address_bunji,onChange:s=>n({...t,address_bunji:s.target.value}),className:"compact-input",placeholder:"ë/í¸ì (ì: 305ë 1201í¸)"})}),e.jsx(c,{label:"ì°í¸ë²í¸",children:e.jsx("input",{type:"text",value:t.address_postal,onChange:s=>n({...t,address_postal:s.target.value}),className:"compact-input",placeholder:"주ì ê²ì ì ìëì
ë ¥"})})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs(T,{title:"ì§ë¶",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(c,{label:"êµì¸êµ¬ë¶",children:e.jsx("select",{value:t.member_classification,onChange:s=>n({...t,member_classification:s.target.value}),className:"compact-input",children:ye.map(s=>e.jsx("option",{value:s,children:s},s))})}),e.jsx(c,{label:"ì§ë¶",children:e.jsx("select",{value:t.position,onChange:s=>n({...t,position:s.target.value}),className:"compact-input",children:Ne.map(s=>e.jsx("option",{value:s,children:s},s))})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(c,{label:"ì¸ë¶ì§ë¶",children:e.jsxs("select",{value:t.detailed_position,onChange:s=>n({...t,detailed_position:s.target.value}),className:"compact-input",children:[e.jsx("option",{value:"",children:"ì ííì¸ì"}),_e.map(s=>e.jsx("option",{value:s,children:s},s))]})}),e.jsx(c,{label:"ìì§ìë²",children:e.jsx("input",{type:"number",value:t.position_order||"",onChange:s=>n({...t,position_order:parseInt(s.target.value)||void 0}),className:"compact-input"})})]}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:e.jsx(c,{label:"ì¸ë¶ì§ë¶ë²í¸",children:e.jsx("input",{type:"number",value:t.detailed_position_order??"",onChange:s=>n({...t,detailed_position_order:parseInt(s.target.value)||void 0}),className:"compact-input"})})}),t.position==="ì¥ë¡"&&e.jsxs("div",{className:"flex items-center gap-3 mt-2",children:[e.jsx("label",{className:"text-xs font-medium text-gray-600 flex-shrink-0 w-16",children:"ë¹íìí "}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:((K=t.roles)==null?void 0:K.includes("ë¹íì기"))||!1,onChange:s=>{const l=s.target.checked?[...t.roles||[],"ë¹íì기"]:(t.roles||[]).filter(o=>o!=="ë¹íì기");n({...t,roles:l})},className:"w-4 h-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500"}),e.jsx("span",{className:"text-sm text-gray-700",children:"ë¹íì기 (íìë¡ ìì± ê¶í)"})]})]})]}),e.jsxs(T,{title:"êµííë",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(c,{label:"ìí",children:e.jsx("select",{value:t.status,onChange:s=>n({...t,status:s.target.value}),className:"compact-input",children:Ce.map(s=>e.jsx("option",{value:s,children:s},s))})}),e.jsx(c,{label:"êµêµ¬",children:e.jsxs("select",{value:t.parish||"",onChange:s=>{const l=s.target.value;n({...t,parish:l,region:"",district:""})},className:"compact-input",children:[e.jsx("option",{value:"",children:"ì ííì¸ì"}),Se.map(s=>e.jsx("option",{value:s,children:s},s))]})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(c,{label:"ì§ì",children:e.jsxs("select",{value:t.region||"",onChange:s=>{const l=s.target.value;n({...t,region:l,district:""})},className:"compact-input",disabled:!t.parish,children:[e.jsx("option",{value:"",children:"ì ííì¸ì"}),t.parish&&Ie(t.parish).map(s=>e.jsx("option",{value:s,children:s},s))]})}),e.jsx(c,{label:"구ì",children:e.jsxs("select",{value:t.district||"",onChange:s=>n({...t,district:s.target.value}),className:"compact-input",disabled:!t.parish||!t.region,children:[e.jsx("option",{value:"",children:"ì ííì¸ì"}),t.parish&&t.region&&Ee(t.parish,t.region).map(s=>e.jsx("option",{value:s,children:s},s))]})}),e.jsx(c,{label:"구ìì¥ ì§ì ",children:e.jsxs("select",{value:t.district_role||"",onChange:s=>n({...t,district_role:s.target.value}),className:"compact-input",children:[e.jsx("option",{value:"",children:"ì¼ë°"}),e.jsx("option",{value:"구ìì¥",children:"구ìì¥"}),e.jsx("option",{value:"ê¶ì°°",children:"ê¶ì°°"})]})})]}),t.member_classification!=="ìëì¶ìêµìì"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 gap-2",children:e.jsx(c,{label:"ì êµí",children:e.jsxs("select",{value:t.evangelism_group,onChange:s=>n({...t,evangelism_group:s.target.value}),className:"compact-input",children:[e.jsx("option",{value:"",children:"ì ííì¸ì"}),(t.gender==="ë¨"?Re:Te).map(s=>e.jsx("option",{value:s,children:s},s))]})})}),e.jsx(c,{label:"ì êµíì§ì±
",children:e.jsxs("select",{value:t.evangelism_position,onChange:s=>n({...t,evangelism_position:s.target.value}),className:"compact-input",children:[e.jsx("option",{value:"",children:"ì ííì¸ì"}),ke.map(s=>e.jsx("option",{value:s,children:s},s))]})})]}),t.position==="ììì§ì¬"&&e.jsx(c,{label:"ììì§ì¬íì§ì
7±
",children:e.jsxs("select",{value:t.deacon_association_position||"",onChange:s=>n({...t,deacon_association_position:s.target.value}),className:"compact-input",children:[e.jsx("option",{value:"",children:"ì ííì¸ì"}),Me.map(s=>e.jsx("option",{value:s,children:s},s))]})}),t.position==="ê¶ì¬"&&e.jsx(c,{label:"ê¶ì¬íì§ì±
",children:e.jsxs("select",{value:t.kwonsa_association_position||"",onChange:s=>n({...t,kwonsa_association_position:s.target.value}),className:"compact-input",children:[e.jsx("option",{value:"",children:"ì ííì¸ì"}),Ae.map(s=>e.jsx("option",{value:s,children:s},s))]})}),(t.detailed_position==="ì무ì¥ë¡"||we.includes(t.detailed_position||""))&&e.jsxs(c,{label:`${t.detailed_position==="ì무ì¥ë¡"?"ê´í ":"ë´ë¹"}ë¶ì (ë³µìì í)`,children:[e.jsxs("select",{value:"",onChange:s=>{if(!s.target.value)return;const l=t.elder_departments||[];l.includes(s.target.value)||n({...t,elder_departments:[...l,s.target.value]}),s.target.value=""},className:"compact-input",children:[e.jsx("option",{value:"",children:"ë¶ì를 ì ííì¸ì"}),(t.detailed_position==="ì무ì¥ë¡"?Pe:De).filter(s=>!(t.elder_departments||[]).includes(s)).map(s=>e.jsx("option",{value:s,children:s},s))]}),t.elder_departments&&t.elder_departments.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:t.elder_departments.map(s=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-xs font-medium bg-blue-50 text-blue-700 rounded-md border border-blue-200",children:[s,e.jsx("button",{type:"button",onClick:()=>{n({...t,elder_departments:t.elder_departments.filter(l=>l!==s)})},className:"text-blue-400 hover:text-blue-600 ml-0.5",children:"Ã"})]},s))})]}),e.jsx(c,{label:"ë´ì¬ë¶ì ë°°ì ",children:e.jsxs("div",{className:"space-y-2",children:[(t.service_assignments||[]).map((s,l)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs("select",{value:s.department,onChange:o=>{const x=[...t.service_assignments||[]];x[l]={...x[l],department:o.target.value},n({...t,service_assignments:x})},className:"compact-input flex-1",children:[e.jsx("option",{value:"",children:"ë¶ìì í"}),Oe.map(o=>e.jsx("optgroup",{label:o.label,children:o.departments.map(x=>e.jsx("option",{value:x,children:x},x))},o.label))]}),e.jsxs("select",{value:s.role,onChange:o=>{const x=[...t.service_assignments||[]];x[l]={...x[l],role:o.target.value},n({...t,service_assignments:x})},className:"compact-input flex-1",children:[e.jsx("option",{value:"",children:"ìí ì í"}),$e.map(o=>e.jsx("option",{value:o,children:o},o))]}),e.jsx("button",{type:"button",onClick:()=>{const o=(t.service_assignments||[]).filter((x,f)=>f!==l);n({...t,service_assignments:o})},className:"p-1 text-red-500 hover:bg-red-50 rounded",children:e.jsx(ae,{className:"w-4 h-4"})})]},l)),e.jsxs("button",{type:"button",onClick:()=>{const s=t.service_assignments||[];n({...t,service_assignments:[...s,{department:"",role:""}]})},className:"flex items-center gap-1 text-xs text-blue-600 hover:text-blue-800",children:[e.jsx(J,{className:"w-4 h-4"}),"ë´ì¬ë¶ì ì¶ê°"]})]})}),e.jsx(c,{label:"ì¬ì",children:e.jsx("input",{type:"text",value:t.ministry,onChange:s=>n({...t,ministry:s.target.value}),className:"compact-input",placeholder:"ì°¬ìí"})})]}),e.jsxs(T,{title:"ì ì ì ë³´",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(c,{label:"ì¸ë¡ì¼",children:e.jsx("input",{type:"date",value:t.baptism_date,onChange:s=>n({...t,baptism_date:s.target.value}),className:"compact-input"})}),e.jsx(c,{label:"ì
êµì¼",children:e.jsx("input",{type:"date",value:t.confirmation_date,onChange:s=>n({...t,confirmation_date:s.target.value}),className:"compact-input"})})]}),e.jsx(c,{label:"ìì ì±ì",children:e.jsx("select",{value:t.spiritual_maturity,onChange:s=>n({...t,spiritual_maturity:s.target.value}),className:"compact-input",children:Le.map(s=>e.jsx("option",{value:s,children:s},s))})})]}),e.jsxs(T,{title:"기í ì ë³´",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(c,{label:"ì§ì
",children:e.jsx("input",{type:"text",value:t.occupation,onChange:s=>n({...t,occupation:s.target.value}),className:"compact-input",placeholder:"íì¬ì"})}),e.jsx(c,{label:"íì¡í",children:e.jsxs("select",{value:t.blood_type,onCh
7ange:s=>n({...t,blood_type:s.target.value}),className:"compact-input",children:[e.jsx("option",{value:"",children:"ì í"}),Ve.map(s=>e.jsx("option",{value:s,children:s},s))]})})]}),e.jsx(c,{label:"ì¬ë¥",children:e.jsx("textarea",{value:t.talents,onChange:s=>n({...t,talents:s.target.value}),className:"compact-input",rows:2,placeholder:"í¼ìë
¸, 기í"})}),e.jsx(c,{label:"ìë£ì ë³´",children:e.jsx("textarea",{value:t.medical_info,onChange:s=>n({...t,medical_info:s.target.value}),className:"compact-input",rows:2,placeholder:"ìë 르기, ë³µì©ì½ë¬¼"})}),e.jsx(c,{label:"목ìë©ëª¨",children:e.jsx("textarea",{value:t.pastoral_notes,onChange:s=>n({...t,pastoral_notes:s.target.value}),className:"compact-input",rows:3,placeholder:"목íì ë©ëª¨"})})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs(T,{title:"ê°ì¡± ì ë³´",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(c,{label:"ë°°ì°ì",children:e.jsx("input",{type:"text",value:t.spouse,onChange:s=>n({...t,spouse:s.target.value}),className:"compact-input"})}),e.jsx(c,{label:"ìë
ì",children:e.jsx("input",{type:"number",value:t.children||"",onChange:s=>n({...t,children:parseInt(s.target.value)||void 0}),className:"compact-input",placeholder:"2"})})]}),e.jsx(c,{label:"ê°ì¡±êµ¬ì¡°",children:e.jsx("select",{value:t.family_structure||"ì¼ë°",onChange:s=>n({...t,family_structure:s.target.value}),className:"compact-input",children:Ue.map(s=>e.jsx("option",{value:s,children:s},s))})}),e.jsx(c,{label:"ëë´ê´ë ¨",children:e.jsx("select",{value:t.care_type||"í´ë¹ìì",onChange:s=>n({...t,care_type:s.target.value}),className:"compact-input",children:Fe.map(s=>e.jsx("option",{value:s,children:s},s))})})]}),e.jsx(T,{title:"ê°ì¡± ê´ê³",children:e.jsx(He,{relations:t.relations||[],onChange:s=>{const l=s.find(_=>_.relationType==="ë¶"),o=s.find(_=>_.relationType==="모");let x=t.father_id,f=t.mother_id;l&&(l.isNone?x="":x=l.memberId||l.relativeId||""),o&&(o.isNone?f="":f=o.memberId||o.relativeId||""),n({...t,relations:s,father_id:x,mother_id:f})}})})]})]}),j==="edit"&&a&&e.jsx("div",{className:"mt-4",children:e.jsx(Be,{memberId:a.id,memberName:t.name||a.name})}),j==="edit"&&v&&e.jsx("div",{className:"mt-4",children:e.jsxs("div",{className:"bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-3 bg-slate-50 border-b border-gray-100 flex items-center justify-between",children:[e.jsxs("button",{type:"button",onClick:()=>V(!L),className:"flex items-center gap-2 hover:opacity-80 transition-opacity",children:[e.jsx(Y,{className:"w-4 h-4 text-blue-600"}),e.jsx("h3",{className:"text-sm font-bold text-gray-800",children:"ì¬ë°© íì¤í 리"}),e.jsxs("span",{className:"text-xs px-2 py-0.5 bg-blue-50 text-blue-700 rounded-full tabular-nums",children:[m.length,"ê±´"]}),L?e.jsx(ee,{className:"w-4 h-4 text-gray-400"}):e.jsx(se,{className:"w-4 h-4 text-gray-400"})]}),e.jsxs("button",{type:"button",onClick:()=>{A(null),k(!0)},className:"flex items-center gap-1 px-2 py-1 bg-blue-600 text-white rounded text-xs font-medium hover:bg-blue-700 transition-colors",children:[e.jsx(J,{className:"w-3 h-3"}),"ì¶ê°"]})]}),L&&e.jsx("div",{className:"p-4",children:y?e.jsx("div",{className:"text-center py-6 text-gray-500 text-sm",children:"ì¬ë°© 기ë¡ì ë¶ë¬ì¤ë ì¤..."}):m.length===0?e.jsxs("div",{className:"text-center py-6",children:[e.jsx(Y,{className:"w-10 h-10 text-gray-300 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-gray-500",children:"ì¬ë°© 기ë¡ì´ ììµëë¤"}),e.jsx("button",{type:"button",onClick:()=>{A(null),k(!0)},className:"mt-3 text-xs text-blue-600 hover:text-blue-700 font-medium",children:"첫 ì¬ë°© ê¸°ë¡ ì¶ê°í기 â"})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-4 gap-2 mb-4",children:[e.jsxs("div",{className:"bg-blue-50 rounded-lg p-2 text-center",children:[e.jsx("div",{className:"text-lg font-bold text-blue-600 tabular-nums",children:m.length}),e.jsx("div",{className:"text-[10px] text-gray-500",children:"ì´ ì¬ë°©"})]}),e.jsxs("div",{className:"bg-gray-50 rounded-lg p-2 text-center",children:[e.jsx("div",{className:"text-xs font-bold text-gray-700",children:((Q=m[0])==null?void 0:Q.visit_date)||"-"}),e.jsx("div",{className:"text-[10px] text-gray-500",children:"ìµê·¼ ì¬ë°©"})]}),e.jsxs("div",{className:"bg-blue-50 rounded-lg p-2 text-center",children:[e.jsx("div",{className:"text-lg font-bold text-blue-600",children:m.filter(s=>s.visit_type==="ê°ì ì¬ë°©").length}),e.jsx("div",{className:"text-[10px] text-gray-500",children:"ê°ì ì¬ë°©"})]}),e.jsxs("div",{className:"bg-orange-50 rounded-lg p-2 text-center",children:[e.jsx("div",{className:"text-lg font-bold text-orange-600",children:m.filter(s=>s.follow_up_needed).length}),e.jsx("div",{className:"text-[10px] text-gray-500",children:"íìì¡°ì¹"})]})]}),e.jsx("div",{className:"max-h-80 overflow-y-auto space-y-2",children:m.map(s=>e.jsx(ze,{visit:s,onEdit:()=>{A(s),k(!0)},onDelete:()=>E(s.id)},s.id))})]})})]})}),q&&v&&e.jsx(qe,{memberId:v,memberName:(a==null?void 0:a.name)||t.name||"",visit:U,onClose:()=>{k(!1),A(null)},onSubmit:s=>{U?h(U.id,s):r({...s,member_id:v})}})]})}function ze({visit:u,onEdit:j,onDelete:i}){const v={ê°ì ì¬ë°©:"bg-blue-100 text-blue-700",ë³ìì¬ë°©:"bg-red-100 text-red-700",ì íì¬ë°©:"bg-green-100 text-green-700",ìë´:"bg-blue-100 text-blue-700",기í:"bg-gray-100 text-gray-700"};return e.jsxs("div",{className:"bg-gray-50 rounded-lg p-3 border border-gray-100 hover:border-gray-200 transition-colors",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-bold text-gray-900",children:u.visit_date}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${v[u.visit_type]||v.기í}`,children:u.visit_type}),u.follow_up_needed&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 bg-orange-100 text-orange-700 rounded flex items-center gap-0.5",children:[e.jsx(ge,{className:"w-2.5 h-2.5"}),"íìì¡°ì¹"]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{type:"button",onClick:j,className:"p-1 hover:bg-gray-200 rounded transition-colors",title:"ìì ",children:e.jsx(be,{className:"w-3 h-3 text-blue-600"})}),e.jsx("button",{type:"button",onClick:i,className:"p-1 hover:bg-gray-200 rounded transition-colors",title:"ìì ",children:e.jsx(ae,{className:"w-3 h-3 text-red-600"})})]})]}),e.jsxs("div",{className:"text-[11px] text-gray-600 space-y-1",children:[u.visitors&&u.visitors.length>0&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium text-gray-700",children:"ì¬ë°©ì:"}
7)," ",u.visitors.join(", ")]}),e.jsxs("p",{children:[e.jsx("span",{className:"font-medium text-gray-700",children:"목ì :"})," ",u.purpose]}),e.jsxs("p",{className:"line-clamp-2",children:[e.jsx("span",{className:"font-medium text-gray-700",children:"ë´ì©:"})," ",u.content]}),u.prayer_topics&&u.prayer_topics.length>0&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium text-gray-700",children:"기ëì 목:"})," ",u.prayer_topics.join(", ")]})]})]})}function qe({memberId:u,memberName:j,visit:i,onClose:v,onSubmit:I}){var a,R;const[C,g]=b.useState(!1),[d,N]=b.useState({visit_type:(i==null?void 0:i.visit_type)||"ê°ì ì¬ë°©",visit_date:(i==null?void 0:i.visit_date)||new Date().toISOString().split("T")[0],visitors:((a=i==null?void 0:i.visitors)==null?void 0:a.join(", "))||"",purpose:(i==null?void 0:i.purpose)||"",content:(i==null?void 0:i.content)||"",prayer_topics:((R=i==null?void 0:i.prayer_topics)==null?void 0:R.join(` 8`))||"",follow_up_needed:(i==null?void 0:i.follow_up_needed)||!1,follow_up_date:(i==null?void 0:i.follow_up_date)||""});async function S(m){if(m.preventDefault(),!d.purpose||!d.content){w.error("목ì ê³¼ ë´ì©ì ì ë ¥íì¸ì");return}g(!0);try{const p={member_id:u,visit_type:d.visit_type,visit_date:d.visit_date,visitors:d.visitors.split(",").map(y=>y.trim()).filter(y=>y),purpose:d.purpose,content:d.content,prayer_topics:d.prayer_topics?d.prayer_topics.split(` 9`).map(y=>y.trim()).filter(y=>y):void 0,follow_up_needed:d.follow_up_needed,follow_up_date:d.follow_up_needed?d.follow_up_date:void 0};I(p)}finally{g(!1)}}return e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white rounded-xl shadow-xl max-w-lg w-full max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"px-4 py-3 bg-blue-600 text-white flex items-center justify-between rounded-t-xl",children:[e.jsxs("h2",{className:"text-sm font-bold flex items-center gap-2",children:[e.jsx(Y,{className:"w-4 h-4"}),i?"ì¬ë°© ê¸°ë¡ ìì ":"ì¬ë°© ê¸°ë¡ ì¶ê°"]}),e.jsx("button",{type:"button",onClick:v,className:"p-1 hover:bg-white/20 rounded transition-colors",children:e.jsx(z,{className:"w-4 h-4"})})]}),e.jsxs("form",{onSubmit:S,className:"p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"êµì¸"}),e.jsx("input",{type:"text",value:j,disabled:!0,className:"w-full px-3 py-2 text-sm border border-gray-200 rounded-lg bg-gray-50"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:["ì¬ë°© ì í ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("select",{value:d.visit_type,onChange:m=>N({...d,visit_type:m.target.value}),className:"w-full px-3 py-2 text-sm border border-gray-200 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",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:"ì¶íì¬ë°©"}),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:"기í"})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:["ì¬ë°© ë ì§ ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"date",value:d.visit_date,onChange:m=>N({...d,visit_date:m.target.value}),className:"w-full px-3 py-2 text-sm border border-gray-200 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",required:!0})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"ì¬ë°©ì (ì¼íë¡ êµ¬ë¶)"}),e.jsx("input",{type:"text",value:d.visitors,onChange:m=>N({...d,visitors:m.target.value}),className:"w-full px-3 py-2 text-sm border border-gray-200 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",placeholder:"í길ë, ê¹ì² ì"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:["ì¬ë°© 목ì ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:d.purpose,onChange:m=>N({...d,purpose:m.target.value}),className:"w-full px-3 py-2 text-sm border border-gray-200 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",placeholder:"ì: ì 기 ì¬ë°©",required:!0})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:["ì¬ë°© ë´ì© ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("textarea",{value:d.content,onChange:m=>N({...d,content:m.target.value}),className:"w-full px-3 py-2 text-sm border border-gray-200 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",rows:3,placeholder:"ì¬ë°© ë´ì©ì 기ë¡íì¸ì",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"기ë ì 목
9(ì¤ë°ê¿ì¼ë¡ 구ë¶)"}),e.jsx("textarea",{value:d.prayer_topics,onChange:m=>N({...d,prayer_topics:m.target.value}),className:"w-full px-3 py-2 text-sm border border-gray-200 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",rows:2,placeholder:`ê±´ê° íë³µ 10ê°ì¡± íì`})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:d.follow_up_needed,onChange:m=>N({...d,follow_up_needed:m.target.checked}),className:"w-4 h-4 text-blue-600 rounded"}),e.jsx("span",{className:"text-xs font-medium text-gray-700",children:"íìì¡°ì¹ íì"})]}),d.follow_up_needed&&e.jsx("input",{type:"date",value:d.follow_up_date,onChange:m=>N({...d,follow_up_date:m.target.value}),className:"w-full px-3 py-2 text-sm border border-gray-200 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",placeholder:"íìì¡°ì¹ ìì ì¼"})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx("button",{type:"button",onClick:v,className:"flex-1 px-3 py-2 border border-gray-300 rounded-lg hover:bg-gray-50 transition-colors text-sm",children:"ì·¨ì"}),e.jsx("button",{type:"submit",disabled:C,className:"flex-1 px-3 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors text-sm font-medium disabled:opacity-50",children:C?"ì ì¥ ì¤...":i?"ìì ":"ì¶ê°"})]})]})]})})}function T({title:u,children:j}){return e.jsxs("div",{className:"bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden",children:[e.jsx("div",{className:"px-4 py-3 bg-slate-50 border-b border-gray-100",children:e.jsx("h3",{className:"text-sm font-bold text-gray-800",children:u})}),e.jsx("div",{className:"p-4 space-y-3",children:j})]})}function c({label:u,required:j,children:i}){return e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("label",{className:"text-xs font-medium text-gray-600 flex-shrink-0 w-16",children:[u,j&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),e.jsx("div",{className:"flex-1",children:i})]})}export{as as MemberForm};
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.