import{Q as K,R as Y,T as L,U as P,u as Z,d as i,V as tt,W as et,m as at,X as rt,o as st,N as lt,y as ft,z as R,M as m,B as p,C as nt,F as w,v as h,w as f,x as it,H as ot,G as _,P as vt}from"./load-DrBKyWa2.js";const T=[...` 	
\r\f \v\uFEFF`];function ct(n,c,e){var t=""+n;if(e){for(var r of Object.keys(e))if(e[r])t=t?t+" "+r:r;else if(t.length)for(var s=r.length,l=0;(l=t.indexOf(r,l))>=0;){var o=l+s;(l===0||T.includes(t[l-1]))&&(o===t.length||T.includes(t[o]))?t=(l===0?"":t.substring(0,l))+t.substring(o+1):l=o}}return t===""?null:t}function dt(n,c,e,t,r,s){var l=n.__className;if(l!==e||l===void 0){var o=ct(e,t,s);o==null?n.removeAttribute("class"):n.className=o,n.__className=e}else if(s&&r!==s)for(var d in s){var u=!!s[d];(r==null||u!==!!r[d])&&n.classList.toggle(d,u)}return s}function ut(n=!1){const c=K,e=c.l.u;if(!e)return;let t=()=>et(c.s);if(n){let r=0,s={};const l=at(()=>{let o=!1;const d=c.s;for(const u in d)d[u]!==s[u]&&(s[u]=d[u],o=!0);return o&&r++,r});t=()=>i(l)}e.b.length&&Y(()=>{U(c,t),P(e.b)}),L(()=>{const r=Z(()=>e.m.map(tt));return()=>{for(const s of r)typeof s=="function"&&s()}}),e.a.length&&L(()=>{U(c,t),P(e.a)})}function U(n,c){if(n.l.s)for(const e of n.l.s)i(e);c()}rt();var ht=w('<p class="empty svelte-1flwarj">No alerts configured for this database.</p>'),_t=w('<tr><td class="svelte-1flwarj"><a><code> </code></a></td><td class="svelte-1flwarj"><code> </code></td><td class="svelte-1flwarj"><span> </span></td><td class="svelte-1flwarj"> </td><td class="svelte-1flwarj"> </td><td class="svelte-1flwarj"> </td><td class="svelte-1flwarj"> </td></tr>'),gt=w('<table class="alerts-table svelte-1flwarj"><thead><tr><th class="svelte-1flwarj">Alert</th><th class="svelte-1flwarj">Table</th><th class="svelte-1flwarj">Type</th><th class="svelte-1flwarj">Notifier</th><th class="svelte-1flwarj">Frequency</th><th class="svelte-1flwarj">Next fire</th><th class="svelte-1flwarj">Last notification</th></tr></thead><tbody></tbody></table>'),pt=w('<div class="alerts-container svelte-1flwarj"><div class="alerts-header svelte-1flwarj"><h2 class="svelte-1flwarj">Alerts</h2> <a class="new-alert-link svelte-1flwarj">New alert</a></div> <!></div>');function wt(n,c){st(c,!1);const e=lt(),t=e.alerts??[],r=e.database_name;function s(a){return a==null?"—":a<0?"overdue":a<60?`${a}s`:a<3600?`${Math.floor(a/60)}m`:a<86400?`${Math.floor(a/3600)}h`:`${Math.floor(a/86400)}d`}ut();var l=pt(),o=f(l),d=h(f(o),2),u=h(o,2);{var q=a=>{var g=ht();p(a,g)},B=a=>{var g=gt(),D=h(f(g));it(D,5,()=>t,ot,(F,v)=>{var j=_t(),y=f(j),x=f(y),O=f(x),z=f(O),N=h(y),E=f(N),G=f(E),$=h(N),A=f($);let M;var H=f(A),C=h($),Q=f(C),I=h(C),S=f(I),b=h(I),V=f(b),W=h(b),X=f(W);R((k,J)=>{m(x,"href",k),_(z,i(v).id),_(G,i(v).table_name),M=dt(A,1,"type-badge svelte-1flwarj",null,M,{trigger:i(v).alert_type==="trigger"}),_(H,i(v).alert_type==="trigger"?"trigger":"cursor"),_(Q,i(v).notifiers),_(S,i(v).alert_type==="trigger"?"—":i(v).frequency),m(b,"title",i(v).next_deadline??""),_(V,J),_(X,i(v).last_notification_at??"—")},[()=>`/-/${encodeURIComponent(r)}/datasette-alerts/alerts/${i(v).id}`,()=>i(v).alert_type==="trigger"?"realtime":s(i(v).seconds_until_next)]),p(F,j)}),p(a,g)};ft(u,a=>{t.length===0?a(q):a(B,!1)})}R(a=>m(d,"href",a),[()=>`/-/${encodeURIComponent(r)}/datasette-alerts/new`]),p(n,l),nt()}vt(wt,{target:document.getElementById("app-root")});
