var _BNTech=function(settings){if(null==settings)return!1;var _bntech={Settings:settings,Variables:{console:!1,Adblock:{variable:null,loaded:!1},URL:{url:null,params:null},Visitor:{referrer:null,viewPort:null,user:null,cid:null,session:null,lip:null,adblock:0},Page:{view:null,Meta:{},Window:{r:null,height:0,width:0},DOM:{height:0,width:0},Scroll:{ticker:!1,x:0,y:0}}},Metrics:{Init:function(event){if(_bntech.Variables.Adblock.loaded=!0,4!=_bntech.Settings.Services.Tracking.Version)return _bntech.Console.Log("Exiting before start.","bntech","mve"),!1;_bntech.Console.Log("Initializing metrics","bntech","mif"),_bntech.Metrics.Meta.Set(),_bntech.Variables.Visitor.referrer=_bntech.Utility.Page.Referrer(),_bntech.Variables.Visitor.viewPort=_bntech.Utility.Page.ViewPort(),_bntech.Variables.Visitor.user=_bntech.User.Cookie(_bntech.Settings.System.Cookies.User),_bntech.Variables.Visitor.cid=_bntech.User.CID(_bntech.Settings.System.Cookies.ID),_bntech.Variables.Visitor.session=_bntech.User.Session.Get(),_bntech.Variables.Visitor.adblock=void 0===window[_bntech.Variables.Adblock.variable]?1:0,_bntech.Variables.URL.url=_bntech.Utility.Page.URL(),_bntech.Metrics.Track("View",null,_bntech.Metrics.Callbacks.View)},Callbacks:{View:function(response){_bntech.Console.Log("Initial tracking response finished","bntech","ite"),void 0!==response.id&&(_bntech.Variables.Page.view=response.id),void 0!==response.message?_bntech.Message.Handle(response.message):_bntech.Variables.Page.Window.r=0,void 0!==_bntech.Settings.Services.Mather&&1==_bntech.Settings.Services.Mather.Active&&_bntech.Integrations.Mather.Queue(response),_bntech.Metrics.Queue.Run()},Scroll:{Ended:function(){_bntech.Variables.Page.Window.height=document.body.clientHeight,_bntech.Variables.Page.Window.width=document.body.clientWidth,_bntech.Variables.Page.DOM.height=Math.max(document.body.scrollHeight,document.body.offsetHeight,document.documentElement.clientHeight,document.documentElement.scrollHeight,document.documentElement.offsetHeight),_bntech.Variables.Page.DOM.width=Math.max(document.body.scrollWidth,document.body.offsetWidth,document.documentElement.clientHeight,document.documentElement.scrollWidth,document.documentElement.offsetWidth),_bntech.Variables.Page.Scroll.x=window.scrollX,_bntech.Variables.Page.Scroll.y=window.scrollY,_bntech.Metrics.Track("Scroll")},Tracker:function(){clearTimeout(_bntech.Variables.Page.Scroll.ticker),_bntech.Variables.Page.Scroll.ticker=setTimeout(_bntech.Metrics.Callbacks.Scroll.Ended,3e3)}}},Meta:{Tag:function(name){var meta=document.querySelectorAll("meta[name='"+name+"'], meta[property='"+name+"']");return!!meta[0]&&meta[0].getAttribute("content")},Local:function(name){var local=window.localStorage.getItem(name);return local||!1},Set:function(){for(var key in _bntech.Settings.Services.Tracking.Meta){var meta=_bntech.Settings.Services.Tracking.Meta[key];switch(void 0===_bntech.Variables.Page.Meta[meta.Group]&&(_bntech.Variables.Page.Meta[meta.Group]={}),meta.MetaType){case"url":_bntech.Console.Log("Looking for url","bntech","rwu"),_bntech.Variables.Page.Meta[meta.Group][meta.Name]=window.location.href;break;case"ls":var value;_bntech.Console.Log("Looking for local storage: "+meta.MetaName,"bntech","rls"),(value=_bntech.Metrics.Meta.Local(meta.MetaName))&&(_bntech.Variables.Page.Meta[meta.Group][meta.Name]=value);break;case"c":var value;_bntech.Console.Log("Looking for cookie: "+meta.MetaName,"bntech","rcv"),(value=_bntech.Utility.Cookie.Get(meta.MetaName))&&(_bntech.Variables.Page.Meta[meta.Group][meta.Name]=value);break;default:var value;_bntech.Console.Log("Looking for meta tag: "+meta.MetaName,"bntech","rmt"),(value=_bntech.Metrics.Meta.Tag(meta.MetaName))&&(_bntech.Variables.Page.Meta[meta.Group][meta.Name]=value)}}}},Track:function(action,custom,_callback){_bntech.Console.Log("Tracking: "+action,"bntech","mtf");var action,custom=null==custom?null:custom,_callback=null==_callback?null:_callback;if("View"!=(action=null==action?null:action)&&null==_bntech.Variables.Page.view)return _bntech.Metrics.Queue.Add(action,custom,_callback),!0;var data=_bntech.Metrics.Data[action]();data.event=_bntech.Utility.Object.Merge(data.event,[custom]);var headers={"X-API-Key":_bntech.Settings.Key,"X-API-Token":_bntech.Settings.System.Key,"X-Metric-Type":data.type};delete data.type,_bntech.Utility.Fetch("PUT",_bntech.Settings.System.URL+"/m/track",data,headers,_callback),_bntech.User.Session.Update(_bntech.Variables.Visitor.session)},Data:{View:function(){var meta=_bntech.Variables.Page.Meta;return meta.metrics.params=_bntech.Variables.URL.params,meta.metrics.url=window.location.href,{api:{url:_bntech.Variables.URL.url},meta:meta,visitor:{referrer:_bntech.Variables.Visitor.referrer,viewport:_bntech.Variables.Visitor.viewPort,user:_bntech.Variables.Visitor.user,cid:_bntech.Variables.Visitor.cid,session:_bntech.Variables.Visitor.session,adblock:_bntech.Variables.Visitor.adblock,ip:{local:_bntech.Variables.Visitor.lip}},event:{},type:"view"}},Click:function(){return{view:_bntech.Variables.Page.view,type:"click",event:{}}},Scroll:function(){return{view:_bntech.Variables.Page.view,type:"scroll",event:{window:{height:_bntech.Variables.Page.Window.height,width:_bntech.Variables.Page.Window.width},page:{height:_bntech.Variables.Page.DOM.height,width:_bntech.Variables.Page.DOM.width},position:{y:_bntech.Variables.Page.Scroll.y,x:_bntech.Variables.Page.Scroll.x}}}},Misc:function(){return{view:_bntech.Variables.Page.view,type:"misc",event:{}}},Error:function(){return{view:_bntech.Variables.Page.view,type:"error",event:{}}}},Queue:{queue:[],Add:function(action,custom,_callback){_bntech.Console.Log("Adding event to the queue.","bntech","mtq"),_bntech.Metrics.Queue.queue.push({action:action,custom:custom,_callback:_callback})},Run:function(){for(;_bntech.Metrics.Queue.queue.length>0;){var event=_bntech.Metrics.Queue.queue.shift();_bntech.Metrics.Track(event.action,event.custom,event._callback),_bntech.Console.console.appendChild(_bntech.Console.queue.shift())}}}},Message:{Handle:function(message){if(_bntech.Console.Log("Handling a message","bntech","hmd"),void 0!==message.redirect&&""!==message.redirect)return _bntech.Variables.Page.Window.r=1,message.redirect=message.redirect.replace("{{returnURL}}",`returnURL=${window.location}`),_bntech.Console.Log("Should be redirecting now","bntech","hmr"),window.location.replace(message.redirect),!0;_bntech.Variables.Page.Window.r=0,void 0!==message.css&&_bntech.Message.Style(message.css),void 0!==message.html&&("ready"===document.readyState||"complete"===document.readyState||"interactive"===document.readyState?_bntech.Message.Add(message.html):document.addEventListener("DOMContentLoaded",(function(event){_bntech.Message.Add(message.html)})))},Style:function(url){_bntech.Console.Log("Adding style sheet","bntech","mss");for(var i=0;i<document.styleSheets.length;i++)if(document.styleSheets[i].href==url)return!0;var head=document.getElementsByTagName("head")[0],link=document.createElement("link");link.rel="stylesheet",link.type="text/css",link.href=url,head.appendChild(link)},Add:function(message){_bntech.Console.Log("Adding message to the screen","bntech","amh");var body=document.getElementsByTagName("body")[0],tempDoc=(new DOMParser).parseFromString(message,"text/html"),container=document.createElement("div");container.setAttribute("id","bntmc"),container.innerHTML=message,body.appendChild(container);var script=tempDoc.querySelector("script");if(null!=script){var newScript=document.createElement("script"),inlineScript=document.createTextNode(script.innerHTML);newScript.appendChild(inlineScript),body.appendChild(newScript)}body=null,tempDoc=null,container=null,script=null,newScript=null,inlineScript=null}},User:{CID:function(key){var cid=_bntech.Utility.Cookie.Get(key);return cid||(cid=_bntech.Utility.Token(64),_bntech.Utility.Cookie.Set(key,cid,1e6)),cid},Cookie:function(key){var user=_bntech.Utility.Cookie.Get(key);return user?user.replace(/%3D/g,"="):null},Session:{Get:function(){var session=_bntech.Utility.Cookie.Get("_bnmsi");return session||(session=_bntech.Utility.Token(10),_bntech.Utility.Cookie.Set("_bnmsi",session,30)),session},Update:function(session){_bntech.Utility.Cookie.Set("_bnmsi",session,30)}},LocalIp:function(_callback){if(window.RTCPeerConnection=window.RTCPeerConnection||window.mozRTCPeerConnection||window.webkitRTCPeerConnection,void 0!==window.RTCPeerConnection){var pc=new RTCPeerConnection({iceServers:[]}),noop=function(){};void 0!==pc.createDataChannel?(pc.createDataChannel(""),pc.createOffer().then((function(offer){return pc.setLocalDescription(offer)})).catch((function(error){_callback("View")})),pc.onicecandidate=function(ice){ice&&ice.candidate&&ice.candidate.candidate?(_bntech.Variables.Visitor.lip=/([0-9]{1,3}(\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/.exec(ice.candidate.candidate)[1],_callback("View"),pc.onicecandidate=noop):_callback("View")}):_callback("View")}else _callback("View")}},Console:{queue:[],AddMessage:function(message,type,file,code,stack){_bntech.Scripts.loaded.console?BNTech.Console.AddMessage(message,type,file,code,stack):_bntech.Console.queue.push({message:message,type:type,file:file,code:code,stack:stack})},Log:function(message,file,code,stack){_bntech.Variables.console&&_bntech.Console.AddMessage(message,"message",file,code,stack)},Warn:function(message,file,code,stack){_bntech.Variables.console&&_bntech.Console.AddMessage(message,"warn",file,code,stack)},Error:function(message,file,code,stack){_bntech.Variables.console&&_bntech.Console.AddMessage(message,"error",file,code,stack)}},Integrations:{Mather:{Queue:function(data){if(_bntech.Console.Log("Adding Event to mather queue","bntech","imq"),response.data){var category="paywall",action="modal";response.data.count.remaining<=0&&(category="block",action="stop");var event={action:{category:category,action:action,vendor:"bntech",data:{cid:data.visitor.client_id,adblock:data.visitor.adblock,session:data.visitor.session,exception:response.data.exception,count:response.data.count.count,show:response.data.count.show,remaining:response.data.count.remaining,limit:response.data.count.limit,message:{}}}};void 0!==response.message&&(event.action.data.message={id:response.message.id,active:response.message.active,message:response.message.message,type:response.message.type}),(window._matherq=window._matherq||[]).push(["actionEvent",event,{userId:data.visitor.client_id}])}}}},Scripts:{loaded:{ab:0,console:0,sso:0},queue:{ab:[],sso:[]},Add:function(url,onload,onerror){var script=document.createElement("script");script.type="text/javascript",script.src=url,void 0!==onload&&(script.onload=onload),void 0!==onerror&&(script.onerror=onerror),document.head.appendChild(script)},Loaded:function(script){_bntech.Console.Log("Script loaded: "+script+".js","bntech","sl1"),_bntech.Scripts.loaded[script]=1,_bntech.Scripts.Run(script)},Run:function(script){for(var index in _bntech.Scripts.queue[script])_bntech.Scripts.queue[script][index]();_bntech.Scripts.queue[script]=[]}},Utility:{Cookie:{Get:function(name){for(var name=name+"=",cookies=document.cookie.split(";"),i=0;i<cookies.length;i++){for(var cookie=cookies[i];" "==cookie.charAt(0);)cookie=cookie.substring(1);if(0==cookie.indexOf(name))return cookie.substring(name.length,cookie.length)}return null},Set:function(name,value,time){document.cookie=name+"="+value+"; expires="+_bntech.Utility.Cookie.Time(time)+";path=/;domain="+_bntech.Settings.System.Cookies.Domain},Time:function(minutes){var date=new Date;return date.setTime(date.getTime()+60*minutes*1e3),date.toUTCString()}},Fetch:function(request,url,body,headers,callback){_bntech.Console.Log("Making an http request to: "+url,"bntech","hfr");var body=null==body?null:body,callback=null==callback?null:callback,xapi=new XMLHttpRequest;xapi.onreadystatechange=function(){if(xapi.readyState==XMLHttpRequest.DONE)if(400==xapi.status);else{var response=JSON.parse(xapi.response);callback&&callback(response)}},xapi.open(request,url,!0),xapi.setRequestHeader("Content-Type","application/json;charset=UTF-8");for(let hid in headers)xapi.setRequestHeader(hid,headers[hid]);xapi.send(JSON.stringify(body))},Token:function(length){for(var text="BNT",possible="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",i=0;i<length;i++)text+=possible.charAt(Math.floor(Math.random()*possible.length));return text},Base64:{_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){var t="",n,r,i,s,o,u,a,f=0;for(e=BNTech.Utility.Base64._utf8_encode(e);f<e.length;)s=(n=e.charCodeAt(f++))>>2,o=(3&n)<<4|(r=e.charCodeAt(f++))>>4,u=(15&r)<<2|(i=e.charCodeAt(f++))>>6,a=63&i,isNaN(r)?u=a=64:isNaN(i)&&(a=64),t=t+this._keyStr.charAt(s)+this._keyStr.charAt(o)+this._keyStr.charAt(u)+this._keyStr.charAt(a);return t},decode:function(e){var t="",n,r,i,s,o,u,a,f=0;for(e=e.replace(/[^A-Za-z0-9+/=]/g,"");f<e.length;)n=(s=this._keyStr.indexOf(e.charAt(f++)))<<2|(o=this._keyStr.indexOf(e.charAt(f++)))>>4,r=(15&o)<<4|(u=this._keyStr.indexOf(e.charAt(f++)))>>2,i=(3&u)<<6|(a=this._keyStr.indexOf(e.charAt(f++))),t+=String.fromCharCode(n),64!=u&&(t+=String.fromCharCode(r)),64!=a&&(t+=String.fromCharCode(i));return t=BNTech.Utility.Base64._utf8_decode(t)},_utf8_encode:function(e){e=e.replace(/rn/g,"n");for(var t="",n=0;n<e.length;n++){var r=e.charCodeAt(n);r<128?t+=String.fromCharCode(r):r>127&&r<2048?(t+=String.fromCharCode(r>>6|192),t+=String.fromCharCode(63&r|128)):(t+=String.fromCharCode(r>>12|224),t+=String.fromCharCode(r>>6&63|128),t+=String.fromCharCode(63&r|128))}return t},_utf8_decode:function(e){for(var t="",n=0,r=c1=c2=0;n<e.length;)(r=e.charCodeAt(n))<128?(t+=String.fromCharCode(r),n++):r>191&&r<224?(c2=e.charCodeAt(n+1),t+=String.fromCharCode((31&r)<<6|63&c2),n+=2):(c2=e.charCodeAt(n+1),c3=e.charCodeAt(n+2),t+=String.fromCharCode((15&r)<<12|(63&c2)<<6|63&c3),n+=3);return t}},Wait:function(ms){var d=new Date,d2=null;do{d2=new Date}while(d2-d<ms)},Object:{Is:function(value){return null!==value&&"object"==typeof value},Merge:function(original,objects){for(var oIndex=0,oLength=objects.length;oIndex<oLength;oIndex++){var object=objects[oIndex];if(_bntech.Utility.Object.Is(object))for(var keys=Object.keys(object),kIndex=0,kLength=keys.length;kIndex<kLength;kIndex++){var key=keys[kIndex],value=object[key];_bntech.Utility.Object.Is(value)?(void 0===original[key]&&(original[key]={}),_bntech.Utility.Object.Merge(original[key],[value])):original[key]=value}}return original}},Page:{URL:function(){return window.location.protocol+"//"+window.location.host},Params:function(url){var queryString=url?url.split("?")[1]:window.location.search.slice(1),params={};if(queryString)for(var arr=(queryString=queryString.split("#")[0]).split("&"),i=0;i<arr.length;i++){var a=arr[i].split("="),paramName=a[0],paramValue=void 0===a[1]||a[1];if(paramName=paramName.toLowerCase(),"string"==typeof paramValue&&(paramValue=paramValue.toLowerCase()),paramName.match(/\[(\d+)?\]$/)){var key=paramName.replace(/\[(\d+)?\]/,"");if(parmas[key]||(params[key]=[]),paramName.match(/\[\d+\]$/)){var index=/\[(\d+)\]/.exec(paramName)[1];params[key][index]=paramValue}else params[key].push(paramValue)}else params[paramName]?obj[paramName]&&"string"==typeof obj[paramName]?(params[paramName]=[params[paramName]],params[paramName].push(paramValue)):params[paramName].push(paramValue):params[paramName]=paramValue}return params},Referrer:function(){var url,ref;return _bntech.Console.Log("Getting referrer","bntech","urf"),document.referrer?document.referrer.match(/^(http([s]?)|android-app):\/\/([a-zA-Z0-9-_\.]+)(:[0-9]+)?/)[0]+"/":_bntech.Utility.Page.URL()},ViewPort:function(){_bntech.Console.Log("Getting view port","bntech","uvp");var width=window.innerWidth;return width<=767?"mobile website":width>=768&&width<992?"tablet-v website":width>=992&&width<1200?"tablet-h website":"desktop website"}}}};_bntech.Variables.URL.params=_bntech.Utility.Page.Params(),"1"===_bntech.Variables.URL.params.bntech_console&&(_bntech.Variables.console=!0,settings.Scripts.push("console")),_bntech.Console.Log("Adding script: ads.js","bntech","js1"),_bntech.Variables.Adblock.variable=_bntech.Utility.Token(10);var adsURL=settings.System.URL+"/js/"+settings.Key+"/ads/"+_bntech.Variables.Adblock.variable+"/googleads/ads.js";for(var index in _bntech.Scripts.Add(adsURL,_bntech.Metrics.Init,_bntech.Metrics.Init),settings.Scripts)_bntech.Console.Log("Loading script: "+settings.Scripts[index]+".js","bntech","js2"),_bntech.Scripts.Add(settings.System.URL+"/js/"+settings.Key+"/"+settings.Scripts[index]);return{Settings:{Get:function(key){return _bntech.Settings[key]}},Variables:{Get:function(variable){return _bntech.Variables[variable]}},Key:{Get:function(){return _bntech.Settings.Key}},Console:{queue:_bntech.Console.queue,Log:_bntech.Console.Log,Warn:_bntech.Console.Warn,Error:_bntech.Console.Error},Cookie:{Domain:function(){return _bntech.Settings.System.Cookies.Domain},Name:function(){return _bntech.Settings.System.Cookies.User},Get:function(a,b){return(b=document.cookie.match("(^|;)\\s*"+a+"\\s*=\\s*([^;]+)"))?b.pop():""},Parse:function(cookie){try{return JSON.parse(BNTech.Utility.Base64.decode(decodeURIComponent(cookie)))}catch(e){return null}}},Queue:function(api,callback){if(1==_bntech.Scripts.loaded[api])return callback(),!0;_bntech.Scripts.queue[api].push(callback)},Loaded:function(script){_bntech.Scripts.Loaded(script)},Utility:{Fetch:_bntech.Utility.Fetch,Base64:_bntech.Utility.Base64,Wait:_bntech.Utility.Wait,Console:{Log:_bntech.Console.Log,Warn:_bntech.Console.Warn,Error:_bntech.Console.Error}},Metrics:{Track:_bntech.Metrics.Track},Adblock:null,SSO:null}};var BNTech = new _BNTech({"Key":"1y9WbPk5fHPLhStc2nrD10OT8kK7KWn0","Scripts":["ab","sso"],"Services":{"Tracking":{"Meta":[{"Name":"page_type","Group":"pageData","MetaName":"og:type","MetaType":"m","Delimiter":""},{"Name":"post_category","Group":"pageData","MetaName":"og:section","MetaType":"m","Delimiter":""},{"Name":"post_id","Group":"pageData","MetaName":"parsely-post-id","MetaType":"m","Delimiter":""},{"Name":"post_title","Group":"pageData","MetaName":"og:title","MetaType":"m","Delimiter":""},{"Name":"post_date","Group":"pageData","MetaName":"parsely-pub-date","MetaType":"m","Delimiter":""},{"Name":"post_author","Group":"pageData","MetaName":"author","MetaType":"m","Delimiter":""},{"Name":"post_keywords","Group":"pageData","MetaName":"keywords","MetaType":"m","Delimiter":","},{"Name":"post_tags","Group":"pageData","MetaName":"parsely-tags","MetaType":"m","Delimiter":","},{"Name":"id","Group":"metrics","MetaName":"m:id","MetaType":"m","Delimiter":""}],"Version":4}},"System":{"Cookies":{"Domain":".buffalonews.com","ID":"TPCI","User":"bnUserInfo"},"Key":"sDHRhYNcAY76jxfUf8TSMaMu8a10WkQaw6DJ4Vi3kboimcYAGX","Source":{"default":{"authControlID":"0413WEB","domID":"a30e490d-c600-4ddf-b83f-76cab0bdced1","productID":"PM,HAMSUN,LDSUN,OPSUN,TWCSUN,WSSUN"},"eedit":{"authControlID":"0413EEDIT","domID":"2737d82e-cf7f-4dac-960d-eaee83cc64e2","productID":"PM"}},"URL":"https://api.bntech.io"}});