import{cb as e}from"./index-dNe6i2rS.js";const c="hopsworks.notifications.history",d=100,s="hopsworks:notifications-history-changed";function f(t){return typeof t=="string"?t:t==null?"":typeof t=="number"||typeof t=="boolean"?String(t):"(rich content)"}function a(){try{const t=window.localStorage.getItem(c);if(!t)return[];const n=JSON.parse(t);return Array.isArray(n)?n:[]}catch{return[]}}function w(t){try{window.localStorage.setItem(c,JSON.stringify(t)),window.dispatchEvent(new CustomEvent(s))}catch{}}function g(t,n,r,o){const u=[{id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,level:t,title:f(n),content:f(r),timestamp:Date.now(),projectId:o??null},...a()].slice(0,d);w(u)}function y(){return a()}function S(t){w(a().filter(n=>n.projectId!==t))}function N(t){const n=o=>{o.key===c&&t()},r=()=>t();return window.addEventListener("storage",n),window.addEventListener(s,r),()=>{window.removeEventListener("storage",n),window.removeEventListener(s,r)}}const p=/^\/p\/(\d+)(\/|$)/,m=()=>{const t=window.location.pathname.match(p);return t?Number(t[1]):null},i=(t,n)=>((r,o)=>(g(t,r,o==null?void 0:o.description,m()),n(r,o))),E=((...t)=>e(...t)),b=Object.assign(E,e,{success:i("success",e.success),error:i("error",e.error),info:i("info",e.info),warning:i("warning",e.warning)});export{S as c,y as g,N as s,b as t};
