// @bun
var{defineProperty:H,getOwnPropertyNames:M,getOwnPropertyDescriptor:P}=Object,Q=Object.prototype.hasOwnProperty;function R(j){return this[j]}var $=(j)=>{var b=(K??=new WeakMap).get(j),k;if(b)return b;if(b=H({},"__esModule",{value:!0}),j&&typeof j==="object"||typeof j==="function"){for(var A of M(j))if(!Q.call(b,A))H(b,A,{get:R.bind(j,A),enumerable:!(k=P(j,A))||k.enumerable})}return K.set(j,b),b},K;var T=(j)=>j;function U(j,b){this[j]=T.bind(null,b)}var E=(j,b)=>{for(var k in b)H(j,k,{get:b[k],enumerable:!0,configurable:!0,set:U.bind(b,k)})};var I=(j,b)=>()=>(j&&(b=j(j=0)),b);var O=import.meta.require;var B=new Map;function V(){let j=typeof window<"u"&&"Notification"in window,b={permission:j?Notification.permission:"denied",isSupported:j},k=[],A=()=>{k.forEach((q)=>q(b))},X=()=>{if(!j)return;b={...b,permission:Notification.permission},A()};return{get:()=>b,subscribe:(q)=>{return k.push(q),q(b),()=>{k=k.filter((z)=>z!==q)}},isSupported:()=>b.isSupported,permission:()=>b.permission,requestPermission:async()=>{if(!j)return"denied";try{let q=await Notification.requestPermission();return b={...b,permission:q},A(),q}catch{return b.permission}},show:(q,z={})=>{if(!j||b.permission!=="granted")return null;let{autoClose:G,...L}=z;try{let D=new Notification(q,L);if(z.tag){let J=B.get(z.tag);if(J)J.close();B.set(z.tag,D),D.addEventListener("close",()=>{B.delete(z.tag)})}if(G&&G>0)setTimeout(()=>{D.close()},G);return D}catch{return null}},close:(q)=>{let z=B.get(q);if(z)z.close(),B.delete(q)}}}async function F(j,b){let k=V();if(k.permission()==="default")await k.requestPermission();return k.show(j,b)}function h(){return typeof window<"u"&&"Notification"in window&&Notification.permission==="granted"}async function w(){if(typeof window>"u"||!("Notification"in window))return"denied";return Notification.requestPermission()}var x={success:(j,b)=>F("Success",{body:j,icon:"\u2705",...b}),error:(j,b)=>F("Error",{body:j,icon:"\u274C",...b}),warning:(j,b)=>F("Warning",{body:j,icon:"\u26A0\uFE0F",...b}),info:(j,b)=>F("Info",{body:j,icon:"\u2139\uFE0F",...b})};export{V as useNotification,w as requestNotificationPermission,F as notify,x as notifications,h as canNotify};
