1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="35b5c220-c1ec-4182-be68-2d14a791e4e8",e._sentryDebugIdIdentifier="sentry-dbid-35b5c220-c1ec-4182-be68-2d14a791e4e8")}catch(e){}}();"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[470],{47530:function(e,t,s){s.d(t,{D:function(){return n},N5:function(){return o},NZ:function(){return m},QO:function(){return i},SE:function(){return r},Td:function(){return x},YS:function(){return f},_c:function(){return c},bo:function(){return l},wt:function(){return d},xb:function(){return u}}),s(83079);var a=s(12119),r=(0,a.$)("75821e967b51c755796464f6e0b141395423cc3b");(0,a.$)("48e158364c4fb4c8ede8c91bf71fda1818d39bec");var n=(0,a.$)("c16552249b1674e0b84830e4215dea12fd05f119");(0,a.$)("af8cd9a5066ae75c37df77bbc39cbf52abafcb9c"),(0,a.$)("8375ac28d2ac43ca475207d49dd8d04c502a6773");var c=(0,a.$)("211b3ce6f37a78120feb0848617a91bba67f79fa"),d=(0,a.$)("6447915653ed541d19bea04e61115ede37cdecc8"),l=(0,a.$)("15f0df082d136ba126418752102c2dea8ce78285");(0,a.$)("4b4ebe0cacaa9d2248ee1728d0a1ea1cf2ed65be");var o=(0,a.$)("fe99010ab1b24740f5dcb67cb5fa32c340e0fc17"),i=(0,a.$)("9692a3d806d835acad312fd1fbf9bdaf77ec62bb");(0,a.$)("0d4a76a59291036e770ed28b7160faf3792ffda3");var m=(0,a.$)("cb9ed1e5ccb90218c30c3cce2e02c528521271bb"),u=(0,a.$)("3f8415657aa9bea174911d0130e6f2f8ca25c9bf"),f=(0,a.$)("493ffc74d1782008d9ef4d75fdf900f04b8042dc"),x=(0,a.$)("c2bf5bcf01129d3092053dc1b6c35d81c378ce9a")},90470:function(e,t,s){s.r(t),s.d(t,{default:function(){return Z}});var a=s(57437),r=s(2265),n=s(79820),c=s(51817),d=s(85929),l=s(70525),o=s(3085),i=s(21047),m=s(31047),u=s(91723),f=s(10407),x=s(12381),h=s(69174),b=s(27648),j=s(47530),p=s(2901),g=s(47625),N=s(21156),v=s(56940),y=s(97059),w=s(62994),k=s(8147),$=s(54061);function Z(e){let{accessUrl:t,templateId:s}=e,[Z,D]=(0,r.useState)([]),[E,V]=(0,r.useState)(!0),[A,M]=(0,r.useState)(null),[_,C]=(0,r.useState)(null);(0,r.useEffect)(()=>{(async()=>{try{V(!0),M(null);let a=await (0,j.N5)(t,s);if(!a.success){var e;throw Error(null!==(e=a.error)&&void 0!==e?e:"Failed to fetch mood check entries")}let r=[...a.data].sort((e,t)=>e.completedAt&&t.completedAt?new Date(t.completedAt).getTime()-new Date(e.completedAt).getTime():0);D(r)}catch(e){console.error("Error fetching mood check data:",e),M(e instanceof Error?e.message:"Failed to load mood check data")}finally{V(!1)}})()},[t,s]);let I=(()=>{if(Z.length<2)return null;let e=Z.slice(0,7).filter(e=>null!==e.moodValue);if(e.length<2)return null;let t=e[e.length-1],s=e[0];if(!t||!s||null===t.moodValue||null===s.moodValue)return null;let a=t.moodValue,r=s.moodValue-a;return .5>Math.abs(r)?"stable":r>0?"improving":"declining"})(),S=Z.filter(e=>null!==e.moodValue&&e.completedAt).slice(0,30).reverse().map(e=>({date:(0,p.WU)(new Date(e.completedAt),"MMM d"),mood:e.moodValue})),O=Z.length>0?Z.filter(e=>null!==e.moodValue).reduce((e,t)=>e+t.moodValue,0)/Z.filter(e=>null!==e.moodValue).length:0;return E?(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-12",children:[(0,a.jsx)(c.Z,{className:"h-8 w-8 animate-spin text-primary mb-3"}),(0,a.jsx)("p",{className:"text-muted-foreground",children:"Loading mood check data..."})]}):A?(0,a.jsxs)("div",{className:"text-center py-12",children:[(0,a.jsx)("p",{className:"text-destructive mb-2",children:"Error loading mood check data"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:A})]}):0===Z.length?(0,a.jsxs)("div",{className:"text-center py-12",children:[(0,a.jsx)(d.Z,{className:"h-12 w-12 text-muted-foreground/30 mx-auto mb-4"}),(0,a.jsx)("p",{className:"text-muted-foreground",children:"No mood check entries found for this template."})]}):(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[(0,a.jsxs)(n.Zb,{children:[(0,a.jsx)(n.Ol,{className:"pb-2",children:(0,a.jsx)(n.ll,{className:"text-sm font-medium",children:"Total Check-ins"})}),(0,a.jsx)(n.aY,{children:(0,a.jsx)("div",{className:"text-2xl font-bold",children:Z.length})})]}),(0,a.jsxs)(n.Zb,{children:[(0,a.jsx)(n.Ol,{className:"pb-2",children:(0,a.jsx)(n.ll,{className:"text-sm font-medium",children:"Average Mood"})}),(0,a.jsxs)(n.aY,{children:[(0,a.jsx)("div",{className:"text-2xl font-bold",children:O.toFixed(1)}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Out of 5"})]})]}),(0,a.jsxs)(n.Zb,{children:[(0,a.jsx)(n.Ol,{className:"pb-2",children:(0,a.jsx)(n.ll,{className:"text-sm font-medium",children:"Trend"})}),(0,a.jsx)(n.aY,{children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:["improving"===I&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(l.Z,{className:"h-5 w-5 text-green-600"}),(0,a.jsx)("span",{className:"text-green-600 font-medium",children:"Improving"})]}),"declining"===I&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.Z,{className:"h-5 w-5 text-red-600"}),(0,a.jsx)("span",{className:"text-red-600 font-medium",children:"Declining"})]}),"stable"===I&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i.Z,{className:"h-5 w-5 text-blue-600"}),(0,a.jsx)("span",{className:"text-blue-600 font-medium",children:"Stable"})]}),!I&&(0,a.jsx)("span",{className:"text-muted-foreground",children:"Not enough data"})]})})]})]}),S.length>1&&(0,a.jsxs)(n.Zb,{children:[(0,a.jsx)(n.Ol,{children:(0,a.jsx)(n.ll,{className:"text-base",children:"Mood Over Time"})}),(0,a.jsx)(n.aY,{children:(0,a.jsx)("div",{className:"h-64 w-full",children:(0,a.jsx)(g.h,{width:"100%",height:"100%",children:(0,a.jsxs)(N.w,{data:S,children:[(0,a.jsx)(v.q,{strokeDasharray:"3 3",className:"stroke-muted"}),(0,a.jsx)(y.K,{dataKey:"date",className:"text-xs",tick:{fill:"
1currentColor"}}),(0,a.jsx)(w.B,{domain:[0,5],className:"text-xs",tick:{fill:"currentColor"}}),(0,a.jsx)(k.u,{contentStyle:{backgroundColor:"hsl(var(--background))",border:"1px solid hsl(var(--border))",borderRadius:"6px"}}),(0,a.jsx)($.x,{type:"monotone",dataKey:"mood",stroke:"hsl(var(--primary))",strokeWidth:2,dot:{fill:"hsl(var(--primary))"}})]})})})})]}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"Recent Entries"}),(0,a.jsx)("div",{className:"space-y-3",children:Z.slice(0,20).map(e=>e.completedAt?(0,a.jsx)(n.Zb,{className:"hover:shadow-md transition-shadow",children:(0,a.jsx)(n.aY,{className:"p-4",children:(0,a.jsxs)("div",{className:"flex items-start justify-between",children:[(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[e.moodEmoji&&(0,a.jsx)("span",{className:"text-2xl",children:e.moodEmoji}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("span",{className:"font-medium",children:[e.moodValue,"/5"]}),e.moodLabel&&(0,a.jsx)(h.C,{variant:"secondary",className:"text-xs",children:e.moodLabel})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-1",children:[(0,a.jsx)(m.Z,{className:"h-3 w-3"}),(0,a.jsx)("span",{children:(0,p.WU)(new Date(e.completedAt),"MMM d, yyyy")}),(0,a.jsx)(u.Z,{className:"h-3 w-3 ml-2"}),(0,a.jsx)("span",{children:(0,p.WU)(new Date(e.completedAt),"h:mm a")})]})]})]}),e.patientNotes&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground mt-2 pl-11",children:e.patientNotes})]}),(0,a.jsx)(b.default,{href:"/home/".concat(t,"/mood-checks?templateId=").concat(s,"&entryId=").concat(e.id),children:(0,a.jsx)(x.z,{variant:"ghost",size:"sm",children:(0,a.jsx)(f.Z,{className:"h-4 w-4"})})})]})})},e.id):null)})]})]})}},69174:function(e,t,s){s.d(t,{C:function(){return d}});var a=s(57437);s(2265);var r=s(90535),n=s(93448);let c=(0,r.j)("inline-flex items-center rounded-full border px-2 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function d(e){let{className:t,variant:s,...r}=e;return(0,a.jsx)("div",{className:(0,n.cn)(c({variant:s}),t),...r})}}}]);
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.