1"use strict";(globalThis.webpackChunksophia_mvp_client||=[]).push([[1417,5290],{5290(e,t,o){o.r(t);var s=o(5043),a=o(9247),n=o(579);const l=function(e){let{isOpen:t,onClose:o,onSetNewGoal:l}=e;const[i,d]=(0,s.useState)(!1),c=(0,s.useRef)(null);return(0,s.useEffect)(()=>{if(t){c.current&&c.current.play().catch(e=>{console.error("[TodoCompletionModal] Video autoplay failed:",e)});const e=setTimeout(()=>d(!0),300);return()=>clearTimeout(e)}d(!1)},[t]),t?(0,n.jsxs)("div",{className:a.A.fullscreenOverlay,children:[(0,n.jsx)("video",{ref:c,className:a.A.backgroundVideo,src:"/celebrations/Investing in Your Future.mp4",loop:!0,muted:!0,playsInline:!0,preload:"auto"}),(0,n.jsx)("div",{className:a.A.overlay}),(0,n.jsx)("div",{className:a.A.celebrationBackground,children:[...Array(50)].map((e,t)=>(0,n.jsx)("div",{className:a.A.confetti,style:{left:100*Math.random()+"%",animationDelay:3*Math.random()+"s",animationDuration:3+2*Math.random()+"s",backgroundColor:["#4a9d7f","#6e8e87","#3a7d6f","#5fb89c","#2d6b5f","#ff6b6b","#ffd93d","#6bcf7f","#4ecdc4","#95e1d3","#a8dadc","#457b9d","#f4a261","#e76f51","#2a9d8f"][Math.floor(15*Math.random())]}},t))}),(0,n.jsxs)("div",{className:`${a.A.celebrationContent} ${i?a.A.visible:""}`,children:[(0,n.jsx)("h1",{className:a.A.celebrationTitle,children:"Mission Complete!"}),(0,n.jsx)("p",{className:a.A.celebrationSubtitle,children:"Congratulations! You've completed all the tasks in your action plan."}),(0,n.jsxs)("p",{className:a.A.celebrationMessage,children:["You've taken incredible steps toward your financial goals. ",(0,n.jsx)("br",{}),"Ready to set your next financial goal and keep the momentum going?"]}),(0,n.jsx)("button",{className:a.A.primaryButton,onClick:()=>{l&&l(),o()},children:"Set New Goal"})]})]}):null};o.d(t,["default",0,l])},1417(e,t,o){o.r(t),o.d(t,{default:()=>ae});var s=o(5043),a=o(4505),n=o(8417),l=o(486),i=o(5290),d=o(240),c=o(7928),r=o(6490),u=o(4511),m=o(8532),_=o(3496);const h="TodoList_container__PPNrl",p="TodoList_changePlanButton__msLMs",g="TodoList_modalContent__CusJm",x="TodoList_modalIcon__mBLKS",T="TodoList_modalTitle__uRy+M",j="TodoList_modalText__Zn2Iq",b="TodoList_modalButton__OHGRF",f="TodoList_stagesList__R2Mds",v="TodoList_goalCard__z-oIV",y="TodoList_goalTopRow__3E2Ry",N="TodoList_changePlanLink__ttdf+",L="TodoList_goalText__rcYjJ",C="TodoList_goalList__XLdor",k="TodoList_goalLabel__zr-oc",A="TodoList_introText__q0rPw",w="TodoList_timeline__EmOUE",S="TodoList_stageRow__7UQWR",P="TodoList_marker__NJH7L",E="TodoList_markerDot__i0NqW",B="TodoList_markerLine__jzox7",I="TodoList_completed__vYzK2",$="TodoList_current__a3Dbv",R="TodoList_stage__a6QvX",F="TodoList_stageHeader__VTjK8",D="TodoList_stageTopRow__p36P3",M="TodoList_stageNumber__Rgp7X",Y="TodoList_accordionIcon__EK5+U",z="TodoList_expanded__bmCD0",O="TodoList_stageTitle__f-kfG",G="TodoList_stageHeaderRight__zAARc",K="TodoList_progressBadge__Tt1yj",H="TodoList_todosList__hWFs9",V="TodoList_error__hIbEn",U="TodoList_emptyState__VFs2N",X="TodoList_editButton__80P9r",q="TodoList_inlineInput__Zs3Tb",J="TodoList_editActions__v3cmR",Q="TodoList_saveButton__LHywz",W="TodoList_deleteButtonInline__cQtBR",Z="TodoList_cancelButton__uXxcX",ee="TodoList_modalActions__GHxAF",te="TodoList_modalButtonSecondary__1DzJp",oe="TodoList_modalButtonDanger__N-nAy";var se=o(579);const ae=function(e){let{conversationId:t,objective:o,onBackToChat:ae,onChangePlan:ne}=e;const[le,ie]=(0,s.useState)([]),[de,ce]=(0,s.useState)(!0),[re,ue]=(0,s.useState)(null),[me,_e]=(0,s.useState)(new Set),[he,pe]=(0,s.useState)(null),[ge,xe]=(0,s.useState)(null),[Te,je]=(0,s.useState)({type:null,id:null,text:""}),be=e=>{if(!e||0===e.length)return!1;const t=e.flatMap(e=>e.todos||[]).filter(e=>!e.is_optional&&!e.is_deleted);return t.length>0&&t.every(e=>e.is_completed)},fe=e=>{for(const t of e){if(t.todos.some(e=>!e.is_optional&&!e.is_completed&&!e.is_deleted))return t.tier_number}if(e.length>0){if(be(e))return e[e.length-1].tier_number;for(const t of e)if(t.todos.length>0)return t.tier_number;return 1}return 1},ve=(0,s.useCallback)(async()=>{try{ue(null);const e=n.A.getTodos();if(e){if(ie(e),e.length>0){const t=fe(e);_e(new Set([t]))}return void ce(!1)}ce(!0);const o=await a.todosAPI.getTodos(t);
1if(n.A.setTodos(o),ie(o),o.length>0){const e=fe(o);_e(new Set([e]))}}catch(e){console.error("Failed to load todos:",e),ue(e.message)}finally{ce(!1)}},[t]);(0,s.useEffect)(()=>{t&&ve()},[t,ve]),(0,s.useEffect)(()=>n.A.subscribe("todos",e=>{ie(e)}),[]),(0,s.useEffect)(()=>{const e=e=>{console.log("[TodoList] Todos refreshed via custom event - updating UI"),e.detail&&ie(e.detail)};return window.addEventListener("todosRefreshed",e),()=>window.removeEventListener("todosRefreshed",e)},[]),(0,s.useEffect)(()=>{if(le.length>0){const e=document.querySelector(`.${f}`);e&&(e.scrollTop=0)}},[le.length]);const ye=fe(le),Ne=(0,u.F7)(o),Le=e=>{const t=new Set(me);t.has(e)?t.delete(e):t.add(e),_e(t)},Ce=async()=>{if(!Te.text.trim())return void je({type:null,id:null,text:""});const e=Te.id,t=Te.text,o=le.map(o=>({...o,todos:o.todos.map(o=>o.id===e?{...o,todo_text:t}:o)}));ie(o),n.A.setTodos(o),je({type:null,id:null,text:""}),a.todosAPI.updateTodo(e,t).catch(e=>{console.error("Failed to update todo:",e),ue("Your changes may not have been saved. Please try again."),setTimeout(()=>ue(null),4e3),ve()})},ke=()=>{je({type:null,id:null,text:""})},Ae=async()=>{if(!Te.text.trim())return void je({type:null,id:null,text:""});const e=Te.id,o=Te.text,s=le.map(t=>t.tier_number===e?{...t,tier_title:o}:t);ie(s),n.A.setTodos(s),je({type:null,id:null,text:""}),a.todosAPI.updateStage(t,e,o).catch(e=>{console.error("Failed to update stage:",e),ue("Your changes may not have been saved. Please try again."),setTimeout(()=>ue(null),4e3),ve()})},we=()=>{je({type:null,id:null,text:""})},Se=async e=>{let{todoId:o,onComplete:s,onError:l}=e;try{await a.todosAPI.toggleTodo(o);const e=await a.todosAPI.getTodos(t);n.A.setTodos(e),ie(e);const l=e.find(e=>e.todos.some(e=>e.id===o));if(l){const t=l.todos.find(e=>e.id===o),s=fe(e);if(t&&t.is_completed&&l.tier_number===s){if(l.todos.filter(e=>!e.is_optional).every(e=>e.is_completed)){const t=e.find(e=>e.tier_number===s+1);t?(pe("stage_unlock"),_e(new Set([t.tier_number]))):pe("all_complete")}}}s&&s()}catch(i){console.error("[TodoList] Failed to toggle todo:",i),ue(i.message||"Failed to update todo"),setTimeout(()=>ue(null),3e3),l&&l(i.message||"Failed to update todo")}};return de?(0,se.jsxs)("div",{className:h,children:[(0,se.jsx)(m.A,{title:"Action Plan",onBack:ae,backLabel:"Chat",actions:(0,se.jsx)("button",{className:p,onClick:ne,children:"Change my action plan"})}),(0,se.jsx)(c.A,{text:"Loading your action plan...",indicator:"dots"})]}):re?(0,se.jsxs)("div",{className:h,children:[(0,se.jsx)(m.A,{title:"Action Plan",onBack:ae,backLabel:"Chat",actions:(0,se.jsx)("button",{className:p,onClick:ne,children:"Change my action plan"})}),(0,se.jsxs)("div",{className:V,children:["Failed to load todos: ",re]})]}):0===le.length?(0,se.jsxs)("div",{className:h,children:[(0,se.jsx)(m.A,{title:"Action Plan",onBack:ae,backLabel:"Chat",actions:(0,se.jsx)("button",{className:p,onClick:ne,children:"Change my action plan"})}),(0,se.jsxs)("div",{className:U,children:[(0,se.jsx)("p",{children:"No action plan yet."}),(0,se.jsx)("p",{children:"Complete onboarding to get started."})]})]}):(0,se.jsxs)("div",{className:h,children:[(0,se.jsx)(m.A,{title:"Action Plan",subtitle:`Stage ${ye} of ${le.length} active`,onBack:ae,backLabel:"Chat"}),(0,se.jsx)(d.A,{isOpen:"stage_unlock"===he,onClose:()=>pe(null),labelledBy:"todo-stage-unlock-title",size:"sm",showClose:!1,children:(0,se.jsxs)("div",{className:g,children:[(0,se.jsx)("div",{className:x,"aria-hidden":"true",children:(0,se.jsx)(r.uQ,{size:48})}),(0,se.jsx)("h2",{className:T,id:"todo-stage-unlock-title",children:"New Stage Unlocked!"}),(0,se.jsx)("p",{className:j,children:"Great progress! You've completed the previous stage and unlocked the next one."}),(0,se.jsx)("button",{className:b,onClick:()=>pe(null),children:"Continue"})]})}),(0,se.jsx)(i.default,{isOpen:"all_complete"===he,onClose:()=>pe(null),onSetNewGoal:ne}),(0,se.jsx)(d.A,{isOpen:Boolean(ge),onClose:()=>xe(null),labelledBy:"todo-delete-confirm-title",size:"sm",showClose:!1,children:ge&&(0,se.jsxs)("div",{className:g,children:[(0,se.jsx)("div",{className:x,"aria-hidden":"true",children:(0,se.jsx)(r.id,{size:48})}),(0,se.jsxs)("h2",{className:T,id:"todo-delete-confirm-title",children:["Delete ","todo"===ge.type?"Task":"Stage","?"]}),(0,se.jsxs)("p",{className:j,children:['Are you sure you want to delete "',ge.name,'"?',"stage"===ge.type&&" This will delete all tasks in this stage.",(0,se.jsx)("br",{}),"This action cannot be undone."]}),(0,se.jsxs)("div",{className:ee,children:[(0,se.jsx)("button",{className:oe,onClick:()=>{"todo"===ge.type?(async e=>{const t=le.map(t=>({...t,todos:t.todos.filter(t=>t.id!==e)}));ie(t),n.A.setTodos(t),xe(null),be(t)&&pe("all_complete"),a.todosAPI.deleteTodo(e).catch(e=>{console.error("Failed to delete todo:",e),ue("Your changes may not have been saved. Please try again."),setTimeout(()=>ue(null),4e3),ve()})})(ge.id):(async e=>{const o=le.filter(t=>t.tier_number!==e);ie(o),n.A.setTodos(o),xe(null),a.todosAPI.deleteStage(t,e).catch(e=>{console.error("Failed to delete stage:",e),ue("Your changes may not have been saved. Please try again."),setTimeout(()=>ue(null),4e3),ve()})})(ge.id)},children:"Delete"}),(0,se.jsx)("button",{className:te,onClick:()=>xe(null),children:"Cancel"})]})]})}),(0,se.jsxs)("div",{className:f,children:[Ne.length>0&&(0,se.jsxs)("div",{className:v,children:[(0,se.jsxs)("div",{className:y,children:[(0,se.jsx)("span",{className:k,children:Ne.length>1?"Your goals":"Your goal"}),(0,se.jsx)("button",{className:N,onClick:ne,children:"Change my action plan"})]}),1===Ne.length?(0,se.jsx)("h2",{className:L,children:Ne[0].goal}):(0,se.jsx)("ul",{className:C,children:Ne.map(e=>(0,se.jsx)("li",{children:e.goal},e.rank))})]}),(0,se.jsx)("p",{className:A,children:"These are some actions to get you started on the goals you selected. Once you complete these actions you can choose the same goal again and it will bring more action steps."}),(0,se.jsx)("div",{className:w,children:le.map((e,t)=>{const o=e.tier_number,s=(e=>{const t=e.todos.filter(e=>!e.is_deleted&&!e.is_optional);return{completed:t.filter(e=>e.is_completed).length,total:t.length}})(e),a=(e=>e<ye)(o),n=o===ye,i=me.has(o),d=t===le.length-1,c=(0,u.Kb)(e.tier_title),r="stage"!==Te.type?{role:"button",tabIndex:0,"aria-expanded":i,"aria-controls":`stage-todos-${o}`,"aria-label":`Stage ${o}: ${c}`,onClick:()=>Le(o),onKeyDown:(0,_.W)(()=>Le(o))}:{};return(0,se.jsxs)("div",{className:`${S} ${a?I:""} ${n?$:""}`,children:[(0,se.jsxs)("div",{className:P,"aria-hidden":"true",children:[(0,se.jsx)("div",{className:E,
1children:a?"\u2713":o}),!d&&(0,se.jsx)("div",{className:B})]}),(0,se.jsxs)("div",{className:R,children:[(0,se.jsxs)("div",{className:F,...r,children:[(0,se.jsxs)("div",{className:D,children:[(0,se.jsxs)("span",{className:M,children:["STAGE ",o]}),(0,se.jsx)("div",{className:G,onClick:e=>e.stopPropagation(),children:"stage"===Te.type&&Te.id===o?(0,se.jsxs)("div",{className:J,children:[(0,se.jsx)("button",{className:Q,onClick:e=>{e.stopPropagation(),Ae()},title:"Save","aria-label":`Save name for stage ${o}`,children:(0,se.jsx)("span",{"aria-hidden":"true",children:"\u2713"})}),(0,se.jsx)("button",{className:W,onClick:e=>{e.stopPropagation(),xe({type:"stage",id:o,name:c})},title:"Delete stage","aria-label":`Delete stage: ${c}`,children:(0,se.jsx)("span",{"aria-hidden":"true",children:"\xd7"})}),(0,se.jsx)("button",{className:Z,onClick:e=>{e.stopPropagation(),we()},title:"Cancel","aria-label":`Cancel editing stage ${o}`,children:(0,se.jsx)("span",{"aria-hidden":"true",children:"\u21a9"})})]}):(0,se.jsxs)(se.Fragment,{children:[(0,se.jsxs)("span",{className:K,children:[s.completed,"/",s.total," complete"," ",s.completed===s.total?"\u2713":""]}),(0,se.jsx)("button",{className:X,onClick:e=>{e.stopPropagation(),je({type:"stage",id:o,text:c})},title:"Edit","aria-label":`Rename stage ${o}: ${c}`,children:(0,se.jsx)("span",{"aria-hidden":"true",children:"\xb7\xb7\xb7"})})]})}),(0,se.jsx)("span",{className:`${Y} ${i?z:""}`,"aria-hidden":"true",children:"\u25bc"})]}),"stage"===Te.type&&Te.id===o?(0,se.jsx)("input",{type:"text",className:q,value:Te.text,onChange:e=>je({...Te,text:e.target.value}),onKeyDown:e=>{"Enter"===e.key&&Ae(),"Escape"===e.key&&we()},onClick:e=>e.stopPropagation(),autoFocus:!0}):(0,se.jsx)("span",{className:O,children:c})]}),i&&(0,se.jsx)("div",{className:H,id:`stage-todos-${o}`,children:e.todos.filter(e=>!e.is_deleted).map(e=>(0,se.jsx)(l.A,{todoId:e.id,todoText:e.todo_text,isCompleted:e.is_completed,isOptional:e.is_optional,variant:"list",onToggle:Se,showActions:!0,onEdit:()=>{return t=e.id,o=e.todo_text,void je({type:"todo",id:t,text:o});var t,o},onDelete:()=>xe({type:"todo",id:e.id,name:e.todo_text}),isEditing:"todo"===Te.type&&Te.id===e.id,editValue:Te.text,onEditChange:e=>je({...Te,text:e}),onEditSave:Ce,onEditCancel:ke},e.id))})]})]},o)})})]})]})}}}]); 2//# sourceMappingURL=1417.cdab2420.chunk.js.map
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.