import{n as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{Fr as n,Ur as r,dn as i,jn as a}from"./vendor-Dnfj1twE.js";import{A as o,j as s}from"./vendor-vue--4CNL3BY.js";import{b as c,d as l}from"./client-api-D-UNvPyj.js";function u(){return`notif_${Date.now()}_${++f}`}function d(){return m||typeof document<`u`&&document.hidden}var f,p,m,h,g=e((()=>{s(),l(),i(),f=0,p=3e3,m=!1,typeof globalThis<`u`&&typeof globalThis.addEventListener==`function`&&globalThis.addEventListener(`cider:window-minimized`,e=>{m=!!e?.detail?.minimized}),h=o(`notificationStore`,()=>{let e=n([]),t=n([]),i=n(null),o=null,s=a(()=>t.value.length>0),l=a(()=>t.value.some(e=>e.working)),f=a(()=>t.value.length),m=a(()=>i.value!==null),h=a(()=>e.value.length),g=a(()=>e.value.length+ +!!i.value);function _(e){return{id:e.id??u(),icon:e.icon,title:e.title,subtitle:e.subtitle,type:e.type??`info`,persistent:e.persistent??!1,duration:e.duration??p,working:e.working??!1,system:e.system??!1,progress:e.progress,onDismiss:e.onDismiss,createdAt:Date.now()}}function v(){o!==null&&(clearTimeout(o),o=null)}function y(e){v(),o=setTimeout(()=>{b()},e)}function b(){v(),i.value=null,e.value.length>0&&x(e.value.shift())}function x(e){i.value=e,e.persistent&&(t.value.find(t=>t.id===e.id)||t.value.push(e)),y(e.duration)}function S(n){let r=_(n);return r.system?(c(r.title,r.subtitle),r.persistent&&(t.value.find(e=>e.id===r.id)||t.value.push(r)),w(r)):(!r.persistent&&d()||(i.value===null?x(r):(e.value.push(r),r.persistent&&(t.value.find(e=>e.id===r.id)||t.value.push(r)))),w(r))}function C(e){return S({...e,persistent:!0})}function w(e){return{id:e.id,update(n){n.title!==void 0&&(e.title=n.title),n.subtitle!==void 0&&(e.subtitle=n.subtitle),n.icon!==void 0&&(e.icon=n.icon),n.working!==void 0&&(e.working=n.working),n.progress!==void 0&&(e.progress=n.progress),n.type!==void 0&&(e.type=n.type),r(i),r(t)},dismiss(){T(e.id)}}}function T(n){let r=t.value.findIndex(e=>e.id===n);r!==-1&&t.value.splice(r,1);let a=e.value.findIndex(e=>e.id===n);if(a!==-1&&e.value.splice(a,1),i.value?.id===n){let e=i.value;b(),e?.onDismiss?.()}else(r!==-1||a!==-1)&&(t.value.find(e=>e.id===n)??e.value.find(e=>e.id===n))?.onDismiss?.()}function E(e){T(e)}function D(){v(),i.value=null,e.value.splice(0);let n=[...t.value];t.value.splice(0),n.forEach(e=>e.onDismiss?.())}return{queue:e,persistentList:t,activeNotification:i,hasPersistent:s,hasWorking:l,persistentCount:f,isExpanded:m,queueCount:h,totalPending:g,push:S,pushPersistent:C,dismiss:E,dismissAll:D}})})),_=t({ciderNotify:()=>b,ciderNotifyPersistent:()=>x,useNotifications:()=>v});function v(){let e=h();function t(t){e.push({...t,persistent:!1})}function n(t){return e.pushPersistent(t)}function r(t){e.dismiss(t)}function i(){e.dismissAll()}return{notify:t,notifyPersistent:n,dismiss:r,dismissAll:i}}function y(){return S||=h(),S}function b(e){y().push({...e,persistent:!1})}function x(e){return y().pushPersistent(e)}var S,C=e((()=>{g(),S=null}));export{g as a,_ as i,x as n,h as o,C as r,b as t};