import e from "/resources/libraries/react19/react.mjs"; import p from "/resources/libraries/react19/react-dom.mjs"; function v() { const [t, a] = e.useState([]); window.setAlertsData = a; const n = t.sort((i, o) => new Date(o.date) - new Date(i.date)), s = { emergency: /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 512 512" }, /* @__PURE__ */ e.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__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 448 512" }, /* @__PURE__ */ e.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__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 576 512" }, /* @__PURE__ */ e.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" })) }, m = n.map((i, o) => { var g = { __html: i.body }, d = new Date(i.date); return /* @__PURE__ */ e.createElement("div", { role: "alert", key: "quur-block-emergency-emergency-alert-" + o, id: "quur-block-emergency-emergency-alert-" + o, className: "quur-emergency-alert-level-" + i.level.toLowerCase() + " quur-block-emergency-emergency-alert" }, /* @__PURE__ */ e.createElement("div", { className: "container" }, /* @__PURE__ */ e.createElement("div", { className: "quur-icon" }, s[i.level.toLowerCase()]), /* @__PURE__ */ e.createElement("div", { id: "quur-emergency-message-content-area-" + o, className: "quur-alert-message" }, /* @__PURE__ */ e.createElement("h2", { className: "quur-alert-title" }, i.title), /* @__PURE__ */ e.createElement("div", { className: "quur-alert-content", dangerouslySetInnerHTML: g })), /* @__PURE__ */ e.createElement("div", { className: "quur-alert-link" }, /* @__PURE__ */ e.createElement(y, { link: i.link, title: i.title })), /* @__PURE__ */ e.createElement("div", { className: "quur-emergency-timestamp" }, /* @__PURE__ */ e.createElement("span", { id: "quur-emergency-message-timestamp-value", className: "quur-emergency-timestamp-value" }, /* @__PURE__ */ e.createElement("nobr", null, d.toLocaleString("en-CA", { month: "short" }), " ", d.toLocaleString("en-CA", { day: "numeric" }), ", ", d.toLocaleString("en-CA", { year: "numeric" })), " ", /* @__PURE__ */ e.createElement("nobr", null, d.toLocaleString("en-CA", { hour: "numeric", hour12: !0, minute: "2-digit" }).replaceAll(".", "")))))); }); return /* @__PURE__ */ e.createElement(e.Fragment, null, m); } function y(t) { if (t.link != null) return /* @__PURE__ */ e.createElement("a", { href: t.link, "aria-label": "View details for " + t.title }, "Details"); } function u(t) { if (t.type === "drupaljsonapi" && t.data.map((a, n) => { const c = { id: a.id, date: a.attributes.field_notification_date, title: a.attributes.title, body: a.attributes.body.value, level: a.attributes.field_level, link: null }; setAlertsData((r) => [...r, c]); }), t.type === "alertable") { const a = { critical: "emergency", advisory: "warning", information: "notice", test: "notice" }; t.data.map((n, c) => { const r = { id: n.id, date: n.properties.sent, title: n.properties.title, body: "

" + n.properties.description + "

", level: a[n.properties.level], link: n.properties.link }; setAlertsData((l) => [...l, r]); }); } } function h(t) { const a = document.querySelector("#quur-emergency-alerts"); p.createRoot(a, { identifierPrefix: "quurEmergencyAlertIds" }).render( /* @__PURE__ */ e.createElement(v, null) ); } function f() { h(); const t = window.location.search, a = new URLSearchParams(t); var n = !1; if (a.get("testemergencyalerts") != null && (n = !0), n == !0) var c = "/contentapi/jsonapi/node/test_notifications?sort=field_notification_date"; else var c = "/contentapi/jsonapi/node/notifications?sort=field_notification_date"; if (fetch(c).then((r) => { r.json().then((l) => { var s = l.data; u({ type: "drupaljsonapi", data: s }); }); }).catch((r) => { console.log(r); }), n == !0) var c = "/alertsapi/testfeed"; else var c = "/alertsapi/feed"; fetch(c).then((r) => { r.json().then((l) => { var s = l.features; if (n == !0) { var m = { 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 }, i = { 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 }, o = { 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 }; s.push(m), s.push(i), s.push(o); } u({ type: "alertable", data: s }); }); }).catch((r) => { console.log(r); }); } function w() { function t() { typeof e < "u" && typeof p < "u" && (clearInterval(a), f()); } const a = setInterval(t, 5); } function b() { document.addEventListener("DOMContentLoaded", w); } const k = b(); export { k as default };