function UET(o){this.stringExists=function(n){return n&&n.length>0};this.domain="bat.bing.com";this.URLLENGTHLIMIT=4096;this.pageLoadEvt="pageLoad";this.customEvt="custom";this.pageViewEvt="page_view";o.Ver=o.Ver!==undefined&&(o.Ver==="1"||o.Ver===1)?1:2;this.uetConfig={};this.beaconParams={};this.supportsCORS=this.supportsXDR=!1;this.paramValidations={string_hotel_partner:{type:"regex",regex:/^[a-zA-Z0-9\_]{1,64}$/,error:"Hotel partner ID ({p}) must contain 1-64 alphanumeric characters or underscore only."},string_hotel_booking:{type:"regex",regex:/^[a-zA-Z0-9]{1,64}$/,error:"Booking ID ({p}) must contain 1-64 alphanumeric characters only. If you use the customer’s actual booking reference number, it must be obfuscated or encrypted."},string_currency:{type:"regex",regex:/^[a-zA-Z]{3}$/,error:"{p} value must be ISO standard currency code"},number:{type:"num",digits:3,max:999999999999},integer:{type:"num",digits:0,max:999999999999},hct_los:{type:"num",digits:0,max:30},date:{type:"regex",regex:/^\d{4}-\d{2}-\d{2}$/,error:"{p} value must be in YYYY-MM-DD date format"},"enum":{type:"enum",error:"{p} value must be one of the allowed values"},array:{type:"array",error:"{p} must be an array with 1+ elements"}};this.knownParams={event_action:{beacon:"ea"},event_category:{beacon:"ec"},event_label:{beacon:"el"},event_value:{type:"number",beacon:"ev"},page_title:{},page_location:{},page_path:{},ecomm_prodid:{beacon:"prodid"},ecomm_pagetype:{type:"enum",values:["home","searchresults","category","product","cart","purchase","other"],beacon:"pagetype"},ecomm_totalvalue:{type:"number"},ecomm_category:{},hct_base_price:{type:"number"},hct_booking_xref:{type:"string_hotel_booking"},hct_checkin_date:{type:"date"},hct_checkout_date:{type:"date"},hct_length_of_stay:{type:"hct_los"},hct_partner_hotel_id:{type:"string_hotel_partner"},hct_total_price:{type:"number"},hct_pagetype:{type:"enum",values:["home","searchresults","offerdetail","conversionintent","conversion","property","cart","purchase","cancel","other"]},travel_destid:{},travel_originid:{},travel_pagetype:{type:"enum",values:["home","searchresults","offerdetail","conversionintent","conversion","cancel","other"]},travel_startdate:{type:"date"},travel_enddate:{type:"date"},travel_totalvalue:{type:"number"},affiliation:{},checkout_option:{},checkout_step:{type:"integer"},content_id:{},content_type:{},coupon:{},currency:{type:"string_currency",beacon:"gc"},description:{},fatal:{},method:{},name:{},revenue_value:{type:"number",beacon:"gv"},screen_name:{},search_term:{},shipping:{type:"number"},tax:{type:"number"},transaction_id:{},items:{type:"array"},"items.brand":{},"items.category":{},"items.creative_name":{},"items.creative_slot":{},"items.id":{},"items.list_name":{},"items.list_position":{type:"integer"},"items.location_id":{},"items.name":{},"items.price":{type:"number"},"items.quantity":{type:"number"},"items.variant":{},promotions:{type:"array"},"promotions.creative_name":{},"promotions.creative_slot":{},"promotions.id":{},"promotions.name":{}};this.knownEvents={add_payment_info:[],add_to_cart:["revenue_value","currency","items"],add_to_wishlist:["revenue_value","currency","items"],begin_checkout:["revenue_value","currency","items","coupon"],checkout_progress:["revenue_value","currency","items","coupon","checkout_step","checkout_option"],exception:["description","fatal"],generate_lead:["revenue_value","currency","transaction_id"],login:["method"],page_view:["page_title","page_location","page_path"],purchase:["transaction_id","revenue_value","currency","tax","shipping","items","coupon"],refund:["transaction_id","revenue_value","currency","tax","shipping","items"],remove_from_cart:["revenue_value","currency","items"],screen_view:["screen_name"],search:["search_term"],select_content:["items","promotion","content_type","content_id"],set_checkout_option:["checkout_step","checkout_option"],share:["method","content_type","content_id"],sign_up:["method"],view_item:["items"],view_item_list:["items"],view_promotion:["promotions"],view_search_results:["search_term"]};this.pageLevelParams={};this.legacyValidCustomEventKeyNames={ec:1,el:1,ev:1,ea:1,gv:1,gc:1,prodid:1,pagetype:1};this.ambiguousValidCustomEventKeyNames={ecomm_prodid:1,ecomm_pagetype:1};this.validRetailPageTypeValues={home:1,searchresults:1,category:1,product:1,cart:1,purchase:1,other:1};this.invalidKeyException="Invalid data: Key Name: ";this.invalidEventException="Invalid event type: Event Type: ";this.invalidPageTypeException="Invalid pagetype value: ";this.invalidProdIdException="The prodid value must be within 1 to 50 characters. Hyphen and alphanumeric characters are allowed.";this.missingPageTypeException="The pagetype parameter is required when you include the prodid parameter.";this.goalCurrencyFormatException="gc value must be ISO standard currency code";this.missingHotelParametersException="The hotel total price (hct_total_price) and currency parameters are required when you include other hotel parameters.";this.hotelVariableRevenueException="The variable revenue parameter (gv) cannot be sent when you include other hotel parameters.";this.evq=o.q instanceof Array?o.q:[];this.evqDispatch=!1;this.pageLoadDispatch=!1;this.documentLoaded=!!document.body;this.eventPushQueue=[];var n=this;this.domainName=null;this.msClkIdCookieName="_uetmsclkid";this.msClkIdCookieValuePrefix="_uet";this.msClkIdParamName="msclkid";this.msClkIdExpirationTime=7776e3;this.lengthMsClkId=32;this.msClkId=null;this.previousPage=null;this.checkuetHostdocumentload=function(){if(this.documentLoaded=!!document.body,n.documentLoaded){if(n.eventPushQueue.length>0){for(var t=0;t=0&&n<=2&&(this.uetConfig.errorBeaconLevel=n));this.uetConfig.disableAutoPageView=!1;o.disableAutoPageView===!0&&(this.uetConfig.disableAutoPageView=!0);window.XMLHttpRequest!==undefined&&"withCredentials"in new XMLHttpRequest&&(this.supportsCORS=!0);typeof XDomainRequest!="undefined"&&(this.supportsXDR=!0);u=window.location.protocol;i=0;o.Ver===1&&o.advertiserId!==undefined&&(i=o.advertiserId);this.postURL=u+"//"+this.domain+"/action/"+i;this.urlPrefix=this.postURL+"?";this.errPrefix=u+"//"+this.domain+"/action-err/"+i+"?";o.Ver!==1?(this.stringExists(o.tagId)&&!this.stringExists(o.ti)&&(o.ti=o.tagId),r={ti:0,Ver:0,tm:1,Tag:0,EXT_Data:0}):r={Ver:0,tagId:0,Tag:0,Sig:0,EXT_Data:0};for(t in o)r.hasOwnProperty(t)&&(this.beaconParams[t]=r[t]===1?encodeURIComponent(o[t]):o[t])};this.loadConfig();this.push=function(){var t=arguments,r,i,u=!1;if(t.length===1)if(r="event",t[0]===this.pageLoadEvt)i=[this.pageViewEvt,{}],u=!0;else{if(t[0]instanceof Array)if(t[0].length>0)t[0]=t[0][0];else return;i=["",t[0]||{}];u=!0}else if(t.length>1&&t[0]!==this.pageLoadEvt)r=t[0],i=Array.prototype.slice.call(t,1);else return;n.documentLoaded?n._push([r,i,u]):n.eventPushQueue.push([r,i,u])};this._push=function(n){var r,t,u,i;if(n[1]instanceof Array)if(n[0]==="event"){if(r=n[1][1]||{},t=n[1][0],t===null||t===undefined)return;u=t===this.pageViewEvt?this.pageLoadEvt:this.customEvt;this.evt(u,t,r,n[2])}else if(n[0]==="set"){if(typeof n[1][0]!="object")return;for(i in n[1][0])this.knownParams.hasOwnProperty(i)&&(this.pageLevelParams[i]=n[1][0][i])}};this.dispatchq=function(){var n,t,i,r,f,e,u;for(this.evqDispatch=!0,i=0;it.name?1:n.name=0?i:i+u;n.p=encodeURIComponent(f);n.r=encodeURIComponent(r)}return n};this.extractMsClkId=function(n){this.stringExists(this.msClkId)||(this.msClkId=this.getQueryParam(n.p,this.msClkIdParamName))};this.addPageData=function(n,t){var i,r;return t=t===!0,n=this.addFraudSignals(n),i=window.document.title,this.stringExists(i)&&!this.stringExists(n.tl)&&(n.tl=encodeURIComponent(i).replace(/%2C/gi,",")),window.document.head.getElementsByTagName("meta").keywords&&(r=window.document.head.getElementsByTagName("meta").keywords.content,this.stringExists(r)&&(n.kw=encodeURIComponent(r).replace(/%2C/gi,","))),t?this.stringExists(this.previousPage)&&!n.hasOwnProperty("r")&&(n.r=this.previousPage):(n=this.addUrlData(n),n=this.addLoadTime(n)),n};this.removeTrailingAmp=function(n){var t=n.charAt(n.length-1);return(t==="&"||t==="?")&&(n=n.substring(0,n.length-1)),n};this.throwError=function(n){var t,i;if(typeof CustomEvent=="function"&&(t={errMsg:n,tagId:o.ti},i=new CustomEvent("uetError",{detail:t}),window.dispatchEvent(i)),this.uetConfig.errorBeaconLevel>0){this.invisibleDiv||this.createInvisibleDiv(document.body);var r=this.combine(this.beaconParams,{errMsg:encodeURIComponent(n)}),u=this.stringifyToRequest(r),f=this.removeTrailingAmp(this.errPrefix+u);this.fireBeaconImg(f)}throw n;};this.validateValue=function(n,t,i,r){var u=0,f=t,e=i===undefined||i===0?!0:!1;return t.toString().indexOf(",")!==-1&&(f=t.replace(/,/g,"")),u=parseFloat(f),(isNaN(f)||isNaN(u)||e&&u.toString().indexOf(".")!==-1)&&this.throwError(n+" should be "+(e?"an integer":"a number")),u>r?this.throwError(n+" cannot be greater than "+r):u<0?this.throwError(n+" cannot be less than 0"):this.getDecimalPlaces(u)>i&&this.throwError(n+" cannot have more than "+i+" decimal places"),u};this.validateRegex=function(n,t,i){var r=n===null||n===undefined?"":n.toString();return r.match(t)||this.throwError(i),r};this.encodeParameter=function(n){var t=n===null||n===undefined?"":n.toString();return t.replace(/&/gi,"%26").replace(/#/gi,"%23")};this._validateProdId=function(n){return(n===null||n===undefined)&&this.throwError(this.invalidProdIdException),this.validateRegex(n,/^[a-zA-Z0-9\-]{1,50}$/,this.invalidProdIdException)};this.validateProdId=function(n){var t="",i;if(n instanceof Array){for(i=0;i0&&(t.ev=this.validateValue("ev",t.ev,3,999999999999));t.hasOwnProperty("gv")>0&&(t.gv=this.validateValue("gv",t.gv,3,999999999999));t.hasOwnProperty("gc")>0&&(t.gc=this.validateRegex(t.gc,/^[a-zA-Z]{3}$/,this.goalCurrencyFormatException));t.hasOwnProperty("ec")>0&&t.ec!==null&&t.ec!==undefined&&(r=encodeURIComponent(t.ec),t.ec=this.encodeParameter(t.ec),t.ec!==r&&(t.ec2=r));t.hasOwnProperty("ea")>0&&t.ea!==null&&t.ea!==undefined&&(u=encodeURIComponent(t.ea),t.ea=this.encodeParameter(t.ea),t.ea!==u&&(t.ea2=u));t.hasOwnProperty("el")>0&&t.el!==null&&t.el!==undefined&&(f=encodeURIComponent(t.el),t.el=this.encodeParameter(t.el),t.el!==f&&(t.el2=f));t.hasOwnProperty("ecomm_prodid")>0&&(t.prodid=t.ecomm_prodid,delete t.ecomm_prodid);t.hasOwnProperty("ecomm_pagetype")>0&&(t.pagetype=t.ecomm_pagetype,delete t.ecomm_pagetype);t.hasOwnProperty("pagetype")>0?(t.pagetype=this.validatePageType(t.pagetype,this.validRetailPageTypeValues),t.hasOwnProperty("prodid")>0&&(t.prodid=this.validateProdId(t.prodid))):t.hasOwnProperty("prodid")>0&&this.throwError(this.missingPageTypeException)};this.evt=function(n,t,i,r){var e,l,a,o,s,u,h,f,v,c;if(r=r!==!1,i=i||{},this.uetConfig.disableAutoPageView===!0&&this.evqDispatch===!1&&this.dispatchq(),typeof i=="object"){if(r?this.validateDataObject(n,i):(i.event_action=t,i=this.validateDataObjectNew(n,i)),n===this.customEvt){e=[];for(l in i)e.push(l);if(e.length===0)return;r||(i.en="Y")}else if(n===this.pageLoadEvt){if(i.ea!=null&&this.knownEvents.hasOwnProperty(i.ea)){a=this.knownEvents[i.ea];for(o in i)a.indexOf(o)===-1&&delete i[o]}if(s=!r&&i.hasOwnProperty("page_path"),s){if(i.spa="Y",this.pageLoadDispatch===!1?(u={},u=this.addPageData(u,!1),this.stringExists(u.p)&&(this.previousPage=u.p),i.r=u.r,i.lt=u.lt,u.hasOwnProperty("pt")&&(i.pt=u.pt),u.hasOwnProperty("pn")&&(i.pn=u.pn)):this.beaconParams.mid=this.getGuid(),i.hasOwnProperty("page_title")&&(i.tl=i.page_title,delete i.page_title),this.stringExists(this.previousPage)){if(h=this.previousPage.toUpperCase(),f=h.indexOf("%3A%2F%2F"),f===-1)return;v=i.page_path.substring(0,3).toUpperCase()==="%2F";v?(f+=9,c=h.indexOf("%2F",f),i.p=c===-1?this.previousPage+i.page_path:this.previousPage.substring(0,c)+i.page_path):i.p=this.previousPage}}else{if(this.pageLoadDispatch===!0)return;if(this.uetConfig.disableAutoPageView===!0&&r)return}this.pageLoadDispatch===!1&&(this.pageLoadDispatch=!0);i=this.addPageData(i,s);this.stringExists(i.p)&&(this.previousPage=i.p)}this.invisibleDiv||this.createInvisibleDiv(document.body);i.evt=n;window.self!=window.top&&(i.ifm=1);i=this.addMsClkId(i);this.fireBeacon(i);i.abf=!0;n===this.pageLoadEvt&&this.evqDispatch===!1&&this.dispatchq()}};this.getCookie=function(n,t,i){var r,u,e,f,o;if(!this.stringExists(n)||!this.stringExists(t)||(r=document.cookie,r.length===0))return null;for(e=0;e0&&r[u-1]!==" "&&r[u-1]!==";")e=u+n.length+1;else break}return(f=r.indexOf(";",u),f=f>=0?f:r.length,o=r.substring(u+n.length+1+t.length,f),o.length>i)?null:o};this._setCookie=function(n,t,i,r){document.cookie=n+"="+t+";expires="+i+(r?";domain=."+r:"")+";path=/"};this.setCookie=function(n,t,i,r,u,f){var s,c,h,o,e;if(!this.stringExists(n)||!this.stringExists(u)||!this.stringExists(t)||t.length>f)return null;if(s=new Date,s.setTime(s.getTime()+i*1e3),c=new Date,c.setTime(0),this.domainName===null||r){if(h=document.location&&document.location.hostname,h&&typeof h=="string"&&h!=="localhost")for(o=h.split("."),e=o.pop(),o.length===3&&Number(e)>=0&&(o=[]);o.length>0;)if(e=o.pop()+"."+e,r&&(this._setCookie(n,"",c.toUTCString(),e),r=!!this.getCookie(n,u,f)),!r&&(this._setCookie(n,u+t,s.toUTCString(),e),this.getCookie(n,u,f))){this.domainName=e;return}this.domainName=""}this._setCookie(n,u+t,s.toUTCString(),this.domainName)};this.getQueryParam=function(n,t){if(!this.stringExists(n)||!this.stringExists(t)||/[^\d\w]/.exec(t))return null;try{n=decodeURIComponent(n)}catch(u){}var i=new RegExp("[?&]"+t+"=([^&#]*)","i"),r=i.exec(n)||[,null];return r[1]};this.addMsClkId=function(n){if(o.Ver<2||this.uetConfig.cookieAllowed===!1)return n;this.extractMsClkId(this.addUrlData({}));var t="0";return this.stringExists(this.msClkId)?this.getCookie(this.msClkIdCookieName,this.msClkIdCookieValuePrefix,this.lengthMsClkId)!==this.msClkId&&(t="1"):this.msClkId=this.getCookie(this.msClkIdCookieName,this.msClkIdCookieValuePrefix,this.lengthMsClkId),this.stringExists(this.msClkId)?(this.setCookie(this.msClkIdCookieName,this.msClkId,this.msClkIdExpirationTime,!0,this.msClkIdCookieValuePrefix,this.lengthMsClkId),this.getCookie(this.msClkIdCookieName,this.msClkIdCookieValuePrefix,this.lengthMsClkId)!==this.msClkId&&(t+="N"),n.msclkid=encodeURIComponent(this.msClkId+"-"+t)):n.msclkid="N",n};this.createIframe=function(n){return this.invisibleFrame=this.createInvisibleElement(n,"iframe"),this.invisibleFrame.src="",this.invisibleFrame.name=this.invisibleFrame.id,this.invisibleFrame.id};this.clone=function(n,t){t===undefined&&(t={});for(var i in n)n.hasOwnProperty(i)&&(t[i]=n[i]);return t};this.combine=function(n,t){var i=this.clone(n);return i.alt&&delete i.alt,this.clone(t,i)};this.addHiddenFields=function(n,t,i,r){var e="",u,f;r&&(e=r+".");for(u in n)n.hasOwnProperty(u)&&(typeof n[u]=="object"?this.addHiddenFields(n[u],t,i,e+u):(f=i.createElement("input"),f.setAttribute("type","hidden"),f.setAttribute("name",e+u),f.setAttribute("value",n[u]),t.appendChild(f)))};this.fireBeacon=function(n){for(var r,e=this.urlPrefix,s=this.postURL,t=this.combine(this.beaconParams,n),u=this.stringifyToRequest(t),f=this.removeTrailingAmp(e+u),o=["el2","ec2","ea2","page_location","page_path","kw","p","tl","items"],i=0;encodeURI(f).length>this.URLLENGTHLIMIT&&o.length>i;i++)(r=o[i],r in t)&&(i<=2?t[r]="":delete t[r],u=this.stringifyToRequest(t),f=this.removeTrailingAmp(e+u));this.fireBeaconImg(f)}}