import{B as e,Bt as t,Ct as n,D as r,F as i,H as a,L as o,N as s,Nt as c,Pt as l,R as u,Vt as d,X as f,Y as p,_t as m,a as h,at as g,b as _,bt as v,ft as y,g as b,ht as x,it as S,mt as C,o as w,ot as T,pt as E,u as D,v as O,vt as k,x as ee,z as A}from"./BT3KAag_.js";import"./t62M88qj.js";import{t as j}from"./9bCTHkeS.js";import"./BZnJ8tbJ.js";import{t as te}from"./CHgG1pyP.js";import{a as ne,c as re,i as ie,n as ae,o as M,r as N,s as P,t as F}from"./CnIuUOU82.js";import{n as I}from"./DPNVpxC52.js";import"./De4vjwu82.js";import{t as L}from"./DPtEUAYV2.js";var R=e(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M12 0 C12 7.5 7.5 12 0 12 C7.5 12 12 16.5 12 24 C12 16.5 16.5 12 24 12 C16.5 12 12 7.5 12 0 Z"></path></svg>`);function z(e,t){let n=w(t,`size`,3,16);var r=R();T(()=>{O(r,`width`,n()),O(r,`height`,n()),O(r,`aria-hidden`,t.title?void 0:!0),O(r,`role`,t.title?`img`:void 0),O(r,`aria-label`,t.title)}),o(e,r)}var B=A(`<span><!></span>`);function V(e,t){l(t,!0);let r=w(t,`agent`,3,!1),u=w(t,`size`,3,`md`),p=w(t,`class`,3,``),m=n(()=>{if(t.userId!==void 0&&t.userId!==null)return L.getColor(t.userId);if(r())return`var(--color-agent)`}),h=n(()=>t.text??(t.name?.[0]??`?`).toUpperCase()),g=n(()=>u()===`sm`?9:11);var v=B();let b,x;var S=y(v),C=e=>{z(e,{get size(){return f(g)}})},E=e=>{var t=a();T(()=>i(t,f(h))),o(e,t)};s(S,e=>{r()?e(C):e(E,-1)}),d(v),T(()=>{b=ee(v,1,`sg-avatar sg-avatar-${u()??``} ${p()??``}`,`svelte-8w5802`,b,{"sg-avatar-agent":r()}),O(v,`title`,t.title),x=_(v,``,x,{background:f(m)})}),o(e,v),c()}var H=A(`<!> <!>`,1),U=A(`<!> <!>`,1),W=A(`<!> <!>`,1);function G(e,s){l(s,!0);let d=w(s,`open`,15),p=w(s,`confirmLabel`,3,`Confirm`),m=w(s,`cancelLabel`,3,`Cancel`),h=w(s,`destructive`,3,!1);var g=u();r(E(g),()=>re,(e,c)=>{c(e,{onOpenChange:e=>{e||s.oncancel()},get open(){return d()},set open(e){d(e)},children:(e,c)=>{var l=u();r(E(l),()=>ae,(e,c)=>{c(e,{children:(e,c)=>{var l=W(),u=E(l);r(u,()=>N,(e,n)=>{n(e,{children:(e,n)=>{var c=H(),l=E(c);r(l,()=>P,(e,n)=>{n(e,{children:(e,n)=>{t();var r=a();T(()=>i(r,s.title)),o(e,r)},$$slots:{default:!0}})}),r(C(l,2),()=>F,(e,n)=>{n(e,{children:(e,n)=>{t();var r=a();T(()=>i(r,s.message)),o(e,r)},$$slots:{default:!0}})}),o(e,c)},$$slots:{default:!0}})}),r(C(u,2),()=>ie,(e,c)=>{c(e,{children:(e,c)=>{var l=U(),u=E(l);{let e=n(()=>I({variant:`ghost`}));r(u,()=>ne,(n,r)=>{r(n,{get class(){return f(e)},get onclick(){return s.oncancel},children:(e,n)=>{t();var r=a();T(()=>i(r,m())),o(e,r)},$$slots:{default:!0}})})}var d=C(u,2);{let e=n(()=>I({variant:h()?`destructive`:`accent`}));r(d,()=>M,(n,r)=>{r(n,{get class(){return f(e)},get onclick(){return s.onconfirm},children:(e,n)=>{t();var r=a();T(()=>i(r,p())),o(e,r)},$$slots:{default:!0}})})}o(e,l)},$$slots:{default:!0}})}),o(e,l)},$$slots:{default:!0}})}),o(e,l)},$$slots:{default:!0}})}),o(e,g),c()}var K=e(`<title> </title>`),q=e(`<svg><!><path d="M17.74,30,16,29l4-7h6a2,2,0,0,0,2-2V8a2,2,0,0,0-2-2H6A2,2,0,0,0,4,8V20a2,2,0,0,0,2,2h9v2H6a4,4,0,0,1-4-4V8A4,4,0,0,1,6,4H26a4,4,0,0,1,4,4V20a4,4,0,0,1-4,4H21.16Z"></path><path d="M8 10H24V12H8z"></path><path d="M8 16H18V18H8z"></path></svg>`);function oe(e,n){let r=h(n,[`children`,`$$slots`,`$$events`,`$$legacy`]),a=h(r,[`size`,`title`]);l(n,!1);let u=m(),_=m(),v=w(n,`size`,8,16),x=w(n,`title`,8,void 0);S(()=>(p(r),p(x())),()=>{k(u,r[`aria-label`]||r[`aria-labelledby`]||x())}),S(()=>(f(u),p(r)),()=>{k(_,{"aria-hidden":f(u)?void 0:!0,role:f(u)?`img`:void 0,focusable:Number(r.tabindex)===0?!0:void 0})}),g(),D();var C=q();b(C,()=>({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`,fill:`currentColor`,preserveAspectRatio:`xMidYMid meet`,width:v(),height:v(),...f(_),...a}));var E=y(C),O=e=>{var t=K(),n=y(t,!0);d(t),T(()=>i(n,x())),o(e,t)};s(E,e=>{x()&&e(O)}),t(3),d(C),o(e,C),c()}async function se(e){return j(`/api/notifications${e?.unreadOnly?`?unreadOnly=true`:``}`)}async function ce(e){await j(`/api/notifications/${e}/read`,{method:`POST`})}async function le(){await j(`/api/notifications/read-all`,{method:`POST`})}async function ue(){let{users:e}=await j(`/api/auth/users`);return e}var J=v(x([])),Y=v(x({}));async function X(){try{let{users:e}=await j(`/api/auth/users`);k(J,e,!0);let t={};for(let n of e)t[n.handle]=n;k(Y,t,!0)}catch{}}function de(e){return e?f(Y)[e]??null:null}X(),te.addConnectHandler(()=>X());var Z={getByHandle:de,load:X,get users(){return f(J)}},Q=v(null),$=v(null),fe={get view(){return f(Q)},set view(e){k(Q,e,!0)},get entity(){return f($)},set entity(e){k($,e,!0)}};export{le as a,G as c,se as i,V as l,Z as n,ce as o,ue as r,oe as s,fe as t};