import * as F from "react";
import n, { useRef as R, useState as w, useCallback as f, useEffect as G, useMemo as A } from "react";
import P from "dompurify";
import { marked as E } from "marked";
import { f as X, t as $, B as J, b as K, a as q, l as ee } from "./useRoutes-367960a3.mjs";
import { Trans as d } from "react-i18next";
import { E as x } from "./ErrorLayout-d232f96c.mjs";
import { T as k } from "./Typography-fd0ebec3.mjs";
import { E as j } from "./Env-92498313.mjs";
import { t as O } from "i18next";
import { S as z } from "./Select-934e9e99.mjs";
import { Accordion as te, AccordionItem as ne, AccordionTrigger as re, AccordionContent as ae } from "@radix-ui/react-accordion";
import ie from "classnames";
import { a as oe } from "./index-28007ca6.mjs";
import { Iam as ce } from "@accelbyte/sdk-iam";
import { Basic as se } from "@accelbyte/sdk-basic";
import { Network as _e } from "@accelbyte/sdk";
import { LocalizedPolicyVersionObject as me, Legal as U } from "@accelbyte/sdk-legal";
import { z as N } from "zod";
import "react-feather";
import "flat";
import "date-fns";
import "./utils.mjs";
import "uuid";
import "axios";
import "./InputLabel-760cfc94.mjs";
import "react-select";
import "./LoadingPage-d6d2cc0b.mjs";
import "react-dom";
import "buffer";
import "react-toastify";
import "@accelbyte/sdk-gdpr";
const le = "app _app_ea553", de = "root _root_3c171", ue = "container _container_dccb6", ge = "content _content_4287b", Me = "breadcrumbs _breadcrumbs_05c6a", Ie = "title _title_eccdd", De = "document _document_24d1c", Ne = "iframeHTMLRenderContent _iframeHTMLRenderContent_74560", Ae = "navigator _navigator_60fbd", Ee = "loadingContainer _loadingContainer_5408d", pe = "errorContainer _errorContainer_e3add", ye = "documentNavigator _documentNavigator_caed2", I = {
  app: le,
  root: de,
  container: ue,
  content: ge,
  breadcrumbs: Me,
  title: Ie,
  document: De,
  iframeHTMLRenderContent: Ne,
  navigator: Ae,
  loadingContainer: Ee,
  errorContainer: pe,
  documentNavigator: ye
}, je = "flexGrid _flexGrid_1b6ca", Ce = "column _column_f6eaf", Le = "row _row_e60e0", ve = {
  flexGrid: je,
  column: Ce,
  row: Le
};
class y extends F.Component {
  render() {
    const { children: e, className: r, flexFlow: o, flex: a } = this.props;
    return /* @__PURE__ */ F.createElement("div", { className: `${ve.flexGrid} ${o} ${r}`, style: { flex: a } }, e);
  }
}
y.defaultProps = {
  flexFlow: "row",
  flex: 1
};
const S = "section-", Te = 2;
var p = /* @__PURE__ */ ((t) => (t.html = "text/html", t.markdown = "text/markdown", t))(p || {});
const On = Object.values(p);
function fe(t) {
  const e = { FORCE_BODY: !0, WHOLE_DOCUMENT: !0 };
  return P.sanitize(t, e);
}
function we(t) {
  E.setOptions({ headerPrefix: S });
  const e = E(t);
  return fe(e);
}
function xe(t) {
  E.setOptions({ headerPrefix: S });
  const e = E.lexer(t).filter((a) => a.type === "heading"), r = e.map((a) => a.depth).filter((a, i, c) => c.indexOf(a) === i);
  return e.map((a) => ({
    ...a,
    depth: r.indexOf(a.depth)
  })).filter((a) => a.depth < Te);
}
function Se({ htmlString: t, localizedPolicy: e }) {
  const r = R(null), [o, a] = w("0px"), i = f(() => {
    const s = r.current, m = s != null && s.contentWindow ? s.contentWindow.document.documentElement.scrollHeight + "px" : "100vh";
    a(m);
  }, [r]);
  G(() => {
    i();
  }, [i]);
  const c = A(
    () => e != null && e.publishedDate ? Intl.DateTimeFormat(X(), {
      year: "numeric",
      month: "long",
      day: "numeric"
    }).format(new Date(e.publishedDate)) : null,
    [e == null ? void 0 : e.publishedDate]
  ), _ = A(
    () => [e == null ? void 0 : e.parentNamespace, c].filter((s) => !!s),
    [e == null ? void 0 : e.parentNamespace, c]
  );
  return /* @__PURE__ */ n.createElement(y, { flex: 1, className: I.content }, _.length > 0 && /* @__PURE__ */ n.createElement("div", { className: I.breadcrumbs }, _.map((s) => /* @__PURE__ */ n.createElement("div", { key: s }, s))), /* @__PURE__ */ n.createElement("div", { className: "relative" }, /* @__PURE__ */ n.createElement("div", { className: I.title }, e == null ? void 0 : e.parentName), (e == null ? void 0 : e.contentType) === p.markdown && t && /* @__PURE__ */ n.createElement("div", { className: I.document, dangerouslySetInnerHTML: { __html: we(t) } }), (e == null ? void 0 : e.contentType) === p.html && /* @__PURE__ */ n.createElement("div", { className: I.document }, /* @__PURE__ */ n.createElement(
    "iframe",
    {
      className: I.iframeHTMLRenderContent,
      title: "htmlEditor",
      srcDoc: t,
      ref: r,
      onLoad: i,
      style: { height: o }
    }
  ))));
}
const be = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNzIiIGhlaWdodD0iMTA4IiB2aWV3Qm94PSIwIDAgNzIgMTA4IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNMCA4N1Y1QzAgMi4yMzg1OCAyLjIzODU4IDAgNSAwSDQ2LjM2NzdDNDcuNzI5OSAwIDQ5LjAzMzEgMC41NTU3OSA0OS45NzYxIDEuNTM4ODdMNzAuNjA4NCAyMy4wNDkyQzcxLjUwMTQgMjMuOTgwMiA3MiAyNS4yMjAzIDcyIDI2LjUxMDNWODdDNzIgODkuNzYxNCA2OS43NjE0IDkyIDY3IDkySDVDMi4yMzg1OCA5MiAwIDg5Ljc2MTQgMCA4N1oiIGZpbGw9IiM3NTc1NzUiLz4KPHBhdGggZD0iTTQ4LjUgMTkuNVYwLjVMNzEuNSAyNC41SDUzLjVDNTAuNzM4NiAyNC41IDQ4LjUgMjIuMjYxNCA0OC41IDE5LjVaIiBmaWxsPSIjRTVFNUU1Ii8+CjxlbGxpcHNlIGN4PSIzNiIgY3k9IjEwNiIgcng9IjIwIiByeT0iMiIgZmlsbD0iIzNBM0EzQSIvPgo8cGF0aCBkPSJNMjggNDZDMjggNDguMjA5MSAyNi4yMDkxIDUwIDI0IDUwQzIxLjc5MDkgNTAgMjAgNDguMjA5MSAyMCA0NkMyMCA0My43OTA5IDIxLjc5MDkgNDIgMjQgNDJDMjYuMjA5MSA0MiAyOCA0My43OTA5IDI4IDQ2WiIgZmlsbD0iI0U1RTVFNSIvPgo8cGF0aCBkPSJNNTIgNDZDNTIgNDguMjA5MSA1MC4yMDkxIDUwIDQ4IDUwQzQ1Ljc5MDkgNTAgNDQgNDguMjA5MSA0NCA0NkM0NCA0My43OTA5IDQ1Ljc5MDkgNDIgNDggNDJDNTAuMjA5MSA0MiA1MiA0My43OTA5IDUyIDQ2WiIgZmlsbD0iI0U1RTVFNSIvPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTM2IDYxQzMwLjU0NzIgNjEgMjYuNTA3OSA2My40NDY3IDI1LjMyODcgNjQuNDk0OEMyNC41MDMyIDY1LjIyODcgMjMuMjM5IDY1LjE1NDMgMjIuNTA1MiA2NC4zMjg3QzIxLjc3MTQgNjMuNTAzMiAyMS44NDU3IDYyLjIzOSAyMi42NzEzIDYxLjUwNTJDMjQuNDkyMSA1OS44ODY3IDI5LjQ1MjggNTcgMzYgNTdDNDIuNTQ3MiA1NyA0Ny41MDc5IDU5Ljg4NjcgNDkuMzI4NyA2MS41MDUyQzUwLjE1NDMgNjIuMjM5IDUwLjIyODcgNjMuNTAzMiA0OS40OTQ4IDY0LjMyODdDNDguNzYxIDY1LjE1NDMgNDcuNDk2OSA2NS4yMjg3IDQ2LjY3MTMgNjQuNDk0OEM0NS40OTIxIDYzLjQ0NjcgNDEuNDUyOCA2MSAzNiA2MVoiIGZpbGw9IiNFNUU1RTUiLz4KPC9zdmc+Cgo=";
class C extends Error {
  constructor(e) {
    super(e), Object.setPrototypeOf(this, C.prototype);
  }
}
function he({ error: t }) {
  return t instanceof C ? /* @__PURE__ */ n.createElement(Fe, null) : t !== void 0 ? /* @__PURE__ */ n.createElement(ke, { error: t }) : /* @__PURE__ */ n.createElement(Oe, null);
}
function Fe() {
  return /* @__PURE__ */ n.createElement(
    x,
    {
      title: /* @__PURE__ */ n.createElement(d, { i18nKey: "Document.error.noPolicy.title" }, "No legal document yet"),
      icon: be,
      description: /* @__PURE__ */ n.createElement("div", null, /* @__PURE__ */ n.createElement(k, { tag: "p" }, /* @__PURE__ */ n.createElement(d, { i18nKey: "Document.error.noPolicy.description" }, "We are working quickly on the document ", /* @__PURE__ */ n.createElement("br", null), " so please do check back soon!")), /* @__PURE__ */ n.createElement(k, { tag: "p", fontSize: "sm" }, /* @__PURE__ */ n.createElement(d, { i18nKey: "Document.error.noPolicy.footer" }, "If you have any question or concern please contact support")))
    }
  );
}
const ke = ({ error: t }) => /* @__PURE__ */ n.createElement(x, { title: "", description: /* @__PURE__ */ n.createElement(ze, { error: t }) }), Oe = () => /* @__PURE__ */ n.createElement(x, { title: "", description: $("CommonError.networkError") });
function ze({ error: t }) {
  if (t) {
    if (j.isAxiosNetworkError(t))
      return /* @__PURE__ */ n.createElement(d, { i18nKey: "CommonError.networkError" }, "Cannot reach server. Please retry.");
  } else
    return null;
  const e = j.extractServiceErrorCode(t);
  if (e)
    switch (e) {
      case 40037:
        return /* @__PURE__ */ n.createElement(d, { i18nKey: "CommonError.LocalizedPolicy.InvalidParam" }, "Invalid Localized Policy Parameter");
      case 40038:
        return /* @__PURE__ */ n.createElement(d, { i18nKey: "CommonError.LocalizedPolicy.NotFound" }, "Policy Data Not Found");
    }
  return (j.isAxiosError(t) && t.response && t.response.status) === 403 ? /* @__PURE__ */ n.createElement(d, { i18nKey: "CommonError.playerPortal.forbidden" }, "You're not allowed") : j.isAxiosServerError(t) ? /* @__PURE__ */ n.createElement(d, { i18nKey: "CommonError.serverError" }, "There is some technical issues with our site right now. Please try again later.") : /* @__PURE__ */ n.createElement(d, { i18nKey: "CommonError.unknownError" }, "Something went wrong. Please contact administrator.");
}
const Qe = "app _app_0d913", Ze = "root _root_9b76f", Ge = "container _container_1218f", Ue = "documentFilter _documentFilter_ce8ce", We = "containerSticky _containerSticky_8e519", Ye = "selection _selection_40907", Be = "title _title_738d2", He = "accordion _accordion_22085", Ve = "filterSelect _filterSelect_07692", Re = "documentFilterMenu _documentFilterMenu_debdf", Pe = "filterClose _filterClose_449c2", Xe = "filterMenu _filterMenu_be0d4", D = {
  app: Qe,
  root: Ze,
  container: Ge,
  documentFilter: Ue,
  containerSticky: We,
  selection: Ye,
  title: Be,
  accordion: He,
  filterSelect: Ve,
  documentFilterMenu: Re,
  filterClose: Pe,
  filterMenu: Xe
};
function $e({
  countrySelectOptions: t,
  countrySelectValue: e,
  languageSelectOptions: r,
  languageSelectValue: o,
  onChangeCountry: a,
  onChangeLanguage: i
}) {
  return /* @__PURE__ */ n.createElement(y, { className: D.documentFilter }, /* @__PURE__ */ n.createElement("div", { className: D.containerSticky }, /* @__PURE__ */ n.createElement("div", { className: D.selection }, /* @__PURE__ */ n.createElement("div", { className: D.title }, /* @__PURE__ */ n.createElement(d, { i18nKey: "DocumentFilter.countryAndLanguages" }, "Country & Language")), /* @__PURE__ */ n.createElement(
    z,
    {
      isFullWidth: !0,
      value: e,
      onChange: a,
      options: t,
      className: D.filterSelect,
      placeholder: O("DocumentFilter.countries.placeholder", "Country")
    }
  ), /* @__PURE__ */ n.createElement(
    z,
    {
      isFullWidth: !0,
      value: o,
      onChange: i,
      options: r,
      className: D.filterSelect,
      placeholder: O("DocumentFilter.language.placeholder", "Language"),
      isDisabled: r && r.length <= 1
    }
  ))));
}
const Je = "app _app_ecc7c", Ke = "root _root_8469a", qe = "container _container_90eb4", et = "accordionContainer _accordionContainer_4e8bd", tt = "accordion _accordion_0a30d", nt = "accordionButton _accordionButton_9c4f5", rt = "accordionTrigger _accordionTrigger_10770", at = "accordionArrow _accordionArrow_9d669", it = "active _active_598e2", M = {
  app: Je,
  root: Ke,
  container: qe,
  accordionContainer: et,
  accordion: tt,
  accordionButton: nt,
  accordionTrigger: rt,
  accordionArrow: at,
  active: it
}, ot = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPG1hc2sgaWQ9Im1hc2swIiBtYXNrLXR5cGU9ImFscGhhIiBtYXNrVW5pdHM9InVzZXJTcGFjZU9uVXNlIiB4PSIwIiB5PSIwIiB3aWR0aD0iMTYiIGhlaWdodD0iMTYiPgo8cmVjdCB5PSIxNiIgd2lkdGg9IjE2IiBoZWlnaHQ9IjE2IiB0cmFuc2Zvcm09InJvdGF0ZSgtOTAgMCAxNikiIGZpbGw9IndoaXRlIi8+CjwvbWFzaz4KPGcgbWFzaz0idXJsKCNtYXNrMCkiPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTYuMzEzMTEgMTEuNjg3NUM2LjExNzg1IDExLjQ5MjMgNi4xMTc4NSAxMS4xNzU3IDYuMzEzMTEgMTAuOTgwNEw5LjI5Mjg5IDguMDAwNjVMNi4zMTMxMSA1LjAyMDg3QzYuMTE3ODUgNC44MjU2MSA2LjExNzg1IDQuNTA5MDMgNi4zMTMxMSA0LjMxMzc2QzYuNTA4MzcgNC4xMTg1IDYuODI0OTYgNC4xMTg1IDcuMDIwMjIgNC4zMTM3NkwxMC4zNTM2IDcuNjQ3MUMxMC41NDg4IDcuODQyMzYgMTAuNTQ4OCA4LjE1ODk0IDEwLjM1MzYgOC4zNTQyTDcuMDIwMjIgMTEuNjg3NUM2LjgyNDk2IDExLjg4MjggNi41MDgzOCAxMS44ODI4IDYuMzEzMTEgMTEuNjg3NVoiIGZpbGw9IndoaXRlIi8+CjwvZz4KPC9zdmc+Cgo=", ct = (t) => /* @__PURE__ */ n.createElement(J, { buttonType: K.PLAIN, buttonStyle: q.SECONDARY, buttonFontSize: ee.EXTRA_SMALL, ...t });
function st({
  groupedPolicies: t,
  localizedPolicy: e,
  onClickPolicy: r
}) {
  const o = e != null && e.localeCode && t ? Object.keys(t[e == null ? void 0 : e.localeCode]) : [];
  return /* @__PURE__ */ n.createElement("div", { className: M.accordionContainer }, /* @__PURE__ */ n.createElement(te, { type: "multiple", defaultValue: o }, o.map((a) => {
    const i = (t && Object.values(t[(e == null ? void 0 : e.localeCode) ?? ""][a] || {})) ?? [];
    return /* @__PURE__ */ n.createElement(ne, { key: a, value: a, className: M.accordion }, /* @__PURE__ */ n.createElement(re, { className: M.accordionTrigger }, /* @__PURE__ */ n.createElement("img", { className: M.accordionArrow, src: ot, alt: "document arrow" }), /* @__PURE__ */ n.createElement(ct, { hasOutline: !1, className: M.accordionButton }, a)), /* @__PURE__ */ n.createElement(ae, { className: M.accordionContent }, /* @__PURE__ */ n.createElement("ul", null, i.map((c) => /* @__PURE__ */ n.createElement(
      _t,
      {
        key: c == null ? void 0 : c.id,
        onClickPolicy: r,
        localizedPolicy: c,
        active: (e == null ? void 0 : e.id) === c.id
      }
    )))));
  })));
}
function _t({ active: t, localizedPolicy: e, onClickPolicy: r }) {
  return /* @__PURE__ */ n.createElement("li", { key: e.id, className: t ? M.active : "" }, t ? /* @__PURE__ */ n.createElement("span", null, e.parentName) : /* @__PURE__ */ n.createElement(
    "a",
    {
      onClick: () => {
        r && r(e);
      }
    },
    e.parentName
  ));
}
const mt = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTE4LjcgMTcuM0MxOS4xIDE3LjcgMTkuMSAxOC4zIDE4LjcgMTguN0MxOC41IDE4LjkgMTguMyAxOSAxOCAxOUMxNy43IDE5IDE3LjUgMTguOSAxNy4zIDE4LjdMMTIgMTMuNEw2LjcgMTguN0M2LjUgMTguOSA2LjMgMTkgNiAxOUM1LjcgMTkgNS41IDE4LjkgNS4zIDE4LjdDNC45IDE4LjMgNC45IDE3LjcgNS4zIDE3LjNMMTAuNiAxMkw1LjMgNi43MDAwMkM0LjkgNi4zMDAwMiA0LjkgNS43MDAwMiA1LjMgNS4zMDAwMkM1LjcgNC45MDAw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jFDMjEuNiAxNyAyMiAxNy40IDIyIDE4QzIyIDE4LjYgMjEuNiAxOSAyMSAxOUgzQzIuNCAxOSAyIDE4LjYgMiAxOEMyIDE3LjQgMi40IDE3IDMgMTdaIiBmaWxsPSJ3aGl0ZSIvPgo8L21hc2s+CjxnIG1hc2s9InVybCgjbWFzazApIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0wIDBIMjRWMjRIMFYwWiIgZmlsbD0id2hpdGUiLz4KPC9nPgo8L3N2Zz4K", dt = "legalDocumentFilter__title _legalDocumentFilter__title_77d59", ut = "legalDocumentFilter__open_btn _legalDocumentFilter__open_btn_0bf77", gt = "legalDocumentFilter__hidden _legalDocumentFilter__hidden_af70b", Mt = "legalDocumentFilter__background _legalDocumentFilter__background_cd4e9", It = "legalDocumentFilter__container _legalDocumentFilter__container_00500", Dt = "legalDocumentFilter__menu _legalDocumentFilter__menu_509ca", Nt = "legalDocumentFilter__close_btn _legalDocumentFilter__close_btn_5e274", u = {
  legalDocumentFilter__title: dt,
  legalDocumentFilter__open_btn: ut,
  legalDocumentFilter__hidden: gt,
  legalDocumentFilter__background: Mt,
  legalDocumentFilter__container: It,
  legalDocumentFilter__menu: Dt,
  legalDocumentFilter__close_btn: Nt
};
function At({
  localizedPolicy: t,
  groupedPolicies: e,
  onClickPolicy: r,
  countrySelectOptions: o,
  countrySelectValue: a,
  languageSelectOptions: i,
  languageSelectValue: c,
  onChangeCountry: _,
  onChangeLanguage: s
}) {
  const [m, l] = w(!1), L = f(() => {
    l(!0);
  }, []), v = f(() => {
    l(!1);
  }, []);
  return /* @__PURE__ */ n.createElement(n.Fragment, null, /* @__PURE__ */ n.createElement("button", { onClick: L, className: u.legalDocumentFilter__open_btn }, /* @__PURE__ */ n.createElement("img", { src: lt, alt: "show filter menu" })), /* @__PURE__ */ n.createElement("div", { className: m ? u.legalDocumentFilter__background : u.legalDocumentFilter__hidden }, /* @__PURE__ */ n.createElement("div", { className: u.legalDocumentFilter__container }, /* @__PURE__ */ n.createElement("div", { className: u.legalDocumentFilter__title }, /* @__PURE__ */ n.createElement("div", { className: u.legalDocumentFilter__menu }, /* @__PURE__ */ n.createElement(d, { i18nKey: "DocumentFilter.menu" }, "MENU")), /* @__PURE__ */ n.createElement("div", { className: u.legalDocumentFilter__close_btn, onClick: v }, /* @__PURE__ */ n.createElement("img", { src: mt, alt: "close filter" }))), /* @__PURE__ */ n.createElement(
    $e,
    {
      countrySelectOptions: o,
      countrySelectValue: a,
      languageSelectOptions: i,
      languageSelectValue: c,
      onChangeCountry: _,
      onChangeLanguage: s
    }
  ), /* @__PURE__ */ n.createElement(
    st,
    {
      groupedPolicies: e,
      localizedPolicy: t,
      onClickPolicy: r
    }
  ))));
}
const Et = "app _app_3be82", pt = "root _root_4d352", yt = "container _container_b1ee3", jt = "navigator _navigator_a00bf", Ct = "documentNavigator _documentNavigator_c8b8c", Lt = "stickyContainer _stickyContainer_84f7a", vt = "title _title_0e49a", Tt = "list _list_6304b", ft = "item _item_32387", wt = "active _active_9109a", g = {
  app: Et,
  root: pt,
  container: yt,
  navigator: jt,
  documentNavigator: Ct,
  stickyContainer: Lt,
  title: vt,
  list: Tt,
  item: ft,
  active: wt
}, xt = (t, e = {
  root: null,
  // Use the viewport as the root
  threshold: 0.5
}) => {
  const [r, o] = w([]);
  return G(() => {
    const a = new IntersectionObserver((i) => {
      const c = i.filter((_) => _.isIntersecting).map((_) => _.target.id);
      o(c);
    }, e);
    return t.forEach((i) => {
      const c = document.getElementById(i);
      c && a.observe(c);
    }), () => a.disconnect();
  }, [t, e]), r;
};
function St({ headings: t }) {
  const e = new E.Slugger(), r = t.map((i) => ({
    ...i,
    id: `${S}${e.slug(i.text)}`
  })), o = r.map(({ id: i }) => i), a = xt(o);
  return /* @__PURE__ */ n.createElement("div", { className: g.navigator }, /* @__PURE__ */ n.createElement(y, { className: g.documentNavigator }, /* @__PURE__ */ n.createElement("div", { className: g.stickyContainer }, /* @__PURE__ */ n.createElement("div", { className: g.title }, /* @__PURE__ */ n.createElement(d, { i18nKey: "Document.navigator.title" }, "Contents")), /* @__PURE__ */ n.createElement("div", { className: g.list }, r.map((i) => /* @__PURE__ */ n.createElement(
    "li",
    {
      key: `${i.id}`,
      "data-depth": i.depth,
      className: ie(g.item, { [g.active]: a.length && a[0] === i.id })
    },
    /* @__PURE__ */ n.createElement("a", { href: `#${i.id}` }, i.text)
  ))))));
}
function bt(t, e) {
  return t.toLowerCase() === e.toLowerCase();
}
function Q(t, e) {
  return e ? t.find((r) => bt(r.value, e)) : t[0];
}
function ht(t, e) {
  var a;
  let r;
  const o = {};
  for (const i of t) {
    const c = (a = i.policyVersions) == null ? void 0 : a[0];
    if (!c)
      continue;
    const _ = c.localizedPolicyVersions || [];
    for (const s of _) {
      let m = o[s.localeCode];
      m || (m = {}, o[s.localeCode] = m);
      let l = m[i.namespace];
      l || (l = {}, m[i.namespace] = l), l[s.id] = {
        ...s,
        parentId: i.id,
        parentNamespace: i.namespace,
        parentCountry: i.countryCode,
        parentName: i.policyName
      }, (e === s.id || !r) && (r = l[s.id]);
    }
  }
  return {
    groupedPolicies: o,
    activeLocalizedPolicy: r
  };
}
function Ft({ htmlString: t, localizedPolicy: e, hideNavigation: r }) {
  const o = A(() => (e == null ? void 0 : e.contentType) === p.markdown, [e == null ? void 0 : e.contentType]), a = A(() => o && t ? xe(t) : [], [o, t]);
  return /* @__PURE__ */ n.createElement("div", { className: "relative flex w-full flex-1" }, /* @__PURE__ */ n.createElement(Se, { htmlString: t, localizedPolicy: e }), !r && a.length > 0 && /* @__PURE__ */ n.createElement(St, { headings: a }));
}
const kt = "app _app_4149d", Ot = "root _root_cb732", zt = "container _container_4b201", Qt = "documentPage _documentPage_09293", Zt = "documentFilter _documentFilter_2d828", Gt = "documentContainer _documentContainer_49ef0", Ut = "documentFilterContainerHide _documentFilterContainerHide_f623f", Wt = "arrowTop _arrowTop_497e9", Yt = "chevronIcon _chevronIcon_c3f94", Bt = "documentFilterContainerShow _documentFilterContainerShow_37048", Ht = "text _text_a0952", Vt = {
  app: kt,
  root: Ot,
  container: zt,
  documentPage: Qt,
  documentFilter: Zt,
  documentContainer: Gt,
  documentFilterContainerHide: Ut,
  arrowTop: Wt,
  chevronIcon: Yt,
  documentFilterContainerShow: Bt,
  text: Ht
};
function zn({
  htmlString: t,
  localizedPolicy: e,
  groupedPolicies: r,
  onClickPolicy: o,
  countrySelectOptions: a,
  countrySelectValue: i,
  languageSelectOptions: c,
  languageSelectValue: _,
  onChangeCountry: s,
  onChangeLanguage: m,
  error: l
}) {
  return /* @__PURE__ */ n.createElement(y, { className: Vt.documentPage }, /* @__PURE__ */ n.createElement(
    At,
    {
      localizedPolicy: e,
      groupedPolicies: r,
      onClickPolicy: o,
      countrySelectOptions: a,
      countrySelectValue: i,
      languageSelectOptions: c,
      languageSelectValue: _,
      onChangeCountry: s,
      onChangeLanguage: m
    }
  ), l ? /* @__PURE__ */ n.createElement(he, { error: l }) : /* @__PURE__ */ n.createElement(Ft, { htmlString: t, localizedPolicy: e }));
}
const Rt = "app _app_0d11d", Pt = "root _root_6ccf7", Xt = "container _container_fc388", $t = "titleWrapper _titleWrapper_e57b0", Jt = "companyName _companyName_42e4c", Z = {
  app: Rt,
  root: Pt,
  container: Xt,
  titleWrapper: $t,
  companyName: Jt
};
function Qn() {
  const { state: t } = oe(), e = A(() => {
    var r, o, a;
    return (a = (o = (r = t.discoveryConfigData) == null ? void 0 : r.brandName) == null ? void 0 : o.data) == null ? void 0 : a.value;
  }, [t]);
  return /* @__PURE__ */ n.createElement("div", { className: Z.titleWrapper }, /* @__PURE__ */ n.createElement("div", { className: Z.companyName }, e, " ", /* @__PURE__ */ n.createElement(d, { i18nKey: "Document.legal" }, "Legal")));
}
async function Kt({ sdk: t }) {
  try {
    return (await ce.CountryApi(t).getCountries()).map(({ code: r, name: o }) => ({
      label: o,
      value: r
    }));
  } catch {
    throw new Error("failed to fetch country options");
  }
}
async function qt({ sdk: t, availableLanguages: e }) {
  try {
    const r = await se.MiscApi(t).getMiscLanguages();
    return e ? e.map((o) => ({
      label: r[o] ?? o,
      value: o
    })) : Object.keys(r).map((o) => ({
      label: r[o],
      value: o
    }));
  } catch {
    throw new Error("failed to fetch language options");
  }
}
async function en(t) {
  const e = _e.create();
  try {
    const { data: r } = await e.get(t);
    return r;
  } catch {
    throw new Error("failed to get legal document");
  }
}
const tn = me, Zn = tn.merge(
  N.object({
    parentId: N.string(),
    parentNamespace: N.string(),
    parentCountry: N.string(),
    parentName: N.string()
  })
);
async function nn({ sdk: t, countryCode: e, localizedPolicyId: r }) {
  const o = await U.PoliciesApi(t).getPolicyCountry_ByCountryCode(e, { defaultOnEmpty: !0 }).catch((s) => {
    throw new Error("failed to get legal policies by country");
  });
  if (!o.length)
    throw new C();
  const { groupedPolicies: a, activeLocalizedPolicy: i } = ht(o, r), c = Object.keys(a)[0], _ = i == null ? void 0 : i.id;
  return {
    policies: o,
    groupedPolicies: a,
    activeLocalizedPolicy: i,
    firstLanguageCode: c,
    firstPolicyId: _
  };
}
async function rn({ sdk: t, localizedPolicyId: e }) {
  try {
    return await U.LocalizedPolicyVersionsApi(t).getLocalizedPolicyVersion_ByLocalizedPolicyVersionId(e);
  } catch {
    throw new Error("failed to fetch localized policy");
  }
}
async function Gn({ sdk: t, localizedPolicyId: e, countryCode: r, languageCode: o }) {
  let a = e, i = r ?? "", c = o ?? "", _ = "", s = "";
  if (a) {
    const T = await rn({ sdk: t, localizedPolicyId: a });
    c = T.localeCode, i = T.policy.countryCode, s = T.attachmentLocation ?? "";
  }
  if (!i)
    throw new Error("Country code is required, because the policyId is undefined!");
  const { groupedPolicies: m, activeLocalizedPolicy: l, policies: L, firstLanguageCode: v, firstPolicyId: W } = await nn({
    sdk: t,
    countryCode: i,
    localizedPolicyId: e
  });
  c || (c = v), a || (a = W);
  const Y = Kt({ sdk: t }), B = qt({ sdk: t, availableLanguages: Object.keys(m) }), [b, h] = await Promise.all([Y, B]), H = Q(b, i), V = Q(h, c);
  return s && (_ = await en(s)), {
    policies: L,
    document: _,
    countryOptions: b,
    languageOptions: h,
    selectedCountry: H,
    selectedLanguage: V,
    groupedPolicies: m,
    activeLocalizedPolicy: l
  };
}
export {
  S as DOCUMENT_HEADER_PREFIX,
  Te as HEADING_LEVEL_DEPTH_TO_DISPLAY,
  he as LegalDocumentErrorWidget,
  st as LegalDocumentFilterAccordionWidget,
  _t as LegalDocumentFilterPolicy,
  At as LegalDocumentFilterWIthAccordionWidget,
  $e as LegalDocumentFilterWidget,
  St as LegalDocumentNavigationWidget,
  Se as LegalDocumentWidget,
  Ft as LegalDocumentWithNavigationWidget,
  Qn as LegalPageTitleWidget,
  zn as LegalPageWidget,
  Zn as LocalizedPolicyWithParentInfo,
  C as NoPolicyDataFound,
  On as SUPPORTED_FILE_TYPE,
  p as contentType,
  Kt as countryOptionsFetcher,
  xe as generateHeadingFromMd,
  we as generateHtmlFromMd,
  Q as getSelectedOptions,
  qt as languageOptionsFetcher,
  en as legalDocumentFetcher,
  nn as legalPoliciesFetcher,
  Gn as legalwidgetFetcher,
  rn as localizedPolicyFetcher,
  ht as processPolicyInformation,
  fe as sanitizeHTML
};
