import { E as M } from "./Env-161a418e.mjs";
import { UrlHelper as q, DesktopChecker as N } from "@accelbyte/sdk";
function T(e) {
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
}
var P = {}, W = {
  get exports() {
    return P;
  },
  set exports(e) {
    P = e;
  }
}, R = {}, z = {
  get exports() {
    return R;
  },
  set exports(e) {
    R = e;
  }
};
(function(e, r) {
  Object.defineProperty(r, "__esModule", {
    value: !0
  }), r.default = _;
  function l(f) {
    return typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? l = function(o) {
      return typeof o;
    } : l = function(o) {
      return o && typeof Symbol == "function" && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
    }, l(f);
  }
  function _(f) {
    var i = typeof f == "string" || f instanceof String;
    if (!i) {
      var o = l(f);
      throw f === null ? o = "null" : o === "object" && (o = f.constructor.name), new TypeError("Expected a string but received a ".concat(o));
    }
  }
  e.exports = r.default, e.exports.default = r.default;
})(z, R);
var A = {}, Q = {
  get exports() {
    return A;
  },
  set exports(e) {
    A = e;
  }
}, S = {}, H = {
  get exports() {
    return S;
  },
  set exports(e) {
    S = e;
  }
};
(function(e, r) {
  Object.defineProperty(r, "__esModule", {
    value: !0
  }), r.default = l;
  function l() {
    var _ = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, f = arguments.length > 1 ? arguments[1] : void 0;
    for (var i in f)
      typeof _[i] > "u" && (_[i] = f[i]);
    return _;
  }
  e.exports = r.default, e.exports.default = r.default;
})(H, S);
(function(e, r) {
  Object.defineProperty(r, "__esModule", {
    value: !0
  }), r.default = o;
  var l = f(R), _ = f(S);
  function f(n) {
    return n && n.__esModule ? n : { default: n };
  }
  var i = {
    require_tld: !0,
    allow_underscores: !1,
    allow_trailing_dot: !1,
    allow_numeric_tld: !1,
    allow_wildcard: !1
  };
  function o(n, h) {
    (0, l.default)(n), h = (0, _.default)(h, i), h.allow_trailing_dot && n[n.length - 1] === "." && (n = n.substring(0, n.length - 1)), h.allow_wildcard === !0 && n.indexOf("*.") === 0 && (n = n.substring(2));
    var v = n.split("."), c = v[v.length - 1];
    return h.require_tld && (v.length < 2 || !/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(c) || /\s/.test(c)) || !h.allow_numeric_tld && /^\d+$/.test(c) ? !1 : v.every(function(g) {
      return !(g.length > 63 || !/^[a-z_\u00a1-\uffff0-9-]+$/i.test(g) || /[\uff01-\uff5e]/.test(g) || /^-|-$/.test(g) || !h.allow_underscores && /_/.test(g));
    });
  }
  e.exports = r.default, e.exports.default = r.default;
})(Q, A);
var E = {}, Y = {
  get exports() {
    return E;
  },
  set exports(e) {
    E = e;
  }
};
(function(e, r) {
  Object.defineProperty(r, "__esModule", {
    value: !0
  }), r.default = v;
  var l = _(R);
  function _(c) {
    return c && c.__esModule ? c : { default: c };
  }
  var f = "(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])", i = "(".concat(f, "[.]){3}").concat(f), o = new RegExp("^".concat(i, "$")), n = "(?:[0-9a-fA-F]{1,4})", h = new RegExp("^(" + "(?:".concat(n, ":){7}(?:").concat(n, "|:)|") + "(?:".concat(n, ":){6}(?:").concat(i, "|:").concat(n, "|:)|") + "(?:".concat(n, ":){5}(?::").concat(i, "|(:").concat(n, "){1,2}|:)|") + "(?:".concat(n, ":){4}(?:(:").concat(n, "){0,1}:").concat(i, "|(:").concat(n, "){1,3}|:)|") + "(?:".concat(n, ":){3}(?:(:").concat(n, "){0,2}:").concat(i, "|(:").concat(n, "){1,4}|:)|") + "(?:".concat(n, ":){2}(?:(:").concat(n, "){0,3}:").concat(i, "|(:").concat(n, "){1,5}|:)|") + "(?:".concat(n, ":){1}(?:(:").concat(n, "){0,4}:").concat(i, "|(:").concat(n, "){1,6}|:)|") + "(?::((?::".concat(n, "){0,5}:").concat(i, "|(?::").concat(n, "){1,7}|:))") + ")(%[0-9a-zA-Z-.:]{1,})?$");
  function v(c) {
    var g = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
    if ((0, l.default)(c), g = String(g), !g)
      return v(c, 4) || v(c, 6);
    if (g === "4") {
      if (!o.test(c))
        return !1;
      var L = c.split(".").sort(function(F, x) {
        return F - x;
      });
      return L[3] <= 255;
    }
    return g === "6" ? !!h.test(c) : !1;
  }
  e.exports = r.default, e.exports.default = r.default;
})(Y, E);
(function(e, r) {
  Object.defineProperty(r, "__esModule", {
    value: !0
  }), r.default = V;
  var l = o(R), _ = o(A), f = o(E), i = o(S);
  function o(t) {
    return t && t.__esModule ? t : { default: t };
  }
  function n(t, a) {
    return L(t) || g(t, a) || v(t, a) || h();
  }
  function h() {
    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 v(t, a) {
    if (t) {
      if (typeof t == "string")
        return c(t, a);
      var u = Object.prototype.toString.call(t).slice(8, -1);
      if (u === "Object" && t.constructor && (u = t.constructor.name), u === "Map" || u === "Set")
        return Array.from(t);
      if (u === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(u))
        return c(t, a);
    }
  }
  function c(t, a) {
    (a == null || a > t.length) && (a = t.length);
    for (var u = 0, d = new Array(a); u < a; u++)
      d[u] = t[u];
    return d;
  }
  function g(t, a) {
    if (!(typeof Symbol > "u" || !(Symbol.iterator in Object(t)))) {
      var u = [], d = !0, p = !1, w = void 0;
      try {
        for (var y = t[Symbol.iterator](), m; !(d = (m = y.next()).done) && (u.push(m.value), !(a && u.length === a)); d = !0)
          ;
      } catch (s) {
        p = !0, w = s;
      } finally {
        try {
          !d && y.return != null && y.return();
        } finally {
          if (p)
            throw w;
        }
      }
      return u;
    }
  }
  function L(t) {
    if (Array.isArray(t))
      return t;
  }
  var F = {
    protocols: ["http", "https", "ftp"],
    require_tld: !0,
    require_protocol: !1,
    require_host: !0,
    require_port: !1,
    require_valid_protocol: !0,
    allow_underscores: !1,
    allow_trailing_dot: !1,
    allow_protocol_relative_urls: !1,
    allow_fragments: !0,
    allow_query_components: !0,
    validate_length: !0
  }, x = /^\[([^\]]+)\](?::([0-9]+))?$/;
  function k(t) {
    return Object.prototype.toString.call(t) === "[object RegExp]";
  }
  function I(t, a) {
    for (var u = 0; u < a.length; u++) {
      var d = a[u];
      if (t === d || k(d) && d.test(t))
        return !0;
    }
    return !1;
  }
  function V(t, a) {
    if ((0, l.default)(t), !t || /[\s<>]/.test(t) || t.indexOf("mailto:") === 0 || (a = (0, i.default)(a, F), a.validate_length && t.length >= 2083) || !a.allow_fragments && t.includes("#") || !a.allow_query_components && (t.includes("?") || t.includes("&")))
      return !1;
    var u, d, p, w, y, m, s, U;
    if (s = t.split("#"), t = s.shift(), s = t.split("?"), t = s.shift(), s = t.split("://"), s.length > 1) {
      if (u = s.shift().toLowerCase(), a.require_valid_protocol && a.protocols.indexOf(u) === -1)
        return !1;
    } else {
      if (a.require_protocol)
        return !1;
      if (t.substr(0, 2) === "//") {
        if (!a.allow_protocol_relative_urls)
          return !1;
        s[0] = t.substr(2);
      }
    }
    if (t = s.join("://"), t === "")
      return !1;
    if (s = t.split("/"), t = s.shift(), t === "" && !a.require_host)
      return !0;
    if (s = t.split("@"), s.length > 1) {
      if (a.disallow_auth || s[0] === "" || (d = s.shift(), d.indexOf(":") >= 0 && d.split(":").length > 2))
        return !1;
      var j = d.split(":"), D = n(j, 2), B = D[0], C = D[1];
      if (B === "" && C === "")
        return !1;
    }
    w = s.join("@"), m = null, U = null;
    var O = w.match(x);
    if (O ? (p = "", U = O[1], m = O[2] || null) : (s = w.split(":"), p = s.shift(), s.length && (m = s.join(":"))), m !== null && m.length > 0) {
      if (y = parseInt(m, 10), !/^[0-9]+$/.test(m) || y <= 0 || y > 65535)
        return !1;
    } else if (a.require_port)
      return !1;
    return a.host_whitelist ? I(p, a.host_whitelist) : !(!(0, f.default)(p) && !(0, _.default)(p, a) && (!U || !(0, f.default)(U, 6)) || (p = p || U, a.host_blacklist && I(p, a.host_blacklist)));
  }
  e.exports = r.default, e.exports.default = r.default;
})(W, P);
const Z = /* @__PURE__ */ T(P), $ = class {
  static silentUrlBuilder(e) {
    try {
      return new URL(e);
    } catch {
      return null;
    }
  }
  static silentSearchParamsBuilder(e) {
    try {
      return new URLSearchParams(e);
    } catch {
      return new URLSearchParams("");
    }
  }
  static makeAbsolutePath(e) {
    return `/${q.trimSlashFromStringStart(e)}`;
  }
  static transformToValidURLOrUndefined(e) {
    try {
      if (e)
        return new URL(e);
    } catch {
    }
  }
  static isValidUrl(e) {
    return typeof e != "string" ? !1 : Z(e, {
      protocols: ["http", "https"],
      require_tld: !1
    }) && e;
  }
  static isImageURL(e) {
    return !!this.isValidUrl(e) && e.match(/\.(jpeg|jpg|gif|png)$/) != null;
  }
  static getCurrentPathWithNoBaseName() {
    return window.location.pathname.slice(M.PLAYER_PORTAL_BASE_URL.length);
  }
  static getRedirectUrl(e, r) {
    return N.isDesktopApp() ? `${e}${q.trimSlashFromStringStart(r)}` : `${q.combineURLPaths(e, r)}`;
  }
  static getRouterRedirection(e, r) {
    const l = new URL(e), _ = new URL(r), f = l.origin === window.location.origin, i = l.origin === _.origin;
    return f || M.IS_DEV_MODE && i ? `${l.pathname}${l.search}` : null;
  }
};
let b = $;
b.stripColonFromProtocol = (e) => e[e.length - 1] === ":" ? e.slice(0, e.length - 1) : e;
b.checkUrlValidity = (e, r = !0) => $.isValidUrl2(e, r) ? null : `${e} is not a valid URL.`;
b.isValidUrl2 = (e, r = !0) => {
  try {
    return Boolean(new URL(e));
  } catch (l) {
    return r && console.error(l), !1;
  }
};
b.fixUrl = (e) => $.isValidUrl2(e, !1) ? e : `https://${e}`;
b.buildURLSearchParamsFromObject = (e) => {
  const r = {};
  for (const l in e)
    e[l] && (r[l] = `${e[l]}`);
  return new URLSearchParams(r);
};
export {
  b as U,
  R as a,
  T as g,
  S as m
};
