{"version":3,"file":"browser-update.js","names":["$bu","navigator","userAgent","ua","indexOf","window","unsupportedBrowser","document","getElementsByTagName","className","noscriptElements","i","length","element","result","j","childNodes","nodeValue","getAttribute","getElementById","outerHTML","t","I18n","div","createElement","innerHTML","sheet","style","body","appendChild","innerText","e","styleSheet","cssText","ex","marginTop","clientHeight","$buo"],"sources":["scripts/browser-update.js"],"sourcesContent":["//browser-update.org notification script, <browser-update.org>\n//Copyright (c) 2007-2009, MIT Style License <browser-update.org/LICENSE.txt>\n\n/* eslint-disable no-var */\n\n(function () {\n  var $buo = function () {\n    // Sometimes we have to resort to parsing the user agent string. :(\n    if (navigator && navigator.userAgent) {\n      var ua = navigator.userAgent;\n\n      // we don't ask Googlebot to update their browser\n      if (\n        ua.indexOf(\"Googlebot\") >= 0 ||\n        ua.indexOf(\"Mediapartners\") >= 0 ||\n        ua.indexOf(\"AdsBot\") >= 0\n      ) {\n        return;\n      }\n    }\n\n    if (!window.unsupportedBrowser) {\n      return;\n    }\n\n    document.getElementsByTagName(\"body\")[0].className += \" crawler\";\n    var noscriptElements = document.getElementsByTagName(\"noscript\");\n    // find the element with the \"data-path\" attribute set\n    for (var i = noscriptElements.length - 1; i >= 0; i--) {\n      var element = noscriptElements[i];\n\n      // noscriptElements[i].innerHTML contains encoded HTML, so we need to access\n      // the childNodes instead. Browsers seem to split very long content into multiple\n      // text childNodes.\n      var result = \"\";\n      for (var j = 0; j < element.childNodes.length; j++) {\n        result += element.childNodes[j].nodeValue;\n      }\n\n      if (element.getAttribute(\"data-path\")) {\n        document.getElementById(\"main\").outerHTML = result;\n      } else {\n        element.outerHTML = result;\n      }\n    }\n\n    // retrieve localized browser upgrade text\n    var t = window.I18n && I18n.t(\"browser_update\"); // eslint-disable-line no-undef\n    if (!t || t.indexOf(\".browser_update]\") !== -1) {\n      // very old browsers might fail to load even translations\n      t =\n        'Unfortunately, <a href=\"https://discourse.org/about#browser\">your browser is unsupported</a>. Please <a href=\"https://browsehappy.com\">switch to a supported browser</a> to view rich content, log in and reply.';\n    }\n\n    // create the notification div HTML\n    var div = document.createElement(\"div\");\n    div.className = \"buorg\";\n    div.innerHTML = \"<div>\" + t + \"</div>\";\n\n    // create the notification div stylesheet\n    var sheet = document.createElement(\"style\");\n    var style =\n      \".buorg {position:absolute; z-index:111111; width:100%; top:0px; left:0px; background:#FDF2AB; text-align:left; font-family: sans-serif; color:#000; font-size: 14px;} .buorg div {padding: 8px;} .buorg a, .buorg a:visited {color:#E25600; text-decoration: underline;} @media print { .buorg { display: none !important; } }\";\n\n    // insert the div and stylesheet into the DOM\n    document.body.appendChild(div); // put it last in the DOM so Googlebot doesn't include it in search excerpts\n    document.getElementsByTagName(\"head\")[0].appendChild(sheet);\n    try {\n      sheet.innerText = style;\n      sheet.innerHTML = style;\n      // eslint-disable-next-line no-unused-vars -- old browsers require binding this variable, even if unused\n    } catch (e) {\n      try {\n        sheet.styleSheet.cssText = style;\n        // eslint-disable-next-line no-unused-vars -- old browser require binding this variable, even if unused\n      } catch (ex) {\n        return;\n      }\n    }\n\n    // shift the body down to make room for our notification div\n    document.body.style.marginTop = div.clientHeight + \"px\";\n  };\n\n  $bu = $buo(); // eslint-disable-line no-undef\n})(this);\n"],"mappings":"AAoFEA,IA9EW,WAET,GAAIC,WAAaA,UAAUC,UAAW,CACpC,IAAIC,EAAKF,UAAUC;AAGnB,GACEC,EAAGC,QAAQ,cAAgB,GAC3BD,EAAGC,QAAQ,kBAAoB,GAC/BD,EAAGC,QAAQ,WAAa,EAExB,MAEJ,CAEA,GAAKC,OAAOC,mBAAZ,CAIAC,SAASC,qBAAqB,QAAQ,GAAGC,WAAa;AAGtD,IAFA,IAAIC,EAAmBH,SAASC,qBAAqB,YAE5CG,EAAID,EAAiBE,OAAS,EAAGD,GAAK,EAAGA,IAAK,CAOrD,IANA,IAAIE,EAAUH,EAAiBC,GAK3BG,EAAS,GACJC,EAAI,EAAGA,EAAIF,EAAQG,WAAWJ,OAAQG,IAC7CD,GAAUD,EAAQG,WAAWD,GAAGE;AAG9BJ,EAAQK,aAAa,aACvBX,SAASY,eAAe,QAAQC,UAAYN,EAE5CD,EAAQO,UAAYN,CAExB,CAGA,IAAIO,EAAIhB,OAAOiB,MAAQA,KAAKD,EAAE;AACzBA,IAAwC,IAAnCA,EAAEjB,QAAQ,sBAElBiB,EACE;AAIJ,IAAIE,EAAMhB,SAASiB,cAAc;AACjCD,EAAId,UAAY,QAChBc,EAAIE,UAAY,QAAUJ,EAAI;AAG9B,IAAIK,EAAQnB,SAASiB,cAAc,SAC/BG,EACF;AAGFpB,SAASqB,KAAKC,YAAYN,GAC1BhB,SAASC,qBAAqB,QAAQ,GAAGqB,YAAYH;AACrD,IACEA,EAAMI,UAAYH,EAClBD,EAAMD,UAAYE,CAEpB,CAAE,MAAOI,GACP,IACEL,EAAMM,WAAWC,QAAUN,CAE7B,CAAE,MAAOO,GACP,MACF,CACF,CAGA3B,SAASqB,KAAKD,MAAMQ,UAAYZ,EAAIa,aAAe,IA1DnD,CA2DF,CAEMC","ignoreList":[]}