function p() { const [e, t] = React.useState([]); window.setAlertsData = t; const a = e.sort((c, s) => new Date(c.date) - new Date(s.date)), i = { emergency: /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 512 512" }, /* @__PURE__ */ React.createElement("path", { d: "M256 32a224 224 0 1 1 0 448 224 224 0 1 1 0-448zm0 480A256 256 0 1 0 256 0a256 256 0 1 0 0 512zm0-384c-8.8 0-16 7.2-16 16V272c0 8.8 7.2 16 16 16s16-7.2 16-16V144c0-8.8-7.2-16-16-16zm24 224a24 24 0 1 0 -48 0 24 24 0 1 0 48 0z" })), warning: /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 448 512" }, /* @__PURE__ */ React.createElement("path", { d: "M208 16c0-8.8 7.2-16 16-16s16 7.2 16 16V32.8c80.9 8 144 76.2 144 159.2v29.1c0 43.7 17.4 85.6 48.3 116.6l2.8 2.8c8.3 8.3 13 19.6 13 31.3c0 24.5-19.8 44.3-44.3 44.3H44.3C19.8 416 0 396.2 0 371.7c0-11.7 4.7-23 13-31.3l2.8-2.8C46.6 306.7 64 264.8 64 221.1V192c0-83 63.1-151.2 144-159.2V16zm16 48C153.3 64 96 121.3 96 192v29.1c0 52.2-20.7 102.3-57.7 139.2L35.6 363c-2.3 2.3-3.6 5.4-3.6 8.7c0 6.8 5.5 12.3 12.3 12.3H403.7c6.8 0 12.3-5.5 12.3-12.3c0-3.3-1.3-6.4-3.6-8.7l-2.8-2.8c-36.9-36.9-57.7-87-57.7-139.2V192c0-70.7-57.3-128-128-128zM193.8 458.7c4.4 12.4 16.3 21.3 30.2 21.3s25.8-8.9 30.2-21.3c2.9-8.3 12.1-12.7 20.4-9.8s12.7 12.1 9.8 20.4C275.6 494.2 251.9 512 224 512s-51.6-17.8-60.4-42.7c-2.9-8.3 1.4-17.5 9.8-20.4s17.5 1.4 20.4 9.8z" })), notice: /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 576 512" }, /* @__PURE__ */ React.createElement("path", { d: "M560 32c-8.8 0-16 7.2-16 16V59.5L32 187.5V176c0-8.8-7.2-16-16-16s-16 7.2-16 16v19.5V208v96 12.5V336c0 8.8 7.2 16 16 16s16-7.2 16-16V324.5l131.7 32.9c-2.4 8.4-3.7 17.4-3.7 26.6c0 53 43 96 96 96c46.2 0 84.7-32.6 93.9-76L544 452.5V464c0 8.8 7.2 16 16 16s16-7.2 16-16V440 72 48c0-8.8-7.2-16-16-16zM544 419.5L32 291.5v-71l512-128v327zM192 384c0-6.5 1-12.9 2.8-18.8l124 31C313.1 425.7 287.2 448 256 448c-35.3 0-64-28.7-64-64z" })) }, d = a.map((c, s) => { var u = { __html: c.body }, l = new Date(c.date); return /* @__PURE__ */ React.createElement("div", { key: "quur-block-emergency-emergency-alert-" + s, id: "quur-block-emergency-emergency-alert-" + s, className: "quur-emergency-alert-level-" + c.level.toLowerCase() + " quur-block-emergency-emergency-alert" }, /* @__PURE__ */ React.createElement("div", { className: "container" }, /* @__PURE__ */ React.createElement("div", { className: "quur-icon" }, i[c.level.toLowerCase()]), /* @__PURE__ */ React.createElement("div", { id: "quur-emergency-message-content-area-" + s, className: "quur-alert-message" }, /* @__PURE__ */ React.createElement("h2", { className: "quur-alert-title" }, c.title), /* @__PURE__ */ React.createElement("div", { className: "quur-alert-content", dangerouslySetInnerHTML: u })), /* @__PURE__ */ React.createElement("div", { className: "quur-alert-link" }, /* @__PURE__ */ React.createElement(g, { link: c.link, title: c.title })), /* @__PURE__ */ React.createElement("div", { className: "quur-emergency-timestamp" }, /* @__PURE__ */ React.createElement("span", { id: "quur-emergency-message-timestamp-value", className: "quur-emergency-timestamp-value" }, /* @__PURE__ */ React.createElement("nobr", null, l.toLocaleString("en-CA", { month: "short" }), " ", l.toLocaleString("en-CA", { day: "numeric" }), ", ", l.toLocaleString("en-CA", { year: "numeric" })), " ", /* @__PURE__ */ React.createElement("nobr", null, l.toLocaleString("en-CA", { hour: "numeric", hour12: !0, minute: "2-digit" }).replaceAll(".", "")))))); }); return /* @__PURE__ */ React.createElement(React.Fragment, null, d); } function g(e) { if (e.link != null) return /* @__PURE__ */ React.createElement("a", { href: e.link, "aria-label": "View details for " + e.title }, "Details"); } function m(e) { if (e.type === "drupaljsonapi" && e.data.map((t, a) => { const r = { id: t.id, date: t.attributes.field_notification_date, title: t.attributes.title, body: t.attributes.body.value, level: t.attributes.field_level, link: null }; setAlertsData((n) => [...n, r]); }), e.type === "alertable") { const t = { critical: "emergency", advisory: "warning", information: "notice", test: "notice" }; e.data.map((a, r) => { const n = { id: a.id, date: a.properties.sent, title: a.properties.title, body: "

