PageSourceSearch

https://phasoric.com/assets/NotificationCenter-BsKGlwDr.js

js phasoric.com collected 2026-09-24 14:50:48 UTC 12,377 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/CelebratorySuccess-F94Vs5ss.js","assets/rolldown-runtime-BNNRdYrd.js","assets/react-vendor-BqQF_9sx.js","assets/check--u4h0CxO.js","assets/index-BQuIkJiK.js","assets/platform-capabilities-Bjt71t6g.js","assets/comparison-positioning-DbkxE00R.js","assets/context-sales-routes-BmilJBIO.js","assets/domain-plugin-catalog-lNnBMB9_.js","assets/plan-entitlements-D-LMrELD.js","assets/index-DNsQKlv_.css","assets/sparkles-HKQN2J4g.js","assets/proxy-BaIM4JZ0.js","assets/AnimatePresence-qoTgOQeg.js","assets/use-reduced-motion-aImA2kNa.js","assets/db-Dgd9zlNH.js","assets/storage-vendor-HZzIgsIR.js","assets/note-trust-Y3C29qxz.js","assets/semantic-links-BmhOhVmH.js","assets/semantic-note-DyLW_AZF.js","assets/task-utils-NfCAvgr9.js","assets/safe-frontmatter-BdZqnLng.js","assets/desktop-vault-binding-CVzuZYam.js","assets/taskUtils-dYCjeCTv.js"])))=>i.map(i=>d[i]);
2import{o as L}from"./rolldown-runtime-BNNRdYrd.js";import{_ as v,b as I,r as O,s as D}from"./react-vendor-BqQF_9sx.js";import{t as P}from"./bell-CDv68bT7.js";import{t as $}from"./calendar-B1zAAb1h.js";import{t as R}from"./check--u4h0CxO.js";import{t as M}from"./circle-alert-BKIhhOiy.js";import{t as U}from"./credit-card-DDqxK5zk.js";import{Dt as q,Ft as V}from"./index-BQuIkJiK.js";import"./AuthContext-DMnfLAt3.js";var s=L(I(),1),t=O(),z=(0,s.lazy)(()=>v(()=>import("./CelebratorySuccess-F94Vs5ss.js").then(c=>c.n).then(c=>({default:c.CelebratorySuccess})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]))),T=(0,s.createContext)();function Z({children:c}){const{user:p}
2=q(),[N,k]=(0,s.useState)([]),[g,x]=(0,s.useState)([]),[y,f]=(0,s.useState)(0),[A,j]=(0,s.useState)("default"),l=(0,s.useRef)(null),o=(0,s.useRef)(null),d=(0,s.useCallback)(()=>!p?.id||p.localOnly?(x([]),f(0),Promise.resolve()):(o.current||(o.current=fetch("/api/notifications?limit=30",{credentials:"include"}).then(async e=>{if(!e.ok)throw new Error((await e.json().catch(()=>({}))).error||"Notifications are unavailable.");return e.json()}).then(e=>{x(Array.isArray(e.notifications)?e.notifications:[]),f(Number(e.unreadCount||0))}).catch(e=>console.warn("[Notifications]",e.message)).finally(()=>{o.current=null})),o.current),[p?.id,p?.localOnly]);(0,s.useEffect)(()=>{typeof window<"u"&&"Notification"in window&&j(Notification.permission),h();const e=()=>h();return window.addEventListener("notes-updated",e),window.addEventListener("knowledge-metadata-updated",e),()=>{window.removeEventListener("notes-updated",e),window.removeEventListener("knowledge-metadata-updated",e)}},[]),(0,s.useEffect)(()=>{d();const e=()=>{d()},r=()=>{document.visibilityState==="visible"&&e()};window.addEventListener("notification-center-refresh",e),document.addEventListener("visibilitychange",r);const a=window.setInterval(e,3e5);return()=>{window.removeEventListener("notification-center-refresh",e),document.removeEventListener("visibilitychange",r),window.clearInterval(a)}},[d]);function h(){return l.current||(l.current=(async()=>{try{const[{listWorkspaceNotes:e},{parseTasksFromContent:r}]=await Promise.all([v(()=>import("./db-Dgd9zlNH.js").then(i=>i.i),__vite__mapDeps([15,1,2,4,5,6,7,8,9,10,16,17,18,19,20,21,22])),v(()=>import("./taskUtils-dYCjeCTv.js").then(i=>i.t),__vite__mapDeps([23,1,20]))]),a=[],w=new Date().toISOString().split("T")[0],C=await e();for(const i of C){const u=i.tasks?.length?i.tasks.map(m=>({...m,path:i.path,noteTitle:i.title})):r(i.content,i.path,i.title);for(const m of u)!m.completed&&m.dueDate&&m.dueDate<=w&&a.push(m)}a.sort((i,u)=>{if(i.dueDate!==u.dueDate)return i.dueDate.localeCompare(u.dueDate);const m={High:3,Medium:2,Low:1};return(m[u.priority]||0)-(m[i.priority]||0)}),k(a),a.length>0&&Notification.permission==="granted"&&(localStorage.getItem("basalt_last_notified_date")||"")!==w&&(new Notification("Phasoric Reminder",{body:`You have ${a.length} tasks due today or overdue. Check your agenda!`,icon:"/brand/phasoric-mark.png"}),localStorage.setItem("basalt_last_notified_date",w))}catch(e){console.error("Error loading reminders:",e)}})().finally(()=>{l.current=null})),l.current}const E=async()=>{if(typeof window<"u"&&"Notification"in window){const e=await Notification.requestPermission();return j(e),e}return"unsupported"},_=async e=>{try{const[{db:r,updateNoteAndQueue:a},{toggleTaskInContent:w}]=await Promise.all([v(()=>import("./db-Dgd9zlNH.js").then(u=>u.i),__vite__mapDeps([15,1,2,4,5,6,7,8,9,10,16,17,18,19,20,21,22])),v(()=>import("./taskUtils-dYCjeCTv.js").then(u=>u.t),__vite__mapDeps([23,1,20]))]),C=await r.notes.get(e.path);if(!C)return!1;const i=w(C.content,e.lineIndex,!0);return await a(e.path,{content:i,updatedAt:Date.now()}),window.dispatchEvent(new CustomEvent("notes-updated")),window.dispatchEvent(new CustomEvent("sync-queue-updated")),await h(),!0}catch(r){return console.error("Error completing task:",r),!1}},b=async e=>{x(r=>r.map(a=>a.id===e?{...a,readAt:a.readAt||new Date().toISOString()}:a)),f(r=>Math.max(0,r-(g.find(a=>a.id===e)?.readAt?0:1))),await fetch(`/api/notifications/${encodeURIComponent(e)}/read`,{method:"POST",credentials:"include"}).catch(r=>console.warn("[Notifications]",r.message))},S=async e=>{const r=g.find(a=>a.id===e);x(a=>a.filter(w=>w.id!==e)),r&&!r.readAt&&f(a=>Math.max(0,a-1)),await fetch(`/api/notifications/${encodeURIComponent(e)}`,{method:"DELETE",credentials:"include"}).catch(a=>console.warn("[Notifications]",a.message))},n=async()=>{const e=new Date().toISOString();x(r=>r.map(a=>({...a,readAt:a.readAt||e}))),f(0),await fetch("/api/notifications/read-all",{method:"POST",credentials:"include"}).catch(r=>console.warn("[Notifications]",r.message))};return(0,t.jsx)(T.Provider,{value:{reminders:N,accountNotifications:g,unreadAccountCount:y,notificationPermission:A,requestPermission:E,completeReminder:_,markAccountNotificationRead:b,dismissAccountNotification:S,markAllAccountNotificationsRead:n,checkUpdates:h,refreshAccountNotifications:d},children:c})}function H(){return(0,s.useContext)(T)}function ee(){const{reminders:c,accountNotifications:p,unreadAccountCount:N,completeReminder:k,notificationPermission:g,requestPermission:x,markAccountNotificationRead:y,dismissAccountNotification:f,markAllAccountNotificationsRead:A,refreshAccountNotifications:j}
2=H(),[l,o]=(0,s.useState)(!1),[d,h]=(0,s.useState)(null);(0,s.useEffect)(()=>{const n=()=>o(!1);return window.addEventListener("click",n),()=>window.removeEventListener("click",n)},[]);const E=n=>{n.stopPropagation();const e=!l;o(e),e&&j()},_=new Date().toISOString().split("T")[0],b=c.length+N,S=async n=>{await k(n)&&h(n)};return(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsxs)("button",{onClick:E,"aria-label":`Open notification center${b?`, ${b} unread or due`:""}`,"aria-expanded":l,className:`active-press min-h-[44px] min-w-[44px] flex items-center justify-center rounded-lg relative hover:bg-basalt-800/40 text-basalt-400 hover:text-white transition-all ${l?"text-white bg-basalt-800/40":""}`,children:[(0,t.jsx)(P,{className:"h-5 w-5"}),b>0&&(0,t.jsx)("span",{className:"absolute -top-1.5 -right-1.5 h-5 w-5 rounded-full bg-accent-purple text-[10px] font-bold text-white flex items-center justify-center animate-pulse border border-basalt-950",children:b>99?"99+":b})]}),l&&(0,t.jsxs)("div",{role:"region","aria-label":"Notification Center Dropdown",onClick:n=>n.stopPropagation(),className:"absolute right-0 mt-2 w-80 max-h-[420px] bg-basalt-900 border border-basalt-800 rounded-xl overflow-hidden shadow-2xl flex flex-col z-50 animate-slideDown",children:[(0,t.jsxs)("div",{className:"p-3.5 border-b border-basalt-850 flex items-center justify-between",children:[(0,t.jsxs)("span",{className:"font-outfit text-xs font-bold text-white uppercase tracking-wider flex items-center gap-1.5",children:[(0,t.jsx)(P,{className:"h-3.5 w-3.5 text-accent-purple"}),"Notification Center"]}),N>0?(0,t.jsx)("button",{type:"button",onClick:A,className:"active-press text-[9px] font-mono text-accent-cyan hover:underline min-h-[44px] min-w-[44px] inline-flex items-center justify-center",children:"Mark billing read"}):g!=="granted"&&(0,t.jsx)("button",{onClick:x,className:"active-press text-[9px] font-mono text-accent-cyan hover:underline min-h-[44px] min-w-[44px] inline-flex items-center justify-center",children:"Enable System Alerts"})]}),(0,t.jsxs)("div",{className:"flex-1 overflow-y-auto max-h-[300px] p-2 flex flex-col gap-1.5",children:[d?(0,t.jsx)(s.Suspense,{fallback:null,children:(0,t.jsx)(z,{message:"Task completed!",duration:3e3,onClose:()=>h(null),className:"my-1"},d.id)}):null,p.map(n=>(0,t.jsx)("div",{className:`rounded-lg border p-3 ${n.readAt?"border-basalt-800 bg-basalt-950/35":n.severity==="critical"?"border-red-400/25 bg-red-400/[.055]":"border-amber-300/20 bg-amber-300/[.04]"}`,children:(0,t.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,t.jsx)(U,{className:n.severity==="critical"?"mt-0.5 shrink-0 text-red-300":"mt-0.5 shrink-0 text-amber-300",size:14}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("div",{className:"text-[10px] font-semibold text-white",children:n.title}),(0,t.jsx)("p",{className:"mt-1 text-[9px] leading-4 text-basalt-400",children:n.body}),(0,t.jsxs)("div",{className:"mt-2 flex items-center gap-3",children:[n.actionUrl?(0,t.jsx)(D,{to:n.actionUrl,onClick:()=>{y(n.id),o(!1)},className:"text-[9px] font-semibold text-cyan-300",children:n.actionLabel||"Review"}):null,n.readAt?null:(0,t.jsx)("button",{type:"button",onClick:()=>y(n.id),className:"active-press text-[9px] text-basalt-500 hover:text-white min-h-[44px] min-w-[44px] inline-flex items-center justify-center",children:"Mark read"})]})]}),(0,t.jsx)("button",{type:"button",onClick:()=>f(n.id),"aria-label":`Dismiss ${n.title}`,className:"active-press rounded min-h-[44px] min-w-[44px] flex items-center justify-center text-basalt-600 hover:bg-white/5 hover:text-white",children:(0,t.jsx)(V,{size:11})})]})},n.id)),p.length>0&&c.length>0?(0,t.jsx)("div",{className:"px-1 pt-2 text-[8px] font-bold uppercase tracking-[.16em] text-basalt-600",children:"Task reminders"}):null,p.length===0&&c.length===0&&!d?(0,t.jsxs)("div",{className:"py-8 text-center flex flex-col items-center justify-center text-basalt-500 font-mono text-xs gap-1.5",children:[(0,t.jsx)(R,{className:"h-6 w-6 text-accent-green bg-accent-green/10 p-1 rounded-full"}),(0,t.jsx)("span",{children:"All caught up."})]}):c.map(n=>{const e=n.dueDate<_;return d?.id===n.id?null:(0,t.jsxs)("div",{className:"p-2.5 rounded-lg border border-basalt-800 bg-basalt-950/40 hover:bg-basalt-950/80 flex items-start gap-2.5 transition-all group",children:[(0,t.jsx)("button",{onClick:()=>{S(n)},className:"active-press flex items-center justify-center min-h-[44px] min-w-[44px] mt-0.5 rounded bg-basalt-900 border border-basalt-800 hover:border-accent-green hover:bg-accent-green/15 text-transparent hover:text-accent-green transition-all",title:"Mark Complete",children:(0,t.jsx)(R,{className:"h-3 w-3"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0 font-mono",children:[(0,t.jsx)("p",{className:"text-xs text-white leading-normal font-semibold truncate group-hover:text-accent-cyan transition-colors",children:n.text}),(0,t.jsxs)("div",{className:"flex items-center gap-2 mt-1.5 text-[9px] text-basalt-500",children:[(0,t.jsxs)("span",{className:`flex items-center gap-0.5 ${e?"text-accent-red font-bold":""}`,children:[(0,t.jsx)($,{className:"h-2.5 w-2.5"}),n.dueDate===_?"Today":n.dueDate]}),(0,t.jsx)("span",{children:"•"}),(0,t.jsx)(D,{to:`/app/dashboard?note=${encodeURIComponent(n.path)}`,onClick:()=>o(!1),className:"hover:underline text-accent-purple truncate max-w-[120px]",children:n.noteTitle})]})]}),n.priority==="High"&&(0,t.jsx)("span",{className:"p-1 rounded bg-accent-red/10 border border-accent-red/20 text-accent-red",title:"High Priority",children:(0,t.jsx)(M,{className:"h-3 w-3"})})]},n.id)})]}),(0,t.jsx)("div",{className:"p-2 border-t border-basalt-850 bg-basalt-950/50 flex justify-center",children:(0,t.jsx)(D,{to:"/app/tasks",onClick:()=>o(!1),className:"w-full text-center py-2 text-[10px] font-bold text-accent-cyan hover:bg-accent-cyan/15 rounded-lg border border-accent-cyan/10 hover:border-accent-cyan/25 transition-all font-mono uppercase tracking-wider",children:"Open Tasks Manager"})})]})]})}export{ee as NotificationBellDropdown,Z as NotificationProvider};

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.