import { __exports as R } from "./index.es91.js";
import "./index.es220.js";
import "./index.es221.js";
import { __exports as U } from "./index.es222.js";
import { __exports as B } from "./index.es223.js";
(function(v) {
  Object.defineProperty(v, "__esModule", {
    value: !0
  }), v.default = v.GA4 = void 0;
  var P = C(U), y = C(B), k = ["eventCategory", "eventAction", "eventLabel", "eventValue", "hitType"], T = ["title", "location"], M = ["page", "hitType"], x = ["action", "category", "label", "value", "nonInteraction", "transport"];
  function C(r) {
    return r && r.__esModule ? r : { default: r };
  }
  function _(r, t) {
    if (r == null)
      return {};
    var e = L(r, t), n, a;
    if (Object.getOwnPropertySymbols) {
      var o = Object.getOwnPropertySymbols(r);
      for (a = 0; a < o.length; a++)
        n = o[a], !(t.indexOf(n) >= 0) && Object.prototype.propertyIsEnumerable.call(r, n) && (e[n] = r[n]);
    }
    return e;
  }
  function L(r, t) {
    if (r == null)
      return {};
    var e = {}, n = Object.keys(r), a, o;
    for (o = 0; o < n.length; o++)
      a = n[o], !(t.indexOf(a) >= 0) && (e[a] = r[a]);
    return e;
  }
  function h(r) {
    "@babel/helpers - typeof";
    return typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? h = function(e) {
      return typeof e;
    } : h = function(e) {
      return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
    }, h(r);
  }
  function p(r) {
    return q(r) || E(r) || S(r) || j();
  }
  function j() {
    throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
  }
  function E(r) {
    if (typeof Symbol < "u" && r[Symbol.iterator] != null || r["@@iterator"] != null)
      return Array.from(r);
  }
  function q(r) {
    if (Array.isArray(r))
      return b(r);
  }
  function A(r, t) {
    var e = Object.keys(r);
    if (Object.getOwnPropertySymbols) {
      var n = Object.getOwnPropertySymbols(r);
      t && (n = n.filter(function(a) {
        return Object.getOwnPropertyDescriptor(r, a).enumerable;
      })), e.push.apply(e, n);
    }
    return e;
  }
  function d(r) {
    for (var t = 1; t < arguments.length; t++) {
      var e = arguments[t] != null ? arguments[t] : {};
      t % 2 ? A(Object(e), !0).forEach(function(n) {
        l(r, n, e[n]);
      }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(e)) : A(Object(e)).forEach(function(n) {
        Object.defineProperty(r, n, Object.getOwnPropertyDescriptor(e, n));
      });
    }
    return r;
  }
  function D(r, t) {
    return F(r) || Q(r, t) || S(r, t) || z();
  }
  function z() {
    throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
  }
  function S(r, t) {
    if (r) {
      if (typeof r == "string")
        return b(r, t);
      var e = Object.prototype.toString.call(r).slice(8, -1);
      if (e === "Object" && r.constructor && (e = r.constructor.name), e === "Map" || e === "Set")
        return Array.from(r);
      if (e === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))
        return b(r, t);
    }
  }
  function b(r, t) {
    (t == null || t > r.length) && (t = r.length);
    for (var e = 0, n = new Array(t); e < t; e++)
      n[e] = r[e];
    return n;
  }
  function Q(r, t) {
    var e = r == null ? null : typeof Symbol < "u" && r[Symbol.iterator] || r["@@iterator"];
    if (e != null) {
      var n = [], a = !0, o = !1, i, u;
      try {
        for (e = e.call(r); !(a = (i = e.next()).done) && (n.push(i.value), !(t && n.length === t)); a = !0)
          ;
      } catch (c) {
        o = !0, u = c;
      } finally {
        try {
          !a && e.return != null && e.return();
        } finally {
          if (o)
            throw u;
        }
      }
      return n;
    }
  }
  function F(r) {
    if (Array.isArray(r))
      return r;
  }
  function V(r, t) {
    if (!(r instanceof t))
      throw new TypeError("Cannot call a class as a function");
  }
  function O(r, t) {
    for (var e = 0; e < t.length; e++) {
      var n = t[e];
      n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(r, n.key, n);
    }
  }
  function W(r, t, e) {
    return t && O(r.prototype, t), e && O(r, e), r;
  }
  function l(r, t, e) {
    return t in r ? Object.defineProperty(r, t, { value: e, enumerable: !0, configurable: !0, writable: !0 }) : r[t] = e, r;
  }
  var I = /* @__PURE__ */ function() {
    function r() {
      var t = this;
      V(this, r), l(this, "reset", function() {
        t.isInitialized = !1, t._testMode = !1, t._currentMeasurementId, t._hasLoadedGA = !1, t._isQueuing = !1, t._queueGtag = [];
      }), l(this, "_gtag", function() {
        for (var e = arguments.length, n = new Array(e), a = 0; a < e; a++)
          n[a] = arguments[a];
        t._testMode || t._isQueuing ? t._queueGtag.push(n) : P.default.apply(void 0, n);
      }), l(this, "_loadGA", function(e, n) {
        if (!(typeof window > "u" || typeof document > "u") && !t._hasLoadedGA) {
          var a = document.createElement("script");
          a.async = !0, a.src = "https://www.googletagmanager.com/gtag/js?id=".concat(e), n && a.setAttribute("nonce", n), document.body.appendChild(a), window.dataLayer = window.dataLayer || [], window.gtag = function() {
            window.dataLayer.push(arguments);
          }, t._hasLoadedGA = !0;
        }
      }), l(this, "_toGtagOptions", function(e) {
        if (e) {
          var n = {
            // Old https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#cookieUpdate
            // New https://developers.google.com/analytics/devguides/collection/gtagjs/cookies-user-id#cookie_update
            cookieUpdate: "cookie_update",
            cookieExpires: "cookie_expires",
            cookieDomain: "cookie_domain",
            cookieFlags: "cookie_flags",
            // must be in set method?
            userId: "user_id",
            clientId: "client_id",
            anonymizeIp: "anonymize_ip",
            // https://support.google.com/analytics/answer/2853546?hl=en#zippy=%2Cin-this-article
            contentGroup1: "content_group1",
            contentGroup2: "content_group2",
            contentGroup3: "content_group3",
            contentGroup4: "content_group4",
            contentGroup5: "content_group5",
            // https://support.google.com/analytics/answer/9050852?hl=en
            allowAdFeatures: "allow_google_signals",
            allowAdPersonalizationSignals: "allow_ad_personalization_signals",
            nonInteraction: "non_interaction",
            page: "page_path",
            hitCallback: "event_callback"
          }, a = Object.entries(e).reduce(function(o, i) {
            var u = D(i, 2), c = u[0], s = u[1];
            return n[c] ? o[n[c]] = s : o[c] = s, o;
          }, {});
          return a;
        }
      }), l(this, "initialize", function(e) {
        var n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
        if (!e)
          throw new Error("Require GA_MEASUREMENT_ID");
        var a = typeof e == "string" ? [{
          trackingId: e
        }] : e;
        t._currentMeasurementId = a[0].trackingId;
        var o = n.gaOptions, i = n.gtagOptions, u = n.legacyDimensionMetric, c = u === void 0 ? !0 : u, s = n.nonce, f = n.testMode, m = f === void 0 ? !1 : f;
        if (t._testMode = m, m || t._loadGA(t._currentMeasurementId, s), t.isInitialized || (t._gtag("js", /* @__PURE__ */ new Date()), a.forEach(function(w) {
          var K = t._appendCustomMap(d(d(d({
            // https://developers.google.com/analytics/devguides/collection/gtagjs/pages#disable_pageview_measurement
            send_page_view: !1
          }, t._toGtagOptions(d(d({}, o), w.gaOptions))), i), w.gtagOptions), c);
          t._gtag("config", w.trackingId, K);
        })), t.isInitialized = !0, !m) {
          var g = p(t._queueGtag);
          for (t._queueGtag = [], t._isQueuing = !1; g.length; ) {
            var G = g.shift();
            t._gtag.apply(t, p(G)), G[0] === "get" && (t._isQueuing = !0);
          }
        }
      }), l(this, "set", function(e) {
        if (!e) {
          console.warn("`fieldsObject` is required in .set()");
          return;
        }
        if (h(e) !== "object") {
          console.warn("Expected `fieldsObject` arg to be an Object");
          return;
        }
        Object.keys(e).length === 0 && console.warn("empty `fieldsObject` given to .set()"), t._gaCommand("set", e);
      }), l(this, "_gaCommandSendEvent", function(e, n, a, o, i) {
        t._gtag("event", n, d(d({
          event_category: e,
          event_label: a,
          value: o
        }, i && {
          non_interaction: i.nonInteraction
        }), t._toGtagOptions(i)));
      }), l(this, "_gaCommandSendEventParameters", function() {
        for (var e = arguments.length, n = new Array(e), a = 0; a < e; a++)
          n[a] = arguments[a];
        if (typeof n[0] == "string")
          t._gaCommandSendEvent.apply(t, p(n.slice(1)));
        else {
          var o = n[0], i = o.eventCategory, u = o.eventAction, c = o.eventLabel, s = o.eventValue;
          o.hitType;
          var f = _(o, k);
          t._gaCommandSendEvent(i, u, c, s, f);
        }
      }), l(this, "_gaCommandSendTiming", function(e, n, a, o) {
        t._gtag("event", "timing_complete", {
          name: n,
          value: a,
          event_category: e,
          event_label: o
        });
      }), l(this, "_gaCommandSendPageview", function(e, n) {
        if (n && Object.keys(n).length) {
          var a = t._toGtagOptions(n), o = a.title, i = a.location, u = _(a, T);
          t._gtag("event", "page_view", d(d(d(d({}, e && {
            page_path: e
          }), o && {
            page_title: o
          }), i && {
            page_location: i
          }), u));
        } else
          e ? t._gtag("event", "page_view", {
            page_path: e
          }) : t._gtag("event", "page_view");
      }), l(this, "_gaCommandSendPageviewParameters", function() {
        for (var e = arguments.length, n = new Array(e), a = 0; a < e; a++)
          n[a] = arguments[a];
        if (typeof n[0] == "string")
          t._gaCommandSendPageview.apply(t, p(n.slice(1)));
        else {
          var o = n[0], i = o.page;
          o.hitType;
          var u = _(o, M);
          t._gaCommandSendPageview(i, u);
        }
      }), l(this, "_gaCommandSend", function() {
        for (var e = arguments.length, n = new Array(e), a = 0; a < e; a++)
          n[a] = arguments[a];
        var o = typeof n[0] == "string" ? n[0] : n[0].hitType;
        switch (o) {
          case "event":
            t._gaCommandSendEventParameters.apply(t, n);
            break;
          case "pageview":
            t._gaCommandSendPageviewParameters.apply(t, n);
            break;
          case "timing":
            t._gaCommandSendTiming.apply(t, p(n.slice(1)));
            break;
          case "screenview":
          case "transaction":
          case "item":
          case "social":
          case "exception":
            console.warn("Unsupported send command: ".concat(o));
            break;
          default:
            console.warn("Send command doesn't exist: ".concat(o));
        }
      }), l(this, "_gaCommandSet", function() {
        for (var e = arguments.length, n = new Array(e), a = 0; a < e; a++)
          n[a] = arguments[a];
        typeof n[0] == "string" && (n[0] = l({}, n[0], n[1])), t._gtag("set", t._toGtagOptions(n[0]));
      }), l(this, "_gaCommand", function(e) {
        for (var n = arguments.length, a = new Array(n > 1 ? n - 1 : 0), o = 1; o < n; o++)
          a[o - 1] = arguments[o];
        switch (e) {
          case "send":
            t._gaCommandSend.apply(t, a);
            break;
          case "set":
            t._gaCommandSet.apply(t, a);
            break;
          default:
            console.warn("Command doesn't exist: ".concat(e));
        }
      }), l(this, "ga", function() {
        for (var e = arguments.length, n = new Array(e), a = 0; a < e; a++)
          n[a] = arguments[a];
        if (typeof n[0] == "string")
          t._gaCommand.apply(t, n);
        else {
          var o = n[0];
          t._gtag("get", t._currentMeasurementId, "client_id", function(i) {
            t._isQueuing = !1;
            var u = t._queueGtag;
            for (o({
              get: function(f) {
                return f === "clientId" ? i : f === "trackingId" ? t._currentMeasurementId : f === "apiVersion" ? "1" : void 0;
              }
            }); u.length; ) {
              var c = u.shift();
              t._gtag.apply(t, p(c));
            }
          }), t._isQueuing = !0;
        }
        return t.ga;
      }), l(this, "event", function(e, n) {
        if (typeof e == "string")
          t._gtag("event", e, t._toGtagOptions(n));
        else {
          var a = e.action, o = e.category, i = e.label, u = e.value, c = e.nonInteraction, s = e.transport, f = _(e, x);
          if (!o || !a) {
            console.warn("args.category AND args.action are required in event()");
            return;
          }
          var m = {
            hitType: "event",
            eventCategory: (0, y.default)(o),
            eventAction: (0, y.default)(a)
          };
          i && (m.eventLabel = (0, y.default)(i)), typeof u < "u" && (typeof u != "number" ? console.warn("Expected `args.value` arg to be a Number.") : m.eventValue = u), typeof c < "u" && (typeof c != "boolean" ? console.warn("`args.nonInteraction` must be a boolean.") : m.nonInteraction = c), typeof s < "u" && (typeof s != "string" ? console.warn("`args.transport` must be a string.") : (["beacon", "xhr", "image"].indexOf(s) === -1 && console.warn("`args.transport` must be either one of these values: `beacon`, `xhr` or `image`"), m.transport = s)), Object.keys(f).filter(function(g) {
            return g.substr(0, 9) === "dimension";
          }).forEach(function(g) {
            m[g] = f[g];
          }), Object.keys(f).filter(function(g) {
            return g.substr(0, 6) === "metric";
          }).forEach(function(g) {
            m[g] = f[g];
          }), t._gaCommand("send", m);
        }
      }), l(this, "send", function(e) {
        t._gaCommand("send", e);
      }), l(this, "pageview", function(e, n, a) {
        var o = e == null ? void 0 : e.trim();
        if (o === "") {
          console.warn("path cannot be an empty string in .pageview()");
          return;
        }
        t._gaCommand("send", "pageview", o, {
          title: a
        });
      }), this.reset();
    }
    return W(r, [{
      key: "gtag",
      value: function() {
        this._gtag.apply(this, arguments);
      }
    }, {
      key: "_appendCustomMap",
      value: function(e) {
        var n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0;
        if (!n)
          return e;
        e.custom_map || (e.custom_map = {});
        for (var a = 1; a <= 200; a++)
          e.custom_map["dimension".concat(a)] || (e.custom_map["dimension".concat(a)] = "dimension".concat(a)), e.custom_map["metric".concat(a)] || (e.custom_map["metric".concat(a)] = "metric".concat(a));
        return e;
      }
      /**
       * @since v1.0.2
       * @param {string} [path="location.href"]
       * @param {string[]} [_] unsupported
       * @param {string} [title="location.pathname"]
       * @deprecated Use `.send("pageview")` instead
       */
    }, {
      key: "outboundLink",
      value: (
        /**
         * @since v1.0.6
         * @param {Object} options
         * @param {string} options.label
         * @param {function} hitCallback
         * @deprecated Use `enhanced measurement` feature in Google Analytics.
         */
        function(e, n) {
          var a = e.label;
          if (typeof n != "function") {
            console.warn("hitCallback function is required");
            return;
          }
          if (!a) {
            console.warn("args.label is required in outboundLink()");
            return;
          }
          var o = {
            hitType: "event",
            eventCategory: "Outbound",
            eventAction: "Click",
            eventLabel: (0, y.default)(a)
          }, i = !1, u = function() {
            i = !0, n();
          }, c = setTimeout(u, 250), s = function() {
            clearTimeout(c), i || n();
          };
          o.hitCallback = s, this._gaCommand("send", o);
        }
      )
    }]), r;
  }();
  v.GA4 = I;
  var H = new I();
  v.default = H;
})(R);
//# sourceMappingURL=index.es90.js.map
