1import{j as e}from"./vendor-data-Z5doMMu-.js";import{r as b}from"./vendor-react-zNM0AU50.js";import{d as j}from"./index-D1K3lVhu.js";import{l as $,q as I,w as T,x as M,B as R,m as F,k as S,j as O,A as C,K as B}from"./vendor-firebase-Da9KY1q_.js";import{c as z,W as A,Y as U,aZ as W,ae as Y,a4 as K,z as v}from"./vendor-ui-CW5bJ11U.js";import"./vendor-charts-08G1rM8P.js";const y={simple:{type:"simple",name:"ê°ë¨í",description:"íµì¬ ë§ìê³¼ ì§§ì 묵ì",fields:{title:!0,verse:!0,bible_text:!0,meditation:!0,prayer:!0,hymn:!1,image:!1,audio:!1,questions:!1,key_verse:!1,application:!1,series_info:!1}},detailed:{type:"detailed",name:"ìì¸í",description:"íµì¬êµ¬ì , 묵ìí¬ì¸í¸, ì ì©ê¹ì§",fields:{title:!0,verse:!0,bible_text:!0,meditation:!0,prayer:!0,hymn:!0,image:!0,audio:!0,questions:!1,key_verse:!0,application:!0,series_info:!1}},interactive:{type:"interactive",name:"ì§ë¬¸í",description:"묵ì ì§ë¬¸ì¼ë¡ ê¹ì´ ìê°í기",fields:{title:!0,verse:!0,bible_text:!0,meditation:!0,prayer:!0,hymn:!1,image:!0,audio:!1,questions:!0,key_verse:!0,application:!0,series_info:!1}},minimal:{type:"minimal",name:"ìµìí",description:"ë§ìë§ ê°ê²°íê²",fields:{title:!1,verse:!0,bible_text:!0,meditation:!1,prayer:!1,hymn:!1,image:!1,audio:!1,questions:!1,key_verse:!1,application:!1,series_info:!1}},series:{type:"series",name:"ì리ì¦í",description:"ì°ì 주ì QT",fields:{title:!0,verse:!0,bible_text:!0,meditation:!0,prayer:!0,hymn:!0,image:!0,audio:!0,questions:!1,key_verse:!0,application:!0,series_info:!0}}};async function P(s,d){try{const n=S(j,"qt_contents",s.date),i={id:s.date,date:s.date,template_type:s.template_type,title:s.title,verse:s.verse,verse_text:s.verse_text,bible_text:s.bible_text,meditation:s.meditation,prayer:s.prayer,scheduled_time:s.scheduled_time||"06:00",status:s.published?"scheduled":"draft",published:s.published,created_by:d,created_at:C(),updated_at:C()};return s.series_id&&(i.series_id=s.series_id),s.series_title&&(i.series_title=s.series_title),s.series_day!==void 0&&(i.series_day=s.series_day),s.series_total!==void 0&&(i.series_total=s.series_total),s.key_point&&(i.key_point=s.key_point),s.application&&(i.application=s.application),s.questions&&s.questions.length>0&&(i.questions=s.questions),s.hymn&&(i.hymn=s.hymn),s.hymn_title&&(i.hymn_title=s.hymn_title),s.image_url&&(i.image_url=s.image_url),s.audio_url&&(i.audio_url=s.audio_url),await B(n,i,{merge:!0}),console.log(`â
QT Content ì ì¥ ìë£: ${s.date} (${s.template_type})`),{success:!0}}catch(n){return console.error("QT Content ì ì¥ ì¤ë¥:",n),{success:!1,error:n.message||"QT ì ì¥ì ì¤í¨íìµëë¤"}}}async function Z(s){var d,n,i,g;try{const u=S(j,"qt_contents",s),a=await O(u);if(a.exists()){const r=a.data();return{success:!0,data:{...r,created_at:((n=(d=r.created_at)==null?void 0:d.toDate)==null?void 0:n.call(d))||new Date,updated_at:((g=(i=r.updated_at)==null?void 0:i.toDate)==null?void 0:g.call(i))||new Date}}}return{success:!0,data:null}}catch(u){return console.error("QT Content ì¡°í ì¤ë¥:",u),{success:!1,error:u.message||"QT ì¡°íì ì¤í¨íìµëë¤"}}}async function Q(s,d=30){try{const n=$(j,"qt_contents"),i=I(n,T("template_type","==",s),T("published","==",!0),M("date","desc"),R(d));return{success:!0,data:(await F(i)).docs.map(a=>{var p,x,h,f;const r=a.data();return{...r,created_at:((x=(p=r.created_at)==null?void 0:p.toDate)==null?void 0:x.call(p))||new Date,updated_at:((f=(h=r.updated_at)==null?void 0:h.toDate)==null?void 0:f.call(h))||new Date}})}}catch(n){return console.error("QT í
íë¦¿ë³ ì¡°í ì¤ë¥:",n),{success:!1,error:n.message||"QT ì¡°íì ì¤í¨íìµëë¤",data:[]}}}function G(s){const d=[];return s.date||d.push("ë ì§ë¥¼ ì
ë ¥í´ì£¼ì¸ì"),s.template_type||d.push("í
í릿 íì
ì ì íí´ì£¼ì¸ì"),(!s.title||s.title.trim().length===0)&&d.push("ì 목ì ì
ë ¥í´ì£¼ì¸ì"),(!s.verse||s.verse.trim().length===0)&&d.push("ì±ê²½ 구ì ì ì
ë ¥í´ì£¼ì¸ì"),(!s.bible_text||s.bible_text.trim().length<10)&&d.push("본문ì ìµì 10ì ì´ì ì
ë ¥í´ì£¼ì¸ì"),s.template_type==="interactive"&&(!s.questions||s.questions.length===0)&&d.push("ì§ë¬¸í í
í릿ì ìµì 1ê° ì´ìì ì§ë¬¸ì´ íìí©ëë¤"),s.template_type==="series"&&((!s.series_id||!s.series_title)&&d.push("ì리ì¦í í
í릿ì ìë¦¬ì¦ ì ë³´ê° íìí©ëë¤"),(!s.series_day||!s.series_total)&&d.push("ìë¦¬ì¦ ì¼ì를 ì
ë ¥í´ì£¼ì¸ì")),{valid:d.length===0,errors:d}}function ee(){const[s,d]=b.useState([]),[n,i]=b.useState(new Date().toISOString().split("T")[0]),[g,u]=b.useState(!1),[a,r]=b.useState({date:n,template_type:"simple",title:"",verse:"",verse_text:"",bible_text:"",meditation:"",prayer:"",published:!1}),[p,x]=b.useState(!1),[h,f]=b.useState({total_published:0,total_drafts:0,this_month_count:0});b.useEffect(()=>{N(),w()},[]),b.useEffect(()=>{L(n)},[n]);const N=async()=>{try{const t=[];for(const l of Object.keys(y)){const m=await Q(l,30);m.success&&m.data&&t.push(...m.data)}t.sort((l,m)=>m.date.localeCompare(l.date)),d(t.slice(0,30))}catch(t){console.error("Failed to load QT list:",t)}},w=async()=>{try{const t=[];for(const c of Object.keys(y)){const _=await Q(c,100);_.success&&_.data&&t.push(..._.data)}const l=new Date,m=`${l.getFullYear()}
1-${String(l.getMonth()+1).padStart(2,"0")}`;f({total_published:t.filter(c=>c.published).length,total_drafts:t.filter(c=>!c.published).length,this_month_count:t.filter(c=>c.date.startsWith(m)).length})}catch(t){console.error("Failed to load stats:",t)}},L=async t=>{x(!0);const l=await Z(t);l.success&&l.data?(r({date:l.data.date,template_type:l.data.template_type,series_id:l.data.series_id,series_title:l.data.series_title,series_day:l.data.series_day,series_total:l.data.series_total,title:l.data.title,verse:l.data.verse,verse_text:l.data.verse_text,bible_text:l.data.bible_text,meditation:l.data.meditation,key_point:l.data.key_point,application:l.data.application,prayer:l.data.prayer,questions:l.data.questions,hymn:l.data.hymn,hymn_title:l.data.hymn_title,image_url:l.data.image_url,audio_url:l.data.audio_url,scheduled_time:l.data.scheduled_time,published:l.data.published}),u(!0)):(r({date:t,template_type:"simple",title:"",verse:"",verse_text:"",bible_text:"",meditation:"",prayer:"",published:!1}),u(!1)),x(!1)},k=async t=>{x(!0);const l={...a,published:t},m=G(l);if(!m.valid){v.error(m.errors[0]),x(!1);return}const c=await P(l,"admin-user-id");c.success?(v.success(t?"QTê° ë°íëììµëë¤! ð":"ì´ìì´ ì ì¥ëììµëë¤"),u(!0),N(),w()):v.error(c.error||"ì ì¥ì ì¤í¨íìµëë¤"),x(!1)},E=t=>{const l=y[t];r({...a,template_type:t,key_point:l.fields.key_verse?a.key_point:void 0,application:l.fields.application?a.application:void 0,questions:l.fields.questions?a.questions:void 0,hymn:l.fields.hymn?a.hymn:void 0,hymn_title:l.fields.hymn?a.hymn_title:void 0,image_url:l.fields.image?a.image_url:void 0,audio_url:l.fields.audio?a.audio_url:void 0,series_id:l.fields.series_info?a.series_id:void 0,series_title:l.fields.series_info?a.series_title:void 0,series_day:l.fields.series_info?a.series_day:void 0,series_total:l.fields.series_info?a.series_total:void 0})},o=y[a.template_type];return e.jsxs("div",{className:"p-6 max-w-7xl mx-auto",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:"text-3xl font-bold text-gray-900 mb-2",children:"QT ê´ë¦¬"}),e.jsx("p",{className:"text-gray-600",children:"ì¤ëì QT를 ìì±íê³ ë°ííì¸ì"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4 mb-6",children:[e.jsxs("div",{className:"bg-blue-50 rounded-lg p-4",children:[e.jsx("div",{className:"text-sm text-blue-600 mb-1",children:"ë°íë QT"}),e.jsx("div",{className:"text-3xl font-bold text-blue-900",children:h.total_published})]}),e.jsxs("div",{className:"bg-yellow-50 rounded-lg p-4",children:[e.jsx("div",{className:"text-sm text-yellow-600 mb-1",children:"ì´ì"}),e.jsx("div",{className:"text-3xl font-bold text-yellow-900",children:h.total_drafts})]}),e.jsxs("div",{className:"bg-green-50 rounded-lg p-4",children:[e.jsx("div",{className:"text-sm text-green-600 mb-1",children:"ì´ë² ë¬"}),e.jsx("div",{className:"text-3xl font-bold text-green-900",children:h.this_month_count})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-6",children:[e.jsxs("div",{className:"col-span-1 bg-white rounded-lg shadow p-4",children:[e.jsxs("h2",{className:"text-lg font-semibold mb-4 flex items-center gap-2",children:[e.jsx(z,{className:"w-5 h-5"}),e.jsx("span",{children:"QT 목ë¡"})]}),e.jsx("div",{className:"space-y-2 max-h-[600px] overflow-y-auto",children:s.map(t=>e.jsxs("button",{onClick:()=>i(t.date),className:`w-full text-left p-3 rounded-lg border transition-colors ${n===t.date?"border-blue-500 bg-blue-50":"border-gray-200 hover:bg-gray-50"}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-sm font-medium text-gray-900",children:t.date}),t.published?e.jsx("span",{className:"text-xs bg-green-100 text-green-700 px-2 py-0.5 rounded",children:"ë°íë¨"}):e.jsx("span",{className:"text-xs bg-gray-100 text-gray-600 px-2 py-0.5 rounded",children:"ì´ì"})]}),e.jsx("div",{className:"text-xs text-gray-600 truncate",children:t.title})]},t.date))})]}),e.jsxs("div",{className:"col-span-2 bg-white rounded-lg shadow p-6",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"ë ì§"}),e.jsx("input",{type:"date",value:n,onChange:t=>i(t.target.value),className:"w-full border border-gray-300 rounded px-3 py-2"})]}),p?e.jsx("div",{className:"text-center py-12 text-gray-500",children:"ë¡ë© ì¤..."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-6 p-4 bg-blue-50 rounded-lg border border-blue-200",children:[e.jsx("label",{className:"block text-sm font-semibold text-gray-900 mb-3",children:"ð í
í릿 ì í *"}
1),e.jsx("div",{className:"grid grid-cols-5 gap-3",children:Object.entries(y).map(([t,l])=>e.jsxs("button",{onClick:()=>E(l.type),className:`p-3 rounded-lg border-2 transition-all ${a.template_type===l.type?"border-blue-600 bg-blue-100 shadow-sm":"border-gray-200 bg-white hover:border-blue-300"}`,children:[e.jsx("div",{className:`text-sm font-semibold mb-1 ${a.template_type===l.type?"text-blue-900":"text-gray-700"}`,children:l.name}),e.jsx("div",{className:"text-xs text-gray-500",children:l.description})]},t))})]}),o.fields.series_info&&e.jsxs("div",{className:"mb-4 p-4 bg-blue-50 rounded-lg border border-blue-200",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900 mb-3",children:"ð ìë¦¬ì¦ ì ë³´"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"ìë¦¬ì¦ ID"}),e.jsx("input",{type:"text",value:a.series_id||"",onChange:t=>r({...a,series_id:t.target.value}),placeholder:"ì: advent-2025",className:"w-full border border-gray-300 rounded px-3 py-2 text-sm"})]}),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:a.series_title||"",onChange:t=>r({...a,series_title:t.target.value}),placeholder:"ì: ë림ì 묵ì",className:"w-full border border-gray-300 rounded px-3 py-2 text-sm"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"Day"}),e.jsx("input",{type:"number",value:a.series_day||"",onChange:t=>r({...a,series_day:parseInt(t.target.value)}),placeholder:"3",className:"w-full border border-gray-300 rounded px-3 py-2 text-sm"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"Total Days"}),e.jsx("input",{type:"number",value:a.series_total||"",onChange:t=>r({...a,series_total:parseInt(t.target.value)}),placeholder:"7",className:"w-full border border-gray-300 rounded px-3 py-2 text-sm"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[o.fields.title&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"ì 목 *"}),e.jsx("input",{type:"text",value:a.title,onChange:t=>r({...a,title:t.target.value}),placeholder:"ì: íëëì ë§ìì ì´ììê³ íë ¥ì´ ìì´",className:"w-full border border-gray-300 rounded px-3 py-2"})]}),o.fields.verse&&e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"ì±ê²½ 구ì *"}),e.jsx("input",{type:"text",value:a.verse,onChange:t=>r({...a,verse:t.target.value}),placeholder:"ì: íë¸ë¦¬ì 4:12",className:"w-full border border-gray-300 rounded px-3 py-2"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"íµì¬ 구ì 본문"}),e.jsx("input",{type:"text",value:a.verse_text,onChange:t=>r({...a,verse_text:t.target.value}),placeholder:"ì¬í¸ìë ëì 목ììë...",className:"w-full border border-gray-300 rounded px-3 py-2"})]})]}),o.fields.bible_text&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"본문 *"}),e.jsx("textarea",{value:a.bible_text,onChange:t=>r({...a,bible_text:t.target.value}),placeholder:"ì±ê²½ 본문ì ì
ë ¥íì¸ì",className:"w-full border border-gray-300 rounded px-3 py-2 h-32"})]}),o.fields.key_verse&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"ð¡ íµì¬ í¬ì¸í¸"}),e.jsx("input",{type:"text",value:a.key_point||"",onChange:t=>r({...a,key_point:t.target.value}),placeholder:"ì´ ë§ìì íµì¬ì...",className:"w-full border border-gray-300 rounded px-3 py-2"})]}),o.fields.meditation&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"묵ì *"}),e.jsx("textarea",{value:a.meditation,onChange:t=>r({...a,meditation:t.target.value}),placeholder:"묵ì ë´ì©ì ì
ë ¥íì¸ì",className:"w-full border border-gray-300 rounded px-3 py-2 h-4
10"})]}),o.fields.application&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"â
ì ì©"}),e.jsx("textarea",{value:a.application||"",onChange:t=>r({...a,application:t.target.value}),placeholder:"ì´ ë§ìì ì´ë»ê² ì ì©í ì ììê¹ì?",className:"w-full border border-gray-300 rounded px-3 py-2 h-24"})]}),o.fields.questions&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"â 묵ì ì§ë¬¸"}),[0,1,2].map(t=>{var l;return e.jsx("input",{type:"text",value:((l=a.questions)==null?void 0:l[t])||"",onChange:m=>{const c=[...a.questions||["","",""]];c[t]=m.target.value,r({...a,questions:c})},placeholder:`ì§ë¬¸ ${t+1}`,className:"w-full border border-gray-300 rounded px-3 py-2 mb-2"},t)})]}),o.fields.prayer&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"기ë *"}),e.jsx("textarea",{value:a.prayer,onChange:t=>r({...a,prayer:t.target.value}),placeholder:"기ë문ì ì
ë ¥íì¸ì",className:"w-full border border-gray-300 rounded px-3 py-2 h-32"})]}),o.fields.hymn&&e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:[e.jsx(A,{className:"w-4 h-4 inline mr-1"}),"ì°¬ì¡ê° ë²í¸"]}),e.jsx("input",{type:"text",value:a.hymn||"",onChange:t=>r({...a,hymn:t.target.value}),placeholder:"ì: 204",className:"w-full border border-gray-300 rounded px-3 py-2"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"ì°¬ì¡ê° ì 목"}),e.jsx("input",{type:"text",value:a.hymn_title||"",onChange:t=>r({...a,hymn_title:t.target.value}),placeholder:"ì: ììë ì¬ë",className:"w-full border border-gray-300 rounded px-3 py-2"})]})]}),(o.fields.image||o.fields.audio)&&e.jsxs("div",{className:"p-4 bg-gray-50 rounded-lg border border-gray-200",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900 mb-3",children:"ð¨ 미ëì´"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.fields.image&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:[e.jsx(U,{className:"w-4 h-4 inline mr-1"}),"ì´ë¯¸ì§ URL"]}),e.jsx("input",{type:"text",value:a.image_url||"",onChange:t=>r({...a,image_url:t.target.value}),placeholder:"https://...",className:"w-full border border-gray-300 rounded px-3 py-2 text-sm"})]}),o.fields.audio&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:[e.jsx(W,{className:"w-4 h-4 inline mr-1"}),"ì¤ëì¤ URL"]}),e.jsx("input",{type:"text",value:a.audio_url||"",onChange:t=>r({...a,audio_url:t.target.value}),placeholder:"https://...",className:"w-full border border-gray-300 rounded px-3 py-2 text-sm"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"â° ë°ì¡ ìì ìê°"}),e.jsx("input",{type:"time",value:a.scheduled_time||"08:00",onChange:t=>r({...a,scheduled_time:t.target.value}),className:"border border-gray-300 rounded px-3 py-2"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"ì¬ì©ìë³ ì í¸ ìê°ì´ ì¤ì ëì§ ìì ê²½ì° ì´ ìê°ì ë°ì¡ë©ëë¤"})]})]}),e.jsxs("div",{className:"flex gap-3 mt-6",children:[e.jsxs("button",{onClick:()=>k(!1),disabled:p,className:"flex items-center gap-2 px-4 py-2 bg-gray-600 text-white rounded hover:bg-gray-700 disabled:opacity-50",children:[e.jsx(Y,{className:"w-4 h-4"}),e.jsx("span",{children:"ì´ì ì ì¥"})]}),e.jsxs("button",{onClick:()=>k(!0),disabled:p,className:"flex items-center gap-2 px-4 py-2 bg-green-600 text-white rounded hover:bg-green-700 disabled:opacity-50",children:[e.jsx(K,{className:"w-4 h-4"}),e.jsx("span",{children:"ë°í"})]})]})]})]})]})]})}export{ee as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.