1import"../chunks/DsnmJJEf.js";import{o as Oe,h as Ve,s as N,d as $e}from"../chunks/BOOa181H.js";import{t as Y,n as xe,G as he,a6 as We,a7 as Fe,W as be,a8 as Ye,a9 as ze,aa as Ge,ab as He,ac as ge,M as Ke,ad as Ze,ae as j,p as je,Z as q,a1 as qe,f as h,a as ne,Y as C,d as t,s as n,b as o,c as Je,k as a,$ as Qe,r as s,a0 as ye,a2 as ke,a5 as re}from"../chunks/YEsR6uFO.js";import{i as M}from"../chunks/C7VAiwEf.js";import{s as F,e as Xe}from"../chunks/JuV6_9Fc.js";import{S as J,i as ea,e as oe,h as aa,U as ta,R as sa}from"../chunks/BX89j6Ey.js";import{N as ia}from"../chunks/CTfSxlx9.js";import{S as na}from"../chunks/w8qUT6hK.js";function ra(S,d,l=!1,m=!1,O=!1){var r=S,b="";Y(()=>{var g=We;if(b===(b=d()??"")){xe&&he();return}if(g.nodes_start!==null&&(Fe(g.nodes_start,g.nodes_end),g.nodes_start=g.nodes_end=null),b!==""){if(xe){be.data;for(var _=he(),U=_;_!==null&&(_.nodeType!==Ye||_.data!=="");)U=_,_=ze(_);if(_===null)throw Ge(),He;ge(be,U),r=Ke(_);return}var T=b+"";l?T=`<svg>${T}</svg>`:m&&(T=`<math>${T}</math>`);var f=Ze(T);if((l||m)&&(f=j(f)),ge(j(f),f.lastChild),l||m)for(;j(f);)r.before(j(f));else r.before(f)}})}var oa=h('<meta name="description" content="View all notifications and announcements from CCPorted" class="svelte-1vxm5u"/>'),la=(S,d)=>C(d,"all"),va=(S,d)=>C(d,"active"),ca=(S,d)=>C(d,"expired"),da=h('<div class="loading svelte-1vxm5u"><div class="spinner svelte-1vxm5u"></div> <p class="svelte-1vxm5u">Loading notifications...</p></div>'),_a=h('<div class="error svelte-1vxm5u"><h3 class="svelte-1vxm5u">â ï¸ Error Loading Notifications</h3> <p class="svelte-1vxm5u"> </p> <button class="svelte-1vxm5u">Try Again</button></div>'),ua=(S,d,l,m)=>{d(a(l)),m(a(l).notification_id)},ma=h('<span class="new-badge svelte-1vxm5u">NEW</span>'),fa=h('<div class="cta-info svelte-1vxm5u"><span class="cta-label svelte-1vxm5u"> </span></div>'),pa=h('<div><div class="notification-header svelte-1vxm5u"><h3 class="svelte-1vxm5u"> </h3> <div class="notification-meta svelte-1vxm5u"><span> </span> <!></div></div> <div class="notification-body svelte-1vxm5u"><p class="svelte-1vxm5u"><!></p></div> <div class="notification-footer svelte-1vxm5u"><div class="expires svelte-1vxm5u"> </div> <!></div></div>'),xa=h('<div class="empty-state svelte-1vxm5u"><div class="empty-icon svelte-1vxm5u">ð</div> <h3 class="svelte-1vxm5u">No notifications found</h3> <p class="svelte-1vxm5u"><!></p></div>'),ha=h('<div class="notifications-list svelte-1vxm5u"><!> <!></div>'),ba=h(`<!> <main class="notifications-page svelte-1vxm5u"><div class="container svelte-1vxm5u"><div class="header svelte-1vxm5u"><h1 class="svelte-1vxm5u">ð Notifications</h1> <p class="svelte-1vxm5u">Stay updated with the latest announcements and news from 2 CCPorted</p></div> <div class="controls svelte-1vxm5u"><div class="filter-tabs svelte-1vxm5u"><button> </button> <button> </button> <button> </button></div> <button class="refresh-btn svelte-1vxm5u"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" class="svelte-1vxm5u"><polyline points="23 4 23 10 17 10" class="svelte-1vxm5u"></polyline><polyline points="1 20 1 14 7 14" class="svelte-1vxm5u"></polyline><path d="m20.49 9A9 9 0 0 0 5.64 5.64L1 10m22 4l-4.64 4.36A9 9 0 0 1 3.51 15" class="svelte-1vxm5u"></path></svg> Refresh</button></div> <!></div></main>`,1);function Da(S,d){je(d,!0);let l=q(qe([])),m=q(!0),O=q(null),r=q("all");async function b(){try{C(m,!0),C(O,null),(!J.dynamoDBClient||!J.awsReady)&&await ea();const i={TableName:"ccported_notifs"},D=new na(i),E=await J.dynamoDBClient?.send(D);E&&E.Items&&(C(l,E.Items.map(c=>({notification_id:c.id?.S||"",title:c.title?.S||"",body:c.body?.S||"",expires:parseInt(c.expires?.N||"0"),ctaText:c.cta_text?.S,ctaLink:c.cta_link?.S})),!0),a(l).sort((c,y)=>y.expires-c.expires))}catch(e){C(O,`Failed to load notifications: ${e instanceof Error?e.message:"Unknown error"}`)}finally{C(m,!1)}}function g(){const e=Date.now();return a(l).filter(i=>a(r)==="active"?i.expires>e:a(r)==="expired"?i.expires<=e:!0)}
2function _(e){return new Date(e).toLocaleString()}function U(e){return e<=Date.now()}function T(e){aa({title:e.title,content:e.body,actions:[...e.ctaText&&e.ctaLink?[{label:e.ctaText,onClick:()=>window.open(e.ctaLink,"_blank")}]:[],{label:"Close",onClick:i=>i.close()}]})}function f(e){oe.seenNotifications.includes(e)||(oe.seenNotifications.push(e),we(e))}function we(e){const i={TableName:"ccported_notifs",Key:{notification_id:{S:e}},UpdateExpression:"ADD impressions :inc",ExpressionAttributeValues:{":inc":{N:"1"}},ReturnValues:sa.UPDATED_NEW},D=new ta(i);J.dynamoDBClient?.send(D).catch(console.error)}Oe(()=>{b()});var le=ba();Ve(e=>{var i=oa();Qe.title="Notifications - CCPorted",o(e,i)});var ve=ne(le);ia(ve,{});var ce=n(ve,2),de=t(ce),Q=n(t(de),2),X=t(Q),V=t(X);let _e;V.__click=[la,r];var Ne=t(V);s(V);var $=n(V,2);let ue;$.__click=[va,r];var Ce=t($);s($);var z=n($,2);let me;z.__click=[ca,r];var Se=t(z);s(z),s(X);var Te=n(X,2);Te.__click=b,s(Q);var De=n(Q,2);{var Ee=e=>{var i=da();o(e,i)},Ae=e=>{var i=ye(),D=ne(i);{var E=y=>{var A=_a(),B=n(t(A),2),ee=t(B,!0);s(B);var ae=n(B,2);ae.__click=b,s(A),Y(()=>N(ee,a(O))),o(y,A)},c=y=>{var A=ha(),B=t(A);Xe(B,17,g,R=>R.notification_id,(R,v)=>{const k=ke(()=>U(a(v).expires)),G=ke(()=>oe.seenNotifications.includes(a(v).notification_id));var L=pa();let H;L.__click=[ua,T,v,f];var u=t(L),w=t(u),te=t(w,!0);s(w);var K=n(w,2),I=t(K);let p;var W=t(I,!0);s(I);var Re=n(I,2);{var Le=x=>{var P=ma();o(x,P)};M(Re,x=>{!a(G)&&!a(k)&&x(Le)})}s(K),s(u);var se=n(u,2),fe=t(se),Pe=t(fe);ra(Pe,()=>a(v).body),s(fe),s(se);var pe=n(se,2),ie=t(pe),Me=t(ie);s(ie);var Ue=n(ie,2);{var Be=x=>{var P=fa(),Z=t(P),Ie=t(Z);s(Z),s(P),Y(()=>N(Ie,`Action: ${a(v).ctaText??""}`)),o(x,P)};M(Ue,x=>{a(v).ctaText&&a(v).ctaLink&&x(Be)})}s(pe),s(L),Y((x,P,Z)=>{H=F(L,1,"notification-card svelte-1vxm5u",null,H,x),N(te,a(v).title),p=F(I,1,"status svelte-1vxm5u",null,p,P),N(W,a(k)?"ð Past":"ð´ Active"),N(Me,`${a(k)?"Expired":"Expires"}: ${Z??""}`)},[()=>({expired:a(k),unseen:!a(G)}),()=>({expired:a(k)}),()=>_(a(v).expires)]),o(R,L)});var ee=n(B,2);{var ae=R=>{var v=xa(),k=n(t(v),4),G=t(k);{var L=u=>{var w=re("There are no active notifications at the moment.");o(u,w)},H=u=>{var w=ye(),te=ne(w);{var K=p=>{var W=re("No past notifications to display.");o(p,W)},I=p=>{var W=re("No notifications available.");o(p,W)};M(te,p=>{a(r)==="expired"?p(K):p(I,!1)},!0)}o(u,w)};M(G,u=>{a(r)==="active"?u(L):u(H,!1)})}s(k),s(v),o(R,v)};M(ee,R=>{g().length===0&&R(ae)})}s(A),o(y,A)};M(D,y=>{a(O)?y(E):y(c,!1)},!0)}o(e,i)};M(De,e=>{a(m)?e(Ee):e(Ae,!1)})}s(de),s(ce),Y((e,i,D,E,c)=>{_e=F(V,1,"tab svelte-1vxm5u",null,_e,e),N(Ne,`All (${a(l).length??""})`),ue=F($,1,"tab svelte-1vxm5u",null,ue,i),N(Ce,`Active (${D??""})`),me=F(z,1,"tab svelte-1vxm5u",null,me,E),N(Se,`Past (${c??""})`)},[()=>({active:a(r)==="all"}),()=>({active:a(r)==="active"}),()=>a(l).filter(e=>!U(e.expires)).length,()=>({active:a(r)==="expired"}),()=>a(l).filter(e=>U(e.expires)).length]),o(S,le),Je()}$e(["click"]);export{Da as component};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.