var BingAds_RS=function(t){"use strict";function e(t,e,n){return(e=function(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function n(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function r(t){for(var r=1;r>>2]>>>24-i%4*8&255;e[r+i>>>2]|=s<<24-(r+i)%4*8}else for(var a=0;a>>2]=n[a>>>2];return this.sigBytes+=o,this},clamp:function(){var e=this.words,n=this.sigBytes;e[n>>>2]&=4294967295<<32-n%4*8,e.length=t.ceil(n/4)},clone:function(){var t=a.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],n=0;n>>2]>>>24-o%4*8&255;r.push((i>>>4).toString(16)),r.push((15&i).toString(16))}return r.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r>>3]|=parseInt(t.substr(r,2),16)<<24-r%8*4;return new u.init(n,e/2)}},p=l.Latin1={stringify:function(t){for(var e=t.words,n=t.sigBytes,r=[],o=0;o>>2]>>>24-o%4*8&255;r.push(String.fromCharCode(i))}return r.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r>>2]|=(255&t.charCodeAt(r))<<24-r%4*8;return new u.init(n,e)}},d=l.Utf8={stringify:function(t){try{return decodeURIComponent(escape(p.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return p.parse(unescape(encodeURIComponent(t)))}},h=s.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=d.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var n,r=this._data,o=r.words,i=r.sigBytes,s=this.blockSize,a=i/(4*s),c=(a=e?t.ceil(a):t.max((0|a)-this._minBufferSize,0))*s,l=t.min(4*c,i);if(c){for(var f=0;f>>7)^(h<<14|h>>>18)^h>>>3,g=u[d-2],v=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;u[d]=y+u[d-7]+v+u[d-16]}var m=r&o^r&i^o&i,w=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),b=p+((c<<26|c>>>6)^(c<<21|c>>>11)^(c<<7|c>>>25))+(c&l^~c&f)+a[d]+u[d];p=f,f=l,l=c,c=s+b|0,s=i,i=o,o=r,r=b+(w+m)|0}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+c|0,n[5]=n[5]+l|0,n[6]=n[6]+f|0,n[7]=n[7]+p|0},_doFinalize:function(){var e=this._data,n=e.words,r=8*this._nDataBytes,o=8*e.sigBytes;return n[o>>>5]|=128<<24-o%32,n[14+(o+64>>>9<<4)]=t.floor(r/4294967296),n[15+(o+64>>>9<<4)]=r,e.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA256=o._createHelper(c),e.HmacSHA256=o._createHmacHelper(c)}(Math),_.SHA256)),y.exports));function B(t){return null!=t&&"object"==typeof t&&!0===t["@@functional/placeholder"]}function S(t){return function e(n){return 0===arguments.length||B(n)?e:t.apply(this,arguments)}}function A(t){return function e(n,r){switch(arguments.length){case 0:return e;case 1:return B(n)?e:S((function(e){return t(n,e)}));default:return B(n)&&B(r)?e:B(n)?S((function(e){return t(e,r)})):B(r)?S((function(e){return t(n,e)})):t(n,r)}}}var j=A((function(t,e){var n={};for(var r in e)t(e[r],r,e)&&(n[r]=e[r]);return n}));const E=t=>!(t=>void 0===t)(t)&&(t=>null!=t)(t),x=["event","category","category_id","currency","total","value","revenue","ecomm_category","transaction_id","order_id","checkout_id","ecomm_pagetype","pagetype","query","products","product_id","sku","event_action","items"],R=t=>{const{properties:e={}}=t,{category_id:n,total:o,value:i,ecomm_category:s,transaction_id:a,order_id:u,checkout_id:c,ecomm_pagetype:l,pagetype:f,query:p}=e,d={ecomm_totalvalue:o||i,search_term:p,ecomm_query:p,ecomm_category:s||n,transaction_id:a||u||c,ecomm_pagetype:l||f||"other"},h=(t=>{const e=[],n=[];(Array.isArray(t.products)?t.products:[t]).forEach((t=>{const{product_id:r,sku:o,price:i,quantity:s=1}=t,a=r||o;if(a){e.push(a);const t={id:a,quantity:s};i&&!Number.isNaN(i)&&(t.price=i),n.push(t)}}));const r={};return n.length>0&&(r.ecomm_prodid=e,r.items=n),r})(e);return r(r({},d),h)};const I=(t,e)=>{const n=p(t,"context.traits.email")||p(t,"traits.email"),r=p(t,"context.traits.phone")||p(t,"traits.phone"),o={};if(E(n)&&(o.em=e?(t=>{let e=t.trim().toLowerCase();if(e=e.replace(/\+[^@]+/g,""),e=e.replace(/\./g,((t,n)=>nt.value===e)).method(...this.getLogData(t))}}getLogData(t){if(Array.isArray(t)&&t.length>0){let e="%c RS SDK";this.scope&&(e=`${e} - ${this.scope}`);e=`${e} %c ${t[0].trim()}`;const n=[];return n.push(e),n.push("font-weight: bold; background: black; color: white;"),n.push("font-weight: normal;"),n.push(...t.slice(1)),n}return t}}("Bing Ads");return t.BingAds=class{constructor(t,n,o){e(this,"track",(t=>{const{type:e,properties:n,context:o}=t.message,i=(null==n?void 0:n.event_action)||e;if(!i)return void D.error("Event type is not present");let s=r(r({},(t=>{const{event:e,properties:n={}}=t,{category:r,currency:o,total:i,value:s,revenue:a}=n;return{event_label:e,event_category:r,currency:o,revenue_value:i||s||a}})(t.message)),R(t.message));const a=function(t,e,n,r){const o=[],i=e;return Array.isArray(n)?n.forEach((e=>{const n=p(t,e);n&&(Object.keys(n).forEach((t=>{r.includes(t)||o.push(t)})),o.forEach((t=>{void 0!==n[t]&&(i[t]=p(n,t))})))})):"root"===n&&(Object.keys(t).forEach((t=>{r.includes(t)||o.push(t)})),o.forEach((e=>{void 0!==t[e]&&(i[e]=p(t,e))}))),i}(t.message,{},["properties"],x);var u;(s=r(r({},s),a),!0===this.enableEnhancedConversions)&&(s.pid=(null==o||null===(u=o.traits)||void 0===u?void 0:u.pid)||I(o,this.isHashRequired));s=j(E,s),window[this.uniqueId].push("event",i,s)})),n.logLevel&&D.setLogLevel(n.logLevel),this.analytics=n,this.tagID=t.tagID,this.name="BINGADS",({shouldApplyDeviceModeTransformation:this.shouldApplyDeviceModeTransformation,propagateEventsUntransformedOnError:this.propagateEventsUntransformedOnError,destinationId:this.destinationId}=null!=o?o:{}),this.uniqueId=`bing${this.tagID}`,this.enableEnhancedConversions=t.enableEnhancedConversions,this.isHashRequired=t.isHashRequired}init(){var t,e;t=this.uniqueId,e=this.tagID,((t,n,r,o,i)=>{let s,a,u;t[i]=t[i]||[],s=()=>{const n={ti:e};n.q=t[i],t[i]=new UET(n)},a=n.createElement(r),a.src="https://bat.bing.com/bat.js",a.async=1,a.setAttribute("data-loader","RS_JS_SDK"),a.onload=a.onreadystatechange=function(){const e=this.readyState;e&&"loaded"!==e&&"complete"!==e&&"function"==typeof t.UET||(s(),a.onload=a.onreadystatechange=null)},u=n.getElementsByTagName(r)[0],u.parentNode.insertBefore(a,u)})(window,document,"script",0,t)}isLoaded(){return!!window.UET&&!!window[this.uniqueId]&&window[this.uniqueId].push!==Array.prototype.push}isReady(){return!(!window[this.uniqueId]||window[this.uniqueId].push===Array.prototype.push)}page(){window[this.uniqueId].push("pageLoad")}},Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),t}({}); //# sourceMappingURL=BingAds.min.js.map