" + a.properties.description + "

", level: t[a.properties.level], link: a.properties.link }; setAlertsData((o) => [...o, n]); }); } } function v(e) { const t = document.querySelector("#quur-emergency-alerts"); ReactDOM.createRoot(t, { identifierPrefix: "quurEmergencyAlertIds" }).render( /* @__PURE__ */ React.createElement(p, null) ); } function y() { v(); const e = window.location.search, t = new URLSearchParams(e); var a = !1; if (t.get("testemergencyalerts") != null && (a = !0), a == !0) var r = "/contentapi/jsonapi/node/test_notifications?sort=field_notification_date"; else var r = "/contentapi/jsonapi/node/notifications?sort=field_notification_date"; if (fetch(r).then((n) => { n.json().then((o) => { var i = o.data; m({ type: "drupaljsonapi", data: i }); }); }).catch((n) => { console.log(n); }), a == !0) var r = "/alertsapi/testfeed"; else var r = "/alertsapi/feed"; fetch(r).then((n) => { n.json().then((o) => { var i = o.features; if (a == !0) { var d = { geometry: { type: "Point", coordinates: [-76.515496, 44.229505] }, type: "Feature", properties: { cap_link: "https://demo.peasi.ca/demo1/2025/7511.cap", description: "For testing purposes, this alert is not generated by the alertable practice system, it is hard coded into the QU emergency alerts test code block.", msg_type: "Update", author: "果酱视频", title: "Simulated Critical Alert", geocode: "360302", link: "https://web-demo.peasi.ca/#/incidents/036a0ede-a95f-4a9a-b26d-ee18a018a3a3", level: "critical", event: "wildfire", sent: "2025-01-01T15:00:00-00:00", icon: "https://demo.peasi.ca/demo1/geo/v1/icons/critical-fire.png" }, id: 7511 }, c = { geometry: { type: "Point", coordinates: [-76.515496, 44.229505] }, type: "Feature", properties: { cap_link: "https://demo.peasi.ca/demo1/2025/7511.cap", description: "For testing purposes, this alert is not generated by the alertable practice system, it is hard coded into the QU emergency alerts test code block.", msg_type: "Update", author: "果酱视频", title: "Simulated Advisory Alert", geocode: "360302", link: "https://web-demo.peasi.ca/#/incidents/036a0ede-a95f-4a9a-b26d-ee18a018a3a3", level: "advisory", event: "wildfire", sent: "2025-01-01T14:00:00-00:00", icon: "https://demo.peasi.ca/demo1/geo/v1/icons/critical-fire.png" }, id: 7511 }, s = { geometry: { type: "Point", coordinates: [-76.515496, 44.229505] }, type: "Feature", properties: { cap_link: "https://demo.peasi.ca/demo1/2025/7511.cap", description: "For testing purposes, this alert is not generated by the alertable practice system, it is hard coded into the QU emergency alerts test code block.", msg_type: "Update", author: "果酱视频", title: "Simulated Information Alert", geocode: "360302", link: "https://web-demo.peasi.ca/#/incidents/036a0ede-a95f-4a9a-b26d-ee18a018a3a3", level: "information", event: "wildfire", sent: "2025-01-01T13:00:00-00:00", icon: "https://demo.peasi.ca/demo1/geo/v1/icons/critical-fire.png" }, id: 7511 }; i.push(d), i.push(c), i.push(s); } m({ type: "alertable", data: i }); }); }).catch((n) => { console.log(n); }); } function h() { function e() { typeof React < "u" && typeof ReactDOM < "u" && (clearInterval(t), y()); } const t = setInterval(e, 5); } function f() { document.addEventListener("DOMContentLoaded", h); } const w = f(); export { w as default };