PageSourceSearch

https://rpc.cfainstitute.org/modules/custom/rpc_search_api_coveo/js/dist/cfa-coveo-atomic-ui.js?tlgbvp

js cfainstitute.org collected 2026-09-24 07:45:23 UTC 6,456 bytes, 189 lines download raw bytes

1import "https://static.cloud.coveo.com/atomic/v2/atomic.esm.js";
2import { loadAdvancedSearchQueryActions as A, buildRedirectionTrigger as _, loadSearchConfigurationActions as E, loadSearchActions as O, loadSearchAnalyticsActions as R, parseCriterionExpression as k, loadSortCriteriaActions as x } from "https://static.cloud.coveo.com/atomic/v2/headless/headless.esm.js";
3const h = (n, e) => (e.customData.cfaData = drupalSettings.cfaData, e.originLevel2 = drupalSettings.cfaData.pageUrl, e);
4async function L() {
5  const n = document.querySelectorAll("#global-search-box");
6  for (const e of n)
7    await S(e, h);
8}
9async function N() {
10  const n = document.querySelectorAll(
11    ".cfa-coveo-atomic-ui-search-interface"
12  );
13  for (const e of n) {
14    if (await S(e, h), e.dataset.aq) {
15      const t = e.engine, o = A(t).updateAdvancedSearchQueries({
16        aq: e.dataset.aq
17      });
18      t.dispatch(o);
19    }
20    T(e), e.executeFirstSearch();
21  }
22}
23async function I() {
24  const n = document.querySelectorAll(
25    ".cfa-coveo-search-interface-atomic-with-headless"
26  );
27  for (const e of n) {
28    await S(e, h);
29    const t = e.engine, o = _(t);
30    o.subscribe(() => {
31      const { redirectTo: i } = o.state;
32      i && window.location.replace(i);
33    });
34    const a = A(
35      t
36    ).updateAdvancedSearchQueries({
37      aq: e.dataset.aq
38    });
39    t.dispatch(a), T(e), e.executeFirstSearch();
40  }
41}
42function q(n, { searchHub: e } = {}) {
43  const t = n.engine;
44  if (!t)
45    return;
46  if (e) {
47    const { updateSearchConfiguration: i } = E(t);
48    t.dispatch(i({ searchHub: e })), n.setAttribute("search-hub", e);
49  }
50  const { executeSearch: o } = O(t), { logInterfaceLoad: a } = R(t);
51  t.dispatch(o(a()));
52}
53window.cfaCoveo = window.cfaCoveo || {};
54window.cfaCoveo.initSearchBox = L;
55window.cfaCoveo.initCoveo = N;
56window.cfaCoveo.initCoveoHeadless = I;
57window.cfaCoveo.updateSearchHubAndRerunSearch = q;
58window.customElements.define("cfa-coveo-ui", Boolean);
59const v = "searchboxSubmit", U = "interfaceLoad", D = [v, "recentQueriesClick", "searchFromLink", "omniboxAnalytics"], l = "relevancy", d = "sortCriteria";
60function P(n) {
61  const e = n.querySelector(
62    "atomic-sort-dropdown > atomic-sort-expression"
63  );
64  return (e == null ? void 0 : e.getAttribute("expression")) ?? null;
65}
66function H(n) {
67  const e = [];
68  for (const [t, o] of n.entries())
69    e.push(o === "" ? t : `${t}=${encodeURIComponent(o)}`);
70  return e.join("&");
71}
72function z(n) {
73  const e = H(n);
74  window.location.hash.slice(1) !== e && history.replaceState(
75    null,
76    "",
77    `${window.location.pathname}${window.location.search}#${e}`
78  );
79}
80function b(n, e) {
81  const t = n.engine;
82  if (!(!t || !e))
83    try {
84      const o = k(e);
85      if (!o.length)
86        return;
87      const { updateSortCriterion: a } = x(t);
88      t.dispatch(
89        a(o.length === 1 ? o[0] : o)
90      );
91    } catch (o) {
92      console.warn("Unable to sync Coveo sort dropdown:", o);
93    }
94}
95function T(n) {
96  const e = new URLSearchParams(window.location.hash.slice(1)), t = e.get("q");
97  if (!(t != null && t.trim()))
98    return;
99  const o = e.get(d);
100  o && o !== l || b(n, l);
101}
102function Q(n, e) {
103  var p, w, C;
104  const t = JSON.parse(n.body), o = new URLSearchParams(window.location.hash.slice(1)), a = o.get(d), i = (p = t.analytics) == null ? void 0 : p.actionCause, s = !!t.q, c = t.sortCriteria, g = P(e);
105  let r = c, u = !1;
106  if (s && c !== l && (i && D.includes(i) && c || i === U && !a) ? (r = l, o.set("q", t.q), u = !0) : i === v && !s && (!c || c === l) && g && (r = g, o.has("q") && (o.delete("q"), u = !0)), r && r !== c) {
107    b(e, r);
108    const f = (C = (w = e.engine) == null ? void 0 : w.state) == null ? void 0 : C.sortCriteria;
109    f && f !== c && (r = f), t.sortCriteria = r, n.body = JSON.stringify(t);
110  }
111  return r && r !== l ? a !== r && (o.set(d, r), u = !0) : a !== null && (o.delete(d), u = !0), u && z(o), n;
112}
113async function S(n, e) {
114  Y(".toggleResultLayout"), await customElements.whenDefined("atomic-search-interface"), n instanceof customElements.get("atomic-search-interface") || customElements.upgrade(n), await n.initialize({
115    accessToken: await m(),
116    preprocessRequest: (a, i, s) => {
117      if (a.url.includes("/querySuggest?") && a.body) {
118        const c = JSON.parse(a.body);
119        c.tab = c.searchHub === "RPC-Site-Search-Hub" ? "/search" : drupalSettings.cfaData.pageUrl, a.body = JSON.stringify(c);
120      }
121      return (s == null ? void 0 : s.method) === "search" && i === "searchApiFetch" ? Q(a, n) : a;
122    },
123    // Replace with an API key or search token that grants the privileges to execute queries and push usage analytics data.
124    organizationId: drupalSettings.coveo.organization_id,
125    organizationEndpoints: await n.getOrganizationEndpoints(
126      drupalSettings.coveo.organization_id
127    ),
128    analytics: {
129      analyticsClientMiddleware: e
130    },
131    renewAccessToken: m
132  });
133  let o = !0;
134  typeof Osano < "u" && Osano && Osano.cm && (o = Osano.cm.analytics), n.analytics = o;
135}
136const y = "coveo_access_token";
137function B() {
138  const e = new URLSearchParams(window.location.search).get("check_logged_in");
139  return !!(e && e === "1");
140}
141async function m() {
142  const n = Cookies.get(y);
143  if (!B() && n && n.length && F(n))
144    return n;
145  {
146    const e = j();
147    if (e) {
148      const t = /* @__PURE__ */ new Date();
149      return t.setTime(t.getTime() + 23 * 3600 * 1e3), Cookies.set(y, await e, {
150        expires: t,
151        secure: !0
152      }), e;
153    }
154  }
155  return "";
156}
157async function j() {
158  const e = await (await fetch("/cfa/coveo/auth/token", {
159    method: "GET",
160    headers: {},
161    cache: "no-store"
162  })).json(), t = JSON.parse(e);
163  return t && t.hasOwnProperty("access_token") ? "" + t.access_token : e;
164}
165function F(n) {
166  if (n)
167    try {
168      const e = J(n), t = /* @__PURE__ */ new Date();
169      if (new Date(e.exp * 1e3) > t)
170        return !0;
171    } catch {
172      return !1;
173    }
174  return !1;
175}
176function J(n) {
177  const t = n.split(".")[1].replace(/-/g, "+").replace(/_/g, "/"), o = decodeURIComponent(window.atob(t).split("").map(function(a) {
178    return "%" + ("00" + a.charCodeAt(0).toString(16)).slice(-2);
179  }).join(""));
180  return JSON.parse(o);
181}
182function Y(n) {
183  const e = document.querySelector("atomic-result-list");
184  e && document.querySelectorAll(n).forEach(
185    (o) => o.addEventListener("click", (a) => {
186      e.display = a.target.dataset.layout;
187    })
188  );
189}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.