import { getToken as n } from "@das-fed/utils/common-info";
const o = (t) => {
  try {
    return new URL(t, location.origin).origin === location.origin;
  } catch {
    return !0;
  }
}, r = (t) => {
  if (!t) return "";
  if (!o(t)) return t;
  const e = new URL(t, location.origin);
  return e.searchParams.has("showLayout") || e.searchParams.set("showLayout", "false"), e.toString();
}, s = (t) => {
  if (!t) return "";
  let e = "";
  return o(t) && !t.includes("showWatermark=false") ? e = t.indexOf("?") !== -1 ? t + "&showWatermark=false" : t + "?showWatermark=false" : e = t, e;
}, i = (t) => {
  const e = n();
  return t.includes("?") ? `${t}&token=${e}` : `${t}?token=${e}`;
};
export {
  o as isRelativeOrSameDomain,
  r as setShowLayout,
  s as setShowWatermark,
  i as withToken
};
