@mparticle/web-rokt-kit 1.36.0 → 1.36.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ie=["active_time_on_site_ms","billingaddress1","billingaddress2","billingcity","billingstate","billingzipcode","cartitems","ccbin","confirmationref","conversiontype","country","couponcode","currency","language","paymentserviceprovider","paymentserviceproviderattribute","paymenttype","shippingaddress1","shippingcity","shippingcountry","shippingmethod","shippingstate","shippingzipcode","totalprice"],Se=new Set(Ie);function se(i){return Se.has(i.toLowerCase())}function b(i){const e={},t=i||{},n=Object.keys(t);for(let r=0;r<n.length;r++){const o=n[r];se(o)||(e[o]=t[o])}return e}function _(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function E(i){return typeof i=="string"}function L(i){return typeof i=="function"}function K(i){return i==null?!0:typeof i=="object"?Object.keys(i).length===0:!1}function x(i){try{const e=new URL(i);return e.search="",e.toString()}catch{return i}}const V="__rokt_ls_probe__";function F(){try{return window.localStorage.setItem(V,"1"),window.localStorage.removeItem(V),!0}catch{return!1}}function N(i){try{const e=window.localStorage.getItem(i);return e===null?null:JSON.parse(e)}catch{return null}}function ae(i,e){try{return window.localStorage.setItem(i,JSON.stringify(e)),!0}catch{return!1}}function ce(i){try{window.localStorage.removeItem(i)}catch{}}function U(i,e){const t=N(i);return _(t)?t[e]:void 0}function Y(i,e,t){const n=N(i),r=_(n)?{...n}:{};return r[e]=t,ae(i,r)}function le(i,e){const t=N(i);if(!_(t)||!(e in t))return;const n={...t};delete n[e],Object.keys(n).length===0?ce(i):ae(i,n)}const p="mp-rokt-kit",R="pageViews",O="utmParams",H="mpPageViews",ue=25,ye=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];function de(i){return i.slice(-ue)}function he(i){const e=N(H);if(e===null)return;!(U(p,R)!==void 0)&&Array.isArray(e)&&(i?.log({message:"Rokt Kit: Migrating legacy page-view storage",code:"PAGE_VIEW_LEGACY_MIGRATION"}),Y(p,R,e)||i?.log({message:"Rokt Kit: Failed to migrate legacy page-view storage [reason: migration_retry]",code:"PAGE_VIEW_CAPTURE_FAILED"})),ce(H)}function z(i){he(i);const e=U(p,R);return Array.isArray(e)?e:[]}function Ae(i){const e=de(i);for(let t=0;t<e.length;t++){const n=e.slice(t);if(Y(p,R,n))return n.length}return 0}function q(){le(p,R)}function ke(i){const e=de(i);return e.map((t,n)=>{const r=t.activeTimeOnSite,o=r!==void 0&&Number.isFinite(r),c=e[n+1]?.activeTimeOnSite,u=c!==void 0&&Number.isFinite(c),l=o&&u?c-r:void 0;return{pageUrl:t.pageUrl,sourceMessageId:t.sourceMessageId,timestamp:t.timestamp,...t.pageTitle!==void 0?{pageTitle:t.pageTitle}:{},...t.canonicalUrl!==void 0?{canonicalUrl:t.canonicalUrl}:{},...o?{activeTimeOnSite:r}:{},...l!==void 0&&l>=0?{activeTimeOnPage:l}:{}}})}function Re(i){if(U(p,O)!==void 0)return;const e=new URLSearchParams(window.location.search),t={};for(const r of ye){const o=e.get(r);o&&(t[r]=o)}if(Object.keys(t).length===0)return;const n=Object.keys(t).join(", ");if(!Y(p,O,t)){const r=F()?"quota":"ls_unavailable";i?.log({message:`Rokt Kit: Failed to persist UTM params [reason: ${r}]`,code:"UTM_CAPTURE_FAILED"});return}i?.log({message:`Rokt Kit: Captured UTM params [${n}]`,code:"UTM_CAPTURE_SUCCESS"})}function ve(){const i=U(p,O);return _(i)?i:null}function $(){le(p,O)}function we(){const e=document.querySelector('link[rel="canonical"]')?.href;if(e)return x(e)}function be(){return{context:null,lifecycle:"idle",recreateInFlight:null}}function Le(i,e){i.context={accountId:e.accountId,launcherOptions:{...e.launcherOptions},legacyRoktExtensions:[...e.legacyRoktExtensions]}}function Te(i){i.lifecycle="attached"}function Pe(i){i.lifecycle!=="idle"&&(i.lifecycle="terminated")}function Oe(i){i.lifecycle="terminated"}function Ne(i){i.context=null,i.lifecycle="idle",i.recreateInFlight=null}function Ue(i,e,t){if(i.recreateInFlight)return i.recreateInFlight;if(i.lifecycle!=="terminated"||!i.context||!e)return;i.lifecycle="recreating";const n=i.context;return i.recreateInFlight=t(n).finally(()=>{i.recreateInFlight=null}),i.recreateInFlight}const d="Rokt",T=181,Ce="selectPlacements",Me="apps.roktecommerce.com",Ke=.1,Fe="ThankYouPageJourney",De="rokt-launcher",xe="rokt-thank-you-element",Ye="userIdentifiedInWorkspace",Ge=3,We=2,je="page_events",Ve="page_view_attributes",He="mparticle_session_id",ze="mparticle_device_id",J=500,G={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST",LOG_DELIVERY_FAILURE:"LOG_DELIVERY_FAILURE"},S={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},qe="apps.rokt-api.com",$e="/v1/log",Je="/v1/errors",Be=10;function a(){return window.mParticle}function B(i,e){const n=[C(i),"/wsdk/integrations/launcher.js"].join("");return!e||e.length===0?n:n+"?extensions="+e.join(",")}function Q(i){return[C(i),"/rokt-elements/rokt-element-thank-you.js"].join("")}function C(i){const e=typeof i<"u"?i:qe;return e.includes("://")?e.replace(/\/+$/,""):["https://",e].join("")}function ge(i,e,t){if(i)return i.startsWith("http://")||i.startsWith("https://")?i:"https://"+i;const r=e?.includes("://")&&!/^https?:\/\//i.test(e)?void 0:e;return C(r)+t}function X(i,e,t){if(document.getElementById(i))return;const n=document.head||document.body,r=document.createElement("script");r.id=i,r.type="text/javascript",r.src=e,r.async=!0,r.crossOrigin="anonymous",r.fetchPriority="high",t?.onLoad&&(r.onload=t.onLoad),t?.onError&&(r.onerror=t.onError),n.appendChild(r)}function P(i){if(!i)return[];try{return JSON.parse(i.replace(/&quot;/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function Z(i){const e=i?P(i):[],t=[],n=[];let r=!1;for(let o=0;o<e.length;o++){const s=e[o].value;s==="thank-you-journey"?(r=!0,n.push(Fe)):t.push(s)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:n,loadThankYouElement:r}}async function Qe(i,e){const t=[];if(e)for(const n of i)t.push(e.use(n));return Promise.all(t)}function ee(i){if(!i)return{};const e={};for(let t=0;t<i.length;t++){const n=i[t];e[n.jsmap]=n.value}return e}function te(i){const e={};if(!Array.isArray(i))return e;for(let t=0;t<i.length;t++){const n=i[t];if(!n||!E(n.value)||!E(n.map))continue;const r=n.value,o=n.map;e[r]||(e[r]=[]),e[r].push({eventAttributeKey:o,conditions:Array.isArray(n.conditions)?n.conditions:[]})}return e}function ie(i,e,t){return a().generateHash([i,e,t].join(""))}function Xe(i){let n="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"1.36.0";return i&&(n+="_"+i),n}function pe(i){let e=5381;for(let t=0;t<i.length;t++)e=(e<<5)+e+i.charCodeAt(t),e=e&e;return e}function D(i){const e=document.createElement("iframe");e.style.display="none",e.setAttribute("sandbox","allow-scripts allow-same-origin"),e.src=i,e.onload=function(){e.onload=null,e.parentNode&&e.parentNode.removeChild(e)};const t=document.body||document.head;t&&t.appendChild(e)}function ne(i,e){const t=pe(window.location.origin);if(y._allowedOriginHashes.indexOf(t)===-1||Math.random()>=Ke)return;const r=window.__rokt_li_guid__;if(!r||i&&i.includes("://")&&!/^https:\/\//i.test(i))return;const o=window.location.href.split("?")[0].split("#")[0],s="version="+encodeURIComponent(e??"")+"&launcherInstanceGuid="+encodeURIComponent(r)+"&pageUrl="+encodeURIComponent(o),c=i?C(i):"https://apps.rokt.com";D(c+"/v1/wsdk-init/index.html?"+s),D("https://"+Me+"/v1/wsdk-init/index.html?"+s+"&isControl=true")}function Ze(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function et(){return typeof window<"u"?window.location?.href:void 0}function tt(){return typeof window<"u"?window.navigator?.userAgent:void 0}class fe{constructor(){this._logCount={}}incrementAndCheck(e){const n=(this._logCount[e]||0)+1;return this._logCount[e]=n,n>Be}}class W{constructor(e,t,n,r,o){this._reporter="mp-wsdk";const s=e.isLoggingEnabled;this._integrationName=t||"",this._launcherInstanceGuid=n,this._accountId=r||null,this._rateLimiter=o||new fe,this._isEnabled=Ze()||s}send(e,t,n,r,o,s){if(!(!this._isEnabled||this._rateLimiter.incrementAndCheck(t)))try{const c={additionalInformation:{message:n,version:this._integrationName},severity:t,code:r||G.UNKNOWN_ERROR,url:et(),deviceInfo:tt(),stackTrace:o,reporter:this._reporter,integration:this._integrationName},u={Accept:"text/plain;charset=UTF-8","Content-Type":"application/json","rokt-launcher-version":this._integrationName,"rokt-wsdk-version":"joint"};this._launcherInstanceGuid&&(u["rokt-launcher-instance-guid"]=this._launcherInstanceGuid),this._accountId&&(u["rokt-account-id"]=this._accountId),fetch(e,{method:"POST",headers:u,body:JSON.stringify(c)}).then(l=>{if(!l.ok){const g=new Error("HTTP "+l.status+" from log endpoint");throw g.statusCode=l.status,g}}).catch(l=>{console.error("ReportingTransport: Failed to send log",l),s&&s(l)})}catch(c){console.error("ReportingTransport: Failed to send log",c),s&&s(c)}}}class re{constructor(e,t,n,r,o){this._transport=new W(e,t,n,r,o),this._errorUrl=ge(e?.errorUrl,e?.integrationDomain,Je)}report(e){if(!e)return;const t=e.severity||S.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class oe{constructor(e,t,n,r,o,s){this._transport=new W(e,n,r,o,s),this._loggingUrl=ge(e?.loggingUrl,e?.integrationDomain,$e),this._errorReportingService=t}log(e){e&&this._transport.send(this._loggingUrl,S.INFO,e.message,e.code,void 0,t=>{if(this._errorReportingService){const n=typeof t.statusCode=="number";this._errorReportingService.report({message:"LoggingService: Failed to send log: "+t.message,code:G.LOG_DELIVERY_FAILURE,severity:n?S.ERROR:S.WARNING})}})}}function it(i){const e=x(window.location.href),t=i.EventAttributes?.title||document.title,n=we(),r=i.ActiveTimeOnSite;return{pageUrl:e,sourceMessageId:i.SourceMessageId,timestamp:i.Timestamp,...t?{pageTitle:t}:{},...n!==void 0?{canonicalUrl:n}:{},...Number.isFinite(r)?{activeTimeOnSite:r}:{}}}const m=class m{constructor(){this.name=d,this.id=T,this.moduleId=T,this.isInitialized=!1,this.launcher=null,this.filters={},this.userAttributes={},this.userIdentifiedInWorkspace=!1,this.testHelpers=null,this.placementEventMappingLookup={},this.placementEventAttributeMappingLookup={},this.integrationName=null,this.errorReportingService=null,this.loggingService=null,this._thankYouElementOnLoadCallback=null,this._isThankYouElementLoaded=!1,this._workspaceSearchInFlightPromise=null,this._launcherAttachState=be()}getEventAttributeValue(e,t){const n=e&&e.EventAttributes;return!n||typeof n[t]>"u"?null:n[t]}doesEventAttributeConditionMatch(e,t){if(!e||!E(e.operator))return!1;const n=e.operator.toLowerCase(),r=e.attributeValue;return n==="exists"?t!==null:t==null?!1:n==="equals"?String(t)===String(r):n==="contains"?String(t).indexOf(String(r))!==-1:!1}doesEventMatchRule(e,t){if(!t||!E(t.eventAttributeKey))return!1;const n=t.conditions;if(!Array.isArray(n))return!1;const r=this.getEventAttributeValue(e,t.eventAttributeKey);if(n.length===0)return r!==null;for(let o=0;o<n.length;o++)if(!this.doesEventAttributeConditionMatch(n[o],r))return!1;return!0}applyPlacementEventAttributeMapping(e){const t=Object.keys(this.placementEventAttributeMappingLookup);for(let n=0;n<t.length;n++){const r=t[n],o=this.placementEventAttributeMappingLookup[r];if(K(o))continue;let s=!0;for(let c=0;c<o.length;c++)if(!this.doesEventMatchRule(e,o[c])){s=!1;break}s&&a().Rokt.setLocalSessionAttribute?.(r,!0)}}capturePageView(e){let t;try{t=x(window.location.href);const n=z(this.loggingService),r=it(e);n.push(r);const o=Math.min(n.length,ue),s=Ae(n);if(s===0){const c=F()?"quota":"ls_unavailable";this.loggingService?.log({message:`Rokt Kit: Failed to persist page view for ${t} [reason: ${c}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}else s<o&&this.loggingService?.log({message:`Rokt Kit: Page view storage reduced from ${o} to ${s} record(s) under quota pressure [reason: quota_eviction]`,code:"PAGE_VIEW_QUOTA_EVICTION"})}catch(n){const r=F()?"exception":"ls_unavailable",o=n instanceof Error?n.message:String(n);this.loggingService?.log({message:`Rokt Kit: Failed to capture page view for ${t}: ${o} [reason: ${r}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}}isLauncherReadyToAttach(){return!!window.Rokt&&L(window.Rokt.createLauncher)}returnUserIdentities(e){if(!e||!e.getUserIdentities)return{};const t=e.getUserIdentities().userIdentities;return this.replaceOtherIdentityWithEmailsha256(t)}returnLocalSessionAttributes(){return!a().Rokt||typeof a().Rokt.getLocalSessionAttributes!="function"?{}:a().Rokt.getLocalSessionAttributes()}replaceOtherIdentityWithEmailsha256(e){const t={...e||{}},n=this._mappedEmailSha256Key;return n&&e[n]&&(t[m.EMAIL_SHA256_KEY]=e[n]),n&&delete t[n],t}logSelectPlacementsEvent(e){if(!window.mParticle||typeof a().logEvent!="function"||!_(e))return;const t=a().EventType.Other;a().logEvent(Ce,t,e)}setRoktSessionId(e){if(!(!e||typeof e!="string"))try{const t=a().getInstance();t&&L(t.setIntegrationAttribute)&&t.setIntegrationAttribute(T,{roktSessionId:e})}catch{}}readMpSessionId(){const e=a()?.sessionManager,t=e?.getSessionId??e?.getSession;if(L(t))return t.call(e)||void 0}readMpDeviceId(){return a()?.getDeviceId?.()||void 0}attachLauncher(e,t,n=[]){Le(this._launcherAttachState,{accountId:e,launcherOptions:t||{},legacyRoktExtensions:n});const r={accountId:e,...t||{}};let o;return this.isPartnerInLocalLauncherTestGroup()?o=Promise.resolve(window.Rokt.createLocalLauncher(r)):o=window.Rokt.createLauncher(r),o.then(async s=>{await Qe([...n],s),this.initRoktLauncher(s)}).catch(s=>{Oe(this._launcherAttachState),console.error("Error creating Rokt launcher:",s)})}recreateLauncherIfTerminated(){return Ue(this._launcherAttachState,this.isLauncherReadyToAttach(),e=>this.attachLauncher(e.accountId,e.launcherOptions,e.legacyRoktExtensions))}initRoktLauncher(e){window.Rokt&&(window.Rokt.currentLauncher=e),this.launcher=e,Te(this._launcherAttachState);const t=a().Rokt?.filters;t?(this.filters=t,t.filteredUser?this._workspaceSearchInFlightPromise=this.search(t.filteredUser):console.warn("Rokt Kit: No filtered user has been set.")):console.warn("Rokt Kit: No filters have been set."),this.isInitialized=!0,ne(this.domain,this.integrationName),a().Rokt.attachKit(this)}fetchOptimizely(){const e=a()._getActiveForwarders().filter(t=>t.name==="Optimizely");try{if(e.length>0&&window.optimizely){const t=window.optimizely.get("state");return!t||!t.getActiveExperimentIds?{}:t.getActiveExperimentIds().reduce((o,s)=>(o["rokt.custom.optimizely.experiment."+s+".variationId"]=t.getVariationMap()[s].id,o),{})}}catch(t){console.error("Error fetching Optimizely attributes:",t)}return{}}isKitReady(){return!!(this.isInitialized&&this.launcher)}isTargetingDisabled(){return a().Rokt?.launcherOptions?.noTargeting===!0}isPartnerInLocalLauncherTestGroup(){return!!(a().config&&a().config.isLocalLauncherEnabled&&this.isAssignedToSampleGroup())}isAssignedToSampleGroup(){return Math.random()>.5}captureTiming(e){window&&a()&&a().captureTiming&&e&&a().captureTiming(e)}init(e,t,n,r,o){const s=e,c=s.accountId;this.userAttributes=b(o),this._onboardingExpProvider=s.onboardingExpProvider;const u=P(s.placementEventMapping);this.placementEventMappingLookup=ee(u);const l=P(s.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=te(l),s.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=s.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=E(s.workspaceIdSyncApiKey)?s.workspaceIdSyncApiKey:void 0;const g=a().Rokt?.domain,{roktExtensionsQueryParams:M,legacyRoktExtensions:v,loadThankYouElement:w}=Z(s.roktExtensions),f={...a().Rokt?.launcherOptions||{}};this.integrationName=Xe(f.integrationName),f.integrationName=this.integrationName,this.domain=g;const A={loggingUrl:s.loggingUrl,errorUrl:s.errorUrl,integrationDomain:g,isLoggingEnabled:a().config?.isLoggingEnabled===!0},I=new re(A,this.integrationName,window.__rokt_li_guid__,s.accountId),k=new oe(A,I,this.integrationName,window.__rokt_li_guid__,s.accountId);if(this.errorReportingService=I,this.loggingService=k,this.isTargetingDisabled())try{q(),$()}catch(h){this.errorReportingService?.report({message:"Rokt Kit: Failed to clear page views when targeting is disabled",code:"PAGE_VIEW_CAPTURE_FAILED",severity:S.INFO,stackTrace:h instanceof Error?h.stack:void 0})}return a()._registerErrorReportingService&&a()._registerErrorReportingService(I),a()._registerLoggingService&&a()._registerLoggingService(k),n?(this.testHelpers={generateLauncherScript:B,generateThankYouElementScript:Q,extractRoktExtensionConfig:Z,hashEventMessage:ie,parseSettingsString:P,generateMappedEventLookup:ee,generateMappedEventAttributeLookup:te,sendAdBlockMeasurementSignals:ne,createAutoRemovedIframe:D,djb2:pe,setAllowedOriginHashes:h=>{m._allowedOriginHashes=h},ReportingTransport:W,ErrorReportingService:re,LoggingService:oe,RateLimiter:fe,ErrorCodes:G,WSDKErrorSeverity:S,resetLauncherAttachState:()=>Ne(this._launcherAttachState)},this.attachLauncher(c,f),"Successfully initialized: "+d):(w&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),X(xe,Q(g),{onLoad:()=>{this._isThankYouElementLoaded=!0,this._thankYouElementOnLoadCallback&&this._thankYouElementOnLoadCallback()},onError:h=>{console.error("Error loading Rokt Thank You Element script:",h)}})),this.isLauncherReadyToAttach()?this.attachLauncher(c,f,v):(X(De,B(g,M),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,f,v):console.error("Rokt object is not available after script load.")},onError:h=>{console.error("Error loading Rokt launcher script:",h)}}),this.captureTiming(m.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+d)}process(e){if(this.isTargetingDisabled()||(e.EventDataType===Ge&&(Re(this.loggingService),this.capturePageView(e)),e.EventDataType===We&&(he(this.loggingService),q(),$())),!this.isKitReady())return"Kit not ready for forwarder: "+d;if(L(a().Rokt?.setLocalSessionAttribute)&&(K(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!K(this.placementEventMappingLookup))){const t=ie(e.EventDataType,e.EventCategory,e.EventName??"");this.placementEventMappingLookup[String(t)]&&a().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(t)],!0)}return"Successfully sent to forwarder: "+d}setExtensionData(e){if(!this.isKitReady()){console.error("Rokt Kit: Not initialized");return}window.Rokt.setExtensionData(e)}setUserAttribute(e,t){return se(e)||(this.userAttributes[e]=t),"Successfully set user attribute for forwarder: "+d}removeUserAttribute(e){return delete this.userAttributes[e],"Successfully removed user attribute for forwarder: "+d}handleIdentityComplete(e,t){return this.userAttributes=b(e.getAllUserAttributes()),"Successfully called "+t+" for forwarder: "+d}onUserIdentified(e){const t=e;return this.filters.filteredUser=t,this._workspaceSearchInFlightPromise=this.search(t),this.handleIdentityComplete(e,"onUserIdentified")}search(e){const t=this._workspaceIdSyncApiKey;if(!t)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const n=a().Identity?.search;if(typeof n!="function")return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const r=e.getUserIdentities?e.getUserIdentities().userIdentities:null,o={};if(r)for(const u of Object.keys(r)){const l=r[u];E(l)&&l.length>0&&(o[u]=l)}const s=Object.keys(o);if(s.length===0)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const c=s.sort().map(u=>`${u}=${o[u]}`).join("&");return c===this._workspaceLastSearchedIdentitiesKey?this._workspaceSearchInFlightPromise||Promise.resolve():(this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=c,new Promise(u=>{try{n(t,o,l=>{l?.httpCode===200&&(this.userIdentifiedInWorkspace=!0),u()})}catch(l){console.error("Rokt Kit: Workspace IDSync search failed",l),this._workspaceLastSearchedIdentitiesKey=void 0,u()}}))}onLoginComplete(e,t){return this.handleIdentityComplete(e,"onLoginComplete")}onLogoutComplete(e,t){return this.userIdentifiedInWorkspace=!1,this._workspaceSearchInFlightPromise=null,this._workspaceLastSearchedIdentitiesKey=void 0,this.handleIdentityComplete(e,"onLogoutComplete")}onModifyComplete(e,t){return this.handleIdentityComplete(e,"onModifyComplete")}selectPlacements(e){const t=this.recreateLauncherIfTerminated();if(t){const n=this._workspaceSearchInFlightPromise,r=n?Promise.race([n,new Promise(o=>setTimeout(o,J))]):Promise.resolve();return Promise.all([t,r]).then(()=>this._dispatchPlacements(e))}if(this._workspaceSearchInFlightPromise){const n=this._workspaceSearchInFlightPromise;return Promise.race([n,new Promise(r=>setTimeout(r,J))]).then(()=>this._dispatchPlacements(e))}return this._dispatchPlacements(e)}_dispatchPlacements(e){const t=e&&e.attributes||{},r={...b(this.userAttributes),...t},o=this.filters||{},s=o.userAttributeFilters||[],c=o.filteredUser||null,u=c?c.getMPID():null;let l;o?o.filterUserAttributes?l=o.filterUserAttributes(r,s):l=r:(console.warn("Rokt Kit: No filters available, using user attributes"),l=r),this.userAttributes=b(l);const g=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},M=this.returnUserIdentities(c),v=this.returnLocalSessionAttributes(),w=ke(z(this.loggingService)),f=ve(),A=this.readMpSessionId(),I=this.readMpDeviceId(),k={...M,...l,...g,...v,...w.length?{[je]:JSON.stringify(w)}:{},...f?{[Ve]:f}:{},...this.userIdentifiedInWorkspace?{[Ye]:!0}:{},...A?{[He]:A}:{},...I?{[ze]:I}:{},mpid:u},h={...e,attributes:k},j=this.launcher.selectPlacements(h),me=()=>this.logSelectPlacementsEvent(k);return Promise.resolve(j).then(Ee=>Ee?.context?.sessionId?.then(_e=>this.setRoktSessionId(_e))).catch(()=>{}).finally(me),j}hashAttributes(e){return this.isKitReady()?this.launcher.hashAttributes(e):(console.error("Rokt Kit: Not initialized"),null)}use(e){return this.isKitReady()?!e||!E(e)?Promise.reject(new Error("Rokt Kit: Invalid extension name")):this.launcher.use(e):(console.error("Rokt Kit: Not initialized"),Promise.reject(new Error("Rokt Kit: Not initialized")))}terminate(){return this.isKitReady()?(Pe(this._launcherAttachState),this.launcher.terminate()):(console.error("Rokt Kit: Not initialized"),Promise.resolve())}onShoppableAdsReady(e){this._isThankYouElementLoaded?e():this._thankYouElementOnLoadCallback=e}};m._allowedOriginHashes=[-553112570,549508659],m.PERFORMANCE_MARKS={RoktScriptAppended:"mp:RoktScriptAppended"},m.EMAIL_SHA256_KEY="emailsha256";let y=m;function nt(){return T}function rt(i){if(!i){window.console.log("You must pass a config object to register the kit "+d);return}if(!_(i)){window.console.log("'config' must be an object. You passed in a "+typeof i);return}_(i.kits)?i.kits[d]={constructor:y}:(i.kits={},i.kits[d]={constructor:y}),window.console.log("Successfully registered "+d+" to your mParticle configuration")}typeof window<"u"&&window.mParticle&&a().addForwarder&&a().addForwarder({name:d,constructor:y,getId:nt});exports.register=rt;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const me=["active_time_on_site_ms","billingaddress1","billingaddress2","billingcity","billingstate","billingzipcode","cartitems","ccbin","confirmationref","conversiontype","country","couponcode","currency","language","paymentserviceprovider","paymentserviceproviderattribute","paymenttype","shippingaddress1","shippingcity","shippingcountry","shippingmethod","shippingstate","shippingzipcode","totalprice"],Ee=new Set(me);function re(i){return Ee.has(i.toLowerCase())}function w(i){const e={},t=i||{},n=Object.keys(t);for(let r=0;r<n.length;r++){const s=n[r];re(s)||(e[s]=t[s])}return e}function E(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function m(i){return typeof i=="string"}function b(i){return typeof i=="function"}function U(i){return i==null?!0:typeof i=="object"?Object.keys(i).length===0:!1}function K(i){try{const e=new URL(i);return e.search="",e.toString()}catch{return i}}const W="__rokt_ls_probe__";function C(){try{return window.localStorage.setItem(W,"1"),window.localStorage.removeItem(W),!0}catch{return!1}}function F(i){try{const e=window.localStorage.getItem(i);return e===null?null:JSON.parse(e)}catch{return null}}function se(i,e){try{return window.localStorage.setItem(i,JSON.stringify(e)),!0}catch{return!1}}function _e(i){try{window.localStorage.removeItem(i)}catch{}}function D(i,e){const t=F(i);return E(t)?t[e]:void 0}function oe(i,e,t){const n=F(i),r=E(n)?{...n}:{};return r[e]=t,se(i,r)}function ae(i,e){const t=F(i);if(!E(t)||!(e in t))return;const n={...t};delete n[e],Object.keys(n).length===0?_e(i):se(i,n)}const _="mp-rokt-kit",x="pageViews",P="utmParams",ce=25,Ie=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];function le(i){return i.slice(-ce)}function H(){const i=D(_,x);return Array.isArray(i)?i:[]}function Se(i){const e=le(i);for(let t=0;t<e.length;t++){const n=e.slice(t);if(oe(_,x,n))return n.length}return 0}function V(){ae(_,x)}function ye(i){const e=le(i);return e.map((t,n)=>{const r=t.activeTimeOnSite,s=r!==void 0&&Number.isFinite(r),c=e[n+1]?.activeTimeOnSite,u=c!==void 0&&Number.isFinite(c),l=s&&u?c-r:void 0;return{pageUrl:t.pageUrl,sourceMessageId:t.sourceMessageId,timestamp:t.timestamp,...t.pageTitle!==void 0?{pageTitle:t.pageTitle}:{},...t.canonicalUrl!==void 0?{canonicalUrl:t.canonicalUrl}:{},...s?{activeTimeOnSite:r}:{},...l!==void 0&&l>=0?{activeTimeOnPage:l}:{}}})}function Ae(i){if(D(_,P)!==void 0)return;const e=new URLSearchParams(window.location.search),t={};for(const r of Ie){const s=e.get(r);s&&(t[r]=s)}if(Object.keys(t).length===0)return;const n=Object.keys(t).join(", ");if(!oe(_,P,t)){const r=C()?"quota":"ls_unavailable";i?.log({message:`Rokt Kit: Failed to persist UTM params [reason: ${r}]`,code:"UTM_CAPTURE_FAILED"});return}i?.log({message:`Rokt Kit: Captured UTM params [${n}]`,code:"UTM_CAPTURE_SUCCESS"})}function ke(){const i=D(_,P);return E(i)?i:null}function z(){ae(_,P)}function Re(){const e=document.querySelector('link[rel="canonical"]')?.href;if(e)return K(e)}function ve(){return{context:null,lifecycle:"idle",recreateInFlight:null}}function we(i,e){i.context={accountId:e.accountId,launcherOptions:{...e.launcherOptions},legacyRoktExtensions:[...e.legacyRoktExtensions]}}function be(i){i.lifecycle="attached"}function Te(i){i.lifecycle!=="idle"&&(i.lifecycle="terminated")}function Le(i){i.lifecycle="terminated"}function Pe(i){i.context=null,i.lifecycle="idle",i.recreateInFlight=null}function Oe(i,e,t){if(i.recreateInFlight)return i.recreateInFlight;if(i.lifecycle!=="terminated"||!i.context||!e)return;i.lifecycle="recreating";const n=i.context;return i.recreateInFlight=t(n).finally(()=>{i.recreateInFlight=null}),i.recreateInFlight}const d="Rokt",T=181,Ne="selectPlacements",Ue="apps.roktecommerce.com",Ce=.1,Me="ThankYouPageJourney",Ke="rokt-launcher",Fe="rokt-thank-you-element",De="userIdentifiedInWorkspace",xe=3,Ye=2,je="page_events",Ge="page_view_attributes",We="mparticle_session_id",He="mparticle_device_id",q=500,Y={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST",LOG_DELIVERY_FAILURE:"LOG_DELIVERY_FAILURE"},S={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},Ve="apps.rokt-api.com",ze="/v1/log",qe="/v1/errors",$e=10;function a(){return window.mParticle}function $(i,e){const n=[O(i),"/wsdk/integrations/launcher.js"].join("");return!e||e.length===0?n:n+"?extensions="+e.join(",")}function J(i){return[O(i),"/rokt-elements/rokt-element-thank-you.js"].join("")}function O(i){const e=typeof i<"u"?i:Ve;return e.includes("://")?e.replace(/\/+$/,""):["https://",e].join("")}function ue(i,e,t){if(i)return i.startsWith("http://")||i.startsWith("https://")?i:"https://"+i;const r=e?.includes("://")&&!/^https?:\/\//i.test(e)?void 0:e;return O(r)+t}function B(i,e,t){if(document.getElementById(i))return;const n=document.head||document.body,r=document.createElement("script");r.id=i,r.type="text/javascript",r.src=e,r.async=!0,r.crossOrigin="anonymous",r.fetchPriority="high",t?.onLoad&&(r.onload=t.onLoad),t?.onError&&(r.onerror=t.onError),n.appendChild(r)}function L(i){if(!i)return[];try{return JSON.parse(i.replace(/&quot;/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function Q(i){const e=i?L(i):[],t=[],n=[];let r=!1;for(let s=0;s<e.length;s++){const o=e[s].value;o==="thank-you-journey"?(r=!0,n.push(Me)):t.push(o)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:n,loadThankYouElement:r}}async function Je(i,e){const t=[];if(e)for(const n of i)t.push(e.use(n));return Promise.all(t)}function X(i){if(!i)return{};const e={};for(let t=0;t<i.length;t++){const n=i[t];e[n.jsmap]=n.value}return e}function Z(i){const e={};if(!Array.isArray(i))return e;for(let t=0;t<i.length;t++){const n=i[t];if(!n||!m(n.value)||!m(n.map))continue;const r=n.value,s=n.map;e[r]||(e[r]=[]),e[r].push({eventAttributeKey:s,conditions:Array.isArray(n.conditions)?n.conditions:[]})}return e}function ee(i,e,t){return a().generateHash([i,e,t].join(""))}function Be(i){let n="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"1.36.1";return i&&(n+="_"+i),n}function de(i){let e=5381;for(let t=0;t<i.length;t++)e=(e<<5)+e+i.charCodeAt(t),e=e&e;return e}function M(i){const e=document.createElement("iframe");e.style.display="none",e.setAttribute("sandbox","allow-scripts allow-same-origin"),e.src=i,e.onload=function(){e.onload=null,e.parentNode&&e.parentNode.removeChild(e)};const t=document.body||document.head;t&&t.appendChild(e)}function te(i,e){const t=de(window.location.origin);if(y._allowedOriginHashes.indexOf(t)===-1||Math.random()>=Ce)return;const r=window.__rokt_li_guid__;if(!r||i&&i.includes("://")&&!/^https:\/\//i.test(i))return;const s=window.location.href.split("?")[0].split("#")[0],o="version="+encodeURIComponent(e??"")+"&launcherInstanceGuid="+encodeURIComponent(r)+"&pageUrl="+encodeURIComponent(s),c=i?O(i):"https://apps.rokt.com";M(c+"/v1/wsdk-init/index.html?"+o),M("https://"+Ue+"/v1/wsdk-init/index.html?"+o+"&isControl=true")}function Qe(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function Xe(){return typeof window<"u"?window.location?.href:void 0}function Ze(){return typeof window<"u"?window.navigator?.userAgent:void 0}class he{constructor(){this._logCount={}}incrementAndCheck(e){const n=(this._logCount[e]||0)+1;return this._logCount[e]=n,n>$e}}class j{constructor(e,t,n,r,s){this._reporter="mp-wsdk";const o=e.isLoggingEnabled;this._integrationName=t||"",this._launcherInstanceGuid=n,this._accountId=r||null,this._rateLimiter=s||new he,this._isEnabled=Qe()||o}send(e,t,n,r,s,o){if(!(!this._isEnabled||this._rateLimiter.incrementAndCheck(t)))try{const c={additionalInformation:{message:n,version:this._integrationName},severity:t,code:r||Y.UNKNOWN_ERROR,url:Xe(),deviceInfo:Ze(),stackTrace:s,reporter:this._reporter,integration:this._integrationName},u={Accept:"text/plain;charset=UTF-8","Content-Type":"application/json","rokt-launcher-version":this._integrationName,"rokt-wsdk-version":"joint"};this._launcherInstanceGuid&&(u["rokt-launcher-instance-guid"]=this._launcherInstanceGuid),this._accountId&&(u["rokt-account-id"]=this._accountId),fetch(e,{method:"POST",headers:u,body:JSON.stringify(c)}).then(l=>{if(!l.ok){const p=new Error("HTTP "+l.status+" from log endpoint");throw p.statusCode=l.status,p}}).catch(l=>{console.error("ReportingTransport: Failed to send log",l),o&&o(l)})}catch(c){console.error("ReportingTransport: Failed to send log",c),o&&o(c)}}}class ie{constructor(e,t,n,r,s){this._transport=new j(e,t,n,r,s),this._errorUrl=ue(e?.errorUrl,e?.integrationDomain,qe)}report(e){if(!e)return;const t=e.severity||S.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class ne{constructor(e,t,n,r,s,o){this._transport=new j(e,n,r,s,o),this._loggingUrl=ue(e?.loggingUrl,e?.integrationDomain,ze),this._errorReportingService=t}log(e){e&&this._transport.send(this._loggingUrl,S.INFO,e.message,e.code,void 0,t=>{if(this._errorReportingService){const n=typeof t.statusCode=="number";this._errorReportingService.report({message:"LoggingService: Failed to send log: "+t.message,code:Y.LOG_DELIVERY_FAILURE,severity:n?S.ERROR:S.WARNING})}})}}function et(i){const e=K(window.location.href),t=i.EventAttributes?.title||document.title,n=Re(),r=i.ActiveTimeOnSite;return{pageUrl:e,sourceMessageId:i.SourceMessageId,timestamp:i.Timestamp,...t?{pageTitle:t}:{},...n!==void 0?{canonicalUrl:n}:{},...Number.isFinite(r)?{activeTimeOnSite:r}:{}}}const f=class f{constructor(){this.name=d,this.id=T,this.moduleId=T,this.isInitialized=!1,this.launcher=null,this.filters={},this.userAttributes={},this.userIdentifiedInWorkspace=!1,this.testHelpers=null,this.placementEventMappingLookup={},this.placementEventAttributeMappingLookup={},this.integrationName=null,this.errorReportingService=null,this.loggingService=null,this._thankYouElementOnLoadCallback=null,this._isThankYouElementLoaded=!1,this._workspaceSearchInFlightPromise=null,this._launcherAttachState=ve()}getEventAttributeValue(e,t){const n=e&&e.EventAttributes;return!n||typeof n[t]>"u"?null:n[t]}doesEventAttributeConditionMatch(e,t){if(!e||!m(e.operator))return!1;const n=e.operator.toLowerCase(),r=e.attributeValue;return n==="exists"?t!==null:t==null?!1:n==="equals"?String(t)===String(r):n==="contains"?String(t).indexOf(String(r))!==-1:!1}doesEventMatchRule(e,t){if(!t||!m(t.eventAttributeKey))return!1;const n=t.conditions;if(!Array.isArray(n))return!1;const r=this.getEventAttributeValue(e,t.eventAttributeKey);if(n.length===0)return r!==null;for(let s=0;s<n.length;s++)if(!this.doesEventAttributeConditionMatch(n[s],r))return!1;return!0}applyPlacementEventAttributeMapping(e){const t=Object.keys(this.placementEventAttributeMappingLookup);for(let n=0;n<t.length;n++){const r=t[n],s=this.placementEventAttributeMappingLookup[r];if(U(s))continue;let o=!0;for(let c=0;c<s.length;c++)if(!this.doesEventMatchRule(e,s[c])){o=!1;break}o&&a().Rokt.setLocalSessionAttribute?.(r,!0)}}capturePageView(e){let t;try{t=K(window.location.href);const n=H(),r=et(e);n.push(r);const s=Math.min(n.length,ce),o=Se(n);if(o===0){const c=C()?"quota":"ls_unavailable";this.loggingService?.log({message:`Rokt Kit: Failed to persist page view for ${t} [reason: ${c}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}else o<s&&this.loggingService?.log({message:`Rokt Kit: Page view storage reduced from ${s} to ${o} record(s) under quota pressure [reason: quota_eviction]`,code:"PAGE_VIEW_QUOTA_EVICTION"})}catch(n){const r=C()?"exception":"ls_unavailable",s=n instanceof Error?n.message:String(n);this.loggingService?.log({message:`Rokt Kit: Failed to capture page view for ${t}: ${s} [reason: ${r}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}}isLauncherReadyToAttach(){return!!window.Rokt&&b(window.Rokt.createLauncher)}returnUserIdentities(e){if(!e||!e.getUserIdentities)return{};const t=e.getUserIdentities().userIdentities;return this.replaceOtherIdentityWithEmailsha256(t)}returnLocalSessionAttributes(){return!a().Rokt||typeof a().Rokt.getLocalSessionAttributes!="function"?{}:a().Rokt.getLocalSessionAttributes()}replaceOtherIdentityWithEmailsha256(e){const t={...e||{}},n=this._mappedEmailSha256Key;return n&&e[n]&&(t[f.EMAIL_SHA256_KEY]=e[n]),n&&delete t[n],t}logSelectPlacementsEvent(e){if(!window.mParticle||typeof a().logEvent!="function"||!E(e))return;const t=a().EventType.Other;a().logEvent(Ne,t,e)}setRoktSessionId(e){if(!(!e||typeof e!="string"))try{const t=a().getInstance();t&&b(t.setIntegrationAttribute)&&t.setIntegrationAttribute(T,{roktSessionId:e})}catch{}}readMpSessionId(){const e=a()?.sessionManager,t=e?.getSessionId??e?.getSession;if(b(t))return t.call(e)||void 0}readMpDeviceId(){return a()?.getDeviceId?.()||void 0}attachLauncher(e,t,n=[]){we(this._launcherAttachState,{accountId:e,launcherOptions:t||{},legacyRoktExtensions:n});const r={accountId:e,...t||{}};let s;return this.isPartnerInLocalLauncherTestGroup()?s=Promise.resolve(window.Rokt.createLocalLauncher(r)):s=window.Rokt.createLauncher(r),s.then(async o=>{await Je([...n],o),this.initRoktLauncher(o)}).catch(o=>{Le(this._launcherAttachState),console.error("Error creating Rokt launcher:",o)})}recreateLauncherIfTerminated(){return Oe(this._launcherAttachState,this.isLauncherReadyToAttach(),e=>this.attachLauncher(e.accountId,e.launcherOptions,e.legacyRoktExtensions))}initRoktLauncher(e){window.Rokt&&(window.Rokt.currentLauncher=e),this.launcher=e,be(this._launcherAttachState);const t=a().Rokt?.filters;t?(this.filters=t,t.filteredUser?this._workspaceSearchInFlightPromise=this.search(t.filteredUser):console.warn("Rokt Kit: No filtered user has been set.")):console.warn("Rokt Kit: No filters have been set."),this.isInitialized=!0,te(this.domain,this.integrationName),a().Rokt.attachKit(this)}fetchOptimizely(){const e=a()._getActiveForwarders().filter(t=>t.name==="Optimizely");try{if(e.length>0&&window.optimizely){const t=window.optimizely.get("state");return!t||!t.getActiveExperimentIds?{}:t.getActiveExperimentIds().reduce((s,o)=>(s["rokt.custom.optimizely.experiment."+o+".variationId"]=t.getVariationMap()[o].id,s),{})}}catch(t){console.error("Error fetching Optimizely attributes:",t)}return{}}isKitReady(){return!!(this.isInitialized&&this.launcher)}isTargetingDisabled(){return a().Rokt?.launcherOptions?.noTargeting===!0}isPartnerInLocalLauncherTestGroup(){return!!(a().config&&a().config.isLocalLauncherEnabled&&this.isAssignedToSampleGroup())}isAssignedToSampleGroup(){return Math.random()>.5}captureTiming(e){window&&a()&&a().captureTiming&&e&&a().captureTiming(e)}init(e,t,n,r,s){const o=e,c=o.accountId;this.userAttributes=w(s),this._onboardingExpProvider=o.onboardingExpProvider;const u=L(o.placementEventMapping);this.placementEventMappingLookup=X(u);const l=L(o.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=Z(l),o.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=o.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=m(o.workspaceIdSyncApiKey)?o.workspaceIdSyncApiKey:void 0;const p=a().Rokt?.domain,{roktExtensionsQueryParams:N,legacyRoktExtensions:R,loadThankYouElement:v}=Q(o.roktExtensions),g={...a().Rokt?.launcherOptions||{}};this.integrationName=Be(g.integrationName),g.integrationName=this.integrationName,this.domain=p;const A={loggingUrl:o.loggingUrl,errorUrl:o.errorUrl,integrationDomain:p,isLoggingEnabled:a().config?.isLoggingEnabled===!0},I=new ie(A,this.integrationName,window.__rokt_li_guid__,o.accountId),k=new ne(A,I,this.integrationName,window.__rokt_li_guid__,o.accountId);if(this.errorReportingService=I,this.loggingService=k,this.isTargetingDisabled())try{V(),z()}catch(h){this.errorReportingService?.report({message:"Rokt Kit: Failed to clear page views when targeting is disabled",code:"PAGE_VIEW_CAPTURE_FAILED",severity:S.INFO,stackTrace:h instanceof Error?h.stack:void 0})}return a()._registerErrorReportingService&&a()._registerErrorReportingService(I),a()._registerLoggingService&&a()._registerLoggingService(k),n?(this.testHelpers={generateLauncherScript:$,generateThankYouElementScript:J,extractRoktExtensionConfig:Q,hashEventMessage:ee,parseSettingsString:L,generateMappedEventLookup:X,generateMappedEventAttributeLookup:Z,sendAdBlockMeasurementSignals:te,createAutoRemovedIframe:M,djb2:de,setAllowedOriginHashes:h=>{f._allowedOriginHashes=h},ReportingTransport:j,ErrorReportingService:ie,LoggingService:ne,RateLimiter:he,ErrorCodes:Y,WSDKErrorSeverity:S,resetLauncherAttachState:()=>Pe(this._launcherAttachState)},this.attachLauncher(c,g),"Successfully initialized: "+d):(v&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),B(Fe,J(p),{onLoad:()=>{this._isThankYouElementLoaded=!0,this._thankYouElementOnLoadCallback&&this._thankYouElementOnLoadCallback()},onError:h=>{console.error("Error loading Rokt Thank You Element script:",h)}})),this.isLauncherReadyToAttach()?this.attachLauncher(c,g,R):(B(Ke,$(p,N),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,g,R):console.error("Rokt object is not available after script load.")},onError:h=>{console.error("Error loading Rokt launcher script:",h)}}),this.captureTiming(f.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+d)}process(e){if(this.isTargetingDisabled()||(e.EventDataType===xe&&(Ae(this.loggingService),this.capturePageView(e)),e.EventDataType===Ye&&(V(),z())),!this.isKitReady())return"Kit not ready for forwarder: "+d;if(b(a().Rokt?.setLocalSessionAttribute)&&(U(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!U(this.placementEventMappingLookup))){const t=ee(e.EventDataType,e.EventCategory,e.EventName??"");this.placementEventMappingLookup[String(t)]&&a().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(t)],!0)}return"Successfully sent to forwarder: "+d}setExtensionData(e){if(!this.isKitReady()){console.error("Rokt Kit: Not initialized");return}window.Rokt.setExtensionData(e)}setUserAttribute(e,t){return re(e)||(this.userAttributes[e]=t),"Successfully set user attribute for forwarder: "+d}removeUserAttribute(e){return delete this.userAttributes[e],"Successfully removed user attribute for forwarder: "+d}handleIdentityComplete(e,t){return this.userAttributes=w(e.getAllUserAttributes()),"Successfully called "+t+" for forwarder: "+d}onUserIdentified(e){const t=e;return this.filters.filteredUser=t,this._workspaceSearchInFlightPromise=this.search(t),this.handleIdentityComplete(e,"onUserIdentified")}search(e){const t=this._workspaceIdSyncApiKey;if(!t)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const n=a().Identity?.search;if(typeof n!="function")return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const r=e.getUserIdentities?e.getUserIdentities().userIdentities:null,s={};if(r)for(const u of Object.keys(r)){const l=r[u];m(l)&&l.length>0&&(s[u]=l)}const o=Object.keys(s);if(o.length===0)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const c=o.sort().map(u=>`${u}=${s[u]}`).join("&");return c===this._workspaceLastSearchedIdentitiesKey?this._workspaceSearchInFlightPromise||Promise.resolve():(this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=c,new Promise(u=>{try{n(t,s,l=>{l?.httpCode===200&&(this.userIdentifiedInWorkspace=!0),u()})}catch(l){console.error("Rokt Kit: Workspace IDSync search failed",l),this._workspaceLastSearchedIdentitiesKey=void 0,u()}}))}onLoginComplete(e,t){return this.handleIdentityComplete(e,"onLoginComplete")}onLogoutComplete(e,t){return this.userIdentifiedInWorkspace=!1,this._workspaceSearchInFlightPromise=null,this._workspaceLastSearchedIdentitiesKey=void 0,this.handleIdentityComplete(e,"onLogoutComplete")}onModifyComplete(e,t){return this.handleIdentityComplete(e,"onModifyComplete")}selectPlacements(e){const t=this.recreateLauncherIfTerminated();if(t){const n=this._workspaceSearchInFlightPromise,r=n?Promise.race([n,new Promise(s=>setTimeout(s,q))]):Promise.resolve();return Promise.all([t,r]).then(()=>this._dispatchPlacements(e))}if(this._workspaceSearchInFlightPromise){const n=this._workspaceSearchInFlightPromise;return Promise.race([n,new Promise(r=>setTimeout(r,q))]).then(()=>this._dispatchPlacements(e))}return this._dispatchPlacements(e)}_dispatchPlacements(e){const t=e&&e.attributes||{},r={...w(this.userAttributes),...t},s=this.filters||{},o=s.userAttributeFilters||[],c=s.filteredUser||null,u=c?c.getMPID():null;let l;s?s.filterUserAttributes?l=s.filterUserAttributes(r,o):l=r:(console.warn("Rokt Kit: No filters available, using user attributes"),l=r),this.userAttributes=w(l);const p=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},N=this.returnUserIdentities(c),R=this.returnLocalSessionAttributes(),v=ye(H()),g=ke(),A=this.readMpSessionId(),I=this.readMpDeviceId(),k={...N,...l,...p,...R,...v.length?{[je]:JSON.stringify(v)}:{},...g?{[Ge]:g}:{},...this.userIdentifiedInWorkspace?{[De]:!0}:{},...A?{[We]:A}:{},...I?{[He]:I}:{},mpid:u},h={...e,attributes:k},G=this.launcher.selectPlacements(h),pe=()=>this.logSelectPlacementsEvent(k);return Promise.resolve(G).then(ge=>ge?.context?.sessionId?.then(fe=>this.setRoktSessionId(fe))).catch(()=>{}).finally(pe),G}hashAttributes(e){return this.isKitReady()?this.launcher.hashAttributes(e):(console.error("Rokt Kit: Not initialized"),null)}use(e){return this.isKitReady()?!e||!m(e)?Promise.reject(new Error("Rokt Kit: Invalid extension name")):this.launcher.use(e):(console.error("Rokt Kit: Not initialized"),Promise.reject(new Error("Rokt Kit: Not initialized")))}terminate(){return this.isKitReady()?(Te(this._launcherAttachState),this.launcher.terminate()):(console.error("Rokt Kit: Not initialized"),Promise.resolve())}onShoppableAdsReady(e){this._isThankYouElementLoaded?e():this._thankYouElementOnLoadCallback=e}};f._allowedOriginHashes=[-553112570,549508659],f.PERFORMANCE_MARKS={RoktScriptAppended:"mp:RoktScriptAppended"},f.EMAIL_SHA256_KEY="emailsha256";let y=f;function tt(){return T}function it(i){if(!i){window.console.log("You must pass a config object to register the kit "+d);return}if(!E(i)){window.console.log("'config' must be an object. You passed in a "+typeof i);return}E(i.kits)?i.kits[d]={constructor:y}:(i.kits={},i.kits[d]={constructor:y}),window.console.log("Successfully registered "+d+" to your mParticle configuration")}typeof window<"u"&&window.mParticle&&a().addForwarder&&a().addForwarder({name:d,constructor:y,getId:tt});exports.register=it;
2
2
  //# sourceMappingURL=Rokt-Kit.common.js.map
@@ -1,4 +1,4 @@
1
- const Ie = [
1
+ const me = [
2
2
  "active_time_on_site_ms",
3
3
  "billingaddress1",
4
4
  "billingaddress2",
@@ -23,31 +23,31 @@ const Ie = [
23
23
  "shippingstate",
24
24
  "shippingzipcode",
25
25
  "totalprice"
26
- ], Se = new Set(Ie);
27
- function se(i) {
28
- return Se.has(i.toLowerCase());
26
+ ], Ee = new Set(me);
27
+ function re(i) {
28
+ return Ee.has(i.toLowerCase());
29
29
  }
30
- function L(i) {
30
+ function w(i) {
31
31
  const e = {}, t = i || {}, n = Object.keys(t);
32
32
  for (let r = 0; r < n.length; r++) {
33
- const o = n[r];
34
- se(o) || (e[o] = t[o]);
33
+ const s = n[r];
34
+ re(s) || (e[s] = t[s]);
35
35
  }
36
36
  return e;
37
37
  }
38
- function _(i) {
38
+ function E(i) {
39
39
  return typeof i == "object" && i !== null && !Array.isArray(i);
40
40
  }
41
- function E(i) {
41
+ function m(i) {
42
42
  return typeof i == "string";
43
43
  }
44
- function T(i) {
44
+ function b(i) {
45
45
  return typeof i == "function";
46
46
  }
47
- function K(i) {
47
+ function U(i) {
48
48
  return i == null ? !0 : typeof i == "object" ? Object.keys(i).length === 0 : !1;
49
49
  }
50
- function x(i) {
50
+ function K(i) {
51
51
  try {
52
52
  const e = new URL(i);
53
53
  return e.search = "", e.toString();
@@ -55,15 +55,15 @@ function x(i) {
55
55
  return i;
56
56
  }
57
57
  }
58
- const j = "__rokt_ls_probe__";
59
- function F() {
58
+ const W = "__rokt_ls_probe__";
59
+ function C() {
60
60
  try {
61
- return window.localStorage.setItem(j, "1"), window.localStorage.removeItem(j), !0;
61
+ return window.localStorage.setItem(W, "1"), window.localStorage.removeItem(W), !0;
62
62
  } catch {
63
63
  return !1;
64
64
  }
65
65
  }
66
- function N(i) {
66
+ function F(i) {
67
67
  try {
68
68
  const e = window.localStorage.getItem(i);
69
69
  return e === null ? null : JSON.parse(e);
@@ -71,95 +71,82 @@ function N(i) {
71
71
  return null;
72
72
  }
73
73
  }
74
- function ae(i, e) {
74
+ function se(i, e) {
75
75
  try {
76
76
  return window.localStorage.setItem(i, JSON.stringify(e)), !0;
77
77
  } catch {
78
78
  return !1;
79
79
  }
80
80
  }
81
- function ce(i) {
81
+ function _e(i) {
82
82
  try {
83
83
  window.localStorage.removeItem(i);
84
84
  } catch {
85
85
  }
86
86
  }
87
- function U(i, e) {
88
- const t = N(i);
89
- return _(t) ? t[e] : void 0;
87
+ function D(i, e) {
88
+ const t = F(i);
89
+ return E(t) ? t[e] : void 0;
90
90
  }
91
- function Y(i, e, t) {
92
- const n = N(i), r = _(n) ? { ...n } : {};
93
- return r[e] = t, ae(i, r);
91
+ function oe(i, e, t) {
92
+ const n = F(i), r = E(n) ? { ...n } : {};
93
+ return r[e] = t, se(i, r);
94
94
  }
95
- function le(i, e) {
96
- const t = N(i);
97
- if (!_(t) || !(e in t))
95
+ function ae(i, e) {
96
+ const t = F(i);
97
+ if (!E(t) || !(e in t))
98
98
  return;
99
99
  const n = { ...t };
100
- delete n[e], Object.keys(n).length === 0 ? ce(i) : ae(i, n);
100
+ delete n[e], Object.keys(n).length === 0 ? _e(i) : se(i, n);
101
101
  }
102
- const p = "mp-rokt-kit", R = "pageViews", O = "utmParams", H = "mpPageViews", ue = 25, Ae = ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"];
103
- function de(i) {
104
- return i.slice(-ue);
102
+ const _ = "mp-rokt-kit", x = "pageViews", P = "utmParams", ce = 25, Ie = ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"];
103
+ function le(i) {
104
+ return i.slice(-ce);
105
105
  }
106
- function he(i) {
107
- const e = N(H);
108
- if (e === null)
109
- return;
110
- !(U(p, R) !== void 0) && Array.isArray(e) && (i?.log({
111
- message: "Rokt Kit: Migrating legacy page-view storage",
112
- code: "PAGE_VIEW_LEGACY_MIGRATION"
113
- }), Y(p, R, e) || i?.log({
114
- message: "Rokt Kit: Failed to migrate legacy page-view storage [reason: migration_retry]",
115
- code: "PAGE_VIEW_CAPTURE_FAILED"
116
- })), ce(H);
117
- }
118
- function z(i) {
119
- he(i);
120
- const e = U(p, R);
121
- return Array.isArray(e) ? e : [];
106
+ function H() {
107
+ const i = D(_, x);
108
+ return Array.isArray(i) ? i : [];
122
109
  }
123
- function ye(i) {
124
- const e = de(i);
110
+ function Se(i) {
111
+ const e = le(i);
125
112
  for (let t = 0; t < e.length; t++) {
126
113
  const n = e.slice(t);
127
- if (Y(p, R, n))
114
+ if (oe(_, x, n))
128
115
  return n.length;
129
116
  }
130
117
  return 0;
131
118
  }
132
- function q() {
133
- le(p, R);
119
+ function V() {
120
+ ae(_, x);
134
121
  }
135
- function ke(i) {
136
- const e = de(i);
122
+ function ye(i) {
123
+ const e = le(i);
137
124
  return e.map((t, n) => {
138
- const r = t.activeTimeOnSite, o = r !== void 0 && Number.isFinite(r), c = e[n + 1]?.activeTimeOnSite, u = c !== void 0 && Number.isFinite(c), l = o && u ? c - r : void 0;
125
+ const r = t.activeTimeOnSite, s = r !== void 0 && Number.isFinite(r), c = e[n + 1]?.activeTimeOnSite, u = c !== void 0 && Number.isFinite(c), l = s && u ? c - r : void 0;
139
126
  return {
140
127
  pageUrl: t.pageUrl,
141
128
  sourceMessageId: t.sourceMessageId,
142
129
  timestamp: t.timestamp,
143
130
  ...t.pageTitle !== void 0 ? { pageTitle: t.pageTitle } : {},
144
131
  ...t.canonicalUrl !== void 0 ? { canonicalUrl: t.canonicalUrl } : {},
145
- ...o ? { activeTimeOnSite: r } : {},
132
+ ...s ? { activeTimeOnSite: r } : {},
146
133
  ...l !== void 0 && l >= 0 ? { activeTimeOnPage: l } : {}
147
134
  };
148
135
  });
149
136
  }
150
- function Re(i) {
151
- if (U(p, O) !== void 0)
137
+ function Ae(i) {
138
+ if (D(_, P) !== void 0)
152
139
  return;
153
140
  const e = new URLSearchParams(window.location.search), t = {};
154
- for (const r of Ae) {
155
- const o = e.get(r);
156
- o && (t[r] = o);
141
+ for (const r of Ie) {
142
+ const s = e.get(r);
143
+ s && (t[r] = s);
157
144
  }
158
145
  if (Object.keys(t).length === 0)
159
146
  return;
160
147
  const n = Object.keys(t).join(", ");
161
- if (!Y(p, O, t)) {
162
- const r = F() ? "quota" : "ls_unavailable";
148
+ if (!oe(_, P, t)) {
149
+ const r = C() ? "quota" : "ls_unavailable";
163
150
  i?.log({
164
151
  message: `Rokt Kit: Failed to persist UTM params [reason: ${r}]`,
165
152
  code: "UTM_CAPTURE_FAILED"
@@ -171,26 +158,26 @@ function Re(i) {
171
158
  code: "UTM_CAPTURE_SUCCESS"
172
159
  });
173
160
  }
174
- function ve() {
175
- const i = U(p, O);
176
- return _(i) ? i : null;
161
+ function ke() {
162
+ const i = D(_, P);
163
+ return E(i) ? i : null;
177
164
  }
178
- function $() {
179
- le(p, O);
165
+ function z() {
166
+ ae(_, P);
180
167
  }
181
- function we() {
168
+ function Re() {
182
169
  const e = document.querySelector('link[rel="canonical"]')?.href;
183
170
  if (e)
184
- return x(e);
171
+ return K(e);
185
172
  }
186
- function Le() {
173
+ function ve() {
187
174
  return {
188
175
  context: null,
189
176
  lifecycle: "idle",
190
177
  recreateInFlight: null
191
178
  };
192
179
  }
193
- function Te(i, e) {
180
+ function we(i, e) {
194
181
  i.context = {
195
182
  accountId: e.accountId,
196
183
  launcherOptions: { ...e.launcherOptions },
@@ -200,16 +187,16 @@ function Te(i, e) {
200
187
  function be(i) {
201
188
  i.lifecycle = "attached";
202
189
  }
203
- function Pe(i) {
190
+ function Te(i) {
204
191
  i.lifecycle !== "idle" && (i.lifecycle = "terminated");
205
192
  }
206
- function Oe(i) {
193
+ function Le(i) {
207
194
  i.lifecycle = "terminated";
208
195
  }
209
- function Ne(i) {
196
+ function Pe(i) {
210
197
  i.context = null, i.lifecycle = "idle", i.recreateInFlight = null;
211
198
  }
212
- function Ue(i, e, t) {
199
+ function Oe(i, e, t) {
213
200
  if (i.recreateInFlight)
214
201
  return i.recreateInFlight;
215
202
  if (i.lifecycle !== "terminated" || !i.context || !e)
@@ -220,7 +207,7 @@ function Ue(i, e, t) {
220
207
  i.recreateInFlight = null;
221
208
  }), i.recreateInFlight;
222
209
  }
223
- const d = "Rokt", b = 181, Ce = "selectPlacements", Me = "apps.roktecommerce.com", Ke = 0.1, Fe = "ThankYouPageJourney", De = "rokt-launcher", xe = "rokt-thank-you-element", Ye = "userIdentifiedInWorkspace", Ge = 3, We = 2, Ve = "page_events", je = "page_view_attributes", He = "mparticle_session_id", ze = "mparticle_device_id", J = 500, G = {
210
+ const d = "Rokt", T = 181, Ne = "selectPlacements", Ue = "apps.roktecommerce.com", Ce = 0.1, Me = "ThankYouPageJourney", Ke = "rokt-launcher", Fe = "rokt-thank-you-element", De = "userIdentifiedInWorkspace", xe = 3, Ye = 2, Ge = "page_events", je = "page_view_attributes", We = "mparticle_session_id", He = "mparticle_device_id", q = 500, Y = {
224
211
  UNKNOWN_ERROR: "UNKNOWN_ERROR",
225
212
  UNHANDLED_EXCEPTION: "UNHANDLED_EXCEPTION",
226
213
  IDENTITY_REQUEST: "IDENTITY_REQUEST",
@@ -229,33 +216,33 @@ const d = "Rokt", b = 181, Ce = "selectPlacements", Me = "apps.roktecommerce.com
229
216
  ERROR: "ERROR",
230
217
  INFO: "INFO",
231
218
  WARNING: "WARNING"
232
- }, qe = "apps.rokt-api.com", $e = "/v1/log", Je = "/v1/errors", Be = 10;
219
+ }, Ve = "apps.rokt-api.com", ze = "/v1/log", qe = "/v1/errors", $e = 10;
233
220
  function a() {
234
221
  return window.mParticle;
235
222
  }
236
- function B(i, e) {
237
- const n = [C(i), "/wsdk/integrations/launcher.js"].join("");
223
+ function $(i, e) {
224
+ const n = [O(i), "/wsdk/integrations/launcher.js"].join("");
238
225
  return !e || e.length === 0 ? n : n + "?extensions=" + e.join(",");
239
226
  }
240
- function Q(i) {
241
- return [C(i), "/rokt-elements/rokt-element-thank-you.js"].join("");
227
+ function J(i) {
228
+ return [O(i), "/rokt-elements/rokt-element-thank-you.js"].join("");
242
229
  }
243
- function C(i) {
244
- const e = typeof i < "u" ? i : qe;
230
+ function O(i) {
231
+ const e = typeof i < "u" ? i : Ve;
245
232
  return e.includes("://") ? e.replace(/\/+$/, "") : ["https://", e].join("");
246
233
  }
247
- function ge(i, e, t) {
234
+ function ue(i, e, t) {
248
235
  if (i)
249
236
  return i.startsWith("http://") || i.startsWith("https://") ? i : "https://" + i;
250
237
  const r = e?.includes("://") && !/^https?:\/\//i.test(e) ? void 0 : e;
251
- return C(r) + t;
238
+ return O(r) + t;
252
239
  }
253
- function X(i, e, t) {
240
+ function B(i, e, t) {
254
241
  if (document.getElementById(i)) return;
255
242
  const n = document.head || document.body, r = document.createElement("script");
256
243
  r.id = i, r.type = "text/javascript", r.src = e, r.async = !0, r.crossOrigin = "anonymous", r.fetchPriority = "high", t?.onLoad && (r.onload = t.onLoad), t?.onError && (r.onerror = t.onError), n.appendChild(r);
257
244
  }
258
- function P(i) {
245
+ function L(i) {
259
246
  if (!i)
260
247
  return [];
261
248
  try {
@@ -265,12 +252,12 @@ function P(i) {
265
252
  }
266
253
  return [];
267
254
  }
268
- function Z(i) {
269
- const e = i ? P(i) : [], t = [], n = [];
255
+ function Q(i) {
256
+ const e = i ? L(i) : [], t = [], n = [];
270
257
  let r = !1;
271
- for (let o = 0; o < e.length; o++) {
272
- const s = e[o].value;
273
- s === "thank-you-journey" ? (r = !0, n.push(Fe)) : t.push(s);
258
+ for (let s = 0; s < e.length; s++) {
259
+ const o = e[s].value;
260
+ o === "thank-you-journey" ? (r = !0, n.push(Me)) : t.push(o);
274
261
  }
275
262
  return {
276
263
  roktExtensionsQueryParams: t,
@@ -278,14 +265,14 @@ function Z(i) {
278
265
  loadThankYouElement: r
279
266
  };
280
267
  }
281
- async function Qe(i, e) {
268
+ async function Je(i, e) {
282
269
  const t = [];
283
270
  if (e)
284
271
  for (const n of i)
285
272
  t.push(e.use(n));
286
273
  return Promise.all(t);
287
274
  }
288
- function ee(i) {
275
+ function X(i) {
289
276
  if (!i)
290
277
  return {};
291
278
  const e = {};
@@ -295,36 +282,36 @@ function ee(i) {
295
282
  }
296
283
  return e;
297
284
  }
298
- function te(i) {
285
+ function Z(i) {
299
286
  const e = {};
300
287
  if (!Array.isArray(i))
301
288
  return e;
302
289
  for (let t = 0; t < i.length; t++) {
303
290
  const n = i[t];
304
- if (!n || !E(n.value) || !E(n.map))
291
+ if (!n || !m(n.value) || !m(n.map))
305
292
  continue;
306
- const r = n.value, o = n.map;
293
+ const r = n.value, s = n.map;
307
294
  e[r] || (e[r] = []), e[r].push({
308
- eventAttributeKey: o,
295
+ eventAttributeKey: s,
309
296
  conditions: Array.isArray(n.conditions) ? n.conditions : []
310
297
  });
311
298
  }
312
299
  return e;
313
300
  }
314
- function ie(i, e, t) {
301
+ function ee(i, e, t) {
315
302
  return a().generateHash([i, e, t].join(""));
316
303
  }
317
- function Xe(i) {
318
- let n = "mParticle_wsdkv_" + a().getVersion() + "_kitv_" + "1.36.0";
304
+ function Be(i) {
305
+ let n = "mParticle_wsdkv_" + a().getVersion() + "_kitv_" + "1.36.1";
319
306
  return i && (n += "_" + i), n;
320
307
  }
321
- function pe(i) {
308
+ function de(i) {
322
309
  let e = 5381;
323
310
  for (let t = 0; t < i.length; t++)
324
311
  e = (e << 5) + e + i.charCodeAt(t), e = e & e;
325
312
  return e;
326
313
  }
327
- function D(i) {
314
+ function M(i) {
328
315
  const e = document.createElement("iframe");
329
316
  e.style.display = "none", e.setAttribute("sandbox", "allow-scripts allow-same-origin"), e.src = i, e.onload = function() {
330
317
  e.onload = null, e.parentNode && e.parentNode.removeChild(e);
@@ -332,43 +319,43 @@ function D(i) {
332
319
  const t = document.body || document.head;
333
320
  t && t.appendChild(e);
334
321
  }
335
- function ne(i, e) {
336
- const t = pe(window.location.origin);
337
- if (A._allowedOriginHashes.indexOf(t) === -1 || Math.random() >= Ke)
322
+ function te(i, e) {
323
+ const t = de(window.location.origin);
324
+ if (y._allowedOriginHashes.indexOf(t) === -1 || Math.random() >= Ce)
338
325
  return;
339
326
  const r = window.__rokt_li_guid__;
340
327
  if (!r || i && i.includes("://") && !/^https:\/\//i.test(i))
341
328
  return;
342
- const o = window.location.href.split("?")[0].split("#")[0], s = "version=" + encodeURIComponent(e ?? "") + "&launcherInstanceGuid=" + encodeURIComponent(r) + "&pageUrl=" + encodeURIComponent(o), c = i ? C(i) : "https://apps.rokt.com";
343
- D(c + "/v1/wsdk-init/index.html?" + s), D(
344
- "https://" + Me + "/v1/wsdk-init/index.html?" + s + "&isControl=true"
329
+ const s = window.location.href.split("?")[0].split("#")[0], o = "version=" + encodeURIComponent(e ?? "") + "&launcherInstanceGuid=" + encodeURIComponent(r) + "&pageUrl=" + encodeURIComponent(s), c = i ? O(i) : "https://apps.rokt.com";
330
+ M(c + "/v1/wsdk-init/index.html?" + o), M(
331
+ "https://" + Ue + "/v1/wsdk-init/index.html?" + o + "&isControl=true"
345
332
  );
346
333
  }
347
- function Ze() {
334
+ function Qe() {
348
335
  return typeof window < "u" && !!window.location?.search?.toLowerCase().includes("mp_enable_logging=true");
349
336
  }
350
- function et() {
337
+ function Xe() {
351
338
  return typeof window < "u" ? window.location?.href : void 0;
352
339
  }
353
- function tt() {
340
+ function Ze() {
354
341
  return typeof window < "u" ? window.navigator?.userAgent : void 0;
355
342
  }
356
- class fe {
343
+ class he {
357
344
  constructor() {
358
345
  this._logCount = {};
359
346
  }
360
347
  incrementAndCheck(e) {
361
348
  const n = (this._logCount[e] || 0) + 1;
362
- return this._logCount[e] = n, n > Be;
349
+ return this._logCount[e] = n, n > $e;
363
350
  }
364
351
  }
365
- class W {
366
- constructor(e, t, n, r, o) {
352
+ class G {
353
+ constructor(e, t, n, r, s) {
367
354
  this._reporter = "mp-wsdk";
368
- const s = e.isLoggingEnabled;
369
- this._integrationName = t || "", this._launcherInstanceGuid = n, this._accountId = r || null, this._rateLimiter = o || new fe(), this._isEnabled = Ze() || s;
355
+ const o = e.isLoggingEnabled;
356
+ this._integrationName = t || "", this._launcherInstanceGuid = n, this._accountId = r || null, this._rateLimiter = s || new he(), this._isEnabled = Qe() || o;
370
357
  }
371
- send(e, t, n, r, o, s) {
358
+ send(e, t, n, r, s, o) {
372
359
  if (!(!this._isEnabled || this._rateLimiter.incrementAndCheck(t)))
373
360
  try {
374
361
  const c = {
@@ -377,10 +364,10 @@ class W {
377
364
  version: this._integrationName
378
365
  },
379
366
  severity: t,
380
- code: r || G.UNKNOWN_ERROR,
381
- url: et(),
382
- deviceInfo: tt(),
383
- stackTrace: o,
367
+ code: r || Y.UNKNOWN_ERROR,
368
+ url: Xe(),
369
+ deviceInfo: Ze(),
370
+ stackTrace: s,
384
371
  reporter: this._reporter,
385
372
  integration: this._integrationName
386
373
  }, u = {
@@ -395,20 +382,20 @@ class W {
395
382
  body: JSON.stringify(c)
396
383
  }).then((l) => {
397
384
  if (!l.ok) {
398
- const g = new Error("HTTP " + l.status + " from log endpoint");
399
- throw g.statusCode = l.status, g;
385
+ const p = new Error("HTTP " + l.status + " from log endpoint");
386
+ throw p.statusCode = l.status, p;
400
387
  }
401
388
  }).catch((l) => {
402
- console.error("ReportingTransport: Failed to send log", l), s && s(l);
389
+ console.error("ReportingTransport: Failed to send log", l), o && o(l);
403
390
  });
404
391
  } catch (c) {
405
- console.error("ReportingTransport: Failed to send log", c), s && s(c);
392
+ console.error("ReportingTransport: Failed to send log", c), o && o(c);
406
393
  }
407
394
  }
408
395
  }
409
- class re {
410
- constructor(e, t, n, r, o) {
411
- this._transport = new W(e, t, n, r, o), this._errorUrl = ge(e?.errorUrl, e?.integrationDomain, Je);
396
+ class ie {
397
+ constructor(e, t, n, r, s) {
398
+ this._transport = new G(e, t, n, r, s), this._errorUrl = ue(e?.errorUrl, e?.integrationDomain, qe);
412
399
  }
413
400
  report(e) {
414
401
  if (!e) return;
@@ -416,9 +403,9 @@ class re {
416
403
  this._transport.send(this._errorUrl, t, e.message, e.code, e.stackTrace);
417
404
  }
418
405
  }
419
- class oe {
420
- constructor(e, t, n, r, o, s) {
421
- this._transport = new W(e, n, r, o, s), this._loggingUrl = ge(e?.loggingUrl, e?.integrationDomain, $e), this._errorReportingService = t;
406
+ class ne {
407
+ constructor(e, t, n, r, s, o) {
408
+ this._transport = new G(e, n, r, s, o), this._loggingUrl = ue(e?.loggingUrl, e?.integrationDomain, ze), this._errorReportingService = t;
422
409
  }
423
410
  log(e) {
424
411
  e && this._transport.send(
@@ -432,7 +419,7 @@ class oe {
432
419
  const n = typeof t.statusCode == "number";
433
420
  this._errorReportingService.report({
434
421
  message: "LoggingService: Failed to send log: " + t.message,
435
- code: G.LOG_DELIVERY_FAILURE,
422
+ code: Y.LOG_DELIVERY_FAILURE,
436
423
  severity: n ? S.ERROR : S.WARNING
437
424
  });
438
425
  }
@@ -440,8 +427,8 @@ class oe {
440
427
  );
441
428
  }
442
429
  }
443
- function it(i) {
444
- const e = x(window.location.href), t = i.EventAttributes?.title || document.title, n = we(), r = i.ActiveTimeOnSite;
430
+ function et(i) {
431
+ const e = K(window.location.href), t = i.EventAttributes?.title || document.title, n = Re(), r = i.ActiveTimeOnSite;
445
432
  return {
446
433
  pageUrl: e,
447
434
  sourceMessageId: i.SourceMessageId,
@@ -451,9 +438,9 @@ function it(i) {
451
438
  ...Number.isFinite(r) ? { activeTimeOnSite: r } : {}
452
439
  };
453
440
  }
454
- const m = class m {
441
+ const f = class f {
455
442
  constructor() {
456
- this.name = d, this.id = b, this.moduleId = b, this.isInitialized = !1, this.launcher = null, this.filters = {}, this.userAttributes = {}, this.userIdentifiedInWorkspace = !1, this.testHelpers = null, this.placementEventMappingLookup = {}, this.placementEventAttributeMappingLookup = {}, this.integrationName = null, this.errorReportingService = null, this.loggingService = null, this._thankYouElementOnLoadCallback = null, this._isThankYouElementLoaded = !1, this._workspaceSearchInFlightPromise = null, this._launcherAttachState = Le();
443
+ this.name = d, this.id = T, this.moduleId = T, this.isInitialized = !1, this.launcher = null, this.filters = {}, this.userAttributes = {}, this.userIdentifiedInWorkspace = !1, this.testHelpers = null, this.placementEventMappingLookup = {}, this.placementEventAttributeMappingLookup = {}, this.integrationName = null, this.errorReportingService = null, this.loggingService = null, this._thankYouElementOnLoadCallback = null, this._isThankYouElementLoaded = !1, this._workspaceSearchInFlightPromise = null, this._launcherAttachState = ve();
457
444
  }
458
445
  // ---- Private helpers ----
459
446
  getEventAttributeValue(e, t) {
@@ -461,13 +448,13 @@ const m = class m {
461
448
  return !n || typeof n[t] > "u" ? null : n[t];
462
449
  }
463
450
  doesEventAttributeConditionMatch(e, t) {
464
- if (!e || !E(e.operator))
451
+ if (!e || !m(e.operator))
465
452
  return !1;
466
453
  const n = e.operator.toLowerCase(), r = e.attributeValue;
467
454
  return n === "exists" ? t !== null : t == null ? !1 : n === "equals" ? String(t) === String(r) : n === "contains" ? String(t).indexOf(String(r)) !== -1 : !1;
468
455
  }
469
456
  doesEventMatchRule(e, t) {
470
- if (!t || !E(t.eventAttributeKey))
457
+ if (!t || !m(t.eventAttributeKey))
471
458
  return !1;
472
459
  const n = t.conditions;
473
460
  if (!Array.isArray(n))
@@ -475,53 +462,53 @@ const m = class m {
475
462
  const r = this.getEventAttributeValue(e, t.eventAttributeKey);
476
463
  if (n.length === 0)
477
464
  return r !== null;
478
- for (let o = 0; o < n.length; o++)
479
- if (!this.doesEventAttributeConditionMatch(n[o], r))
465
+ for (let s = 0; s < n.length; s++)
466
+ if (!this.doesEventAttributeConditionMatch(n[s], r))
480
467
  return !1;
481
468
  return !0;
482
469
  }
483
470
  applyPlacementEventAttributeMapping(e) {
484
471
  const t = Object.keys(this.placementEventAttributeMappingLookup);
485
472
  for (let n = 0; n < t.length; n++) {
486
- const r = t[n], o = this.placementEventAttributeMappingLookup[r];
487
- if (K(o))
473
+ const r = t[n], s = this.placementEventAttributeMappingLookup[r];
474
+ if (U(s))
488
475
  continue;
489
- let s = !0;
490
- for (let c = 0; c < o.length; c++)
491
- if (!this.doesEventMatchRule(e, o[c])) {
492
- s = !1;
476
+ let o = !0;
477
+ for (let c = 0; c < s.length; c++)
478
+ if (!this.doesEventMatchRule(e, s[c])) {
479
+ o = !1;
493
480
  break;
494
481
  }
495
- s && a().Rokt.setLocalSessionAttribute?.(r, !0);
482
+ o && a().Rokt.setLocalSessionAttribute?.(r, !0);
496
483
  }
497
484
  }
498
485
  capturePageView(e) {
499
486
  let t;
500
487
  try {
501
- t = x(window.location.href);
502
- const n = z(this.loggingService), r = it(e);
488
+ t = K(window.location.href);
489
+ const n = H(), r = et(e);
503
490
  n.push(r);
504
- const o = Math.min(n.length, ue), s = ye(n);
505
- if (s === 0) {
506
- const c = F() ? "quota" : "ls_unavailable";
491
+ const s = Math.min(n.length, ce), o = Se(n);
492
+ if (o === 0) {
493
+ const c = C() ? "quota" : "ls_unavailable";
507
494
  this.loggingService?.log({
508
495
  message: `Rokt Kit: Failed to persist page view for ${t} [reason: ${c}]`,
509
496
  code: "PAGE_VIEW_CAPTURE_FAILED"
510
497
  });
511
- } else s < o && this.loggingService?.log({
512
- message: `Rokt Kit: Page view storage reduced from ${o} to ${s} record(s) under quota pressure [reason: quota_eviction]`,
498
+ } else o < s && this.loggingService?.log({
499
+ message: `Rokt Kit: Page view storage reduced from ${s} to ${o} record(s) under quota pressure [reason: quota_eviction]`,
513
500
  code: "PAGE_VIEW_QUOTA_EVICTION"
514
501
  });
515
502
  } catch (n) {
516
- const r = F() ? "exception" : "ls_unavailable", o = n instanceof Error ? n.message : String(n);
503
+ const r = C() ? "exception" : "ls_unavailable", s = n instanceof Error ? n.message : String(n);
517
504
  this.loggingService?.log({
518
- message: `Rokt Kit: Failed to capture page view for ${t}: ${o} [reason: ${r}]`,
505
+ message: `Rokt Kit: Failed to capture page view for ${t}: ${s} [reason: ${r}]`,
519
506
  code: "PAGE_VIEW_CAPTURE_FAILED"
520
507
  });
521
508
  }
522
509
  }
523
510
  isLauncherReadyToAttach() {
524
- return !!window.Rokt && T(window.Rokt.createLauncher);
511
+ return !!window.Rokt && b(window.Rokt.createLauncher);
525
512
  }
526
513
  /**
527
514
  * Returns the user identities from the filtered user, if any.
@@ -537,19 +524,19 @@ const m = class m {
537
524
  }
538
525
  replaceOtherIdentityWithEmailsha256(e) {
539
526
  const t = { ...e || {} }, n = this._mappedEmailSha256Key;
540
- return n && e[n] && (t[m.EMAIL_SHA256_KEY] = e[n]), n && delete t[n], t;
527
+ return n && e[n] && (t[f.EMAIL_SHA256_KEY] = e[n]), n && delete t[n], t;
541
528
  }
542
529
  logSelectPlacementsEvent(e) {
543
- if (!window.mParticle || typeof a().logEvent != "function" || !_(e))
530
+ if (!window.mParticle || typeof a().logEvent != "function" || !E(e))
544
531
  return;
545
532
  const t = a().EventType.Other;
546
- a().logEvent(Ce, t, e);
533
+ a().logEvent(Ne, t, e);
547
534
  }
548
535
  setRoktSessionId(e) {
549
536
  if (!(!e || typeof e != "string"))
550
537
  try {
551
538
  const t = a().getInstance();
552
- t && T(t.setIntegrationAttribute) && t.setIntegrationAttribute(b, {
539
+ t && b(t.setIntegrationAttribute) && t.setIntegrationAttribute(T, {
553
540
  roktSessionId: e
554
541
  });
555
542
  } catch {
@@ -557,14 +544,14 @@ const m = class m {
557
544
  }
558
545
  readMpSessionId() {
559
546
  const e = a()?.sessionManager, t = e?.getSessionId ?? e?.getSession;
560
- if (T(t))
547
+ if (b(t))
561
548
  return t.call(e) || void 0;
562
549
  }
563
550
  readMpDeviceId() {
564
551
  return a()?.getDeviceId?.() || void 0;
565
552
  }
566
553
  attachLauncher(e, t, n = []) {
567
- Te(this._launcherAttachState, {
554
+ we(this._launcherAttachState, {
568
555
  accountId: e,
569
556
  launcherOptions: t || {},
570
557
  legacyRoktExtensions: n
@@ -573,15 +560,15 @@ const m = class m {
573
560
  accountId: e,
574
561
  ...t || {}
575
562
  };
576
- let o;
577
- return this.isPartnerInLocalLauncherTestGroup() ? o = Promise.resolve(window.Rokt.createLocalLauncher(r)) : o = window.Rokt.createLauncher(r), o.then(async (s) => {
578
- await Qe([...n], s), this.initRoktLauncher(s);
579
- }).catch((s) => {
580
- Oe(this._launcherAttachState), console.error("Error creating Rokt launcher:", s);
563
+ let s;
564
+ return this.isPartnerInLocalLauncherTestGroup() ? s = Promise.resolve(window.Rokt.createLocalLauncher(r)) : s = window.Rokt.createLauncher(r), s.then(async (o) => {
565
+ await Je([...n], o), this.initRoktLauncher(o);
566
+ }).catch((o) => {
567
+ Le(this._launcherAttachState), console.error("Error creating Rokt launcher:", o);
581
568
  });
582
569
  }
583
570
  recreateLauncherIfTerminated() {
584
- return Ue(
571
+ return Oe(
585
572
  this._launcherAttachState,
586
573
  this.isLauncherReadyToAttach(),
587
574
  (e) => this.attachLauncher(e.accountId, e.launcherOptions, e.legacyRoktExtensions)
@@ -590,14 +577,14 @@ const m = class m {
590
577
  initRoktLauncher(e) {
591
578
  window.Rokt && (window.Rokt.currentLauncher = e), this.launcher = e, be(this._launcherAttachState);
592
579
  const t = a().Rokt?.filters;
593
- t ? (this.filters = t, t.filteredUser ? this._workspaceSearchInFlightPromise = this.search(t.filteredUser) : console.warn("Rokt Kit: No filtered user has been set.")) : console.warn("Rokt Kit: No filters have been set."), this.isInitialized = !0, ne(this.domain, this.integrationName), a().Rokt.attachKit(this);
580
+ t ? (this.filters = t, t.filteredUser ? this._workspaceSearchInFlightPromise = this.search(t.filteredUser) : console.warn("Rokt Kit: No filtered user has been set.")) : console.warn("Rokt Kit: No filters have been set."), this.isInitialized = !0, te(this.domain, this.integrationName), a().Rokt.attachKit(this);
594
581
  }
595
582
  fetchOptimizely() {
596
583
  const e = a()._getActiveForwarders().filter((t) => t.name === "Optimizely");
597
584
  try {
598
585
  if (e.length > 0 && window.optimizely) {
599
586
  const t = window.optimizely.get("state");
600
- return !t || !t.getActiveExperimentIds ? {} : t.getActiveExperimentIds().reduce((o, s) => (o["rokt.custom.optimizely.experiment." + s + ".variationId"] = t.getVariationMap()[s].id, o), {});
587
+ return !t || !t.getActiveExperimentIds ? {} : t.getActiveExperimentIds().reduce((s, o) => (s["rokt.custom.optimizely.experiment." + o + ".variationId"] = t.getVariationMap()[o].id, s), {});
601
588
  }
602
589
  } catch (t) {
603
590
  console.error("Error fetching Optimizely attributes:", t);
@@ -625,41 +612,41 @@ const m = class m {
625
612
  /**
626
613
  * Initializes the Rokt forwarder with settings from the mParticle server.
627
614
  */
628
- init(e, t, n, r, o) {
629
- const s = e, c = s.accountId;
630
- this.userAttributes = L(o), this._onboardingExpProvider = s.onboardingExpProvider;
631
- const u = P(s.placementEventMapping);
632
- this.placementEventMappingLookup = ee(u);
633
- const l = P(
634
- s.placementEventAttributeMapping
615
+ init(e, t, n, r, s) {
616
+ const o = e, c = o.accountId;
617
+ this.userAttributes = w(s), this._onboardingExpProvider = o.onboardingExpProvider;
618
+ const u = L(o.placementEventMapping);
619
+ this.placementEventMappingLookup = X(u);
620
+ const l = L(
621
+ o.placementEventAttributeMapping
635
622
  );
636
- this.placementEventAttributeMappingLookup = te(l), s.hashedEmailUserIdentityType && (this._mappedEmailSha256Key = s.hashedEmailUserIdentityType.toLowerCase()), this._workspaceIdSyncApiKey = E(s.workspaceIdSyncApiKey) ? s.workspaceIdSyncApiKey : void 0;
637
- const g = a().Rokt?.domain, { roktExtensionsQueryParams: M, legacyRoktExtensions: v, loadThankYouElement: w } = Z(
638
- s.roktExtensions
639
- ), f = {
623
+ this.placementEventAttributeMappingLookup = Z(l), o.hashedEmailUserIdentityType && (this._mappedEmailSha256Key = o.hashedEmailUserIdentityType.toLowerCase()), this._workspaceIdSyncApiKey = m(o.workspaceIdSyncApiKey) ? o.workspaceIdSyncApiKey : void 0;
624
+ const p = a().Rokt?.domain, { roktExtensionsQueryParams: N, legacyRoktExtensions: R, loadThankYouElement: v } = Q(
625
+ o.roktExtensions
626
+ ), g = {
640
627
  ...a().Rokt?.launcherOptions || {}
641
628
  };
642
- this.integrationName = Xe(f.integrationName), f.integrationName = this.integrationName, this.domain = g;
643
- const y = {
644
- loggingUrl: s.loggingUrl,
645
- errorUrl: s.errorUrl,
646
- integrationDomain: g,
629
+ this.integrationName = Be(g.integrationName), g.integrationName = this.integrationName, this.domain = p;
630
+ const A = {
631
+ loggingUrl: o.loggingUrl,
632
+ errorUrl: o.errorUrl,
633
+ integrationDomain: p,
647
634
  isLoggingEnabled: a().config?.isLoggingEnabled === !0
648
- }, I = new re(
649
- y,
635
+ }, I = new ie(
636
+ A,
650
637
  this.integrationName,
651
638
  window.__rokt_li_guid__,
652
- s.accountId
653
- ), k = new oe(
654
- y,
639
+ o.accountId
640
+ ), k = new ne(
641
+ A,
655
642
  I,
656
643
  this.integrationName,
657
644
  window.__rokt_li_guid__,
658
- s.accountId
645
+ o.accountId
659
646
  );
660
647
  if (this.errorReportingService = I, this.loggingService = k, this.isTargetingDisabled())
661
648
  try {
662
- q(), $();
649
+ V(), z();
663
650
  } catch (h) {
664
651
  this.errorReportingService?.report({
665
652
  message: "Rokt Kit: Failed to clear page views when targeting is disabled",
@@ -669,47 +656,47 @@ const m = class m {
669
656
  });
670
657
  }
671
658
  return a()._registerErrorReportingService && a()._registerErrorReportingService(I), a()._registerLoggingService && a()._registerLoggingService(k), n ? (this.testHelpers = {
672
- generateLauncherScript: B,
673
- generateThankYouElementScript: Q,
674
- extractRoktExtensionConfig: Z,
675
- hashEventMessage: ie,
676
- parseSettingsString: P,
677
- generateMappedEventLookup: ee,
678
- generateMappedEventAttributeLookup: te,
679
- sendAdBlockMeasurementSignals: ne,
680
- createAutoRemovedIframe: D,
681
- djb2: pe,
659
+ generateLauncherScript: $,
660
+ generateThankYouElementScript: J,
661
+ extractRoktExtensionConfig: Q,
662
+ hashEventMessage: ee,
663
+ parseSettingsString: L,
664
+ generateMappedEventLookup: X,
665
+ generateMappedEventAttributeLookup: Z,
666
+ sendAdBlockMeasurementSignals: te,
667
+ createAutoRemovedIframe: M,
668
+ djb2: de,
682
669
  setAllowedOriginHashes: (h) => {
683
- m._allowedOriginHashes = h;
670
+ f._allowedOriginHashes = h;
684
671
  },
685
- ReportingTransport: W,
686
- ErrorReportingService: re,
687
- LoggingService: oe,
688
- RateLimiter: fe,
689
- ErrorCodes: G,
672
+ ReportingTransport: G,
673
+ ErrorReportingService: ie,
674
+ LoggingService: ne,
675
+ RateLimiter: he,
676
+ ErrorCodes: Y,
690
677
  WSDKErrorSeverity: S,
691
- resetLauncherAttachState: () => Ne(this._launcherAttachState)
692
- }, this.attachLauncher(c, f), "Successfully initialized: " + d) : (w && (a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this), X(xe, Q(g), {
678
+ resetLauncherAttachState: () => Pe(this._launcherAttachState)
679
+ }, this.attachLauncher(c, g), "Successfully initialized: " + d) : (v && (a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this), B(Fe, J(p), {
693
680
  onLoad: () => {
694
681
  this._isThankYouElementLoaded = !0, this._thankYouElementOnLoadCallback && this._thankYouElementOnLoadCallback();
695
682
  },
696
683
  onError: (h) => {
697
684
  console.error("Error loading Rokt Thank You Element script:", h);
698
685
  }
699
- })), this.isLauncherReadyToAttach() ? this.attachLauncher(c, f, v) : (X(De, B(g, M), {
686
+ })), this.isLauncherReadyToAttach() ? this.attachLauncher(c, g, R) : (B(Ke, $(p, N), {
700
687
  onLoad: () => {
701
- this.isLauncherReadyToAttach() ? this.attachLauncher(c, f, v) : console.error("Rokt object is not available after script load.");
688
+ this.isLauncherReadyToAttach() ? this.attachLauncher(c, g, R) : console.error("Rokt object is not available after script load.");
702
689
  },
703
690
  onError: (h) => {
704
691
  console.error("Error loading Rokt launcher script:", h);
705
692
  }
706
- }), this.captureTiming(m.PERFORMANCE_MARKS.RoktScriptAppended)), "Successfully initialized: " + d);
693
+ }), this.captureTiming(f.PERFORMANCE_MARKS.RoktScriptAppended)), "Successfully initialized: " + d);
707
694
  }
708
695
  process(e) {
709
- if (this.isTargetingDisabled() || (e.EventDataType === Ge && (Re(this.loggingService), this.capturePageView(e)), e.EventDataType === We && (he(this.loggingService), q(), $())), !this.isKitReady())
696
+ if (this.isTargetingDisabled() || (e.EventDataType === xe && (Ae(this.loggingService), this.capturePageView(e)), e.EventDataType === Ye && (V(), z())), !this.isKitReady())
710
697
  return "Kit not ready for forwarder: " + d;
711
- if (T(a().Rokt?.setLocalSessionAttribute) && (K(this.placementEventAttributeMappingLookup) || this.applyPlacementEventAttributeMapping(e), !K(this.placementEventMappingLookup))) {
712
- const t = ie(e.EventDataType, e.EventCategory, e.EventName ?? "");
698
+ if (b(a().Rokt?.setLocalSessionAttribute) && (U(this.placementEventAttributeMappingLookup) || this.applyPlacementEventAttributeMapping(e), !U(this.placementEventMappingLookup))) {
699
+ const t = ee(e.EventDataType, e.EventCategory, e.EventName ?? "");
713
700
  this.placementEventMappingLookup[String(t)] && a().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(t)], !0);
714
701
  }
715
702
  return "Successfully sent to forwarder: " + d;
@@ -722,13 +709,13 @@ const m = class m {
722
709
  window.Rokt.setExtensionData(e);
723
710
  }
724
711
  setUserAttribute(e, t) {
725
- return se(e) || (this.userAttributes[e] = t), "Successfully set user attribute for forwarder: " + d;
712
+ return re(e) || (this.userAttributes[e] = t), "Successfully set user attribute for forwarder: " + d;
726
713
  }
727
714
  removeUserAttribute(e) {
728
715
  return delete this.userAttributes[e], "Successfully removed user attribute for forwarder: " + d;
729
716
  }
730
717
  handleIdentityComplete(e, t) {
731
- return this.userAttributes = L(e.getAllUserAttributes()), "Successfully called " + t + " for forwarder: " + d;
718
+ return this.userAttributes = w(e.getAllUserAttributes()), "Successfully called " + t + " for forwarder: " + d;
732
719
  }
733
720
  onUserIdentified(e) {
734
721
  const t = e;
@@ -741,19 +728,19 @@ const m = class m {
741
728
  const n = a().Identity?.search;
742
729
  if (typeof n != "function")
743
730
  return this.userIdentifiedInWorkspace = !1, this._workspaceLastSearchedIdentitiesKey = void 0, Promise.resolve();
744
- const r = e.getUserIdentities ? e.getUserIdentities().userIdentities : null, o = {};
731
+ const r = e.getUserIdentities ? e.getUserIdentities().userIdentities : null, s = {};
745
732
  if (r)
746
733
  for (const u of Object.keys(r)) {
747
734
  const l = r[u];
748
- E(l) && l.length > 0 && (o[u] = l);
735
+ m(l) && l.length > 0 && (s[u] = l);
749
736
  }
750
- const s = Object.keys(o);
751
- if (s.length === 0)
737
+ const o = Object.keys(s);
738
+ if (o.length === 0)
752
739
  return this.userIdentifiedInWorkspace = !1, this._workspaceLastSearchedIdentitiesKey = void 0, Promise.resolve();
753
- const c = s.sort().map((u) => `${u}=${o[u]}`).join("&");
740
+ const c = o.sort().map((u) => `${u}=${s[u]}`).join("&");
754
741
  return c === this._workspaceLastSearchedIdentitiesKey ? this._workspaceSearchInFlightPromise || Promise.resolve() : (this.userIdentifiedInWorkspace = !1, this._workspaceLastSearchedIdentitiesKey = c, new Promise((u) => {
755
742
  try {
756
- n(t, o, (l) => {
743
+ n(t, s, (l) => {
757
744
  l?.httpCode === 200 && (this.userIdentifiedInWorkspace = !0), u();
758
745
  });
759
746
  } catch (l) {
@@ -799,7 +786,7 @@ const m = class m {
799
786
  if (t) {
800
787
  const n = this._workspaceSearchInFlightPromise, r = n ? Promise.race([
801
788
  n,
802
- new Promise((o) => setTimeout(o, J))
789
+ new Promise((s) => setTimeout(s, q))
803
790
  ]) : Promise.resolve();
804
791
  return Promise.all([t, r]).then(
805
792
  () => this._dispatchPlacements(e)
@@ -809,29 +796,29 @@ const m = class m {
809
796
  const n = this._workspaceSearchInFlightPromise;
810
797
  return Promise.race([
811
798
  n,
812
- new Promise((r) => setTimeout(r, J))
799
+ new Promise((r) => setTimeout(r, q))
813
800
  ]).then(() => this._dispatchPlacements(e));
814
801
  }
815
802
  return this._dispatchPlacements(e);
816
803
  }
817
804
  _dispatchPlacements(e) {
818
- const t = e && e.attributes || {}, r = { ...L(this.userAttributes), ...t }, o = this.filters || {}, s = o.userAttributeFilters || [], c = o.filteredUser || null, u = c ? c.getMPID() : null;
805
+ const t = e && e.attributes || {}, r = { ...w(this.userAttributes), ...t }, s = this.filters || {}, o = s.userAttributeFilters || [], c = s.filteredUser || null, u = c ? c.getMPID() : null;
819
806
  let l;
820
- o ? o.filterUserAttributes ? l = o.filterUserAttributes(r, s) : l = r : (console.warn("Rokt Kit: No filters available, using user attributes"), l = r), this.userAttributes = L(l);
821
- const g = this._onboardingExpProvider === "Optimizely" ? this.fetchOptimizely() : {}, M = this.returnUserIdentities(c), v = this.returnLocalSessionAttributes(), w = ke(z(this.loggingService)), f = ve(), y = this.readMpSessionId(), I = this.readMpDeviceId(), k = {
822
- ...M,
807
+ s ? s.filterUserAttributes ? l = s.filterUserAttributes(r, o) : l = r : (console.warn("Rokt Kit: No filters available, using user attributes"), l = r), this.userAttributes = w(l);
808
+ const p = this._onboardingExpProvider === "Optimizely" ? this.fetchOptimizely() : {}, N = this.returnUserIdentities(c), R = this.returnLocalSessionAttributes(), v = ye(H()), g = ke(), A = this.readMpSessionId(), I = this.readMpDeviceId(), k = {
809
+ ...N,
823
810
  ...l,
824
- ...g,
825
- ...v,
826
- ...w.length ? { [Ve]: JSON.stringify(w) } : {},
827
- ...f ? { [je]: f } : {},
828
- ...this.userIdentifiedInWorkspace ? { [Ye]: !0 } : {},
829
- ...y ? { [He]: y } : {},
830
- ...I ? { [ze]: I } : {},
811
+ ...p,
812
+ ...R,
813
+ ...v.length ? { [Ge]: JSON.stringify(v) } : {},
814
+ ...g ? { [je]: g } : {},
815
+ ...this.userIdentifiedInWorkspace ? { [De]: !0 } : {},
816
+ ...A ? { [We]: A } : {},
817
+ ...I ? { [He]: I } : {},
831
818
  mpid: u
832
- }, h = { ...e, attributes: k }, V = this.launcher.selectPlacements(h), me = () => this.logSelectPlacementsEvent(k);
833
- return Promise.resolve(V).then((Ee) => Ee?.context?.sessionId?.then((_e) => this.setRoktSessionId(_e))).catch(() => {
834
- }).finally(me), V;
819
+ }, h = { ...e, attributes: k }, j = this.launcher.selectPlacements(h), pe = () => this.logSelectPlacementsEvent(k);
820
+ return Promise.resolve(j).then((ge) => ge?.context?.sessionId?.then((fe) => this.setRoktSessionId(fe))).catch(() => {
821
+ }).finally(pe), j;
835
822
  }
836
823
  /**
837
824
  * Passes attributes to the Rokt Web SDK for client-side hashing.
@@ -845,7 +832,7 @@ const m = class m {
845
832
  * @deprecated This functionality has been internalized and will be removed in a future release.
846
833
  */
847
834
  use(e) {
848
- return this.isKitReady() ? !e || !E(e) ? Promise.reject(new Error("Rokt Kit: Invalid extension name")) : this.launcher.use(e) : (console.error("Rokt Kit: Not initialized"), Promise.reject(new Error("Rokt Kit: Not initialized")));
835
+ return this.isKitReady() ? !e || !m(e) ? Promise.reject(new Error("Rokt Kit: Invalid extension name")) : this.launcher.use(e) : (console.error("Rokt Kit: Not initialized"), Promise.reject(new Error("Rokt Kit: Not initialized")));
849
836
  }
850
837
  /**
851
838
  * Tears down the Rokt launcher and the placements it rendered.
@@ -857,7 +844,7 @@ const m = class m {
857
844
  * here would flip the kit to not-ready with no drain path for queued calls.
858
845
  */
859
846
  terminate() {
860
- return this.isKitReady() ? (Pe(this._launcherAttachState), this.launcher.terminate()) : (console.error("Rokt Kit: Not initialized"), Promise.resolve());
847
+ return this.isKitReady() ? (Te(this._launcherAttachState), this.launcher.terminate()) : (console.error("Rokt Kit: Not initialized"), Promise.resolve());
861
848
  }
862
849
  /**
863
850
  * Registers a callback to be invoked once rokt-thank-you-element.js becomes available.
@@ -866,34 +853,34 @@ const m = class m {
866
853
  this._isThankYouElementLoaded ? e() : this._thankYouElementOnLoadCallback = e;
867
854
  }
868
855
  };
869
- m._allowedOriginHashes = [-553112570, 549508659], m.PERFORMANCE_MARKS = {
856
+ f._allowedOriginHashes = [-553112570, 549508659], f.PERFORMANCE_MARKS = {
870
857
  RoktScriptAppended: "mp:RoktScriptAppended"
871
- }, m.EMAIL_SHA256_KEY = "emailsha256";
872
- let A = m;
873
- function nt() {
874
- return b;
858
+ }, f.EMAIL_SHA256_KEY = "emailsha256";
859
+ let y = f;
860
+ function tt() {
861
+ return T;
875
862
  }
876
- function rt(i) {
863
+ function it(i) {
877
864
  if (!i) {
878
865
  window.console.log("You must pass a config object to register the kit " + d);
879
866
  return;
880
867
  }
881
- if (!_(i)) {
868
+ if (!E(i)) {
882
869
  window.console.log("'config' must be an object. You passed in a " + typeof i);
883
870
  return;
884
871
  }
885
- _(i.kits) ? i.kits[d] = {
886
- constructor: A
872
+ E(i.kits) ? i.kits[d] = {
873
+ constructor: y
887
874
  } : (i.kits = {}, i.kits[d] = {
888
- constructor: A
875
+ constructor: y
889
876
  }), window.console.log("Successfully registered " + d + " to your mParticle configuration");
890
877
  }
891
878
  typeof window < "u" && window.mParticle && a().addForwarder && a().addForwarder({
892
879
  name: d,
893
- constructor: A,
894
- getId: nt
880
+ constructor: y,
881
+ getId: tt
895
882
  });
896
883
  export {
897
- rt as register
884
+ it as register
898
885
  };
899
886
  //# sourceMappingURL=Rokt-Kit.esm.js.map
@@ -1,2 +1,2 @@
1
- var RoktKit=(function(M){"use strict";const Ee=["active_time_on_site_ms","billingaddress1","billingaddress2","billingcity","billingstate","billingzipcode","cartitems","ccbin","confirmationref","conversiontype","country","couponcode","currency","language","paymentserviceprovider","paymentserviceproviderattribute","paymenttype","shippingaddress1","shippingcity","shippingcountry","shippingmethod","shippingstate","shippingzipcode","totalprice"],_e=new Set(Ee);function V(i){return _e.has(i.toLowerCase())}function v(i){const e={},t=i||{},n=Object.keys(t);for(let r=0;r<n.length;r++){const o=n[r];V(o)||(e[o]=t[o])}return e}function E(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function _(i){return typeof i=="string"}function w(i){return typeof i=="function"}function K(i){return i==null?!0:typeof i=="object"?Object.keys(i).length===0:!1}function F(i){try{const e=new URL(i);return e.search="",e.toString()}catch{return i}}const H="__rokt_ls_probe__";function D(){try{return window.localStorage.setItem(H,"1"),window.localStorage.removeItem(H),!0}catch{return!1}}function b(i){try{const e=window.localStorage.getItem(i);return e===null?null:JSON.parse(e)}catch{return null}}function z(i,e){try{return window.localStorage.setItem(i,JSON.stringify(e)),!0}catch{return!1}}function q(i){try{window.localStorage.removeItem(i)}catch{}}function L(i,e){const t=b(i);return E(t)?t[e]:void 0}function Y(i,e,t){const n=b(i),r=E(n)?{...n}:{};return r[e]=t,z(i,r)}function $(i,e){const t=b(i);if(!E(t)||!(e in t))return;const n={...t};delete n[e],Object.keys(n).length===0?q(i):z(i,n)}const g="mp-rokt-kit",A="pageViews",T="utmParams",J="mpPageViews",B=25,Ie=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];function Q(i){return i.slice(-B)}function X(i){const e=b(J);if(e===null)return;!(L(g,A)!==void 0)&&Array.isArray(e)&&(i?.log({message:"Rokt Kit: Migrating legacy page-view storage",code:"PAGE_VIEW_LEGACY_MIGRATION"}),Y(g,A,e)||i?.log({message:"Rokt Kit: Failed to migrate legacy page-view storage [reason: migration_retry]",code:"PAGE_VIEW_CAPTURE_FAILED"})),q(J)}function Z(i){X(i);const e=L(g,A);return Array.isArray(e)?e:[]}function Se(i){const e=Q(i);for(let t=0;t<e.length;t++){const n=e.slice(t);if(Y(g,A,n))return n.length}return 0}function ee(){$(g,A)}function ye(i){const e=Q(i);return e.map((t,n)=>{const r=t.activeTimeOnSite,o=r!==void 0&&Number.isFinite(r),c=e[n+1]?.activeTimeOnSite,u=c!==void 0&&Number.isFinite(c),l=o&&u?c-r:void 0;return{pageUrl:t.pageUrl,sourceMessageId:t.sourceMessageId,timestamp:t.timestamp,...t.pageTitle!==void 0?{pageTitle:t.pageTitle}:{},...t.canonicalUrl!==void 0?{canonicalUrl:t.canonicalUrl}:{},...o?{activeTimeOnSite:r}:{},...l!==void 0&&l>=0?{activeTimeOnPage:l}:{}}})}function Ae(i){if(L(g,T)!==void 0)return;const e=new URLSearchParams(window.location.search),t={};for(const r of Ie){const o=e.get(r);o&&(t[r]=o)}if(Object.keys(t).length===0)return;const n=Object.keys(t).join(", ");if(!Y(g,T,t)){const r=D()?"quota":"ls_unavailable";i?.log({message:`Rokt Kit: Failed to persist UTM params [reason: ${r}]`,code:"UTM_CAPTURE_FAILED"});return}i?.log({message:`Rokt Kit: Captured UTM params [${n}]`,code:"UTM_CAPTURE_SUCCESS"})}function ke(){const i=L(g,T);return E(i)?i:null}function te(){$(g,T)}function Re(){const e=document.querySelector('link[rel="canonical"]')?.href;if(e)return F(e)}function ve(){return{context:null,lifecycle:"idle",recreateInFlight:null}}function we(i,e){i.context={accountId:e.accountId,launcherOptions:{...e.launcherOptions},legacyRoktExtensions:[...e.legacyRoktExtensions]}}function be(i){i.lifecycle="attached"}function Le(i){i.lifecycle!=="idle"&&(i.lifecycle="terminated")}function Te(i){i.lifecycle="terminated"}function Pe(i){i.context=null,i.lifecycle="idle",i.recreateInFlight=null}function Oe(i,e,t){if(i.recreateInFlight)return i.recreateInFlight;if(i.lifecycle!=="terminated"||!i.context||!e)return;i.lifecycle="recreating";const n=i.context;return i.recreateInFlight=t(n).finally(()=>{i.recreateInFlight=null}),i.recreateInFlight}const d="Rokt",P=181,Ne="selectPlacements",Ue="apps.roktecommerce.com",Ce=.1,Me="ThankYouPageJourney",Ke="rokt-launcher",Fe="rokt-thank-you-element",De="userIdentifiedInWorkspace",Ye=3,xe=2,Ge="page_events",We="page_view_attributes",je="mparticle_session_id",Ve="mparticle_device_id",ie=500,x={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST",LOG_DELIVERY_FAILURE:"LOG_DELIVERY_FAILURE"},I={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},He="apps.rokt-api.com",ze="/v1/log",qe="/v1/errors",$e=10;function a(){return window.mParticle}function ne(i,e){const n=[O(i),"/wsdk/integrations/launcher.js"].join("");return!e||e.length===0?n:n+"?extensions="+e.join(",")}function re(i){return[O(i),"/rokt-elements/rokt-element-thank-you.js"].join("")}function O(i){const e=typeof i<"u"?i:He;return e.includes("://")?e.replace(/\/+$/,""):["https://",e].join("")}function oe(i,e,t){if(i)return i.startsWith("http://")||i.startsWith("https://")?i:"https://"+i;const r=e?.includes("://")&&!/^https?:\/\//i.test(e)?void 0:e;return O(r)+t}function se(i,e,t){if(document.getElementById(i))return;const n=document.head||document.body,r=document.createElement("script");r.id=i,r.type="text/javascript",r.src=e,r.async=!0,r.crossOrigin="anonymous",r.fetchPriority="high",t?.onLoad&&(r.onload=t.onLoad),t?.onError&&(r.onerror=t.onError),n.appendChild(r)}function N(i){if(!i)return[];try{return JSON.parse(i.replace(/&quot;/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function ae(i){const e=i?N(i):[],t=[],n=[];let r=!1;for(let o=0;o<e.length;o++){const s=e[o].value;s==="thank-you-journey"?(r=!0,n.push(Me)):t.push(s)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:n,loadThankYouElement:r}}async function Je(i,e){const t=[];if(e)for(const n of i)t.push(e.use(n));return Promise.all(t)}function ce(i){if(!i)return{};const e={};for(let t=0;t<i.length;t++){const n=i[t];e[n.jsmap]=n.value}return e}function le(i){const e={};if(!Array.isArray(i))return e;for(let t=0;t<i.length;t++){const n=i[t];if(!n||!_(n.value)||!_(n.map))continue;const r=n.value,o=n.map;e[r]||(e[r]=[]),e[r].push({eventAttributeKey:o,conditions:Array.isArray(n.conditions)?n.conditions:[]})}return e}function ue(i,e,t){return a().generateHash([i,e,t].join(""))}function Be(i){let n="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"1.36.0";return i&&(n+="_"+i),n}function de(i){let e=5381;for(let t=0;t<i.length;t++)e=(e<<5)+e+i.charCodeAt(t),e=e&e;return e}function G(i){const e=document.createElement("iframe");e.style.display="none",e.setAttribute("sandbox","allow-scripts allow-same-origin"),e.src=i,e.onload=function(){e.onload=null,e.parentNode&&e.parentNode.removeChild(e)};const t=document.body||document.head;t&&t.appendChild(e)}function he(i,e){const t=de(window.location.origin);if(S._allowedOriginHashes.indexOf(t)===-1||Math.random()>=Ce)return;const r=window.__rokt_li_guid__;if(!r||i&&i.includes("://")&&!/^https:\/\//i.test(i))return;const o=window.location.href.split("?")[0].split("#")[0],s="version="+encodeURIComponent(e??"")+"&launcherInstanceGuid="+encodeURIComponent(r)+"&pageUrl="+encodeURIComponent(o),c=i?O(i):"https://apps.rokt.com";G(c+"/v1/wsdk-init/index.html?"+s),G("https://"+Ue+"/v1/wsdk-init/index.html?"+s+"&isControl=true")}function Qe(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function Xe(){return typeof window<"u"?window.location?.href:void 0}function Ze(){return typeof window<"u"?window.navigator?.userAgent:void 0}class ge{constructor(){this._logCount={}}incrementAndCheck(e){const n=(this._logCount[e]||0)+1;return this._logCount[e]=n,n>$e}}class W{constructor(e,t,n,r,o){this._reporter="mp-wsdk";const s=e.isLoggingEnabled;this._integrationName=t||"",this._launcherInstanceGuid=n,this._accountId=r||null,this._rateLimiter=o||new ge,this._isEnabled=Qe()||s}send(e,t,n,r,o,s){if(!(!this._isEnabled||this._rateLimiter.incrementAndCheck(t)))try{const c={additionalInformation:{message:n,version:this._integrationName},severity:t,code:r||x.UNKNOWN_ERROR,url:Xe(),deviceInfo:Ze(),stackTrace:o,reporter:this._reporter,integration:this._integrationName},u={Accept:"text/plain;charset=UTF-8","Content-Type":"application/json","rokt-launcher-version":this._integrationName,"rokt-wsdk-version":"joint"};this._launcherInstanceGuid&&(u["rokt-launcher-instance-guid"]=this._launcherInstanceGuid),this._accountId&&(u["rokt-account-id"]=this._accountId),fetch(e,{method:"POST",headers:u,body:JSON.stringify(c)}).then(l=>{if(!l.ok){const p=new Error("HTTP "+l.status+" from log endpoint");throw p.statusCode=l.status,p}}).catch(l=>{console.error("ReportingTransport: Failed to send log",l),s&&s(l)})}catch(c){console.error("ReportingTransport: Failed to send log",c),s&&s(c)}}}class pe{constructor(e,t,n,r,o){this._transport=new W(e,t,n,r,o),this._errorUrl=oe(e?.errorUrl,e?.integrationDomain,qe)}report(e){if(!e)return;const t=e.severity||I.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class fe{constructor(e,t,n,r,o,s){this._transport=new W(e,n,r,o,s),this._loggingUrl=oe(e?.loggingUrl,e?.integrationDomain,ze),this._errorReportingService=t}log(e){e&&this._transport.send(this._loggingUrl,I.INFO,e.message,e.code,void 0,t=>{if(this._errorReportingService){const n=typeof t.statusCode=="number";this._errorReportingService.report({message:"LoggingService: Failed to send log: "+t.message,code:x.LOG_DELIVERY_FAILURE,severity:n?I.ERROR:I.WARNING})}})}}function et(i){const e=F(window.location.href),t=i.EventAttributes?.title||document.title,n=Re(),r=i.ActiveTimeOnSite;return{pageUrl:e,sourceMessageId:i.SourceMessageId,timestamp:i.Timestamp,...t?{pageTitle:t}:{},...n!==void 0?{canonicalUrl:n}:{},...Number.isFinite(r)?{activeTimeOnSite:r}:{}}}const f=class f{constructor(){this.name=d,this.id=P,this.moduleId=P,this.isInitialized=!1,this.launcher=null,this.filters={},this.userAttributes={},this.userIdentifiedInWorkspace=!1,this.testHelpers=null,this.placementEventMappingLookup={},this.placementEventAttributeMappingLookup={},this.integrationName=null,this.errorReportingService=null,this.loggingService=null,this._thankYouElementOnLoadCallback=null,this._isThankYouElementLoaded=!1,this._workspaceSearchInFlightPromise=null,this._launcherAttachState=ve()}getEventAttributeValue(e,t){const n=e&&e.EventAttributes;return!n||typeof n[t]>"u"?null:n[t]}doesEventAttributeConditionMatch(e,t){if(!e||!_(e.operator))return!1;const n=e.operator.toLowerCase(),r=e.attributeValue;return n==="exists"?t!==null:t==null?!1:n==="equals"?String(t)===String(r):n==="contains"?String(t).indexOf(String(r))!==-1:!1}doesEventMatchRule(e,t){if(!t||!_(t.eventAttributeKey))return!1;const n=t.conditions;if(!Array.isArray(n))return!1;const r=this.getEventAttributeValue(e,t.eventAttributeKey);if(n.length===0)return r!==null;for(let o=0;o<n.length;o++)if(!this.doesEventAttributeConditionMatch(n[o],r))return!1;return!0}applyPlacementEventAttributeMapping(e){const t=Object.keys(this.placementEventAttributeMappingLookup);for(let n=0;n<t.length;n++){const r=t[n],o=this.placementEventAttributeMappingLookup[r];if(K(o))continue;let s=!0;for(let c=0;c<o.length;c++)if(!this.doesEventMatchRule(e,o[c])){s=!1;break}s&&a().Rokt.setLocalSessionAttribute?.(r,!0)}}capturePageView(e){let t;try{t=F(window.location.href);const n=Z(this.loggingService),r=et(e);n.push(r);const o=Math.min(n.length,B),s=Se(n);if(s===0){const c=D()?"quota":"ls_unavailable";this.loggingService?.log({message:`Rokt Kit: Failed to persist page view for ${t} [reason: ${c}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}else s<o&&this.loggingService?.log({message:`Rokt Kit: Page view storage reduced from ${o} to ${s} record(s) under quota pressure [reason: quota_eviction]`,code:"PAGE_VIEW_QUOTA_EVICTION"})}catch(n){const r=D()?"exception":"ls_unavailable",o=n instanceof Error?n.message:String(n);this.loggingService?.log({message:`Rokt Kit: Failed to capture page view for ${t}: ${o} [reason: ${r}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}}isLauncherReadyToAttach(){return!!window.Rokt&&w(window.Rokt.createLauncher)}returnUserIdentities(e){if(!e||!e.getUserIdentities)return{};const t=e.getUserIdentities().userIdentities;return this.replaceOtherIdentityWithEmailsha256(t)}returnLocalSessionAttributes(){return!a().Rokt||typeof a().Rokt.getLocalSessionAttributes!="function"?{}:a().Rokt.getLocalSessionAttributes()}replaceOtherIdentityWithEmailsha256(e){const t={...e||{}},n=this._mappedEmailSha256Key;return n&&e[n]&&(t[f.EMAIL_SHA256_KEY]=e[n]),n&&delete t[n],t}logSelectPlacementsEvent(e){if(!window.mParticle||typeof a().logEvent!="function"||!E(e))return;const t=a().EventType.Other;a().logEvent(Ne,t,e)}setRoktSessionId(e){if(!(!e||typeof e!="string"))try{const t=a().getInstance();t&&w(t.setIntegrationAttribute)&&t.setIntegrationAttribute(P,{roktSessionId:e})}catch{}}readMpSessionId(){const e=a()?.sessionManager,t=e?.getSessionId??e?.getSession;if(w(t))return t.call(e)||void 0}readMpDeviceId(){return a()?.getDeviceId?.()||void 0}attachLauncher(e,t,n=[]){we(this._launcherAttachState,{accountId:e,launcherOptions:t||{},legacyRoktExtensions:n});const r={accountId:e,...t||{}};let o;return this.isPartnerInLocalLauncherTestGroup()?o=Promise.resolve(window.Rokt.createLocalLauncher(r)):o=window.Rokt.createLauncher(r),o.then(async s=>{await Je([...n],s),this.initRoktLauncher(s)}).catch(s=>{Te(this._launcherAttachState),console.error("Error creating Rokt launcher:",s)})}recreateLauncherIfTerminated(){return Oe(this._launcherAttachState,this.isLauncherReadyToAttach(),e=>this.attachLauncher(e.accountId,e.launcherOptions,e.legacyRoktExtensions))}initRoktLauncher(e){window.Rokt&&(window.Rokt.currentLauncher=e),this.launcher=e,be(this._launcherAttachState);const t=a().Rokt?.filters;t?(this.filters=t,t.filteredUser?this._workspaceSearchInFlightPromise=this.search(t.filteredUser):console.warn("Rokt Kit: No filtered user has been set.")):console.warn("Rokt Kit: No filters have been set."),this.isInitialized=!0,he(this.domain,this.integrationName),a().Rokt.attachKit(this)}fetchOptimizely(){const e=a()._getActiveForwarders().filter(t=>t.name==="Optimizely");try{if(e.length>0&&window.optimizely){const t=window.optimizely.get("state");return!t||!t.getActiveExperimentIds?{}:t.getActiveExperimentIds().reduce((o,s)=>(o["rokt.custom.optimizely.experiment."+s+".variationId"]=t.getVariationMap()[s].id,o),{})}}catch(t){console.error("Error fetching Optimizely attributes:",t)}return{}}isKitReady(){return!!(this.isInitialized&&this.launcher)}isTargetingDisabled(){return a().Rokt?.launcherOptions?.noTargeting===!0}isPartnerInLocalLauncherTestGroup(){return!!(a().config&&a().config.isLocalLauncherEnabled&&this.isAssignedToSampleGroup())}isAssignedToSampleGroup(){return Math.random()>.5}captureTiming(e){window&&a()&&a().captureTiming&&e&&a().captureTiming(e)}init(e,t,n,r,o){const s=e,c=s.accountId;this.userAttributes=v(o),this._onboardingExpProvider=s.onboardingExpProvider;const u=N(s.placementEventMapping);this.placementEventMappingLookup=ce(u);const l=N(s.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=le(l),s.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=s.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=_(s.workspaceIdSyncApiKey)?s.workspaceIdSyncApiKey:void 0;const p=a().Rokt?.domain,{roktExtensionsQueryParams:j,legacyRoktExtensions:U,loadThankYouElement:C}=ae(s.roktExtensions),m={...a().Rokt?.launcherOptions||{}};this.integrationName=Be(m.integrationName),m.integrationName=this.integrationName,this.domain=p;const k={loggingUrl:s.loggingUrl,errorUrl:s.errorUrl,integrationDomain:p,isLoggingEnabled:a().config?.isLoggingEnabled===!0},y=new pe(k,this.integrationName,window.__rokt_li_guid__,s.accountId),R=new fe(k,y,this.integrationName,window.__rokt_li_guid__,s.accountId);if(this.errorReportingService=y,this.loggingService=R,this.isTargetingDisabled())try{ee(),te()}catch(h){this.errorReportingService?.report({message:"Rokt Kit: Failed to clear page views when targeting is disabled",code:"PAGE_VIEW_CAPTURE_FAILED",severity:I.INFO,stackTrace:h instanceof Error?h.stack:void 0})}return a()._registerErrorReportingService&&a()._registerErrorReportingService(y),a()._registerLoggingService&&a()._registerLoggingService(R),n?(this.testHelpers={generateLauncherScript:ne,generateThankYouElementScript:re,extractRoktExtensionConfig:ae,hashEventMessage:ue,parseSettingsString:N,generateMappedEventLookup:ce,generateMappedEventAttributeLookup:le,sendAdBlockMeasurementSignals:he,createAutoRemovedIframe:G,djb2:de,setAllowedOriginHashes:h=>{f._allowedOriginHashes=h},ReportingTransport:W,ErrorReportingService:pe,LoggingService:fe,RateLimiter:ge,ErrorCodes:x,WSDKErrorSeverity:I,resetLauncherAttachState:()=>Pe(this._launcherAttachState)},this.attachLauncher(c,m),"Successfully initialized: "+d):(C&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),se(Fe,re(p),{onLoad:()=>{this._isThankYouElementLoaded=!0,this._thankYouElementOnLoadCallback&&this._thankYouElementOnLoadCallback()},onError:h=>{console.error("Error loading Rokt Thank You Element script:",h)}})),this.isLauncherReadyToAttach()?this.attachLauncher(c,m,U):(se(Ke,ne(p,j),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,m,U):console.error("Rokt object is not available after script load.")},onError:h=>{console.error("Error loading Rokt launcher script:",h)}}),this.captureTiming(f.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+d)}process(e){if(this.isTargetingDisabled()||(e.EventDataType===Ye&&(Ae(this.loggingService),this.capturePageView(e)),e.EventDataType===xe&&(X(this.loggingService),ee(),te())),!this.isKitReady())return"Kit not ready for forwarder: "+d;if(w(a().Rokt?.setLocalSessionAttribute)&&(K(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!K(this.placementEventMappingLookup))){const t=ue(e.EventDataType,e.EventCategory,e.EventName??"");this.placementEventMappingLookup[String(t)]&&a().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(t)],!0)}return"Successfully sent to forwarder: "+d}setExtensionData(e){if(!this.isKitReady()){console.error("Rokt Kit: Not initialized");return}window.Rokt.setExtensionData(e)}setUserAttribute(e,t){return V(e)||(this.userAttributes[e]=t),"Successfully set user attribute for forwarder: "+d}removeUserAttribute(e){return delete this.userAttributes[e],"Successfully removed user attribute for forwarder: "+d}handleIdentityComplete(e,t){return this.userAttributes=v(e.getAllUserAttributes()),"Successfully called "+t+" for forwarder: "+d}onUserIdentified(e){const t=e;return this.filters.filteredUser=t,this._workspaceSearchInFlightPromise=this.search(t),this.handleIdentityComplete(e,"onUserIdentified")}search(e){const t=this._workspaceIdSyncApiKey;if(!t)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const n=a().Identity?.search;if(typeof n!="function")return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const r=e.getUserIdentities?e.getUserIdentities().userIdentities:null,o={};if(r)for(const u of Object.keys(r)){const l=r[u];_(l)&&l.length>0&&(o[u]=l)}const s=Object.keys(o);if(s.length===0)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const c=s.sort().map(u=>`${u}=${o[u]}`).join("&");return c===this._workspaceLastSearchedIdentitiesKey?this._workspaceSearchInFlightPromise||Promise.resolve():(this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=c,new Promise(u=>{try{n(t,o,l=>{l?.httpCode===200&&(this.userIdentifiedInWorkspace=!0),u()})}catch(l){console.error("Rokt Kit: Workspace IDSync search failed",l),this._workspaceLastSearchedIdentitiesKey=void 0,u()}}))}onLoginComplete(e,t){return this.handleIdentityComplete(e,"onLoginComplete")}onLogoutComplete(e,t){return this.userIdentifiedInWorkspace=!1,this._workspaceSearchInFlightPromise=null,this._workspaceLastSearchedIdentitiesKey=void 0,this.handleIdentityComplete(e,"onLogoutComplete")}onModifyComplete(e,t){return this.handleIdentityComplete(e,"onModifyComplete")}selectPlacements(e){const t=this.recreateLauncherIfTerminated();if(t){const n=this._workspaceSearchInFlightPromise,r=n?Promise.race([n,new Promise(o=>setTimeout(o,ie))]):Promise.resolve();return Promise.all([t,r]).then(()=>this._dispatchPlacements(e))}if(this._workspaceSearchInFlightPromise){const n=this._workspaceSearchInFlightPromise;return Promise.race([n,new Promise(r=>setTimeout(r,ie))]).then(()=>this._dispatchPlacements(e))}return this._dispatchPlacements(e)}_dispatchPlacements(e){const t=e&&e.attributes||{},r={...v(this.userAttributes),...t},o=this.filters||{},s=o.userAttributeFilters||[],c=o.filteredUser||null,u=c?c.getMPID():null;let l;o?o.filterUserAttributes?l=o.filterUserAttributes(r,s):l=r:(console.warn("Rokt Kit: No filters available, using user attributes"),l=r),this.userAttributes=v(l);const p=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},j=this.returnUserIdentities(c),U=this.returnLocalSessionAttributes(),C=ye(Z(this.loggingService)),m=ke(),k=this.readMpSessionId(),y=this.readMpDeviceId(),R={...j,...l,...p,...U,...C.length?{[Ge]:JSON.stringify(C)}:{},...m?{[We]:m}:{},...this.userIdentifiedInWorkspace?{[De]:!0}:{},...k?{[je]:k}:{},...y?{[Ve]:y}:{},mpid:u},h={...e,attributes:R},me=this.launcher.selectPlacements(h),nt=()=>this.logSelectPlacementsEvent(R);return Promise.resolve(me).then(rt=>rt?.context?.sessionId?.then(ot=>this.setRoktSessionId(ot))).catch(()=>{}).finally(nt),me}hashAttributes(e){return this.isKitReady()?this.launcher.hashAttributes(e):(console.error("Rokt Kit: Not initialized"),null)}use(e){return this.isKitReady()?!e||!_(e)?Promise.reject(new Error("Rokt Kit: Invalid extension name")):this.launcher.use(e):(console.error("Rokt Kit: Not initialized"),Promise.reject(new Error("Rokt Kit: Not initialized")))}terminate(){return this.isKitReady()?(Le(this._launcherAttachState),this.launcher.terminate()):(console.error("Rokt Kit: Not initialized"),Promise.resolve())}onShoppableAdsReady(e){this._isThankYouElementLoaded?e():this._thankYouElementOnLoadCallback=e}};f._allowedOriginHashes=[-553112570,549508659],f.PERFORMANCE_MARKS={RoktScriptAppended:"mp:RoktScriptAppended"},f.EMAIL_SHA256_KEY="emailsha256";let S=f;function tt(){return P}function it(i){if(!i){window.console.log("You must pass a config object to register the kit "+d);return}if(!E(i)){window.console.log("'config' must be an object. You passed in a "+typeof i);return}E(i.kits)?i.kits[d]={constructor:S}:(i.kits={},i.kits[d]={constructor:S}),window.console.log("Successfully registered "+d+" to your mParticle configuration")}return typeof window<"u"&&window.mParticle&&a().addForwarder&&a().addForwarder({name:d,constructor:S,getId:tt}),M.register=it,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"}),M})({});
1
+ var RoktKit=(function(N){"use strict";const ge=["active_time_on_site_ms","billingaddress1","billingaddress2","billingcity","billingstate","billingzipcode","cartitems","ccbin","confirmationref","conversiontype","country","couponcode","currency","language","paymentserviceprovider","paymentserviceproviderattribute","paymenttype","shippingaddress1","shippingcity","shippingcountry","shippingmethod","shippingstate","shippingzipcode","totalprice"],fe=new Set(ge);function W(i){return fe.has(i.toLowerCase())}function R(i){const e={},t=i||{},n=Object.keys(t);for(let r=0;r<n.length;r++){const o=n[r];W(o)||(e[o]=t[o])}return e}function m(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function E(i){return typeof i=="string"}function v(i){return typeof i=="function"}function U(i){return i==null?!0:typeof i=="object"?Object.keys(i).length===0:!1}function C(i){try{const e=new URL(i);return e.search="",e.toString()}catch{return i}}const H="__rokt_ls_probe__";function M(){try{return window.localStorage.setItem(H,"1"),window.localStorage.removeItem(H),!0}catch{return!1}}function K(i){try{const e=window.localStorage.getItem(i);return e===null?null:JSON.parse(e)}catch{return null}}function V(i,e){try{return window.localStorage.setItem(i,JSON.stringify(e)),!0}catch{return!1}}function me(i){try{window.localStorage.removeItem(i)}catch{}}function F(i,e){const t=K(i);return m(t)?t[e]:void 0}function z(i,e,t){const n=K(i),r=m(n)?{...n}:{};return r[e]=t,V(i,r)}function q(i,e){const t=K(i);if(!m(t)||!(e in t))return;const n={...t};delete n[e],Object.keys(n).length===0?me(i):V(i,n)}const _="mp-rokt-kit",D="pageViews",w="utmParams",$=25,Ee=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];function J(i){return i.slice(-$)}function B(){const i=F(_,D);return Array.isArray(i)?i:[]}function _e(i){const e=J(i);for(let t=0;t<e.length;t++){const n=e.slice(t);if(z(_,D,n))return n.length}return 0}function Q(){q(_,D)}function Ie(i){const e=J(i);return e.map((t,n)=>{const r=t.activeTimeOnSite,o=r!==void 0&&Number.isFinite(r),c=e[n+1]?.activeTimeOnSite,u=c!==void 0&&Number.isFinite(c),l=o&&u?c-r:void 0;return{pageUrl:t.pageUrl,sourceMessageId:t.sourceMessageId,timestamp:t.timestamp,...t.pageTitle!==void 0?{pageTitle:t.pageTitle}:{},...t.canonicalUrl!==void 0?{canonicalUrl:t.canonicalUrl}:{},...o?{activeTimeOnSite:r}:{},...l!==void 0&&l>=0?{activeTimeOnPage:l}:{}}})}function Se(i){if(F(_,w)!==void 0)return;const e=new URLSearchParams(window.location.search),t={};for(const r of Ee){const o=e.get(r);o&&(t[r]=o)}if(Object.keys(t).length===0)return;const n=Object.keys(t).join(", ");if(!z(_,w,t)){const r=M()?"quota":"ls_unavailable";i?.log({message:`Rokt Kit: Failed to persist UTM params [reason: ${r}]`,code:"UTM_CAPTURE_FAILED"});return}i?.log({message:`Rokt Kit: Captured UTM params [${n}]`,code:"UTM_CAPTURE_SUCCESS"})}function ye(){const i=F(_,w);return m(i)?i:null}function X(){q(_,w)}function Ae(){const e=document.querySelector('link[rel="canonical"]')?.href;if(e)return C(e)}function ke(){return{context:null,lifecycle:"idle",recreateInFlight:null}}function Re(i,e){i.context={accountId:e.accountId,launcherOptions:{...e.launcherOptions},legacyRoktExtensions:[...e.legacyRoktExtensions]}}function ve(i){i.lifecycle="attached"}function we(i){i.lifecycle!=="idle"&&(i.lifecycle="terminated")}function be(i){i.lifecycle="terminated"}function Te(i){i.context=null,i.lifecycle="idle",i.recreateInFlight=null}function Le(i,e,t){if(i.recreateInFlight)return i.recreateInFlight;if(i.lifecycle!=="terminated"||!i.context||!e)return;i.lifecycle="recreating";const n=i.context;return i.recreateInFlight=t(n).finally(()=>{i.recreateInFlight=null}),i.recreateInFlight}const d="Rokt",b=181,Pe="selectPlacements",Oe="apps.roktecommerce.com",Ne=.1,Ue="ThankYouPageJourney",Ce="rokt-launcher",Me="rokt-thank-you-element",Ke="userIdentifiedInWorkspace",Fe=3,De=2,xe="page_events",Ye="page_view_attributes",je="mparticle_session_id",Ge="mparticle_device_id",Z=500,x={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST",LOG_DELIVERY_FAILURE:"LOG_DELIVERY_FAILURE"},I={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},We="apps.rokt-api.com",He="/v1/log",Ve="/v1/errors",ze=10;function a(){return window.mParticle}function ee(i,e){const n=[T(i),"/wsdk/integrations/launcher.js"].join("");return!e||e.length===0?n:n+"?extensions="+e.join(",")}function te(i){return[T(i),"/rokt-elements/rokt-element-thank-you.js"].join("")}function T(i){const e=typeof i<"u"?i:We;return e.includes("://")?e.replace(/\/+$/,""):["https://",e].join("")}function ie(i,e,t){if(i)return i.startsWith("http://")||i.startsWith("https://")?i:"https://"+i;const r=e?.includes("://")&&!/^https?:\/\//i.test(e)?void 0:e;return T(r)+t}function ne(i,e,t){if(document.getElementById(i))return;const n=document.head||document.body,r=document.createElement("script");r.id=i,r.type="text/javascript",r.src=e,r.async=!0,r.crossOrigin="anonymous",r.fetchPriority="high",t?.onLoad&&(r.onload=t.onLoad),t?.onError&&(r.onerror=t.onError),n.appendChild(r)}function L(i){if(!i)return[];try{return JSON.parse(i.replace(/&quot;/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function re(i){const e=i?L(i):[],t=[],n=[];let r=!1;for(let o=0;o<e.length;o++){const s=e[o].value;s==="thank-you-journey"?(r=!0,n.push(Ue)):t.push(s)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:n,loadThankYouElement:r}}async function qe(i,e){const t=[];if(e)for(const n of i)t.push(e.use(n));return Promise.all(t)}function oe(i){if(!i)return{};const e={};for(let t=0;t<i.length;t++){const n=i[t];e[n.jsmap]=n.value}return e}function se(i){const e={};if(!Array.isArray(i))return e;for(let t=0;t<i.length;t++){const n=i[t];if(!n||!E(n.value)||!E(n.map))continue;const r=n.value,o=n.map;e[r]||(e[r]=[]),e[r].push({eventAttributeKey:o,conditions:Array.isArray(n.conditions)?n.conditions:[]})}return e}function ae(i,e,t){return a().generateHash([i,e,t].join(""))}function $e(i){let n="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"1.36.1";return i&&(n+="_"+i),n}function ce(i){let e=5381;for(let t=0;t<i.length;t++)e=(e<<5)+e+i.charCodeAt(t),e=e&e;return e}function Y(i){const e=document.createElement("iframe");e.style.display="none",e.setAttribute("sandbox","allow-scripts allow-same-origin"),e.src=i,e.onload=function(){e.onload=null,e.parentNode&&e.parentNode.removeChild(e)};const t=document.body||document.head;t&&t.appendChild(e)}function le(i,e){const t=ce(window.location.origin);if(S._allowedOriginHashes.indexOf(t)===-1||Math.random()>=Ne)return;const r=window.__rokt_li_guid__;if(!r||i&&i.includes("://")&&!/^https:\/\//i.test(i))return;const o=window.location.href.split("?")[0].split("#")[0],s="version="+encodeURIComponent(e??"")+"&launcherInstanceGuid="+encodeURIComponent(r)+"&pageUrl="+encodeURIComponent(o),c=i?T(i):"https://apps.rokt.com";Y(c+"/v1/wsdk-init/index.html?"+s),Y("https://"+Oe+"/v1/wsdk-init/index.html?"+s+"&isControl=true")}function Je(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function Be(){return typeof window<"u"?window.location?.href:void 0}function Qe(){return typeof window<"u"?window.navigator?.userAgent:void 0}class ue{constructor(){this._logCount={}}incrementAndCheck(e){const n=(this._logCount[e]||0)+1;return this._logCount[e]=n,n>ze}}class j{constructor(e,t,n,r,o){this._reporter="mp-wsdk";const s=e.isLoggingEnabled;this._integrationName=t||"",this._launcherInstanceGuid=n,this._accountId=r||null,this._rateLimiter=o||new ue,this._isEnabled=Je()||s}send(e,t,n,r,o,s){if(!(!this._isEnabled||this._rateLimiter.incrementAndCheck(t)))try{const c={additionalInformation:{message:n,version:this._integrationName},severity:t,code:r||x.UNKNOWN_ERROR,url:Be(),deviceInfo:Qe(),stackTrace:o,reporter:this._reporter,integration:this._integrationName},u={Accept:"text/plain;charset=UTF-8","Content-Type":"application/json","rokt-launcher-version":this._integrationName,"rokt-wsdk-version":"joint"};this._launcherInstanceGuid&&(u["rokt-launcher-instance-guid"]=this._launcherInstanceGuid),this._accountId&&(u["rokt-account-id"]=this._accountId),fetch(e,{method:"POST",headers:u,body:JSON.stringify(c)}).then(l=>{if(!l.ok){const p=new Error("HTTP "+l.status+" from log endpoint");throw p.statusCode=l.status,p}}).catch(l=>{console.error("ReportingTransport: Failed to send log",l),s&&s(l)})}catch(c){console.error("ReportingTransport: Failed to send log",c),s&&s(c)}}}class de{constructor(e,t,n,r,o){this._transport=new j(e,t,n,r,o),this._errorUrl=ie(e?.errorUrl,e?.integrationDomain,Ve)}report(e){if(!e)return;const t=e.severity||I.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class he{constructor(e,t,n,r,o,s){this._transport=new j(e,n,r,o,s),this._loggingUrl=ie(e?.loggingUrl,e?.integrationDomain,He),this._errorReportingService=t}log(e){e&&this._transport.send(this._loggingUrl,I.INFO,e.message,e.code,void 0,t=>{if(this._errorReportingService){const n=typeof t.statusCode=="number";this._errorReportingService.report({message:"LoggingService: Failed to send log: "+t.message,code:x.LOG_DELIVERY_FAILURE,severity:n?I.ERROR:I.WARNING})}})}}function Xe(i){const e=C(window.location.href),t=i.EventAttributes?.title||document.title,n=Ae(),r=i.ActiveTimeOnSite;return{pageUrl:e,sourceMessageId:i.SourceMessageId,timestamp:i.Timestamp,...t?{pageTitle:t}:{},...n!==void 0?{canonicalUrl:n}:{},...Number.isFinite(r)?{activeTimeOnSite:r}:{}}}const g=class g{constructor(){this.name=d,this.id=b,this.moduleId=b,this.isInitialized=!1,this.launcher=null,this.filters={},this.userAttributes={},this.userIdentifiedInWorkspace=!1,this.testHelpers=null,this.placementEventMappingLookup={},this.placementEventAttributeMappingLookup={},this.integrationName=null,this.errorReportingService=null,this.loggingService=null,this._thankYouElementOnLoadCallback=null,this._isThankYouElementLoaded=!1,this._workspaceSearchInFlightPromise=null,this._launcherAttachState=ke()}getEventAttributeValue(e,t){const n=e&&e.EventAttributes;return!n||typeof n[t]>"u"?null:n[t]}doesEventAttributeConditionMatch(e,t){if(!e||!E(e.operator))return!1;const n=e.operator.toLowerCase(),r=e.attributeValue;return n==="exists"?t!==null:t==null?!1:n==="equals"?String(t)===String(r):n==="contains"?String(t).indexOf(String(r))!==-1:!1}doesEventMatchRule(e,t){if(!t||!E(t.eventAttributeKey))return!1;const n=t.conditions;if(!Array.isArray(n))return!1;const r=this.getEventAttributeValue(e,t.eventAttributeKey);if(n.length===0)return r!==null;for(let o=0;o<n.length;o++)if(!this.doesEventAttributeConditionMatch(n[o],r))return!1;return!0}applyPlacementEventAttributeMapping(e){const t=Object.keys(this.placementEventAttributeMappingLookup);for(let n=0;n<t.length;n++){const r=t[n],o=this.placementEventAttributeMappingLookup[r];if(U(o))continue;let s=!0;for(let c=0;c<o.length;c++)if(!this.doesEventMatchRule(e,o[c])){s=!1;break}s&&a().Rokt.setLocalSessionAttribute?.(r,!0)}}capturePageView(e){let t;try{t=C(window.location.href);const n=B(),r=Xe(e);n.push(r);const o=Math.min(n.length,$),s=_e(n);if(s===0){const c=M()?"quota":"ls_unavailable";this.loggingService?.log({message:`Rokt Kit: Failed to persist page view for ${t} [reason: ${c}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}else s<o&&this.loggingService?.log({message:`Rokt Kit: Page view storage reduced from ${o} to ${s} record(s) under quota pressure [reason: quota_eviction]`,code:"PAGE_VIEW_QUOTA_EVICTION"})}catch(n){const r=M()?"exception":"ls_unavailable",o=n instanceof Error?n.message:String(n);this.loggingService?.log({message:`Rokt Kit: Failed to capture page view for ${t}: ${o} [reason: ${r}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}}isLauncherReadyToAttach(){return!!window.Rokt&&v(window.Rokt.createLauncher)}returnUserIdentities(e){if(!e||!e.getUserIdentities)return{};const t=e.getUserIdentities().userIdentities;return this.replaceOtherIdentityWithEmailsha256(t)}returnLocalSessionAttributes(){return!a().Rokt||typeof a().Rokt.getLocalSessionAttributes!="function"?{}:a().Rokt.getLocalSessionAttributes()}replaceOtherIdentityWithEmailsha256(e){const t={...e||{}},n=this._mappedEmailSha256Key;return n&&e[n]&&(t[g.EMAIL_SHA256_KEY]=e[n]),n&&delete t[n],t}logSelectPlacementsEvent(e){if(!window.mParticle||typeof a().logEvent!="function"||!m(e))return;const t=a().EventType.Other;a().logEvent(Pe,t,e)}setRoktSessionId(e){if(!(!e||typeof e!="string"))try{const t=a().getInstance();t&&v(t.setIntegrationAttribute)&&t.setIntegrationAttribute(b,{roktSessionId:e})}catch{}}readMpSessionId(){const e=a()?.sessionManager,t=e?.getSessionId??e?.getSession;if(v(t))return t.call(e)||void 0}readMpDeviceId(){return a()?.getDeviceId?.()||void 0}attachLauncher(e,t,n=[]){Re(this._launcherAttachState,{accountId:e,launcherOptions:t||{},legacyRoktExtensions:n});const r={accountId:e,...t||{}};let o;return this.isPartnerInLocalLauncherTestGroup()?o=Promise.resolve(window.Rokt.createLocalLauncher(r)):o=window.Rokt.createLauncher(r),o.then(async s=>{await qe([...n],s),this.initRoktLauncher(s)}).catch(s=>{be(this._launcherAttachState),console.error("Error creating Rokt launcher:",s)})}recreateLauncherIfTerminated(){return Le(this._launcherAttachState,this.isLauncherReadyToAttach(),e=>this.attachLauncher(e.accountId,e.launcherOptions,e.legacyRoktExtensions))}initRoktLauncher(e){window.Rokt&&(window.Rokt.currentLauncher=e),this.launcher=e,ve(this._launcherAttachState);const t=a().Rokt?.filters;t?(this.filters=t,t.filteredUser?this._workspaceSearchInFlightPromise=this.search(t.filteredUser):console.warn("Rokt Kit: No filtered user has been set.")):console.warn("Rokt Kit: No filters have been set."),this.isInitialized=!0,le(this.domain,this.integrationName),a().Rokt.attachKit(this)}fetchOptimizely(){const e=a()._getActiveForwarders().filter(t=>t.name==="Optimizely");try{if(e.length>0&&window.optimizely){const t=window.optimizely.get("state");return!t||!t.getActiveExperimentIds?{}:t.getActiveExperimentIds().reduce((o,s)=>(o["rokt.custom.optimizely.experiment."+s+".variationId"]=t.getVariationMap()[s].id,o),{})}}catch(t){console.error("Error fetching Optimizely attributes:",t)}return{}}isKitReady(){return!!(this.isInitialized&&this.launcher)}isTargetingDisabled(){return a().Rokt?.launcherOptions?.noTargeting===!0}isPartnerInLocalLauncherTestGroup(){return!!(a().config&&a().config.isLocalLauncherEnabled&&this.isAssignedToSampleGroup())}isAssignedToSampleGroup(){return Math.random()>.5}captureTiming(e){window&&a()&&a().captureTiming&&e&&a().captureTiming(e)}init(e,t,n,r,o){const s=e,c=s.accountId;this.userAttributes=R(o),this._onboardingExpProvider=s.onboardingExpProvider;const u=L(s.placementEventMapping);this.placementEventMappingLookup=oe(u);const l=L(s.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=se(l),s.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=s.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=E(s.workspaceIdSyncApiKey)?s.workspaceIdSyncApiKey:void 0;const p=a().Rokt?.domain,{roktExtensionsQueryParams:G,legacyRoktExtensions:P,loadThankYouElement:O}=re(s.roktExtensions),f={...a().Rokt?.launcherOptions||{}};this.integrationName=$e(f.integrationName),f.integrationName=this.integrationName,this.domain=p;const A={loggingUrl:s.loggingUrl,errorUrl:s.errorUrl,integrationDomain:p,isLoggingEnabled:a().config?.isLoggingEnabled===!0},y=new de(A,this.integrationName,window.__rokt_li_guid__,s.accountId),k=new he(A,y,this.integrationName,window.__rokt_li_guid__,s.accountId);if(this.errorReportingService=y,this.loggingService=k,this.isTargetingDisabled())try{Q(),X()}catch(h){this.errorReportingService?.report({message:"Rokt Kit: Failed to clear page views when targeting is disabled",code:"PAGE_VIEW_CAPTURE_FAILED",severity:I.INFO,stackTrace:h instanceof Error?h.stack:void 0})}return a()._registerErrorReportingService&&a()._registerErrorReportingService(y),a()._registerLoggingService&&a()._registerLoggingService(k),n?(this.testHelpers={generateLauncherScript:ee,generateThankYouElementScript:te,extractRoktExtensionConfig:re,hashEventMessage:ae,parseSettingsString:L,generateMappedEventLookup:oe,generateMappedEventAttributeLookup:se,sendAdBlockMeasurementSignals:le,createAutoRemovedIframe:Y,djb2:ce,setAllowedOriginHashes:h=>{g._allowedOriginHashes=h},ReportingTransport:j,ErrorReportingService:de,LoggingService:he,RateLimiter:ue,ErrorCodes:x,WSDKErrorSeverity:I,resetLauncherAttachState:()=>Te(this._launcherAttachState)},this.attachLauncher(c,f),"Successfully initialized: "+d):(O&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),ne(Me,te(p),{onLoad:()=>{this._isThankYouElementLoaded=!0,this._thankYouElementOnLoadCallback&&this._thankYouElementOnLoadCallback()},onError:h=>{console.error("Error loading Rokt Thank You Element script:",h)}})),this.isLauncherReadyToAttach()?this.attachLauncher(c,f,P):(ne(Ce,ee(p,G),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,f,P):console.error("Rokt object is not available after script load.")},onError:h=>{console.error("Error loading Rokt launcher script:",h)}}),this.captureTiming(g.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+d)}process(e){if(this.isTargetingDisabled()||(e.EventDataType===Fe&&(Se(this.loggingService),this.capturePageView(e)),e.EventDataType===De&&(Q(),X())),!this.isKitReady())return"Kit not ready for forwarder: "+d;if(v(a().Rokt?.setLocalSessionAttribute)&&(U(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!U(this.placementEventMappingLookup))){const t=ae(e.EventDataType,e.EventCategory,e.EventName??"");this.placementEventMappingLookup[String(t)]&&a().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(t)],!0)}return"Successfully sent to forwarder: "+d}setExtensionData(e){if(!this.isKitReady()){console.error("Rokt Kit: Not initialized");return}window.Rokt.setExtensionData(e)}setUserAttribute(e,t){return W(e)||(this.userAttributes[e]=t),"Successfully set user attribute for forwarder: "+d}removeUserAttribute(e){return delete this.userAttributes[e],"Successfully removed user attribute for forwarder: "+d}handleIdentityComplete(e,t){return this.userAttributes=R(e.getAllUserAttributes()),"Successfully called "+t+" for forwarder: "+d}onUserIdentified(e){const t=e;return this.filters.filteredUser=t,this._workspaceSearchInFlightPromise=this.search(t),this.handleIdentityComplete(e,"onUserIdentified")}search(e){const t=this._workspaceIdSyncApiKey;if(!t)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const n=a().Identity?.search;if(typeof n!="function")return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const r=e.getUserIdentities?e.getUserIdentities().userIdentities:null,o={};if(r)for(const u of Object.keys(r)){const l=r[u];E(l)&&l.length>0&&(o[u]=l)}const s=Object.keys(o);if(s.length===0)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const c=s.sort().map(u=>`${u}=${o[u]}`).join("&");return c===this._workspaceLastSearchedIdentitiesKey?this._workspaceSearchInFlightPromise||Promise.resolve():(this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=c,new Promise(u=>{try{n(t,o,l=>{l?.httpCode===200&&(this.userIdentifiedInWorkspace=!0),u()})}catch(l){console.error("Rokt Kit: Workspace IDSync search failed",l),this._workspaceLastSearchedIdentitiesKey=void 0,u()}}))}onLoginComplete(e,t){return this.handleIdentityComplete(e,"onLoginComplete")}onLogoutComplete(e,t){return this.userIdentifiedInWorkspace=!1,this._workspaceSearchInFlightPromise=null,this._workspaceLastSearchedIdentitiesKey=void 0,this.handleIdentityComplete(e,"onLogoutComplete")}onModifyComplete(e,t){return this.handleIdentityComplete(e,"onModifyComplete")}selectPlacements(e){const t=this.recreateLauncherIfTerminated();if(t){const n=this._workspaceSearchInFlightPromise,r=n?Promise.race([n,new Promise(o=>setTimeout(o,Z))]):Promise.resolve();return Promise.all([t,r]).then(()=>this._dispatchPlacements(e))}if(this._workspaceSearchInFlightPromise){const n=this._workspaceSearchInFlightPromise;return Promise.race([n,new Promise(r=>setTimeout(r,Z))]).then(()=>this._dispatchPlacements(e))}return this._dispatchPlacements(e)}_dispatchPlacements(e){const t=e&&e.attributes||{},r={...R(this.userAttributes),...t},o=this.filters||{},s=o.userAttributeFilters||[],c=o.filteredUser||null,u=c?c.getMPID():null;let l;o?o.filterUserAttributes?l=o.filterUserAttributes(r,s):l=r:(console.warn("Rokt Kit: No filters available, using user attributes"),l=r),this.userAttributes=R(l);const p=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},G=this.returnUserIdentities(c),P=this.returnLocalSessionAttributes(),O=Ie(B()),f=ye(),A=this.readMpSessionId(),y=this.readMpDeviceId(),k={...G,...l,...p,...P,...O.length?{[xe]:JSON.stringify(O)}:{},...f?{[Ye]:f}:{},...this.userIdentifiedInWorkspace?{[Ke]:!0}:{},...A?{[je]:A}:{},...y?{[Ge]:y}:{},mpid:u},h={...e,attributes:k},pe=this.launcher.selectPlacements(h),tt=()=>this.logSelectPlacementsEvent(k);return Promise.resolve(pe).then(it=>it?.context?.sessionId?.then(nt=>this.setRoktSessionId(nt))).catch(()=>{}).finally(tt),pe}hashAttributes(e){return this.isKitReady()?this.launcher.hashAttributes(e):(console.error("Rokt Kit: Not initialized"),null)}use(e){return this.isKitReady()?!e||!E(e)?Promise.reject(new Error("Rokt Kit: Invalid extension name")):this.launcher.use(e):(console.error("Rokt Kit: Not initialized"),Promise.reject(new Error("Rokt Kit: Not initialized")))}terminate(){return this.isKitReady()?(we(this._launcherAttachState),this.launcher.terminate()):(console.error("Rokt Kit: Not initialized"),Promise.resolve())}onShoppableAdsReady(e){this._isThankYouElementLoaded?e():this._thankYouElementOnLoadCallback=e}};g._allowedOriginHashes=[-553112570,549508659],g.PERFORMANCE_MARKS={RoktScriptAppended:"mp:RoktScriptAppended"},g.EMAIL_SHA256_KEY="emailsha256";let S=g;function Ze(){return b}function et(i){if(!i){window.console.log("You must pass a config object to register the kit "+d);return}if(!m(i)){window.console.log("'config' must be an object. You passed in a "+typeof i);return}m(i.kits)?i.kits[d]={constructor:S}:(i.kits={},i.kits[d]={constructor:S}),window.console.log("Successfully registered "+d+" to your mParticle configuration")}return typeof window<"u"&&window.mParticle&&a().addForwarder&&a().addForwarder({name:d,constructor:S,getId:Ze}),N.register=et,Object.defineProperty(N,Symbol.toStringTag,{value:"Module"}),N})({});
2
2
  //# sourceMappingURL=Rokt-Kit.iife.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mparticle/web-rokt-kit",
3
- "version": "1.36.0",
3
+ "version": "1.36.1",
4
4
  "description": "mParticle integration kit for Rokt",
5
5
  "main": "dist/Rokt-Kit.common.js",
6
6
  "module": "dist/Rokt-Kit.esm.js",