(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,70925,e=>{"use strict";var t=e.i(43476),r=e.i(71645),a=e.i(63398),s=e.i(1569),n=e.i(77237),o=e.i(22677),l=e.i(87922);let i={introEnabled:!0,outroEnabled:!0,sessionTotalMinutes:30,autoAdvance:!1,vibrateOnTimeUp:!0};var d=e.i(58579),c=e.i(51264),u=e.i(83656),x=e.i(37902),p=e.i(2593),g=e.i(27963);function m({prayerLog:e,lang:r}){let a=(0,d.getUiText)(r),s=new Date,n=new Date;n.setFullYear(s.getFullYear()-1);let o=Object.entries(e).map(([e,t])=>({date:e,count:t.count,durationSeconds:t.durationSeconds}));return(0,t.jsxs)("div",{className:"jsx-519e488ee2b2172b mt-4",children:[(0,t.jsx)(p.default,{startDate:n,endDate:s,values:o,showWeekdayLabels:!0,tooltipDataAttrs:e=>{let t=e?.count??0,r=Math.round((e?.durationSeconds??0)/60);return{"data-tip":(0,g.replaceText)(a.prayerHeatmapTooltip,{count:t,minutes:r})}},classForValue:e=>e&&e.count?1===e.count?"color-scale-1":e.count<=3?"color-scale-2":"color-scale-3":"color-empty"}),(0,t.jsx)(x.default,{id:"519e488ee2b2172b",children:".color-empty{fill:#e2e8f0}.dark .color-empty{fill:#374151}.color-scale-1{fill:#bfdbfe}.color-scale-2{fill:#60a5fa}.color-scale-3{fill:#2563eb}.color-scale-4{fill:#1d4ed8}"})]})}function b({type:e,initial:a,t:s,onSave:n,onCancel:o,onRemove:l}){let[i,d]=(0,r.useState)(a?.startDate??""),[c,u]=(0,r.useState)(a?.endDate??""),[x,p]=(0,r.useState)(a?.startTime??""),[g,m]=(0,r.useState)(a?.endTime??""),[y,h]=(0,r.useState)(a?.goalText??""),[f,k]=(0,r.useState)(a?.reminderEnabled??!1),[N,j]=(0,r.useState)(""),v="focus"===e?s.prayerFocusSessionTitle:s.prayerFastingSessionTitle,S=i.length>0&&c.length>0&&c>=i&&(!f||x.length>0);async function w(e){if(!e){k(!1),j("");return}if("u"d(e.target.value),required:!0,className:"px-3 py-2 text-sm border rounded dark:bg-gray-800 dark:border-gray-600 dark:text-white focus:outline-none focus:ring-1 focus:ring-blue-400"})]}),(0,t.jsxs)("label",{className:"flex flex-col gap-1 text-xs text-gray-500 dark:text-gray-400",children:[s.prayerSessionEndDate,(0,t.jsx)("input",{type:"date",value:c,onChange:e=>u(e.target.value),required:!0,className:"px-3 py-2 text-sm border rounded dark:bg-gray-800 dark:border-gray-600 dark:text-white focus:outline-none focus:ring-1 focus:ring-blue-400"})]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,t.jsxs)("label",{className:"flex flex-col gap-1 text-xs text-gray-500 dark:text-gray-400",children:[s.prayerSessionStartTime,(0,t.jsx)("input",{type:"time",step:300,value:x,onChange:e=>p(e.target.value),className:"px-3 py-2 text-sm border rounded dark:bg-gray-800 dark:border-gray-600 dark:text-white focus:outline-none focus:ring-1 focus:ring-blue-400"})]}),(0,t.jsxs)("label",{className:"flex flex-col gap-1 text-xs text-gray-500 dark:text-gray-400",children:[s.prayerSessionEndTime,(0,t.jsx)("input",{type:"time",step:300,value:g,onChange:e=>m(e.target.value),className:"px-3 py-2 text-sm border rounded dark:bg-gray-800 dark:border-gray-600 dark:text-white focus:outline-none focus:ring-1 focus:ring-blue-400"})]})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("textarea",{value:y,onChange:e=>{e.target.value.length<=300&&h(e.target.value)},placeholder:s.prayerSessionGoalPlaceholder,rows:3,className:"w-full px-3 py-2 text-sm border rounded resize-none dark:bg-gray-800 dark:border-gray-600 dark:text-white focus:outline-none focus:ring-1 focus:ring-blue-400 leading-relaxed"}),(0,t.jsxs)("div",{className:"text-right text-xs text-gray-400",children:[y.length," / ",300]})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[(0,t.jsx)("input",{type:"checkbox",checked:f,onChange:e=>w(e.target.checked),className:"cursor-pointer"}),s.prayerSessionReminderToggle]}),N&&(0,t.jsx)("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:N})]}),(0,t.jsxs)("div",{className:"flex items-center justify-end gap-2 pt-1",children:[a&&l&&(0,t.jsx)("button",{onClick:l,className:"mr-auto px-3 py-1 text-sm text-red-500 hover:text-red-600 dark:text-red-400 dark:hover:text-red-300 cursor-pointer",children:s.prayerSessionRemove}),(0,t.jsx)("button",{onClick:o,className:"px-3 py-1 text-sm text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 cursor-pointer",children:s.prayerNoteCancel}),(0,t.jsx)("button",{onClick:function(){S&&n({type:e,startDate:i,endDate:c,startTime:x||void 0,endTime:g||void 0,goalText:y.trim()?y.trim():void 0,reminderEnabled:f})},disabled:!S,className:"px-3 py-1 text-sm bg-blue-600 text-white rounded hover:bg-blue-700 disabled:opacity-40 disabled:cursor-default cursor-pointer transition-colors",children:s.prayerSessionSave})]})]})}function y(e){let t=Math.max(0,Math.floor(e));return`${String(Math.floor(t/60)).padStart(2,"0")}:${String(t%60).padStart(2,"0")}`}function h({notes:e,reorderNotes:a,totalMinutes:s,onTotalMinutesChange:n,onStart:o,onClose:l,t:i}){let d,c,u=(0,r.useMemo)(()=>e.filter(e=>"praying"===e.status).sort((e,t)=>e.sortOrder-t.sortOrder),[e]),x={hours:Math.floor((d=Math.max(0,Math.floor(s)))/60),minutes:d%60},[p,m]=(0,r.useState)(x.hours),[b,y]=(0,r.useState)(x.minutes),f=Number.isFinite(c=60*Math.floor(p)+Math.floor(b))?Math.min(720,Math.max(1,c)):1,k=(0,r.useMemo)(()=>(function(e,t){if(t<=0)return[];let r=Math.max(0,Math.floor(e));if(r<=0)return Array(t).fill(0);if(r+(tr===t-1?a+s:a)})(f,u.length),[f,u.length]),N=u.length>0,j=k.some(e=>0===e),v=(0,r.useRef)(f);return(0,r.useEffect)(()=>{v.current=f},[f]),(0,r.useEffect)(()=>{if(f===s)return;let e=setTimeout(()=>n(f),600);return()=>clearTimeout(e)},[f,s,n]),(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 px-4",children:(0,t.jsxs)("div",{role:"dialog","aria-modal":"true","aria-labelledby":"prayer-session-setup-title",className:"flex max-h-[85vh] w-full max-w-md flex-col gap-4 rounded-2xl bg-white p-5 shadow-2xl dark:bg-gray-900 dark:text-white",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("h2",{id:"prayer-session-setup-title",className:"text-lg font-bold",children:["๐Ÿ™ ",i.prayerSessionSetupTitle]}),(0,t.jsx)("button",{type:"button","aria-label":i.close,onClick:l,className:"rounded-full border border-gray-300 px-3 py-1 text-sm dark:border-gray-600 dark:text-gray-300 cursor-pointer",children:"โœ•"})]}),0===u.length?(0,t.jsx)("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:i.prayerSessionSetupEmpty}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"rounded-lg border border-gray-200 p-3 dark:border-gray-700",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:i.prayerSessionTotalTime}),(0,t.jsxs)("label",{className:"ml-auto flex items-center gap-1 text-sm",children:[(0,t.jsx)("input",{type:"number",min:0,max:Math.floor(12),value:p,onChange:e=>m(Math.min(Math.floor(12),Math.max(0,Number(e.target.value)||0))),className:"w-14 rounded border px-2 py-1 text-right dark:bg-gray-800 dark:border-gray-600 dark:text-white"}),i.prayerSessionHours]}),(0,t.jsxs)("label",{className:"flex items-center gap-1 text-sm",children:[(0,t.jsx)("input",{type:"number",min:0,max:59,value:b,onChange:e=>y(Math.min(59,Math.max(0,Number(e.target.value)||0))),className:"w-14 rounded border px-2 py-1 text-right dark:bg-gray-800 dark:border-gray-600 dark:text-white"}),i.prayerSessionMinutes]})]}),(0,t.jsx)("p",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:(0,g.replaceText)(i.prayerSessionAllocationHint,{count:u.length,total:f})}),j&&(0,t.jsx)("p",{className:"mt-1 text-xs text-amber-600 dark:text-amber-400",children:i.prayerSessionZeroAllocationWarning})]}),(0,t.jsx)("ul",{className:"flex-1 space-y-2 overflow-auto",children:u.map((e,r)=>(0,t.jsxs)("li",{className:"flex items-center gap-2 rounded-lg border border-gray-200 px-3 py-2 dark:border-gray-700",children:[(0,t.jsx)("span",{className:"flex-1 truncate text-sm font-medium",children:e.title}),(0,t.jsx)("span",{className:"shrink-0 rounded-full bg-blue-50 px-2 py-0.5 text-xs font-medium text-blue-700 dark:bg-blue-900/30 dark:text-blue-300",children:(0,g.replaceText)(i.prayerSessionMinutesShort,{minutes:k[r]??0})}),(0,t.jsxs)("div",{className:"flex shrink-0 gap-1",children:[(0,t.jsx)("button",{type:"button","aria-label":i.prayerSessionReorderUp,disabled:0===r,onClick:()=>{let e,t;return e=u[r],t=u[r-1],void(e&&t&&a(e.noteId,t.noteId))},className:"rounded border border-gray-300 px-2 py-1 text-xs disabled:opacity-30 disabled:cursor-default dark:border-gray-600 cursor-pointer",children:"โ–ฒ"}),(0,t.jsx)("button",{type:"button","aria-label":i.prayerSessionReorderDown,disabled:r===u.length-1,onClick:()=>{let e,t;return e=u[r],t=u[r+1],void(e&&t&&a(e.noteId,t.noteId))},className:"rounded border border-gray-300 px-2 py-1 text-xs disabled:opacity-30 disabled:cursor-default dark:border-gray-600 cursor-pointer",children:"โ–ผ"})]})]},e.noteId))})]}),(0,t.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,t.jsx)("button",{type:"button",onClick:l,className:"px-3 py-1 text-sm text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 cursor-pointer",children:i.prayerNoteCancel}),(0,t.jsx)("button",{type:"button",disabled:!N,onClick:function(){N&&(v.current!==s&&n(v.current),o(u.map(e=>e.noteId),k))},className:"rounded-full bg-blue-600 px-4 py-2 text-sm font-medium text-white hover:bg-blue-700 disabled:opacity-40 disabled:cursor-default cursor-pointer transition-colors",children:i.prayerSessionBegin})]})]})})}function f({notes:e,orderedNoteIds:a,allocatedMinutes:s,introEnabled:n,introText:o,outroEnabled:l,outroText:i,autoAdvance:d,vibrateOnTimeUp:c,markPrayed:u,onClose:x,t:p}){let[m,b]=(0,r.useState)(()=>0===a.length?"done":n?"intro":"praying"),[h,k]=(0,r.useState)(0),[N,j]=(0,r.useState)(0),[v,S]=(0,r.useState)(0),[w]=(0,r.useState)(()=>Date.now()),T=(0,r.useRef)(w),C=(0,r.useRef)(-1),A=(s[h]??0)*60,M=A-N,D=A>0&&M<=0,I=(0,r.useCallback)(()=>{let e=a[h];if(!e)return;let t=Math.round((Date.now()-T.current)/1e3);u(e,t),S(e=>e+t),T.current=Date.now(),j(0);let r=h+1;r>=a.length?b(l?"outro":"done"):k(r)},[h,u,a,l]);if((0,r.useEffect)(()=>{if("praying"!==m)return;let e=()=>j(Math.floor((Date.now()-T.current)/1e3));e();let t=setInterval(e,1e3);return()=>clearInterval(t)},[m,h]),(0,r.useEffect)(()=>{"praying"!==m||!D||C.current!==h&&(C.current=h,c&&function(){try{"u">typeof navigator&&"function"==typeof navigator.vibrate&&navigator.vibrate([200,100,200])}catch{}}(),d&&I())},[m,D,h,c,d,I]),"intro"===m)return(0,t.jsxs)("div",{className:"fixed inset-0 z-50 flex flex-col items-center justify-center bg-white px-6 text-center dark:bg-gray-900 dark:text-white",children:[(0,t.jsx)("button",{type:"button","aria-label":p.close,onClick:x,className:"absolute right-4 top-4 rounded-full border border-gray-300 px-3 py-1 text-sm dark:border-gray-600 dark:text-gray-300 cursor-pointer",children:"โœ•"}),(0,t.jsx)("p",{className:"max-w-md whitespace-pre-wrap text-base leading-relaxed text-gray-700 dark:text-gray-300",children:o}),(0,t.jsxs)("button",{type:"button",onClick:function(){T.current=Date.now(),b("praying")},className:"mt-8 rounded-full bg-blue-600 px-6 py-3 text-base font-semibold text-white hover:bg-blue-700 cursor-pointer transition-colors",children:["๐Ÿ™ ",p.prayerSessionBegin]})]});if("praying"===m){let r=a[h],n=e.find(e=>e.noteId===r),o=a.slice(h+1).map((t,r)=>({note:e.find(e=>e.noteId===t),minutes:s[h+1+r]??0})).filter(e=>!!e.note);return(0,t.jsxs)("div",{className:"fixed inset-0 z-50 flex flex-col bg-white dark:bg-gray-900 dark:text-white",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between border-b border-gray-200 px-4 py-3 dark:border-gray-700",children:[(0,t.jsxs)("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:[h+1," / ",a.length]}),(0,t.jsx)("button",{type:"button",onClick:x,className:"text-sm text-gray-500 hover:text-red-500 dark:text-gray-400 dark:hover:text-red-400 cursor-pointer",children:p.prayerSessionExit})]}),(0,t.jsxs)("div",{className:"flex-1 overflow-auto px-4 py-6",children:[(0,t.jsx)("p",{className:"text-xs font-medium uppercase tracking-wide text-blue-600 dark:text-blue-400",children:p.prayerSessionCurrentTopic}),(0,t.jsx)("h2",{className:"mt-1 text-xl font-bold",children:n?.title}),n?.content&&(0,t.jsx)("p",{className:"mt-3 whitespace-pre-wrap text-sm text-gray-700 dark:text-gray-300",children:n.content}),(0,t.jsx)("div",{className:"mt-6",children:A>0?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,t.jsx)("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:D?p.prayerSessionOvertimeLabel:p.prayerSessionRemainingLabel}),(0,t.jsx)("span",{className:`font-mono text-4xl font-semibold tabular-nums ${D?"text-amber-600 dark:text-amber-400":""}`,children:D?`+${y(-M)}`:y(M)})]}),(0,t.jsx)("div",{className:"mt-2 h-1.5 w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700",children:(0,t.jsx)("div",{className:`h-full transition-all duration-1000 ${D?"bg-amber-500":"bg-blue-600"}`,style:{width:`${Math.min(100,N/A*100)}%`}})}),(0,t.jsx)("p",{className:"mt-2 text-xs text-gray-400 dark:text-gray-500",children:(0,g.replaceText)(p.prayerSessionAllocatedFor,{minutes:s[h]??0,elapsed:y(N)})})]}):(0,t.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,t.jsx)("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:p.prayerSessionElapsedLabel}),(0,t.jsx)("span",{className:"font-mono text-4xl font-semibold tabular-nums",children:y(N)})]})}),o.length>0&&(0,t.jsx)("ul",{className:"mt-8 space-y-1",children:o.map(({note:e,minutes:r})=>(0,t.jsxs)("li",{className:"flex items-center gap-2 text-sm text-gray-400 dark:text-gray-500",children:[(0,t.jsxs)("span",{className:"truncate",children:["ยท ",e.title]}),(0,t.jsx)("span",{className:"ml-auto shrink-0 tabular-nums",children:(0,g.replaceText)(p.prayerSessionMinutesShort,{minutes:r})})]},e.noteId))})]}),(0,t.jsx)("div",{className:"border-t border-gray-200 px-4 py-4 dark:border-gray-700",children:(0,t.jsxs)("button",{type:"button",onClick:I,className:"w-full rounded-full bg-blue-600 px-4 py-3 text-base font-semibold text-white hover:bg-blue-700 cursor-pointer transition-colors",children:["๐Ÿ™ ",p.prayerSessionMarkPrayed]})})]})}if("outro"===m)return(0,t.jsxs)("div",{className:"fixed inset-0 z-50 flex flex-col items-center justify-center bg-white px-6 text-center dark:bg-gray-900 dark:text-white",children:[(0,t.jsx)("p",{className:"max-w-md whitespace-pre-wrap text-base leading-relaxed text-gray-700 dark:text-gray-300",children:i}),(0,t.jsx)("button",{type:"button",onClick:()=>b("done"),className:"mt-8 rounded-full bg-blue-600 px-6 py-3 text-base font-semibold text-white hover:bg-blue-700 cursor-pointer transition-colors",children:p.prayerSessionClose})]});let E=Math.round(v/60);return(0,t.jsxs)("div",{className:"fixed inset-0 z-50 flex flex-col items-center justify-center bg-white px-6 text-center dark:bg-gray-900 dark:text-white",children:[(0,t.jsx)("h2",{className:"text-xl font-bold",children:p.prayerSessionDoneTitle}),(0,t.jsx)("p",{className:"mt-3 text-sm text-gray-600 dark:text-gray-300",children:(0,g.replaceText)(p.prayerSessionDoneSummary,{count:a.length,minutes:E})}),(0,t.jsx)("button",{type:"button",onClick:x,className:"mt-8 rounded-full bg-blue-600 px-6 py-3 text-base font-semibold text-white hover:bg-blue-700 cursor-pointer transition-colors",children:p.prayerSessionClose})]})}var k=e.i(61056);function N({t:e,settings:a,onSave:s}){let[n,o]=(0,r.useState)(a.introText??""),[l,i]=(0,r.useState)(a.outroText??"");return(0,t.jsxs)("div",{className:"mb-6 border rounded-lg p-4 dark:border-gray-700 space-y-3",children:[(0,t.jsx)("h3",{className:"font-medium",children:e.prayerSettingsTitle}),(0,t.jsxs)("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[(0,t.jsx)("input",{type:"checkbox",checked:a.introEnabled,onChange:e=>s({...a,introText:n,introEnabled:e.target.checked}),className:"cursor-pointer"}),e.prayerIntroToggleLabel]}),(0,t.jsx)("textarea",{value:n,onChange:e=>o(e.target.value),onBlur:()=>{n!==(a.introText??"")&&s({...a,introText:n})},placeholder:e.prayerIntroDefaultText,rows:3,className:"w-full px-3 py-2 text-sm border rounded resize-none dark:bg-gray-800 dark:border-gray-600 dark:text-white focus:outline-none focus:ring-1 focus:ring-blue-400 leading-relaxed"}),(0,t.jsxs)("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[(0,t.jsx)("input",{type:"checkbox",checked:a.outroEnabled,onChange:e=>s({...a,outroText:l,outroEnabled:e.target.checked}),className:"cursor-pointer"}),e.prayerOutroToggleLabel]}),(0,t.jsx)("textarea",{value:l,onChange:e=>i(e.target.value),onBlur:()=>{l!==(a.outroText??"")&&s({...a,outroText:l})},placeholder:e.prayerOutroDefaultText,rows:3,className:"w-full px-3 py-2 text-sm border rounded resize-none dark:bg-gray-800 dark:border-gray-600 dark:text-white focus:outline-none focus:ring-1 focus:ring-blue-400 leading-relaxed"}),(0,t.jsxs)("div",{className:"border-t pt-3 dark:border-gray-700 space-y-2",children:[(0,t.jsxs)("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[(0,t.jsx)("input",{type:"checkbox",checked:a.vibrateOnTimeUp,onChange:e=>s({...a,vibrateOnTimeUp:e.target.checked}),className:"cursor-pointer"}),e.prayerSessionVibrateToggle]}),(0,t.jsxs)("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[(0,t.jsx)("input",{type:"checkbox",checked:a.autoAdvance,onChange:e=>s({...a,autoAdvance:e.target.checked}),className:"cursor-pointer"}),e.prayerSessionAutoAdvanceToggle]}),(0,t.jsx)("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:e.prayerSessionTimerHint})]})]})}function j({t:e,initialTitle:a="",initialContent:s="",onSave:n,onCancel:o}){let[l,i]=(0,r.useState)(a),[d,c]=(0,r.useState)(s),u=(0,r.useRef)(null);(0,r.useEffect)(()=>{u.current&&(u.current.style.height="auto",u.current.style.height=`${u.current.scrollHeight}px`)},[d]);let x=l===a&&d===s,p=l.trim().length>0&&!x;return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("input",{type:"text",value:l,onChange:e=>i(e.target.value),maxLength:200,placeholder:e.prayerNoteTitlePlaceholder,className:"w-full px-3 py-2 text-sm font-medium border rounded dark:bg-gray-800 dark:border-gray-600 dark:text-white focus:outline-none focus:ring-1 focus:ring-blue-400"}),(0,t.jsx)("textarea",{ref:u,value:d,onChange:e=>c(e.target.value),maxLength:2e3,placeholder:e.prayerNoteContentPlaceholder,rows:3,className:"w-full px-3 py-2 text-sm border rounded resize-none overflow-hidden dark:bg-gray-800 dark:border-gray-600 dark:text-white focus:outline-none focus:ring-1 focus:ring-blue-400 leading-relaxed"}),(0,t.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,t.jsx)("button",{onClick:o,className:"px-3 py-1 text-sm text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 cursor-pointer",children:e.prayerNoteCancel}),(0,t.jsx)("button",{onClick:()=>{p&&n(l.trim(),d.trim())},disabled:!p,className:"px-3 py-1 text-sm bg-blue-600 text-white rounded hover:bg-blue-700 disabled:opacity-40 disabled:cursor-default cursor-pointer transition-colors",children:e.prayerNoteSave})]})]})}function v({item:e,t:r,locale:a,lang:s,isEditing:n,onStartEdit:o,onCancelEdit:l,onSaveEdit:i,onToggleAnswered:d,onToggleSpecial:c,onMarkPrayed:x,showHeatmap:p,onToggleHeatmap:g,showMemo:b,onToggleMemo:y,onAddMemo:h,onDeleteMemo:f,onOpenSession:k,onRemoveSession:N,isConfirmingDelete:w,onDelete:T}){return n?(0,t.jsx)("li",{className:"border rounded-lg p-4 dark:border-gray-700",children:(0,t.jsx)(j,{t:r,initialTitle:e.title,initialContent:e.content,onSave:i,onCancel:l})}):(0,t.jsxs)("li",{className:`flex flex-col gap-1 border rounded-lg p-4 ${e.isSpecial?"border-amber-400 bg-amber-50 dark:border-amber-500/60 dark:bg-amber-950/20":"dark:border-gray-700"}`,children:[(0,t.jsxs)("div",{className:"flex items-start gap-2",children:[(0,t.jsx)("button",{onClick:c,title:r.prayerMarkSpecial,className:`text-lg leading-none cursor-pointer ${e.isSpecial?"text-amber-500":"text-gray-300 dark:text-gray-600 hover:text-amber-400"}`,children:e.isSpecial?"โ˜…":"โ˜†"}),(0,t.jsxs)("button",{onClick:o,className:"text-left flex-1 cursor-pointer",children:[(0,t.jsx)("span",{className:"font-medium",children:e.title}),e.isSpecial&&(0,t.jsx)("span",{className:"ml-2 text-xs uppercase tracking-wide text-amber-600 dark:text-amber-400",children:r.prayerSpecialBadge})]}),(0,t.jsx)("span",{className:`text-xs shrink-0 px-2 py-0.5 rounded-full ${"answered"===e.status?"bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-300":"bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-300"}`,children:"answered"===e.status?r.prayerNoteFilterAnswered:r.prayerNoteFilterPraying})]}),e.content&&(0,t.jsx)("p",{className:"text-sm text-gray-700 dark:text-gray-300 whitespace-pre-wrap",children:e.content}),"answered"===e.status&&e.answeredAt&&(0,t.jsxs)("p",{className:"text-xs text-green-700 dark:text-green-400",children:[r.prayerNoteAnsweredOn," ",new Date(e.answeredAt).toLocaleDateString(a),e.answerNote?` โ€” ${e.answerNote}`:""]}),e.prayerSession?(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs text-gray-500 dark:text-gray-400",children:[(0,t.jsx)("span",{className:"px-2 py-0.5 rounded-full bg-purple-100 text-purple-700 dark:bg-purple-900/40 dark:text-purple-300",children:"focus"===e.prayerSession.type?r.prayerFocusSessionTitle:r.prayerFastingSessionTitle}),(0,t.jsxs)("span",{children:[e.prayerSession.startDate," ~ ",e.prayerSession.endDate]}),e.prayerSession.startTime&&(0,t.jsxs)("span",{children:[e.prayerSession.startTime,e.prayerSession.endTime?`โ€“${e.prayerSession.endTime}`:""]}),(0,t.jsx)("button",{onClick:()=>k(e.prayerSession.type),className:"px-3 py-1 rounded-full border border-blue-300 bg-blue-50 text-blue-700 hover:bg-blue-100 dark:border-blue-700 dark:bg-blue-900/30 dark:text-blue-300 dark:hover:bg-blue-900/50 cursor-pointer",children:r.prayerSessionEdit}),(0,t.jsx)("button",{onClick:N,className:"px-3 py-1 rounded-full border border-red-300 bg-red-50 text-red-600 hover:bg-red-100 dark:border-red-700 dark:bg-red-900/30 dark:text-red-300 dark:hover:bg-red-900/50 cursor-pointer",children:r.prayerSessionRemove})]}):(0,t.jsx)("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:(0,t.jsx)("button",{onClick:()=>k("fasting"),className:"px-3 py-1 rounded-full border border-purple-300 bg-purple-50 text-purple-700 hover:bg-purple-100 dark:border-purple-700 dark:bg-purple-900/30 dark:text-purple-300 dark:hover:bg-purple-900/50 cursor-pointer",children:r.prayerFastingSessionTitle})}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-3 mt-1",children:[(0,t.jsxs)("button",{onClick:x,className:"text-xs px-2 py-1 rounded-full bg-blue-50 text-blue-700 hover:bg-blue-100 dark:bg-blue-900/30 dark:text-blue-300 dark:hover:bg-blue-900/50 cursor-pointer",children:[r.prayerCheckButton," (",e.prayerLog[(0,u.toLocalDateString)()]?.count??0,")"]}),(0,t.jsx)("button",{onClick:g,className:"text-xs text-gray-500 hover:text-blue-600 dark:text-gray-400 dark:hover:text-blue-400 cursor-pointer",children:r.prayerHeatmapToggle}),(0,t.jsxs)("button",{onClick:y,className:"text-xs text-gray-500 hover:text-blue-600 dark:text-gray-400 dark:hover:text-blue-400 cursor-pointer",children:[r.prayerMemoToggle,e.memos?.length>0?` (${e.memos.length})`:""]}),(0,t.jsx)("span",{className:"text-xs text-gray-400",children:new Date(e.updatedAt).toLocaleDateString(a)}),(0,t.jsx)("button",{onClick:d,className:"text-xs text-gray-500 hover:text-blue-600 dark:text-gray-400 dark:hover:text-blue-400 cursor-pointer",children:"answered"===e.status?r.prayerNoteMarkPraying:r.prayerNoteMarkAnswered}),(0,t.jsx)("button",{onClick:T,className:`text-xs ml-auto cursor-pointer transition-colors ${w?"text-red-500 font-semibold":"text-gray-400 hover:text-red-500"}`,children:w?r.prayerNoteDeleteConfirm:r.prayerNoteDelete})]}),p&&(0,t.jsx)("div",{className:"mt-2",children:(0,t.jsx)(m,{prayerLog:e.prayerLog,lang:s})}),b&&(0,t.jsx)(S,{t:r,locale:a,memos:e.memos??[],onAdd:h,onDelete:f})]})}function S({t:e,locale:a,memos:s,onAdd:n,onDelete:o}){let[l,i]=(0,r.useState)(""),d=[...s].sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime());return(0,t.jsxs)("div",{className:"mt-2 border-t pt-2 dark:border-gray-700 space-y-2",children:[(0,t.jsxs)("div",{className:"flex items-start gap-2",children:[(0,t.jsx)("textarea",{value:l,onChange:e=>i(e.target.value),maxLength:500,placeholder:e.prayerMemoAddPlaceholder,rows:2,className:"flex-1 px-2 py-1 text-sm border rounded resize-none dark:bg-gray-800 dark:border-gray-600 dark:text-white focus:outline-none focus:ring-1 focus:ring-blue-400 leading-relaxed"}),(0,t.jsx)("button",{onClick:function(){l.trim()&&n(l)&&i("")},disabled:!l.trim(),className:"px-3 py-1 text-sm bg-blue-600 text-white rounded hover:bg-blue-700 disabled:opacity-40 disabled:cursor-default cursor-pointer transition-colors",children:e.prayerMemoAddButton})]}),0===d.length?(0,t.jsx)("p",{className:"text-xs text-gray-400",children:e.prayerMemoEmpty}):(0,t.jsx)("ul",{className:"space-y-1.5",children:d.map(r=>(0,t.jsxs)("li",{className:"flex items-start gap-2 text-sm",children:[(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("p",{className:"text-gray-700 dark:text-gray-300 whitespace-pre-wrap",children:r.text}),(0,t.jsx)("p",{className:"text-xs text-gray-400",children:new Date(r.createdAt).toLocaleDateString(a)})]}),(0,t.jsx)("button",{onClick:()=>o(r.id),title:e.prayerMemoDelete,className:"text-xs text-gray-400 hover:text-red-500 cursor-pointer shrink-0",children:"ร—"})]},r.id))})]})}e.s(["default",0,function(){let e,{user:u,status:x,signIn:p}=(0,a.useAuth)(),g=(0,k.useHydrated)(),{notes:y,loading:S,loadError:w,savePrayerNote:T,deletePrayerNote:C,markPrayed:A,addPrayerMemo:M,deletePrayerMemo:D,reorderNotes:I,reload:E}=(0,s.usePrayerNotes)(),{settings:L,loaded:O,saveSettings:P,reloadSettings:R}=function(){let{user:e,sessionReady:t}=(0,a.useAuth)(),s=e?.email||"",[d,c]=(0,n.useOwnedState)(s,i),[u,x]=(0,n.useOwnedState)(s,!1),p=(0,r.useRef)(0);(0,r.useEffect)(()=>{p.current+=1},[s]);let g=(0,r.useCallback)(()=>{if(!s||!t)return Promise.resolve();let e=++p.current;return(0,l.fetchWithRetry)("https://jwhhboergk.execute-api.ap-northeast-2.amazonaws.com/Prod/loadPrayerSettings",{headers:{Authorization:`Bearer ${(0,o.getSessionToken)()}`}}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(t=>{p.current===e&&(c({...i,...t}),x(!0))}).catch(e=>{console.error("Failed to load prayer settings:",e)})},[s,t,c,x]);return(0,r.useEffect)(()=>{g()},[g]),{settings:d,loaded:u,saveSettings:(0,r.useCallback)(async e=>{if(s){c(e),await (0,o.waitForSessionToken)();try{let t=await fetch("https://jwhhboergk.execute-api.ap-northeast-2.amazonaws.com/Prod/savePrayerSettings",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${(0,o.getSessionToken)()}`},body:JSON.stringify({data:e})});if(!t.ok)throw Error(`HTTP ${t.status}`)}catch(e){console.error("Failed to save prayer settings:",e)}}},[s,c]),reloadSettings:g}}(),F=(0,c.useUiLang)(),$=(0,d.getUiText)(F),z=(0,d.getUiLocale)(F),[B,U]=(0,r.useState)("all"),[H,q]=(0,r.useState)("recent"),[W,K]=(0,r.useState)(""),[V,Y]=(0,r.useState)(!1),[G,J]=(0,r.useState)(null),[Z,Q]=(0,r.useState)(null),[X,_]=(0,r.useState)(null),[ee,et]=(0,r.useState)(null),[er,ea]=(0,r.useState)(null),[es,en]=(0,r.useState)(!1),[eo,el]=(0,r.useState)(null),[ei,ed]=(0,r.useState)(!1),ec=(0,r.useRef)(null);if((0,r.useEffect)(()=>()=>{ec.current&&clearTimeout(ec.current)},[]),!g||"loading"===x||u&&S)return(0,t.jsx)("div",{className:"min-h-screen px-0 sm:px-2 md:px-6 py-6 bg-white dark:bg-gray-900 dark:text-white",children:(0,t.jsx)("p",{children:$.loading})});if(!u)return(0,t.jsxs)("div",{className:"min-h-screen px-0 sm:px-2 md:px-6 py-6 bg-white dark:bg-gray-900 dark:text-white",children:[(0,t.jsx)("h1",{className:"text-2xl font-bold mb-4",children:$.headerPrayerNotes}),(0,t.jsx)("p",{className:"text-gray-500 dark:text-gray-400 mb-4",children:$.prayerNoteLoginRequired}),(0,t.jsx)("button",{onClick:()=>p(),className:"px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 cursor-pointer",children:$.login})]});if(w&&0===y.length)return(0,t.jsxs)("div",{className:"min-h-screen px-0 sm:px-2 md:px-6 py-6 bg-white text-black dark:bg-gray-900 dark:text-white",children:[(0,t.jsx)("h1",{className:"text-2xl font-bold mb-4",children:$.headerPrayerNotes}),(0,t.jsxs)("div",{className:"rounded-xl border border-amber-200 bg-amber-50 px-6 py-10 text-center dark:border-amber-900/50 dark:bg-amber-950/30",children:[(0,t.jsx)("p",{className:"text-sm text-amber-800 dark:text-amber-200",children:$.noteLoadError}),(0,t.jsx)("button",{onClick:()=>E(),className:"mt-4 rounded-full bg-blue-600 px-4 py-2 text-sm font-medium text-white hover:bg-blue-700 cursor-pointer",children:$.searchRetry})]})]});let eu=y.filter(e=>"all"===B||e.status===B).filter(e=>{if(!W.trim())return!0;let t=W.toLowerCase();return e.title.toLowerCase().includes(t)||e.content.toLowerCase().includes(t)}).sort((e,t)=>{if(e.isSpecial!==t.isSpecial)return e.isSpecial?-1:1;if("manual"===H)return e.sortOrder-t.sortOrder;if("answered"===H){let r=e.answeredAt?new Date(e.answeredAt).getTime():0;return(t.answeredAt?new Date(t.answeredAt).getTime():0)-r}return new Date(t.updatedAt).getTime()-new Date(e.updatedAt).getTime()});function ex(e,t){T({noteId:e.noteId,title:e.title,content:e.content,status:e.status,createdAt:e.createdAt,answeredAt:e.answeredAt,answerNote:e.answerNote,isSpecial:e.isSpecial,sortOrder:e.sortOrder,prayerLog:e.prayerLog,prayerSession:t,memos:e.memos}),ea(null)}return(0,t.jsxs)("div",{className:"min-h-screen px-0 sm:px-2 md:px-6 py-6 bg-white text-black dark:bg-gray-900 dark:text-white",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,t.jsxs)("h1",{className:"text-2xl font-bold",children:[$.headerPrayerNotes,y.length>0&&(0,t.jsxs)("span",{className:"text-lg font-normal text-gray-500 dark:text-gray-400 ml-1",children:["(",y.length,")"]})]}),(0,t.jsx)("button",{onClick:()=>en(!0),className:"ml-auto text-sm px-3 py-1 rounded-full bg-blue-600 text-white hover:bg-blue-700 transition-colors cursor-pointer",children:$.prayerSessionStartButton}),(0,t.jsx)("button",{onClick:()=>ed(e=>!e),title:$.prayerSettingsTitle,"aria-label":$.prayerSettingsTitle,"aria-pressed":ei,className:`text-sm px-2 py-1 rounded border transition-colors cursor-pointer ${ei?"bg-blue-600 text-white border-blue-600":"border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:border-blue-400 hover:text-blue-600"}`,children:"โš™๏ธ"}),(0,t.jsx)("button",{onClick:()=>{Y(e=>!e),J(null)},className:"text-sm px-3 py-1 rounded border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:border-blue-400 hover:text-blue-600 transition-colors cursor-pointer",children:V?$.prayerNoteCancel:`+ ${$.prayerNoteAddTitle}`})]}),y.length>0&&(0,t.jsx)("div",{className:"mb-6 border rounded-lg p-4 dark:border-gray-700",children:(0,t.jsx)(m,{prayerLog:function(e){let t={};for(let r of e)for(let[e,a]of Object.entries(r.prayerLog)){let r=t[e]??{count:0,durationSeconds:0};t[e]={count:r.count+a.count,durationSeconds:r.durationSeconds+a.durationSeconds}}return t}(y),lang:F})}),ei&&(O?(0,t.jsx)(N,{t:$,settings:L,onSave:P}):(0,t.jsxs)("div",{className:"mb-6 border rounded-lg p-4 dark:border-gray-700 flex items-center gap-3",children:[(0,t.jsx)("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:$.loading}),(0,t.jsx)("button",{onClick:()=>R(),className:"text-xs text-blue-600 hover:underline cursor-pointer",children:$.searchRetry})]})),V&&(0,t.jsx)("div",{className:"mb-6 border rounded-lg p-4 dark:border-gray-700",children:(0,t.jsx)(j,{t:$,onSave:function(e,t){T({title:e,content:t,status:"praying"}),Y(!1)},onCancel:()=>Y(!1)})}),y.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"flex gap-2 mb-3",children:["all","praying","answered"].map(e=>(0,t.jsx)("button",{onClick:()=>U(e),className:`min-w-0 flex-1 sm:flex-none px-3 py-1 text-sm rounded-full border transition-colors ${B===e?"bg-blue-600 text-white border-blue-600":"border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:border-blue-400"}`,children:"all"===e?$.prayerNoteFilterAll:"praying"===e?$.prayerNoteFilterPraying:$.prayerNoteFilterAnswered},e))}),(0,t.jsxs)("select",{value:H,onChange:e=>q(e.target.value),className:"mb-3 px-2 py-1 text-sm border rounded dark:bg-gray-800 dark:border-gray-600 dark:text-white",children:[(0,t.jsx)("option",{value:"recent",children:$.prayerSortRecent}),(0,t.jsx)("option",{value:"answered",children:$.prayerSortAnswered}),(0,t.jsx)("option",{value:"manual",children:$.prayerSortManual})]}),(0,t.jsx)("input",{type:"text",value:W,onChange:e=>{K(e.target.value),Q(null)},placeholder:$.prayerNoteSearchPlaceholder,className:"w-full mb-4 px-3 py-2 text-sm border rounded dark:bg-gray-800 dark:border-gray-600 dark:text-white focus:outline-none focus:ring-1 focus:ring-blue-400"})]}),0===y.length?(0,t.jsx)("p",{className:"text-gray-500 dark:text-gray-400",children:$.prayerNoteEmpty}):0===eu.length?(0,t.jsx)("p",{className:"text-gray-500 dark:text-gray-400",children:$.noteSearchEmpty}):(0,t.jsx)("ul",{className:"space-y-3",children:eu.map(e=>(0,t.jsx)(v,{item:e,t:$,locale:z,lang:F,isEditing:G===e.noteId,onStartEdit:()=>{J(e.noteId),Y(!1)},onCancelEdit:()=>J(null),onSaveEdit:(t,r)=>{T({noteId:e.noteId,title:t,content:r,status:e.status,createdAt:e.createdAt,answeredAt:e.answeredAt,answerNote:e.answerNote,isSpecial:e.isSpecial,sortOrder:e.sortOrder,prayerLog:e.prayerLog,prayerSession:e.prayerSession,memos:e.memos}),J(null)},onToggleAnswered:()=>(function(e){if("answered"===e.status)return void T({noteId:e.noteId,title:e.title,content:e.content,status:"praying",createdAt:e.createdAt,answerNote:e.answerNote,isSpecial:e.isSpecial,sortOrder:e.sortOrder,prayerLog:e.prayerLog,prayerSession:e.prayerSession,memos:e.memos});let t=window.prompt($.prayerNoteAnswerNotePlaceholder,e.answerNote??""),r=null===t?e.answerNote:t.trim()||void 0;T({noteId:e.noteId,title:e.title,content:e.content,status:"answered",createdAt:e.createdAt,answeredAt:new Date().toISOString(),answerNote:r,isSpecial:e.isSpecial,sortOrder:e.sortOrder,prayerLog:e.prayerLog,prayerSession:e.prayerSession,memos:e.memos})})(e),onToggleSpecial:()=>{T({noteId:e.noteId,title:e.title,content:e.content,status:e.status,createdAt:e.createdAt,answeredAt:e.answeredAt,answerNote:e.answerNote,isSpecial:!e.isSpecial,sortOrder:e.sortOrder,prayerLog:e.prayerLog,prayerSession:e.prayerSession,memos:e.memos})},onMarkPrayed:()=>A(e.noteId),showHeatmap:X===e.noteId,onToggleHeatmap:()=>_(X===e.noteId?null:e.noteId),showMemo:ee===e.noteId,onToggleMemo:()=>et(ee===e.noteId?null:e.noteId),onAddMemo:t=>M(e.noteId,t),onDeleteMemo:t=>D(e.noteId,t),onOpenSession:t=>ea({noteId:e.noteId,type:t}),onRemoveSession:()=>ex(e,void 0),isConfirmingDelete:Z===e.noteId,onDelete:()=>{var t;Z===(t=e.noteId)?(C(t),Q(null),ec.current&&clearTimeout(ec.current)):(Q(t),ec.current&&clearTimeout(ec.current),ec.current=setTimeout(()=>Q(null),3e3))}},e.noteId))}),es&&(0,t.jsx)(h,{notes:y,reorderNotes:I,totalMinutes:L.sessionTotalMinutes,onTotalMinutesChange:e=>{O&&P({...L,sessionTotalMinutes:e})},onStart:(e,t)=>{en(!1),el({orderedNoteIds:e,allocatedMinutes:t})},onClose:()=>en(!1),t:$}),eo&&(0,t.jsx)(f,{notes:y,orderedNoteIds:eo.orderedNoteIds,allocatedMinutes:eo.allocatedMinutes,autoAdvance:L.autoAdvance,vibrateOnTimeUp:L.vibrateOnTimeUp,introEnabled:L.introEnabled,introText:L.introText?.trim()||$.prayerIntroDefaultText,outroEnabled:L.outroEnabled,outroText:L.outroText?.trim()||$.prayerOutroDefaultText,markPrayed:A,onClose:()=>el(null),t:$}),er&&((e=y.find(e=>e.noteId===er.noteId))?(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",children:(0,t.jsx)("div",{className:"w-full max-w-md bg-white dark:bg-gray-900 rounded-lg max-h-[90vh] overflow-y-auto",children:(0,t.jsx)(b,{type:er.type,initial:e.prayerSession?.type===er.type?e.prayerSession:void 0,t:$,onSave:t=>ex(e,t),onCancel:()=>ea(null),onRemove:e.prayerSession?()=>{ex(e,void 0)}:void 0})})}):null)]})}],70925)}]);