1import{a as u,b as v,d as y,e as x}from"./chunk-4PBMPCQQ.js";import{a as S}from"./chunk-ILOV6MNE.js";import{ea as A,ja as g}from"./chunk-A2PGLIM2.js";import{a as l,b as f}from"./chunk-5KTCK5IS.js";var H=[{value:"all",label:"All Users",description:"Every mentor on the platform",icon:"fa-users"},{value:"brightside",label:"Brightside-led",description:"Mentors on Brightside-led projects",icon:"fa-building"},{value:"partner",label:"Partner-led",description:"Mentors on partner-led projects",icon:"fa-handshake-o"}],K=[{value:"link",label:"Redirect to link",description:"Clicking the button takes the mentor to a page.",icon:"fa-link"},{value:"popup",label:"Show message popup",description:"Clicking the button opens a popup with your message \u2014 no redirect.",icon:"fa-comment"}],z=[{value:"now",label:"Publish Now",description:"Goes live as soon as you save.",icon:"fa-bolt"},{value:"schedule",label:"Schedule",description:"Goes live at a future date/time.",icon:"fa-calendar"}],G=[{id:"step1",type:"step",title:"Complete training",description:"Learn how to mentor confidently on Brightside, including high-quality mentoring, safeguarding and using the platform.",buttonText:"Complete training",redirect:"/mentor-hub/training"},{id:"step2",type:"step",title:"Complete DBS check",description:"We'll ask for ID and run a DBS (Disclosure and Barring Service) check",buttonText:"Complete DBS check",redirect:"/mentor-hub/training"},{id:"step3",type:"step",title:"Complete profile",description:"Share your experience, skills and interests to help young people understand how you can support them.",buttonText:"Complete profile",redirect:"/mentor-hub/training"},{id:"project",type:"project",title:"Explore Programmes",description:"Find a programme and join to start mentoring students.",buttonText:"Explore Programmes",redirect:"/mentor-hub/projects"}],Y=[{value:"step1",label:"Step 1: Training not completed"},{value:"step2",label:"Step 2: DBS check not completed"},{value:"step3",label:"Step 3: Profile not completed"},{value:"project",label:"Explore / Sign up to a programme"},{value:"fallback",label:"All actions complete (fallback message)"},{value:"override",label:"Announcement (not active)"}];function c(e){return{audience:e,title:"",description:"",buttonText:"",mode:"link",link:"",popupMessage:"",publishMode:"now",startDate:"",startTime:"09:00",endDate:"",endTime:"23:59"}}var r={title:"Keep going!",description:"You're all caught up! Check back later for new actions and updates.",buttonText:"Explore Mentor Hub",link:"/mentor-hub/dashboard"};var d="mentor_hub_announcements",R=`${d}/default_message`,k=(()=>{class e{constructor(){this.http=g(S)}getAnnouncements(){return this.http.get(d,"admin")}createAnnouncement(t){return this.http.post(d,t,"admin")}updateAnnouncement(t,a){return this.http.patch(`${d}/${t}`,a,"admin")}updateDefaultMessage(t){return this.http.patch(R,t,"admin")}deleteAnnouncement(t){return this.http.delete(`${d}/${t}`,"admin")}static{this.\u0275fac=function(a){return new(a||e)}}static{this.\u0275prov=A({token:e,factory:e.\u0275fac,providedIn:"root"})}}return e})();var O={all:"all_users",brightside:"brightside_led",partner:"partner_led"},U={all_users:"all",brightside_led:"brightside",partner_led:"partner"};function p(e){let n=$(e),t=j(e),a=L(n);if(!a&&!t)return null;if(!a)return l({id:null,announcement:c("all"),status:"none"},t?{fallback:t}:{});let s=U[a.audience]??"all";return l({id:a.id,announcement:F(a,s),status:w(a)},t?{fallback:t}:{})}function h(e,n,t){let a={audience:O[e.audience],title:e.title,description:e.description,button_text:e.buttonText,button_action:e.mode==="link"?"redirect":"popup",publish_type:n==="now"?"publish_now":"schedule",link:null,popup_message:null,scheduled_at:null,expires_at:E(e.endDate,e.endTime)};e.mode==="link"?a.link=e.link:a.popup_message=e.popupMessage,n==="schedule"&&(a.scheduled_at=E(e.startDate,e.startTime));let s={type:"mentor_hub_announcements",attributes:a};return t&&(s.id=t),{data:s}}function N(e){return{default_message:{title:e.title,description:e.description,button_text:e.buttonText,button_action:"redirect",link:e.link}}}function $(e){if(!e||typeof e!="object")return[];let n=e;if(Array.isArray(n.mentor_hub_announcements))return n.mentor_hub_announcements.map(t=>D(t));if(n.mentor_hub_announcement)return[D(n.mentor_hub_announcement)];if(Array.isArray(n.data))return n.data.map(t=>M(t));if(n.data&&typeof n.data=="object"){let t=n.data;if(t.attributes||t.id)return[M(t)]}return[]}function j(e){if(!e||typeof e!="object")return null;let n=e;if(n.default_message)return T(n.default_message);let t=n.data;return t&&typeof t=="object"&&"default_message"in t?T(t.default_message):null}function L(e){if(!e.length)return null;let n=e.find(a=>w(a)!=="none");return n||(e.find(a=>a.id||a.title?.trim())??null)}
1function D(e){return{id:e.id??null,audience:String(e.audience??""),status:e.status??null,state:e.state??null,publish_type:e.publish_type??null,title:String(e.title??""),description:String(e.description??""),button_text:String(e.button_text??""),button_action:e.button_action??null,link:e.link??null,popup_message:e.popup_message??null,scheduled_at:e.scheduled_at??null,expires_at:e.expires_at??null}}function M(e){let n=e.attributes??{};return{id:e.id??null,audience:String(n.audience??""),status:n.status??null,state:n.state??null,publish_type:n.publish_type??null,title:String(n.title??""),description:String(n.description??""),button_text:String(n.button_text??""),button_action:n.button_action??null,link:n.link??null,popup_message:n.popup_message??null,scheduled_at:n.scheduled_at??null,expires_at:n.expires_at??null}}function F(e,n){let t=e.button_action==="popup"?"popup":"link",a=e.publish_type==="schedule"?"schedule":"now",s=I(e.scheduled_at),i=I(e.expires_at);return{audience:n,title:e.title??"",description:e.description??"",buttonText:e.button_text??"",mode:t,link:e.link??"",popupMessage:e.popup_message??"",publishMode:a,startDate:s.date,startTime:s.time,endDate:i.date,endTime:i.time}}function T(e){return e?{title:e.title??r.title,description:e.description??r.description,buttonText:e.button_text??r.buttonText,link:e.link??r.link}:l({},r)}function w(e){let n=new Date,t=e.state??e.status;return t==="inactive"||t==="draft"||!e.title?.trim()||e.expires_at&&new Date(e.expires_at)<=n?"none":t==="scheduled"?"scheduled":t==="published"||t==="active"||t==="live"?"live":e.publish_type==="schedule"&&e.scheduled_at?new Date(e.scheduled_at)>n?"scheduled":"live":e.publish_type==="publish_now"&&e.title?.trim()?"live":"none"}function E(e,n){if(!e?.trim()||!n?.trim())return null;let[t,a,s]=e.split("/").map(o=>o.trim());if(!t||!a||!s)return null;let i=n.trim().length===5?`${n.trim()}:00`:n.trim();return new Date(`${s}-${a}
1-${t}T${i}`).toISOString()}function I(e){if(!e)return{date:"",time:""};let n=new Date(e);if(Number.isNaN(n.getTime()))return{date:"",time:""};let t=String(n.getDate()).padStart(2,"0"),a=String(n.getMonth()+1).padStart(2,"0"),s=n.getFullYear(),i=String(n.getHours()).padStart(2,"0"),o=String(n.getMinutes()).padStart(2,"0");return{date:`${t}/${a}/${s}`,time:`${i}:${o}`}}var P={announcementId:null,announcementStatus:"none",announcement:c("all"),fallback:r,loading:!1,saving:!1,error:null,successMessage:null};function b(e){return l({announcementId:e.id,announcement:e.announcement,announcementStatus:e.status},e.fallback?{fallback:e.fallback}:{})}function q(e,n){return e==="schedule"?n?"Scheduled announcement updated successfully.":"Announcement scheduled successfully.":n?"Announcement updated successfully.":"Announcement published successfully."}var oe=v(x(P),y((e,n=g(k))=>({clearSuccessMessage(){u(e,{successMessage:null})},updateAnnouncement(t){u(e,{announcement:l(l({},e.announcement()),t)})},updateFallback(t){u(e,{fallback:l(l({},e.fallback()),t)})},loadAnnouncement(){u(e,{loading:!0,error:null,successMessage:null}),n.getAnnouncements().subscribe({next:t=>{let a=p(t);u(e,a?f(l({},b(a)),{loading:!1}):{loading:!1})},error:()=>{u(e,{loading:!1,error:"Unable to load announcement."})}})},saveAnnouncement(t){let a=f(l({},e.announcement()),{publishMode:t}),s=e.announcementId(),i=!!s,o=h(a,t,s),m=s?n.updateAnnouncement(s,o):n.createAnnouncement(o);u(e,{saving:!0,error:null,successMessage:null}),m.subscribe({next:B=>{let _=p(B),C=t==="schedule"?"scheduled":"live";u(e,l({saving:!1,successMessage:q(t,i)},_?b(_):{announcement:a,announcementStatus:C}))},error:()=>{u(e,{saving:!1,error:"Unable to save announcement."})}})},goLiveAnnouncement(){let t=e.announcementId(),a=f(l({},e.announcement()),{publishMode:"now"}),s=h(a,"now",t),i=t?n.updateAnnouncement(t,s):n.createAnnouncement(s);u(e,{saving:!0,error:null,successMessage:null}),i.subscribe({next:o=>{let m=p(o);u(e,l({saving:!1,successMessage:"Announcement is now live."},m?b(m):{announcement:a,announcementStatus:"live"}))},error:()=>{u(e,{saving:!1,error:"Unable to publish announcement."})}})},removeAnnouncement(){let t=e.announcementId();if(!t){u(e,{announcementId:null,announcementStatus:"none",announcement:c("all"),successMessage:"Announcement removed successfully."});return}u(e,{saving:!0,error:null,successMessage:null}),n.deleteAnnouncement(t).subscribe({next:a=>{let s=p(a);u(e,s?l({saving:!1,successMessage:"Announcement removed successfully."},b(s)):{saving:!1,successMessage:"Announcement removed successfully.",announcementId:null,announcementStatus:"none",announcement:c("all")})},error:()=>{u(e,{saving:!1,error:"Unable to remove announcement."})}})},saveFallback(){let t=N(e.fallback());u(e,{saving:!0,error:null,successMessage:null}),n.updateDefaultMessage(t).subscribe({next:a=>{let s=p(a);u(e,l({saving:!1,successMessage:"Default message saved successfully."},s?.fallback?{fallback:s.fallback}:{}))},error:()=>{u(e,{saving:!1,error:"Unable to save default message."})}})}})));export{H as a,K as b,z as c,G as d,Y as e,oe as f};
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.