!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("scc-c2",[],e):"object"==typeof exports?exports["scc-c2"]=e():t["scc-c2"]=e()}(self,(()=>(()=>{"use strict";var t={d:(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e);var n={};t.r(n),t.d(n,{_isDebug:()=>d,debug:()=>O,error:()=>g,info:()=>h,log:()=>h,setDebug:()=>b,warn:()=>w});var r={};t.r(r),t.d(r,{cmdLogEvent:()=>Jo,cmdLogPerf:()=>Zo});var o,i,a,c,u,f=(o="",a={document:i=Object.create({get cookie(){return o},set cookie(t){o=t}})},c={},"undefined"==typeof window?{window:a,document:i,navigator:c}:{window:window||a,document:window.document||i,navigator:navigator||c}),s=function(){return f.window},l=function(){return f.document},p=function(){return f.navigator},y=function(){var t=s().location;return t&&t.hostname?t.hostname:""},v=function(){var t=y(),e=t.split(".");return e.length>=2&&"co.uk"===(t=e.splice(e.length-2).join("."))&&(t="".concat(e.pop(),".").concat(t)),t},d=!1,b=function(t){d=!0===t||"true"===t},m=function(t){return s().console,function(){}},h=m(),g=m(),w=m(),O=function(){if(d){for(var t=arguments.length,e=new Array(t),n=0;n1&&void 0!==arguments[1])||arguments[1]||void 0!==t)return!0===t||1===t||"string"==typeof t&&("true"===t.toLowerCase()||"1"===t)},B=function(t){var e=parseInt(t,10);if(!isNaN(e))return e},q=function(t){return/^-?\d+$/.test(t)},F=function(){return function(t){var e=t.getUTCFullYear()+"-"+A(t.getUTCMonth()+1);if(e+="-"+A(t.getUTCDate())+"T"+A(t.getUTCHours())+":",e+=A(t.getUTCMinutes())+":"+A(t.getUTCSeconds()),t.getUTCMilliseconds){var n=t.getUTCMilliseconds();q(n)&&(e+="."+String((n/1e3).toFixed(3)).slice(2,5))}return e+"Z"}(new Date)},U=function(t){return"[object Array]"===Object.prototype.toString.call(t)},V=function(t,e){U(t)&&t.push({timestamp:F(),data:e})};function N(t){return N="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},N(t)}function K(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 G(t,e){for(var n=0;n0},ot=!1;function it(t){return it="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},it(t)}function at(t,e){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:"";return"https://".concat(t?t+".":"").concat(function(){if(ct)return ct;var t=v();if("secureserver.net"===(t=function(t){var e=t||v();return e.indexOf("godaddy.com")>=0||e.indexOf("secureserver.net")>=0}(t)?t:"secureserver.net")){var e=vt("build","env");t="prod"===e?t:"".concat(e,"-").concat(t)}return ct=t}())};function gt(t){return gt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},gt(t)}function wt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,c=[],u=!0,f=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(c.push(r.value),c.length!==e);u=!0);}catch(t){f=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(f)throw o}}return c}}(t,e)||Ot(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ot(t,e){if(t){if("string"==typeof t)return jt(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?jt(t,e):void 0}}function jt(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n1&&void 0!==arguments[1]?arguments[1]:10;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._eventQueue=[],this._sendBatchCallback=e,this._maxEvents=r,this._bindUnload(),this._processInterval=setInterval((function(){n._sendBatch()}),250)}var e,n;return e=t,(n=[{key:"_bindUnload",value:function(){var t=this,e=this.flush.bind(this),n=s().attachEvent,r=s().addEventListener,o=l().addEventListener;r?(r("beforeunload",e,!1),r("pagehide",e,!1)):n&&n("beforeunload",e),o&&o("visibilitychange",function(){"hidden"===l().visibilityState&&t.flush()}.bind(this))}},{key:"_sendRequests",value:function(t){var e=this;Object.entries(t).forEach((function(t){var n=wt(t,2),r=n[0],o=n[1];try{var i=wt(r.split("|"),2),a=i[0],c={schemaId:i[1],data:[]};Object.values(o).forEach((function(t){if(t.events.length>10)for(var e=t.events.length/10,n=0;nthis._maxEvents&&this.pushEvent(C(n,{events:n.events.slice(this._maxEvents)})),u[c]=a,Math.min(n.events.length,this._maxEvents)}},{key:"_sendBatch",value:function(t){var e=0,n={},r=[];for(t&&(e+=this._processEvent(n,r,t));this._eventQueue.length>0&&e0;)this._sendBatch()}}])&&St(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();var Pt,Et="_eventBusSendLog",kt=function(t,e){yt("".concat(ht("csp"),"/eventbus"),null,"POST",t,Et,{Authorization:"api-key ".concat(e)})};function Tt(t){return Tt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Tt(t)}function Ct(t,e){for(var n=0;nt.length)&&(e=t.length);for(var n=0,r=new Array(e);n=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==n.return||n.return()}finally{if(c)throw i}}}}(Vt);try{for(n.s();!(e=n.n()).done;){var r=e.value;if(t.startsWith("".concat(r,".")))return!1}}catch(t){n.e(t)}finally{n.f()}return!0},$t=function(t,e){"debug"===t&&b(e)},Ht=function(){var t,e,n=function(){for(var t={},e=0;et.length)&&(e=t.length);for(var n=0,r=new Array(e);n0;)this.process(this.asyncCommands.shift());this.loaded=!0}}])&&oe(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function ae(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n0&&!this.allowedValuesList.includes(t))throw"Input '".concat(t,"' for property '").concat(this.name,"' is not one of the allowed values (").concat(this.allowedValuesList,").")}},{key:"optional",value:function(){return this._fieldType=be,this}},{key:"required",value:function(){return this._fieldType=me,this}},{key:"load",value:function(){for(var t=0;t0)try{this.load(),e=ge(Se(n.prototype),"parse",this).call(this,t||{}),this.clean()}catch(t){throw""}return Object.freeze(e)}}]),n}(Ce),Ie=function(t){we(n,t);var e=je(n);function n(t){return _e(this,n),e.call(this,t)}return Ee(n,[{key:"parse",value:function(t){return this.validate(t),t}},{key:"stringify",value:function(){var t={};return t[this.name]=this._fieldType,t}}]),n}(Ce),Re=function(t){we(n,t);var e=je(n);function n(){var t;return _e(this,n),(t=e.call(this)).objDefinitions=[],t.definitionType="Object",t}return Ee(n,[{key:"load",value:function(){this.properties=this.properties.concat(this.objDefinitions),this.extraDefinitions&&(this.properties=this.properties.concat(this.extraDefinitions)),ge(Se(n.prototype),"load",this).call(this)}},{key:"stringify",value:function(){if(this._resolutionType===he){var t={};return t["".concat(this.name," (").concat(this._fieldType,")")]=ge(Se(n.prototype),"stringify",this).call(this),t}return ge(Se(n.prototype),"stringify",this).call(this)}},{key:"substitute",value:function(t){return this.objDefinitions=t,this._resolutionType="sub",this}},{key:"map",value:function(t,e){return this.name=t,this.objDefinitions=e,this._resolutionType=he,this}},{key:"extend",value:function(t){return this.extraDefinitions=t,this}}]),n}(Ce),Le=function(t){we(n,t);var e=je(n);function n(){var t;return _e(this,n),(t=e.call(this)).definitionType="Collection",t.minElements=0,t}return Ee(n,[{key:"parse",value:function(t){if(this.minElements&&(!t||t.length0?me:be,this}}]),n}(Re);function De(t){return De="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},De(t)}function Ae(t){return function(t){if(Array.isArray(t))return Me(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Me(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Me(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Me(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n=0;e--){var n=this.asyncCommands[e];n.schema!==this.pageViewSchema||n.data&&n.data.virtual_path||(t=!1),"set_config"===n.schema&&this.process.apply(this,Ae(this.asyncCommands.splice(e,1)))}t&&this.process({schema:this.pageViewSchema})}},{key:"process",value:function(t){qe(Ue(c.prototype),"pushLog",this).call(this,t);try{var e=t.data,r=t.schema||t.interface,o=t.type,i=t.version||"v1",a=t.targets||[],u={eventId:ee()};this.beforeEvent&&this.beforeEvent(),function(){for(;ztt.length)&&(e=t.length);for(var n=0,r=new Array(e);n=0;o--){var i=r[o].split("=");if(e){if((i[0]+"").toLowerCase()===(t+"").toLowerCase())return i[1]}else if(i[0]===t)return i[1]}}("plid")},function(){var t=v().replace("dev-","").replace("test-","").replace("stg-","");if(mn.hasOwnProperty(t))return mn[t]}],gn=function(){for(var t=0;t=0;n--)e[n]=e[n].trim(),e[n]||e.splice(n,1);if(e.length>0)for(;e.length<3;)e.push("Other");return e.join(" / ")}()},"page.host":function(){return y()},"page.path":function(t){return t.win.location.pathname},"page.virtualPath":function(){return Ze.get("virtual_path")},"page.location":function(){return n=(t=mt()).length?(function(t){for(var e=0;et.length)&&(e=t.length);for(var n=0,r=new Array(e);n=0||(o[n]=t[n]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(o[n]=t[n])}return o}(e,Tn),r=t.fields||[];return In.forEach((function(t){r.includes(t)||delete n[t]})),n}(e,n);e.batch?(o.events=r?n.events.filter((function(t){return r.includes(t.schemaId)})):n.events,o.events.length>0&&Rn(t,e,o)):n.events.forEach((function(n){r&&!r.includes(n.schemaId)||Rn(t,e,C(o,{event:n}))}))},Dn=function(t,e){var n=Bn();n.length>=An&&w("".concat(t," subscribed to SCC after the eventQueue was full. Some events may have been lost.")),n.forEach((function(n){return Ln(t,e,n)})),xn[t]=e},An=2e3,Mn=[],Bn=function(){return[].concat(Mn)};function qn(t){return qn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},qn(t)}function Fn(t,e){for(var n=0;nAn&&Mn.shift(),this.internal.hasFired=!0}}var a}},{key:"_getSchemaId",value:function(){}},{key:"_getEvents",value:function(t){return[{schemaId:this._getSchemaId(),data:t}]}},{key:"_getGlobalSchemaId",value:function(){return gn()?"urn:shared:user:events:/v2":"urn:shared:user:events:/v1"}},{key:"_getBusinessContext",value:function(){}},{key:"_getApiKey",value:function(){return qt("eventBus","sccApiKey")}},{key:"_hasConversion",value:function(){}},{key:"_getWebContext",value:function(t){}}])&&Nn(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),a}(Un);function Wn(t){return Wn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Wn(t)}function $n(t,e){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{},e=t.eid,n=t.customProperties,r=t.eventCategory;return C({pageLevelProperties:C(Gt),identityRealm:qt("identity","realm")},e&&{eid:e},n&&{customProperties:n},r&&{eventCategory:r})},vr=function(t,e,n,r){var o={traffic:yr({eid:e,customProperties:r}),producerEventId:t};if(e){var i=function(t){return t.split(".")}(e),a=function(t){return t[t.length-1]}(i);(function(t){return!!(t.match(pr)&&t.length<=500)})(e)&&function(t,e,n){return e===n&&t.length>=5&&t.length<=6}(i,a,n)&&(o.element=function(t,e){var n=6===t.length?1:0,r={area:t[0],product:t[1],section:t[2+n],widget:t[3+n]};return["impression","click"].includes(e)||(r.action=e),r}(i,a))}return o},dr=function(t,e,n,r){null!=r&&null!=n&&0!==r&&0!==n&&n>r&&(t[e]=Math.round(n-r))},br=function(t,e,n,r){var o=Y(e);!function(t,e){dr(t,"pageLoadTime",e.loadEventStart,e.navigationStart),dr(t,"domContentLoadedTime",e.domContentLoadedEventStart,e.navigationStart),dr(t,"domInteractiveTime",e.domInteractive,e.navigationStart),dr(t,"pageDownloadTime",e.responseEnd,e.responseStart),dr(t,"domainLookupTime",e.domainLookupEnd,e.domainLookupStart),dr(t,"serverResponseTime",e.responseStart,e.requestStart),dr(t,"serverConnectionTime",e.connectEnd,e.connectStart),dr(t,"redirectionTime",e.fetchStart,e.navigationStart)}(o,e);var i={navigationType:e.navigationType,timing:{navigation:o},traffic:yr({customProperties:n}),producerEventId:t,contentLoadType:r};return"hard"===r&&(i.response=tt(e),i.timing.marks=e.marks,i.timing.measures=e.measures,i.timing.paint={firstPaint:e.fp,firstContentfulPaint:e.fcp,largestContentfulPaint:e.lcp}),i},mr=function(t,e,n){return{timing:{paint:{largestContentfulPaint:e.LCP},vitals:{cumulativeLayoutShift:e.CLS,firstInputDelay:e.FID,timeToInteractive:e.timeToInteractive}},traffic:yr({customProperties:n}),producerEventId:t}};function hr(t){return hr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},hr(t)}function gr(t,e){for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:"".concat(e.area,".").concat(e.product,".").concat(e.section,".").concat(e.widget,".").concat(t)}},{key:"_transformLegacyPromo",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.eid,o=n.customProperties,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return{id:i.id,name:i.name,creative_name:i.creative,creative_slot:i.position,type:t,properties:o,eid:this._buildLegacyEid(t,e,r)}}},{key:"_isPromo",value:function(t){return t.promotion&&Object.keys(t.promotion).length>0}}],n&&gr(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),a}(zn);function Sr(t){return Sr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Sr(t)}function _r(t,e){for(var n=0;nt.length)&&(e=t.length);for(var n=0,r=new Array(e);n