1import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{D as t,E as n}from"./icons-BZs8Kec8.js";import{n as r,t as i}from"./react-query-6iCWGIMD.js";import{p as a,s as o}from"./vendor-CaqDieP8.js";import{J as s,Jt as c,Q as l,Qt as u,Wt as d,Y as f,Zt as p,c as m,m as h,rn as g,s as _,un as v,x as y}from"./index-BrqyoUMR.js";var b={container:`_container_1w7ls_1`,button:`_button_1w7ls_6`,button_icon:`_button_icon_1w7ls_18`,open:`_open_1w7ls_24`,badge:`_badge_1w7ls_37`},x={svg:`_svg_1r8lf_1`},S=n();function C({className:e}){return(0,S.jsx)(`svg`,{className:a(x.svg,e),viewBox:`0 0 15 19`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,S.jsx)(`path`,{d:`M12.7885 7.07089C12.7885 5.67595 12.2115 4.32911 11.25 3.31899C10.2404 2.30886 8.89423 1.77975 7.5 1.77975C6.10577 1.77975 4.75962 2.30886 3.75 3.31899C2.78846 4.32911 2.21154 5.67595 2.21154 7.07089V14.1418H12.7885V7.07089ZM14.5673 14.719L14.9038 15.2C14.9519 15.2481 15 15.3443 15 15.4405C15 15.5367 15 15.5848 14.9519 15.681C14.9038 15.7772 14.8558 15.8253 14.8077 15.8734C14.7596 15.9215 14.6635 15.9215 14.5673 15.9215H0.432692C0.336538 15.9215 0.288462 15.9215 0.192308 15.8734C0.144231 15.8253 0.0480769 15.7772 0.0480769 15.681C0.0480769 15.5848 0 15.4886 0 15.4405C0 15.3443 0.0480769 15.2962 0.0961538 15.2L0.432692 14.719V7.07089C0.432692 5.19494 1.15385 3.41519 2.5 2.06835C3.84615 0.721519 5.625 0 7.5 0C9.375 0 11.2019 0.721519 12.5 2.06835C13.8462 3.41519 14.5673 5.19494 14.5673 7.07089V14.719ZM5.28846 16.7873H9.71154C9.71154 17.3646 9.47115 17.9418 9.08654 18.3266C8.65385 18.7595 8.125 18.9519 7.54808 18.9519C6.97115 18.9519 6.39423 18.7114 6.00962 18.3266C5.52885 17.9418 5.28846 17.3646 5.28846 16.7873Z`})})}var w=e(t(),1),T={popup:`_popup_1rmtd_1`,no_items:`_no_items_1rmtd_11`,notifications:`_notifications_1rmtd_15`,separator:`_separator_1rmtd_21`,view_all:`_view_all_1rmtd_26`,loading:`_loading_1rmtd_37`,notification:`_notification_1rmtd_15`,image:`_image_1rmtd_64`,date:`_date_1rmtd_75`};async function E(){return p(`https://api.microprose.com/customer/v1/customer/notifications/latest`)}function D(){let{data:e,error:t,isFetching:n,refetch:i}=r({queryKey:[`NOTIFICATIONS_LATEST_NOTIFICATIONS`],queryFn:async function(){return await E()},staleTime:3e4,gcTime:3e4});return{unread:e?.unread,read:e?.read,totalUnread:e?.totalUnread,totalRead:e?.totalRead,isLoading:n,reload:()=>i({throwOnError:!0}),error:t}}function O({setIsOpen:e}){let{getMessage:t,getDate:n}=l(),{isLoading:r,error:i,unread:s,totalRead:u,reload:f}=D(),{showNotificationModal:p}=h();function g(t){e(!1),p(t)}return r?(0,S.jsx)(`div`,{className:T.popup,children:(0,S.jsx)(`ul`,{className:T.notifications,children:(0,S.jsx)(`li`,{className:T.loading})})}):s?.length?(0,S.jsxs)(`div`,{className:T.popup,children:[(0,S.jsx)(`ul`,{className:T.notifications,children:s.map(e=>(0,S.jsxs)(`li`,{className:T.notification,onClick:()=>{g(e.id)},children:[(0,S.jsx)(`div`,{children:(0,S.jsx)(k,{notification:e})}),(0,S.jsxs)(`div`,{children:[e.title,(0,S.jsx)(`br`,{}),(0,S.jsx)(`span`,{className:T.date,children:n(e.date)})]})]},e.id)).reduce((e,t)=>[e,(0,S.jsx)(`li`,{className:T.separator},`${o()}_separator`),t])}),(0,S.jsx)(`div`,{className:T.view_all,children:(0,S.jsx)(d,{url:v.NOTIFICATIONS,text:t(`features:notifications:viewAll`),size:c.SMALL,clickHandler:()=>{e(!1)}})})]}):i?(0,S.jsx)(`div`,{className:T.popup,children:(0,S.jsx)(m,{retryHandler:()=>void f()})}):u?(0,S.jsxs)(`div`,{className:T.popup,children:[(0,S.jsx)(`div`,{className:T.no_items,children:t(`features:notifications:noNewNotifications`)}),(0,S.jsx)(`div`,{className:T.view_all,children:(0,S.jsx)(d,{url:v.NOTIFICATIONS,text:t(`features:notifications:viewAll`),size:c.SMALL,clickHandler:()=>{e(!1)}})})]}):(0,S.jsx)(`div`,{className:a(T.popup,T.no_items),children:t(`features:notifications:noNotifications`)})}function k({notification:e}){if(!e.referenceTypeId||!e.referenceId)return null;switch(e.referenceTypeId){case s.PRODUCT:return(0,S.jsx)(A,{productId:e.referenceId});default:return null}}function A({productId:e}){let{data:t,isLoading:n,error:r}=y();if(n||r||!t)return null;let i=t.find(t=>
1t.id===e);return i?(0,S.jsx)(`img`,{className:T.image,src:i.thumbnail}):null}function j({className:e}){let[t,n]=(0,w.useState)(!1),{getMessage:r}=l(),i=g(s),{totalUnread:o}=D();function s(){n(!1)}function c(){n(e=>!e)}return(0,S.jsxs)(`div`,{className:a(b.container,{[b.open]:t},e),ref:i,children:[(0,S.jsxs)(`button`,{type:`button`,className:b.button,onClick:c,title:r(`features:notifications:notifications`),children:[(0,S.jsx)(C,{className:b.button_icon}),(0,S.jsx)(_,{count:o??0,className:b.badge})]}),t&&(0,S.jsx)(O,{setIsOpen:n})]})}async function M(e,t){return u(`https://api.microprose.com/customer/v1/customer/notifications/`,{page:e.toString(),isRead:(t===f.READ).toString()})}function N(e){let{data:t,error:n,fetchNextPage:r,hasNextPage:a,isFetching:o,isFetchingNextPage:s,refetch:c}=i({queryKey:[`NOTIFICATIONS_NOTIFICATIONS`,e],queryFn:async function({pageParam:t}){return await M(t,e)},initialPageParam:1,getNextPageParam:function(e,t,n){if(e.hasMore)return n+1},staleTime:3e4,gcTime:3e4});function l(e){return!e||e.pages.length===0?[]:e.pages.map(e=>e.results).flat().filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t)}return{data:l(t),isLoading:o,isLoadingFirstPage:o&&!s,isLoadingNextPage:s,hasNextPage:a,loadNextPage:()=>r(),reload:()=>c({throwOnError:!0}),error:n}}export{j as n,N as t};
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.