{"version":3,"file":"components/localized-header.3334eff6d49ea09ca07c.js","mappings":"qIAuEA,IApEO,WACL,MAEMA,EAAM,MAGZ,IAAIC,EAAe,IAAIC,gBAAgBC,OAAOC,SAASC,QAuDvD,SAASC,IACPC,EAAE,eAAeC,YA5DW,oBA6D9B,CAtBA,IAA4BC,EA7BrBR,EAAaS,IAAIV,IAASC,EAAaS,IARlC,QAqCgBD,EAvBIR,EAAaS,IAAIV,GAAOA,EAd5C,MAsCHO,EAAEG,IAAoB,uEAAID,KAAOR,EAAaS,IAAID,OAZtDE,MAAMC,IAoBX,IAA6BC,KApBeD,SAqBE,IAAhBC,GAI5BN,EAAE,kDAAkDO,KAAKD,EAAe,eAzBrB,IAChDE,QAAO,IAAMT,MAlBdA,GAqDN,C","sources":["webpack://stdcheck-exposed-wp-theme/./themes/stdcheck-exposed/src/js/components/localized-header.js"],"sourcesContent":["/**\n * JS component for actions on Localized Header Components\n */\nexport function LocalizedHeaderComponent() {\n  const GEOTARGET_URL = 'https://us-central1-stdcheck-wp-theme.cloudfunctions.net/geotargets';\n  const LOADING_SPINNER_CLASS = 'is-loading-inline';\n  const IID = 'iid';\n  const PID = 'pid';\n\n  let searchParams = new URLSearchParams(window.location.search);\n\n  /**\n   * Starts the logic for localized header function\n   */\n  function localizedHeader() {\n    if (!searchParams.get(IID) && !searchParams.get(PID)) {\n      removeLoadingSpinner();\n\n      return;\n    }\n\n    displayGeotargetNameInHeading(searchParams.get(IID) ? IID : PID);\n  }\n\n  /**\n   * Fetches and displays the geotargeting name if it exists.\n   *\n   * A bad response will result in the default title being displayed.\n   *\n   * @param {string} key either iid or pid\n   */\n  function displayGeotargetNameInHeading(key) {\n    fetchGeotargetName(key)\n      .then((response) => displayLocationName(response))\n      .always(() => removeLoadingSpinner());\n  }\n\n  /**\n   * Executes the get location request.\n   *\n   * @param {string} key either iid or pid\n   *\n   * @returns {$.jqXHR}\n   */\n  function fetchGeotargetName(key) {\n    return $.get(GEOTARGET_URL + `?${key}=${searchParams.get(key)}`);\n  }\n\n  /**\n   * Replace the Primary section title showing user location based on either iid or pid\n   *\n   * @param {string} locationName Location name retrieved from STDCheck api.\n   */\n  function displayLocationName(locationName) {\n    if (!locationName || typeof locationName == 'undefined') {\n      return;\n    }\n\n    $(\"section[data-qa-id='Primary Index Section'] h1\").html(locationName + ' STD Testing');\n  }\n\n  /**\n   * Removes the loading spinner that is displayed while the geotarget is fetched.\n   */\n  function removeLoadingSpinner() {\n    $('#page-title').removeClass(LOADING_SPINNER_CLASS);\n  }\n\n  localizedHeader();\n}\n\nnew LocalizedHeaderComponent();\n"],"names":["IID","searchParams","URLSearchParams","window","location","search","removeLoadingSpinner","$","removeClass","key","get","then","response","locationName","html","always"],"sourceRoot":""}