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:\/\/.*)\/analytics\.js\/v1\/(?:.*?)\/(?:platform|analytics.*)?/,s=function(){var e;return Array.prototype.slice.call(document.querySelectorAll(`script`)).forEach(function(t){var n=t.getAttribute(`src`)??``,r=o.exec(n);r&&r[1]&&(e=r[1])}),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://cdn.segment.com`},f=function(){return`${d()}/next-integrations`};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.querySelector(`script`);d?(i=d.parentElement)==null||i.insertBefore(a,d):window.document.head.appendChild(a)})}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};