function e(){return typeof window<`u`}function t(){return!e()}var n=`analytics`;function r(){return window[n]}function i(e){n=e}function a(e){window[n]=e}var o=/(https?:\/\/[\w.\-:]+)\/(?:analytics\.js\/v1|v1\/analytics-js\/snippet)\/[\w\-:]+\/(analytics\.(?:min)\.js)/,s=function(){for(var e,t=Array.prototype.slice.call(document.querySelectorAll(`script`)),n=0,r=t;n<r.length;n++){var i=r[n],a=i.getAttribute(`src`)??``,s=o.exec(a);if(s&&s[1]&&(e=s[1]),i.dataset?.globalCustomerioAnalyticsKey!=null)break}return e},c,l=function(){return c??r()?._cdn},u=function(e){var t=r();t&&(t._cdn=e),c=e},d=function(){return l()||s()||`https://cdp.customer.io`},f=function(){return`${d()}/v1/analytics-js/actions`};function p(e){return Array.prototype.slice.call(window.document.querySelectorAll(`script`)).find(function(t){return t.src===e})}function m(e,t){var n=p(e);if(n!==void 0){var r=n?.getAttribute(`status`);if(r===`loaded`)return Promise.resolve(n);if(r===`loading`)return new Promise(function(e,t){n.addEventListener(`load`,function(){return e(n)}),n.addEventListener(`error`,function(e){return t(e)})})}return new Promise(function(n,r){var i,a=window.document.createElement(`script`);a.type=`text/javascript`,a.src=e,a.async=!0,a.setAttribute(`status`,`loading`);for(var o=0,s=Object.entries(t??{});o<s.length;o++){var c=s[o],l=c[0],u=c[1];a.setAttribute(l,u)}a.onload=function(){a.onerror=a.onload=null,a.setAttribute(`status`,`loaded`),n(a)},a.onerror=function(){a.onerror=a.onload=null,a.setAttribute(`status`,`error`),r(Error(`Failed to load ${e}`))};var d=window.document.getElementsByTagName(`script`)[0];(i=d.parentElement)==null||i.insertBefore(a,d)})}function h(e){var t=p(e);return t!==void 0&&t.remove(),Promise.resolve()}export{u as a,i as c,f as i,e as l,h as n,r as o,d as r,a as s,m as t,t as u};