sessionStorage.getItem("2f7038aa") || sessionStorage.setItem("2f7038aa", JSON.stringify({id: crypto.randomUUID(),start: new Date().getTime(),end: new Date().getTime()}));localStorage.getItem("b9d0a7f0") || localStorage.setItem("b9d0a7f0", JSON.stringify({id: crypto.randomUUID(),addedAt: new Date().getTime(),settings: {}}));var BMCWeb = {site: {"id":"0fd90fee-ab3a-471f-b64d-405e08a5cd09","name":"Sound of Aotearoa","website":"https://soundofaotearoa.co.nz/","hostname":"soundofaotearoa.co.nz","type":"Blog","timezone":"Pacific/Auckland"},view: {id: crypto.randomUUID(),start: new Date().getTime()},get: {},scripts: {},content: {}};BMCWeb.get.sessionDetails = function() {var i = JSON.parse(sessionStorage.getItem("2f7038aa"));i.end = new Date().getTime();i.duration = i.end - i.start;sessionStorage.setItem("2f7038aa", JSON.stringify(i));return i;};BMCWeb.get.activeTime = function() {var user = JSON.parse(localStorage.getItem("b9d0a7f0"));var now = new Date().getTime();var sess = JSON.parse(sessionStorage.getItem("2f7038aa"));return {user: now - user.addedAt,view: now - BMCWeb.view.start,session: now - sess.start};};BMCWeb.scripts.stringToSlug = function(string) {return String(string).toLowerCase().replaceAll("ā", "a").replaceAll("ē", "e").replaceAll("ī", "i").replaceAll("ō", "o").replaceAll("ū", "u").split("").filter((elem) => /^[a-zA-Z0-9 ]+$/.test(elem)).join("").split(" ").filter((elem) => elem).join("-");};var stringToSlug = BMCWeb.scripts.stringToSlug;BMCWeb.scripts.getSearchParams = function(url) {url = url || window.location.href;try {url = new URL(url);} catch (error) {return { success: false, error: "Invalid URL" };};var search = Object.fromEntries(url.searchParams.entries());return { success: true, search };};BMCWeb.scripts.waitForVar = function(gtr, interval = 100) {return new Promise((resolve) => {const timer = setInterval(() => {try {const val = gtr();if (val && typeof val !== "undefined") {clearInterval(timer);resolve(val);};} catch (e) {};}, interval);});};BMCWeb.scripts.normalString = function(str) {return str.replace(/([a-z])([A-Z])/g, '$1 $2').replace(/[-_]/g, ' ').split(' ').map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(' ');};BMCWeb.scripts.getScrollPercent = function() {const scrollX = window.scrollX || document.documentElement.scrollLeft;const scrollY = window.scrollY || document.documentElement.scrollTop;const docWidth = document.documentElement.scrollWidth - window.innerWidth;const docHeight = document.documentElement.scrollHeight - window.innerHeight;return [(scrollX / docWidth) * 100, (scrollY / docHeight) * 100];};BMCWeb.scripts.setFavicon = function(url) {let link = document.querySelector("link[rel~='icon']");if (!link) {link = document.createElement('link');link.rel = 'icon';document.head.appendChild(link);};link.href = url;};BMCWeb.scripts.importCSS = function(url) {var link = document.createElement("link");link.rel = "stylesheet";link.href = url;document.head.appendChild(link);};BMCWeb.scripts.importCSS(`https://scripts.bmcweb.co.nz/import?site=${BMCWeb.site.id}&type=style`);BMCWeb.scripts.importJS = function(src) {var s = document.createElement("script");s.src = src;document.head.appendChild(s);};BMCWeb.scripts.getTimezone = function(timeZone) {const date = new Date();const options = {timeZone,year: 'numeric',month: '2-digit',day: '2-digit',hour: '2-digit',minute: '2-digit',second: '2-digit'};const parts = new Intl.DateTimeFormat('en-US', options).formatToParts(date);const get = type => parts.find(p => p.type === type).value;return new Date(`${get('year')}-${get('month')}-${get('day')}T${get('hour')}:${get('minute')}:${get('second')}`);};var getTimezone = BMCWeb.scripts.getTimezone;BMCWeb.scripts.formatNames = function(names) {const len = names.length;if (len === 0) return '';if (len === 1) return names[0];if (len === 2) return `${names[0]} & ${names[1]}`;return `${names.slice(0, -1).join(', ')} & ${names[len - 1]}`;};BMCWeb.dataFill = {};BMCWeb.scripts.addToDataFill = function(key, value) {BMCWeb.scripts.updateDataFill();if (!key || value === undefined) return { success: false, error: "Missing Content" };if (typeof value !== "string") return { success: false, error: "Value Must Be String" };if (BMCWeb.dataFill[key] === value) return { success: false, error: "Already Exists", value };BMCWeb.dataFill[key] = value;BMCWeb.scripts.updateDataFill();return { success: true, value };};BMCWeb.scripts.updateDataFill = function() {var data = Object.keys(BMCWeb.dataFill).map((key) => key = { key, value: BMCWeb.dataFill[key] });for (var item of data) {function getElem(elem) {if (elem && elem instanceof HTMLElement && elem.innerHTML !== item.value) elem.innerHTML = item.value;};document.querySelectorAll(`[data-fill="${item.key}"]`).forEach(getElem);document.querySelectorAll(`[datafill="${item.key}"]`).forEach(getElem);document.querySelectorAll(`[filldata="${item.key}"]`).forEach(getElem);document.querySelectorAll(`[fillcontent="${item.key}"]`).forEach(getElem);document.querySelectorAll(`[content-fill="${item.key}"]`).forEach(getElem);};};BMCWeb.scripts.updateDataFill();document.addEventListener("DOMContentLoaded", BMCWeb.scripts.updateDataFill);document.addEventListener("DOMContentLoaded", function(){function getLogo(logo) {if (logo instanceof HTMLElement) {logo.setAttribute("title", logo.getAttribute("title") || BMCWeb.site.name);};};document.querySelectorAll(`[data-fitlogo]`).forEach(getLogo);document.querySelectorAll(`[fitlogo]`).forEach(getLogo);document.querySelectorAll(`.fitLogo`).forEach(getLogo);document.querySelectorAll(`.fitlogo`).forEach(getLogo);});BMCWeb.scripts.validateData = {isNumber: function(val) {return typeof val === "number" && !isNaN(val);}};(function(){var regexes = [["UUID", /^[0-9a-fA-F]{8}(-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}$/]];for (var item of regexes) {BMCWeb.scripts.validateData[`is${item[0]}`] = function(value, basic) {var out = item[1].test(value) ? { success: true, value } : { success: false, error: "Does Not Match" };return basic === true ? out.success : out;};};})();BMCWeb.site.foundedAt = new Date(BMCWeb.site.foundedAt);BMCWeb.scripts.logAnalytics = function() {var data = {url: window.location.href,hostname: window.location.hostname,site: BMCWeb.site.id,time: new Date().getTime(),device: {platform: navigator.platform,documentSize: [document.documentElement?.scrollWidth, document.documentElement?.scrollHeight],languages: navigator.languages,referer: document.referrer || document.referer,user: localStorage.getItem("b9d0a7f0") ? JSON.parse(localStorage.getItem("b9d0a7f0")).id : null},session: BMCWeb.get.sessionDetails()};navigator.sendBeacon(`https://api.bmcweb.co.nz/analytics/log`, JSON.stringify(data));};BMCWeb.scripts.logAnalytics();window.addEventListener("beforeunload", BMCWeb.scripts.logAnalytics);BMCWeb.scripts.updateAnalytics = function() {var sess = BMCWeb.get.sessionDetails();sess.pings = sess.pings || [];sess.pages = sess.pages || [];if (!sess.pages[0] || sess.pages[0].pathname !== window.location.pathname || sess.pages[0].view !== BMCWeb.view.id) sess.pages.unshift({id: crypto.randomUUID(),start: new Date().getTime(),end: new Date().getTime(),pathname: window.location.pathname,url: window.location.href,view: BMCWeb.view.id});var ping = JSON.stringify({page: sess.pages[0].id,url: window.location.href,title: document.title,view: BMCWeb.view.id,scroll: BMCWeb.scripts.getScrollPercent(),screen: [screen.width, screen.height, screen.availWidth, screen.availHeight],hidden: document.hidden,referrer: document.referrer || document.referer,online: navigator.onLine});if (!sess.pings[0] || sess.pings[0].data !== ping) sess.pings.unshift({id: crypto.randomUUID(),time: new Date().getTime(),data: ping});var page = sess.pages[0];page.end = new Date().getTime();sessionStorage.setItem("2f7038aa", JSON.stringify(sess));};BMCWeb.scripts.updateAnalytics();window.addEventListener("popstate", BMCWeb.scripts.updateAnalytics);window.addEventListener("mousemove", BMCWeb.scripts.updateAnalytics);window.addEventListener("focus", BMCWeb.scripts.updateAnalytics);window.addEventListener("blur", BMCWeb.scripts.updateAnalytics);window.addEventListener("scroll", BMCWeb.scripts.updateAnalytics);window.addEventListener("resize", BMCWeb.scripts.updateAnalytics);