@mparticle/web-rokt-kit 1.31.0 → 1.32.0

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 ae=["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"],ce=new Set(ae);function X(i){return ce.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];X(o)||(e[o]=t[o])}return e}function y(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function m(i){return typeof i=="string"}function P(i){return i==null?!0:typeof i=="object"?Object.keys(i).length===0:!1}function M(i){try{const e=new URL(i);return e.search="",e.toString()}catch{return i}}function N(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 ee(i){try{window.localStorage.removeItem(i)}catch{}}function te(i,e){const t=N(i);return y(t)?t[e]:void 0}function U(i,e,t){const n=N(i),r=y(n)?{...n}:{};return r[e]=t,Z(i,r)}function le(i,e){const t=N(i);if(!y(t)||!(e in t))return;const n={...t};delete n[e],Object.keys(n).length===0?ee(i):Z(i,n)}function ue(i,e,t,n){const r=t.slice(),o=()=>r.length<=1?!1:(r.shift(),!0);let s=JSON.stringify(r).length>n;for(;s&&o();)s=JSON.stringify(r).length>n;let c=U(i,e,r);for(;!c&&o();)c=U(i,e,r);return c}const S="mp-rokt-kit",k="pageViews",x="mpPageViews",de=100*1024;function ie(i){const e=N(x);if(e===null)return;if(!(te(S,k)!==void 0)&&Array.isArray(e)&&!U(S,k,e)){i?.log({message:"Rokt Kit: Failed to migrate legacy page-view storage; retaining legacy key for retry",code:"PAGE_VIEW_CAPTURE_FAILED"});return}ee(x)}function Y(i){ie(i);const e=te(S,k);return Array.isArray(e)?e:[]}function he(i){return ue(S,k,i,de)}function G(){le(S,k)}function ge(i){return i.map((e,t)=>{const n=e.activeTimeOnSite,r=n!==void 0&&Number.isFinite(n),s=i[t+1]?.activeTimeOnSite,c=s!==void 0&&Number.isFinite(s),u=r&&c?s-n:void 0;return{pageUrl:e.pageUrl,sourceMessageId:e.sourceMessageId,timestamp:e.timestamp,...e.pageTitle!==void 0?{pageTitle:e.pageTitle}:{},...e.canonicalUrl!==void 0?{canonicalUrl:e.canonicalUrl}:{},...r?{activeTimeOnSite:n}:{},...u!==void 0&&u>=0?{activeTimeOnPage:u}:{}}})}function pe(){const e=document.querySelector('link[rel="canonical"]')?.href;if(e)return M(e)}const d="Rokt",L=181,fe="selectPlacements",me="apps.roktecommerce.com",Ee=.1,_e="ThankYouPageJourney",ye="rokt-launcher",Ie="rokt-thank-you-element",Se="userIdentifiedInWorkspace",ke=3,Ae=2,Re="page_events",ve=500,K={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST",LOG_DELIVERY_FAILURE:"LOG_DELIVERY_FAILURE"},_={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},we="apps.rokt-api.com",be="/v1/log",Le="/v1/errors",Te=10;function a(){return window.mParticle}function W(i,e){const n=[D(i),"/wsdk/integrations/launcher.js"].join("");return!e||e.length===0?n:n+"?extensions="+e.join(",")}function j(i){return[D(i),"/rokt-elements/rokt-element-thank-you.js"].join("")}function D(i){return["https://",typeof i<"u"?i:we].join("")}function ne(i,e,t){return i?i.startsWith("http://")||i.startsWith("https://")?i:"https://"+i:D(e)+t}function H(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 T(i){if(!i)return[];try{return JSON.parse(i.replace(/&quot;/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function V(i){const e=i?T(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(_e)):t.push(s)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:n,loadThankYouElement:r}}async function Ne(i,e){const t=[];if(e)for(const n of i)t.push(e.use(n));return Promise.all(t)}function z(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 J(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,o=n.map;e[r]||(e[r]=[]),e[r].push({eventAttributeKey:o,conditions:Array.isArray(n.conditions)?n.conditions:[]})}return e}function B(i,e,t){return a().generateHash([i,e,t].join(""))}function Oe(i){let n="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"1.31.0";return i&&(n+="_"+i),n}function re(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 C(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 q(i,e){const t=re(window.location.origin);if(I._allowedOriginHashes.indexOf(t)===-1||Math.random()>=Ee)return;const r=window.__rokt_li_guid__;if(!r)return;const o=window.location.href.split("?")[0].split("#")[0],s="version="+encodeURIComponent(e??"")+"&launcherInstanceGuid="+encodeURIComponent(r)+"&pageUrl="+encodeURIComponent(o);C("https://"+(i||"apps.rokt.com")+"/v1/wsdk-init/index.html?"+s),C("https://"+me+"/v1/wsdk-init/index.html?"+s+"&isControl=true")}function Pe(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function Ue(){return typeof window<"u"?window.location?.href:void 0}function Ce(){return typeof window<"u"?window.navigator?.userAgent:void 0}class oe{constructor(){this._logCount={}}incrementAndCheck(e){const n=(this._logCount[e]||0)+1;return this._logCount[e]=n,n>Te}}class F{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 oe,this._isEnabled=Pe()||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||K.UNKNOWN_ERROR,url:Ue(),deviceInfo:Ce(),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 Q{constructor(e,t,n,r,o){this._transport=new F(e,t,n,r,o),this._errorUrl=ne(e?.errorUrl,e?.integrationDomain,Le)}report(e){if(!e)return;const t=e.severity||_.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class ${constructor(e,t,n,r,o,s){this._transport=new F(e,n,r,o,s),this._loggingUrl=ne(e?.loggingUrl,e?.integrationDomain,be),this._errorReportingService=t}log(e){e&&this._transport.send(this._loggingUrl,_.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:K.LOG_DELIVERY_FAILURE,severity:n?_.ERROR:_.WARNING})}})}}function Me(i){const e=M(window.location.href),t=i.EventAttributes?.title||document.title,n=pe(),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=L,this.moduleId=L,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}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 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(P(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=M(window.location.href);const n=Y(this.loggingService),r=Me(e);n.push(r),he(n)||this.loggingService?.log({message:`Rokt Kit: Failed to persist page view for ${t}`,code:"PAGE_VIEW_CAPTURE_FAILED"})}catch(n){this.loggingService?.log({message:`Rokt Kit: Failed to capture page view for ${t}: ${n instanceof Error?n.message:String(n)}`,code:"PAGE_VIEW_CAPTURE_FAILED"})}}isLauncherReadyToAttach(){return!!window.Rokt&&typeof window.Rokt.createLauncher=="function"}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"||!y(e))return;const t=a().EventType.Other;a().logEvent(fe,t,e)}setRoktSessionId(e){if(!(!e||typeof e!="string"))try{const t=a().getInstance();t&&typeof t.setIntegrationAttribute=="function"&&t.setIntegrationAttribute(L,{roktSessionId:e})}catch{}}attachLauncher(e,t,n=[]){const r=a()&&a().sessionManager&&typeof a().sessionManager.getSession=="function"?a().sessionManager.getSession():void 0,o={accountId:e,...t||{},...r?{mpSessionId:r}:{}};let s;this.isPartnerInLocalLauncherTestGroup()?s=Promise.resolve(window.Rokt.createLocalLauncher(o)):s=window.Rokt.createLauncher(o),s.then(async c=>{await Ne(n,c),this.initRoktLauncher(c)}).catch(c=>{console.error("Error creating Rokt launcher:",c)})}initRoktLauncher(e){window.Rokt&&(window.Rokt.currentLauncher=e),this.launcher=e;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,q(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=T(s.placementEventMapping);this.placementEventMappingLookup=z(u);const l=T(s.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=J(l),s.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=s.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=m(s.workspaceIdSyncApiKey)?s.workspaceIdSyncApiKey:void 0;const g=a().Rokt?.domain,{roktExtensionsQueryParams:O,legacyRoktExtensions:A,loadThankYouElement:R}=V(s.roktExtensions),p={...a().Rokt?.launcherOptions||{}};this.integrationName=Oe(p.integrationName),p.integrationName=this.integrationName,this.domain=g;const v={loggingUrl:s.loggingUrl,errorUrl:s.errorUrl,integrationDomain:g,isLoggingEnabled:a().config?.isLoggingEnabled===!0},E=new Q(v,this.integrationName,window.__rokt_li_guid__,s.accountId),w=new $(v,E,this.integrationName,window.__rokt_li_guid__,s.accountId);if(this.errorReportingService=E,this.loggingService=w,this.isTargetingDisabled())try{G()}catch(h){this.errorReportingService?.report({message:"Rokt Kit: Failed to clear page views when targeting is disabled",code:"PAGE_VIEW_CAPTURE_FAILED",severity:_.INFO,stackTrace:h instanceof Error?h.stack:void 0})}return a()._registerErrorReportingService&&a()._registerErrorReportingService(E),a()._registerLoggingService&&a()._registerLoggingService(w),n?(this.testHelpers={generateLauncherScript:W,generateThankYouElementScript:j,extractRoktExtensionConfig:V,hashEventMessage:B,parseSettingsString:T,generateMappedEventLookup:z,generateMappedEventAttributeLookup:J,sendAdBlockMeasurementSignals:q,createAutoRemovedIframe:C,djb2:re,setAllowedOriginHashes:h=>{f._allowedOriginHashes=h},ReportingTransport:F,ErrorReportingService:Q,LoggingService:$,RateLimiter:oe,ErrorCodes:K,WSDKErrorSeverity:_},this.attachLauncher(c,p),"Successfully initialized: "+d):(R&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),H(Ie,j(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,p,A):(H(ye,W(g,O),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,p,A):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===ke&&this.capturePageView(e),e.EventDataType===Ae&&(ie(this.loggingService),G())),!this.isKitReady())return"Kit not ready for forwarder: "+d;if(typeof a().Rokt?.setLocalSessionAttribute=="function"&&(P(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!P(this.placementEventMappingLookup))){const t=B(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 X(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];m(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){if(this._workspaceSearchInFlightPromise){const t=this._workspaceSearchInFlightPromise;return Promise.race([t,new Promise(n=>setTimeout(n,ve))]).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():{},O=this.returnUserIdentities(c),A=this.returnLocalSessionAttributes(),R=ge(Y(this.loggingService)),p={...O,...l,...g,...A,...R.length?{[Re]:JSON.stringify(R)}:{},...this.userIdentifiedInWorkspace?{[Se]:!0}:{},mpid:u},v={...e,attributes:p},E=this.launcher.selectPlacements(v),w=()=>this.logSelectPlacementsEvent(p);return Promise.resolve(E).then(h=>h?.context?.sessionId?.then(se=>this.setRoktSessionId(se))).catch(()=>{}).finally(w),E}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")))}onShoppableAdsReady(e){this._isThankYouElementLoaded?e():this._thankYouElementOnLoadCallback=e}};f._allowedOriginHashes=[-553112570,549508659],f.PERFORMANCE_MARKS={RoktScriptAppended:"mp:RoktScriptAppended"},f.EMAIL_SHA256_KEY="emailsha256";let I=f;function Ke(){return L}function De(i){if(!i){window.console.log("You must pass a config object to register the kit "+d);return}if(!y(i)){window.console.log("'config' must be an object. You passed in a "+typeof i);return}y(i.kits)?i.kits[d]={constructor:I}:(i.kits={},i.kits[d]={constructor:I}),window.console.log("Successfully registered "+d+" to your mParticle configuration")}typeof window<"u"&&window.mParticle&&a().addForwarder&&a().addForwarder({name:d,constructor:I,getId:Ke});exports.register=De;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ae=["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"],ce=new Set(ae);function X(i){return ce.has(i.toLowerCase())}function b(i){const e={},t=i||{},n=Object.keys(t);for(let r=0;r<n.length;r++){const s=n[r];X(s)||(e[s]=t[s])}return e}function y(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function m(i){return typeof i=="string"}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}}function N(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 ee(i){try{window.localStorage.removeItem(i)}catch{}}function te(i,e){const t=N(i);return y(t)?t[e]:void 0}function C(i,e,t){const n=N(i),r=y(n)?{...n}:{};return r[e]=t,Z(i,r)}function le(i,e){const t=N(i);if(!y(t)||!(e in t))return;const n={...t};delete n[e],Object.keys(n).length===0?ee(i):Z(i,n)}function ue(i,e,t,n){const r=t.slice(),s=()=>r.length<=1?!1:(r.shift(),!0);let o=JSON.stringify(r).length>n;for(;o&&s();)o=JSON.stringify(r).length>n;let c=C(i,e,r);for(;!c&&s();)c=C(i,e,r);return c}const I="mp-rokt-kit",k="pageViews",Y="mpPageViews",de=100*1024;function ie(i){const e=N(Y);if(e===null)return;if(!(te(I,k)!==void 0)&&Array.isArray(e)&&!C(I,k,e)){i?.log({message:"Rokt Kit: Failed to migrate legacy page-view storage; retaining legacy key for retry",code:"PAGE_VIEW_CAPTURE_FAILED"});return}ee(Y)}function x(i){ie(i);const e=te(I,k);return Array.isArray(e)?e:[]}function he(i){return ue(I,k,i,de)}function G(){le(I,k)}function ge(i){return i.map((e,t)=>{const n=e.activeTimeOnSite,r=n!==void 0&&Number.isFinite(n),o=i[t+1]?.activeTimeOnSite,c=o!==void 0&&Number.isFinite(o),u=r&&c?o-n:void 0;return{pageUrl:e.pageUrl,sourceMessageId:e.sourceMessageId,timestamp:e.timestamp,...e.pageTitle!==void 0?{pageTitle:e.pageTitle}:{},...e.canonicalUrl!==void 0?{canonicalUrl:e.canonicalUrl}:{},...r?{activeTimeOnSite:n}:{},...u!==void 0&&u>=0?{activeTimeOnPage:u}:{}}})}function pe(){const e=document.querySelector('link[rel="canonical"]')?.href;if(e)return K(e)}const d="Rokt",L=181,fe="selectPlacements",me="apps.roktecommerce.com",Ee=.1,_e="ThankYouPageJourney",ye="rokt-launcher",Se="rokt-thank-you-element",Ie="userIdentifiedInWorkspace",ke=3,Ae=2,Re="page_events",ve=500,D={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST",LOG_DELIVERY_FAILURE:"LOG_DELIVERY_FAILURE"},_={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},we="apps.rokt-api.com",be="/v1/log",Le="/v1/errors",Te=10;function a(){return window.mParticle}function W(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:we;return e.includes("://")?e.replace(/\/+$/,""):["https://",e].join("")}function ne(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 H(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 T(i){if(!i)return[];try{return JSON.parse(i.replace(/&quot;/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function V(i){const e=i?T(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(_e)):t.push(o)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:n,loadThankYouElement:r}}async function Ne(i,e){const t=[];if(e)for(const n of i)t.push(e.use(n));return Promise.all(t)}function z(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 J(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 B(i,e,t){return a().generateHash([i,e,t].join(""))}function Oe(i){let n="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"1.32.0";return i&&(n+="_"+i),n}function re(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 q(i,e){const t=re(window.location.origin);if(S._allowedOriginHashes.indexOf(t)===-1||Math.random()>=Ee)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://"+me+"/v1/wsdk-init/index.html?"+o+"&isControl=true")}function Pe(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function Ue(){return typeof window<"u"?window.location?.href:void 0}function Ce(){return typeof window<"u"?window.navigator?.userAgent:void 0}class se{constructor(){this._logCount={}}incrementAndCheck(e){const n=(this._logCount[e]||0)+1;return this._logCount[e]=n,n>Te}}class F{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 se,this._isEnabled=Pe()||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||D.UNKNOWN_ERROR,url:Ue(),deviceInfo:Ce(),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 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),o&&o(l)})}catch(c){console.error("ReportingTransport: Failed to send log",c),o&&o(c)}}}class ${constructor(e,t,n,r,s){this._transport=new F(e,t,n,r,s),this._errorUrl=ne(e?.errorUrl,e?.integrationDomain,Le)}report(e){if(!e)return;const t=e.severity||_.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class Q{constructor(e,t,n,r,s,o){this._transport=new F(e,n,r,s,o),this._loggingUrl=ne(e?.loggingUrl,e?.integrationDomain,be),this._errorReportingService=t}log(e){e&&this._transport.send(this._loggingUrl,_.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:D.LOG_DELIVERY_FAILURE,severity:n?_.ERROR:_.WARNING})}})}}function Me(i){const e=K(window.location.href),t=i.EventAttributes?.title||document.title,n=pe(),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=L,this.moduleId=L,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}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=x(this.loggingService),r=Me(e);n.push(r),he(n)||this.loggingService?.log({message:`Rokt Kit: Failed to persist page view for ${t}`,code:"PAGE_VIEW_CAPTURE_FAILED"})}catch(n){this.loggingService?.log({message:`Rokt Kit: Failed to capture page view for ${t}: ${n instanceof Error?n.message:String(n)}`,code:"PAGE_VIEW_CAPTURE_FAILED"})}}isLauncherReadyToAttach(){return!!window.Rokt&&typeof window.Rokt.createLauncher=="function"}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"||!y(e))return;const t=a().EventType.Other;a().logEvent(fe,t,e)}setRoktSessionId(e){if(!(!e||typeof e!="string"))try{const t=a().getInstance();t&&typeof t.setIntegrationAttribute=="function"&&t.setIntegrationAttribute(L,{roktSessionId:e})}catch{}}attachLauncher(e,t,n=[]){const r=a()&&a().sessionManager&&typeof a().sessionManager.getSession=="function"?a().sessionManager.getSession():void 0,s={accountId:e,...t||{},...r?{mpSessionId:r}:{}};let o;this.isPartnerInLocalLauncherTestGroup()?o=Promise.resolve(window.Rokt.createLocalLauncher(s)):o=window.Rokt.createLauncher(s),o.then(async c=>{await Ne(n,c),this.initRoktLauncher(c)}).catch(c=>{console.error("Error creating Rokt launcher:",c)})}initRoktLauncher(e){window.Rokt&&(window.Rokt.currentLauncher=e),this.launcher=e;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,q(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=b(s),this._onboardingExpProvider=o.onboardingExpProvider;const u=T(o.placementEventMapping);this.placementEventMappingLookup=z(u);const l=T(o.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=J(l),o.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=o.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=m(o.workspaceIdSyncApiKey)?o.workspaceIdSyncApiKey:void 0;const g=a().Rokt?.domain,{roktExtensionsQueryParams:P,legacyRoktExtensions:A,loadThankYouElement:R}=V(o.roktExtensions),p={...a().Rokt?.launcherOptions||{}};this.integrationName=Oe(p.integrationName),p.integrationName=this.integrationName,this.domain=g;const v={loggingUrl:o.loggingUrl,errorUrl:o.errorUrl,integrationDomain:g,isLoggingEnabled:a().config?.isLoggingEnabled===!0},E=new $(v,this.integrationName,window.__rokt_li_guid__,o.accountId),w=new Q(v,E,this.integrationName,window.__rokt_li_guid__,o.accountId);if(this.errorReportingService=E,this.loggingService=w,this.isTargetingDisabled())try{G()}catch(h){this.errorReportingService?.report({message:"Rokt Kit: Failed to clear page views when targeting is disabled",code:"PAGE_VIEW_CAPTURE_FAILED",severity:_.INFO,stackTrace:h instanceof Error?h.stack:void 0})}return a()._registerErrorReportingService&&a()._registerErrorReportingService(E),a()._registerLoggingService&&a()._registerLoggingService(w),n?(this.testHelpers={generateLauncherScript:W,generateThankYouElementScript:j,extractRoktExtensionConfig:V,hashEventMessage:B,parseSettingsString:T,generateMappedEventLookup:z,generateMappedEventAttributeLookup:J,sendAdBlockMeasurementSignals:q,createAutoRemovedIframe:M,djb2:re,setAllowedOriginHashes:h=>{f._allowedOriginHashes=h},ReportingTransport:F,ErrorReportingService:$,LoggingService:Q,RateLimiter:se,ErrorCodes:D,WSDKErrorSeverity:_},this.attachLauncher(c,p),"Successfully initialized: "+d):(R&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),H(Se,j(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,p,A):(H(ye,W(g,P),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,p,A):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===ke&&this.capturePageView(e),e.EventDataType===Ae&&(ie(this.loggingService),G())),!this.isKitReady())return"Kit not ready for forwarder: "+d;if(typeof a().Rokt?.setLocalSessionAttribute=="function"&&(U(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!U(this.placementEventMappingLookup))){const t=B(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 X(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,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){if(this._workspaceSearchInFlightPromise){const t=this._workspaceSearchInFlightPromise;return Promise.race([t,new Promise(n=>setTimeout(n,ve))]).then(()=>this._dispatchPlacements(e))}return this._dispatchPlacements(e)}_dispatchPlacements(e){const t=e&&e.attributes||{},r={...b(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=b(l);const g=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},P=this.returnUserIdentities(c),A=this.returnLocalSessionAttributes(),R=ge(x(this.loggingService)),p={...P,...l,...g,...A,...R.length?{[Re]:JSON.stringify(R)}:{},...this.userIdentifiedInWorkspace?{[Ie]:!0}:{},mpid:u},v={...e,attributes:p},E=this.launcher.selectPlacements(v),w=()=>this.logSelectPlacementsEvent(p);return Promise.resolve(E).then(h=>h?.context?.sessionId?.then(oe=>this.setRoktSessionId(oe))).catch(()=>{}).finally(w),E}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")))}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 Ke(){return L}function De(i){if(!i){window.console.log("You must pass a config object to register the kit "+d);return}if(!y(i)){window.console.log("'config' must be an object. You passed in a "+typeof i);return}y(i.kits)?i.kits[d]={constructor:S}:(i.kits={},i.kits[d]={constructor:S}),window.console.log("Successfully registered "+d+" to your mParticle configuration")}typeof window<"u"&&window.mParticle&&a().addForwarder&&a().addForwarder({name:d,constructor:S,getId:Ke});exports.register=De;
2
2
  //# sourceMappingURL=Rokt-Kit.common.js.map
@@ -30,8 +30,8 @@ function X(i) {
30
30
  function b(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
- X(o) || (e[o] = t[o]);
33
+ const s = n[r];
34
+ X(s) || (e[s] = t[s]);
35
35
  }
36
36
  return e;
37
37
  }
@@ -41,10 +41,10 @@ function y(i) {
41
41
  function m(i) {
42
42
  return typeof i == "string";
43
43
  }
44
- function P(i) {
44
+ function U(i) {
45
45
  return i == null ? !0 : typeof i == "object" ? Object.keys(i).length === 0 : !1;
46
46
  }
47
- function M(i) {
47
+ function K(i) {
48
48
  try {
49
49
  const e = new URL(i);
50
50
  return e.search = "", e.toString();
@@ -77,7 +77,7 @@ function te(i, e) {
77
77
  const t = N(i);
78
78
  return y(t) ? t[e] : void 0;
79
79
  }
80
- function U(i, e, t) {
80
+ function C(i, e, t) {
81
81
  const n = N(i), r = y(n) ? { ...n } : {};
82
82
  return r[e] = t, Z(i, r);
83
83
  }
@@ -89,13 +89,13 @@ function le(i, e) {
89
89
  delete n[e], Object.keys(n).length === 0 ? ee(i) : Z(i, n);
90
90
  }
91
91
  function ue(i, e, t, n) {
92
- const r = t.slice(), o = () => r.length <= 1 ? !1 : (r.shift(), !0);
93
- let s = JSON.stringify(r).length > n;
94
- for (; s && o(); )
95
- s = JSON.stringify(r).length > n;
96
- let c = U(i, e, r);
97
- for (; !c && o(); )
98
- c = U(i, e, r);
92
+ const r = t.slice(), s = () => r.length <= 1 ? !1 : (r.shift(), !0);
93
+ let o = JSON.stringify(r).length > n;
94
+ for (; o && s(); )
95
+ o = JSON.stringify(r).length > n;
96
+ let c = C(i, e, r);
97
+ for (; !c && s(); )
98
+ c = C(i, e, r);
99
99
  return c;
100
100
  }
101
101
  const S = "mp-rokt-kit", k = "pageViews", x = "mpPageViews", de = 100 * 1024;
@@ -103,7 +103,7 @@ function ie(i) {
103
103
  const e = N(x);
104
104
  if (e === null)
105
105
  return;
106
- if (!(te(S, k) !== void 0) && Array.isArray(e) && !U(S, k, e)) {
106
+ if (!(te(S, k) !== void 0) && Array.isArray(e) && !C(S, k, e)) {
107
107
  i?.log({
108
108
  message: "Rokt Kit: Failed to migrate legacy page-view storage; retaining legacy key for retry",
109
109
  code: "PAGE_VIEW_CAPTURE_FAILED"
@@ -125,7 +125,7 @@ function G() {
125
125
  }
126
126
  function ge(i) {
127
127
  return i.map((e, t) => {
128
- const n = e.activeTimeOnSite, r = n !== void 0 && Number.isFinite(n), s = i[t + 1]?.activeTimeOnSite, c = s !== void 0 && Number.isFinite(s), u = r && c ? s - n : void 0;
128
+ const n = e.activeTimeOnSite, r = n !== void 0 && Number.isFinite(n), o = i[t + 1]?.activeTimeOnSite, c = o !== void 0 && Number.isFinite(o), u = r && c ? o - n : void 0;
129
129
  return {
130
130
  pageUrl: e.pageUrl,
131
131
  sourceMessageId: e.sourceMessageId,
@@ -140,9 +140,9 @@ function ge(i) {
140
140
  function pe() {
141
141
  const e = document.querySelector('link[rel="canonical"]')?.href;
142
142
  if (e)
143
- return M(e);
143
+ return K(e);
144
144
  }
145
- const d = "Rokt", L = 181, fe = "selectPlacements", me = "apps.roktecommerce.com", Ee = 0.1, _e = "ThankYouPageJourney", ye = "rokt-launcher", Ie = "rokt-thank-you-element", Se = "userIdentifiedInWorkspace", ke = 3, Ae = 2, Re = "page_events", ve = 500, K = {
145
+ const d = "Rokt", L = 181, fe = "selectPlacements", me = "apps.roktecommerce.com", Ee = 0.1, _e = "ThankYouPageJourney", ye = "rokt-launcher", Ie = "rokt-thank-you-element", Se = "userIdentifiedInWorkspace", ke = 3, Ae = 2, Re = "page_events", ve = 500, D = {
146
146
  UNKNOWN_ERROR: "UNKNOWN_ERROR",
147
147
  UNHANDLED_EXCEPTION: "UNHANDLED_EXCEPTION",
148
148
  IDENTITY_REQUEST: "IDENTITY_REQUEST",
@@ -156,17 +156,21 @@ function a() {
156
156
  return window.mParticle;
157
157
  }
158
158
  function W(i, e) {
159
- const n = [D(i), "/wsdk/integrations/launcher.js"].join("");
159
+ const n = [O(i), "/wsdk/integrations/launcher.js"].join("");
160
160
  return !e || e.length === 0 ? n : n + "?extensions=" + e.join(",");
161
161
  }
162
162
  function j(i) {
163
- return [D(i), "/rokt-elements/rokt-element-thank-you.js"].join("");
163
+ return [O(i), "/rokt-elements/rokt-element-thank-you.js"].join("");
164
164
  }
165
- function D(i) {
166
- return ["https://", typeof i < "u" ? i : we].join("");
165
+ function O(i) {
166
+ const e = typeof i < "u" ? i : we;
167
+ return e.includes("://") ? e.replace(/\/+$/, "") : ["https://", e].join("");
167
168
  }
168
169
  function ne(i, e, t) {
169
- return i ? i.startsWith("http://") || i.startsWith("https://") ? i : "https://" + i : D(e) + t;
170
+ if (i)
171
+ return i.startsWith("http://") || i.startsWith("https://") ? i : "https://" + i;
172
+ const r = e?.includes("://") && !/^https?:\/\//i.test(e) ? void 0 : e;
173
+ return O(r) + t;
170
174
  }
171
175
  function H(i, e, t) {
172
176
  if (document.getElementById(i)) return;
@@ -186,9 +190,9 @@ function T(i) {
186
190
  function V(i) {
187
191
  const e = i ? T(i) : [], t = [], n = [];
188
192
  let r = !1;
189
- for (let o = 0; o < e.length; o++) {
190
- const s = e[o].value;
191
- s === "thank-you-journey" ? (r = !0, n.push(_e)) : t.push(s);
193
+ for (let s = 0; s < e.length; s++) {
194
+ const o = e[s].value;
195
+ o === "thank-you-journey" ? (r = !0, n.push(_e)) : t.push(o);
192
196
  }
193
197
  return {
194
198
  roktExtensionsQueryParams: t,
@@ -221,9 +225,9 @@ function J(i) {
221
225
  const n = i[t];
222
226
  if (!n || !m(n.value) || !m(n.map))
223
227
  continue;
224
- const r = n.value, o = n.map;
228
+ const r = n.value, s = n.map;
225
229
  e[r] || (e[r] = []), e[r].push({
226
- eventAttributeKey: o,
230
+ eventAttributeKey: s,
227
231
  conditions: Array.isArray(n.conditions) ? n.conditions : []
228
232
  });
229
233
  }
@@ -233,7 +237,7 @@ function B(i, e, t) {
233
237
  return a().generateHash([i, e, t].join(""));
234
238
  }
235
239
  function Oe(i) {
236
- let n = "mParticle_wsdkv_" + a().getVersion() + "_kitv_" + "1.31.0";
240
+ let n = "mParticle_wsdkv_" + a().getVersion() + "_kitv_" + "1.32.0";
237
241
  return i && (n += "_" + i), n;
238
242
  }
239
243
  function re(i) {
@@ -242,7 +246,7 @@ function re(i) {
242
246
  e = (e << 5) + e + i.charCodeAt(t), e = e & e;
243
247
  return e;
244
248
  }
245
- function C(i) {
249
+ function M(i) {
246
250
  const e = document.createElement("iframe");
247
251
  e.style.display = "none", e.setAttribute("sandbox", "allow-scripts allow-same-origin"), e.src = i, e.onload = function() {
248
252
  e.onload = null, e.parentNode && e.parentNode.removeChild(e);
@@ -255,11 +259,11 @@ function q(i, e) {
255
259
  if (I._allowedOriginHashes.indexOf(t) === -1 || Math.random() >= Ee)
256
260
  return;
257
261
  const r = window.__rokt_li_guid__;
258
- if (!r)
262
+ if (!r || i && i.includes("://") && !/^https:\/\//i.test(i))
259
263
  return;
260
- const o = window.location.href.split("?")[0].split("#")[0], s = "version=" + encodeURIComponent(e ?? "") + "&launcherInstanceGuid=" + encodeURIComponent(r) + "&pageUrl=" + encodeURIComponent(o);
261
- C("https://" + (i || "apps.rokt.com") + "/v1/wsdk-init/index.html?" + s), C(
262
- "https://" + me + "/v1/wsdk-init/index.html?" + s + "&isControl=true"
264
+ 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";
265
+ M(c + "/v1/wsdk-init/index.html?" + o), M(
266
+ "https://" + me + "/v1/wsdk-init/index.html?" + o + "&isControl=true"
263
267
  );
264
268
  }
265
269
  function Pe() {
@@ -271,7 +275,7 @@ function Ue() {
271
275
  function Ce() {
272
276
  return typeof window < "u" ? window.navigator?.userAgent : void 0;
273
277
  }
274
- class oe {
278
+ class se {
275
279
  constructor() {
276
280
  this._logCount = {};
277
281
  }
@@ -281,12 +285,12 @@ class oe {
281
285
  }
282
286
  }
283
287
  class F {
284
- constructor(e, t, n, r, o) {
288
+ constructor(e, t, n, r, s) {
285
289
  this._reporter = "mp-wsdk";
286
- const s = e.isLoggingEnabled;
287
- this._integrationName = t || "", this._launcherInstanceGuid = n, this._accountId = r || null, this._rateLimiter = o || new oe(), this._isEnabled = Pe() || s;
290
+ const o = e.isLoggingEnabled;
291
+ this._integrationName = t || "", this._launcherInstanceGuid = n, this._accountId = r || null, this._rateLimiter = s || new se(), this._isEnabled = Pe() || o;
288
292
  }
289
- send(e, t, n, r, o, s) {
293
+ send(e, t, n, r, s, o) {
290
294
  if (!(!this._isEnabled || this._rateLimiter.incrementAndCheck(t)))
291
295
  try {
292
296
  const c = {
@@ -295,10 +299,10 @@ class F {
295
299
  version: this._integrationName
296
300
  },
297
301
  severity: t,
298
- code: r || K.UNKNOWN_ERROR,
302
+ code: r || D.UNKNOWN_ERROR,
299
303
  url: Ue(),
300
304
  deviceInfo: Ce(),
301
- stackTrace: o,
305
+ stackTrace: s,
302
306
  reporter: this._reporter,
303
307
  integration: this._integrationName
304
308
  }, u = {
@@ -317,16 +321,16 @@ class F {
317
321
  throw g.statusCode = l.status, g;
318
322
  }
319
323
  }).catch((l) => {
320
- console.error("ReportingTransport: Failed to send log", l), s && s(l);
324
+ console.error("ReportingTransport: Failed to send log", l), o && o(l);
321
325
  });
322
326
  } catch (c) {
323
- console.error("ReportingTransport: Failed to send log", c), s && s(c);
327
+ console.error("ReportingTransport: Failed to send log", c), o && o(c);
324
328
  }
325
329
  }
326
330
  }
327
- class Q {
328
- constructor(e, t, n, r, o) {
329
- this._transport = new F(e, t, n, r, o), this._errorUrl = ne(e?.errorUrl, e?.integrationDomain, Le);
331
+ class $ {
332
+ constructor(e, t, n, r, s) {
333
+ this._transport = new F(e, t, n, r, s), this._errorUrl = ne(e?.errorUrl, e?.integrationDomain, Le);
330
334
  }
331
335
  report(e) {
332
336
  if (!e) return;
@@ -334,9 +338,9 @@ class Q {
334
338
  this._transport.send(this._errorUrl, t, e.message, e.code, e.stackTrace);
335
339
  }
336
340
  }
337
- class $ {
338
- constructor(e, t, n, r, o, s) {
339
- this._transport = new F(e, n, r, o, s), this._loggingUrl = ne(e?.loggingUrl, e?.integrationDomain, be), this._errorReportingService = t;
341
+ class Q {
342
+ constructor(e, t, n, r, s, o) {
343
+ this._transport = new F(e, n, r, s, o), this._loggingUrl = ne(e?.loggingUrl, e?.integrationDomain, be), this._errorReportingService = t;
340
344
  }
341
345
  log(e) {
342
346
  e && this._transport.send(
@@ -350,7 +354,7 @@ class $ {
350
354
  const n = typeof t.statusCode == "number";
351
355
  this._errorReportingService.report({
352
356
  message: "LoggingService: Failed to send log: " + t.message,
353
- code: K.LOG_DELIVERY_FAILURE,
357
+ code: D.LOG_DELIVERY_FAILURE,
354
358
  severity: n ? _.ERROR : _.WARNING
355
359
  });
356
360
  }
@@ -359,7 +363,7 @@ class $ {
359
363
  }
360
364
  }
361
365
  function Me(i) {
362
- const e = M(window.location.href), t = i.EventAttributes?.title || document.title, n = pe(), r = i.ActiveTimeOnSite;
366
+ const e = K(window.location.href), t = i.EventAttributes?.title || document.title, n = pe(), r = i.ActiveTimeOnSite;
363
367
  return {
364
368
  pageUrl: e,
365
369
  sourceMessageId: i.SourceMessageId,
@@ -393,30 +397,30 @@ const f = class f {
393
397
  const r = this.getEventAttributeValue(e, t.eventAttributeKey);
394
398
  if (n.length === 0)
395
399
  return r !== null;
396
- for (let o = 0; o < n.length; o++)
397
- if (!this.doesEventAttributeConditionMatch(n[o], r))
400
+ for (let s = 0; s < n.length; s++)
401
+ if (!this.doesEventAttributeConditionMatch(n[s], r))
398
402
  return !1;
399
403
  return !0;
400
404
  }
401
405
  applyPlacementEventAttributeMapping(e) {
402
406
  const t = Object.keys(this.placementEventAttributeMappingLookup);
403
407
  for (let n = 0; n < t.length; n++) {
404
- const r = t[n], o = this.placementEventAttributeMappingLookup[r];
405
- if (P(o))
408
+ const r = t[n], s = this.placementEventAttributeMappingLookup[r];
409
+ if (U(s))
406
410
  continue;
407
- let s = !0;
408
- for (let c = 0; c < o.length; c++)
409
- if (!this.doesEventMatchRule(e, o[c])) {
410
- s = !1;
411
+ let o = !0;
412
+ for (let c = 0; c < s.length; c++)
413
+ if (!this.doesEventMatchRule(e, s[c])) {
414
+ o = !1;
411
415
  break;
412
416
  }
413
- s && a().Rokt.setLocalSessionAttribute?.(r, !0);
417
+ o && a().Rokt.setLocalSessionAttribute?.(r, !0);
414
418
  }
415
419
  }
416
420
  capturePageView(e) {
417
421
  let t;
418
422
  try {
419
- t = M(window.location.href);
423
+ t = K(window.location.href);
420
424
  const n = Y(this.loggingService), r = Me(e);
421
425
  n.push(r), he(n) || this.loggingService?.log({
422
426
  message: `Rokt Kit: Failed to persist page view for ${t}`,
@@ -465,13 +469,13 @@ const f = class f {
465
469
  }
466
470
  }
467
471
  attachLauncher(e, t, n = []) {
468
- const r = a() && a().sessionManager && typeof a().sessionManager.getSession == "function" ? a().sessionManager.getSession() : void 0, o = {
472
+ const r = a() && a().sessionManager && typeof a().sessionManager.getSession == "function" ? a().sessionManager.getSession() : void 0, s = {
469
473
  accountId: e,
470
474
  ...t || {},
471
475
  ...r ? { mpSessionId: r } : {}
472
476
  };
473
- let s;
474
- this.isPartnerInLocalLauncherTestGroup() ? s = Promise.resolve(window.Rokt.createLocalLauncher(o)) : s = window.Rokt.createLauncher(o), s.then(async (c) => {
477
+ let o;
478
+ this.isPartnerInLocalLauncherTestGroup() ? o = Promise.resolve(window.Rokt.createLocalLauncher(s)) : o = window.Rokt.createLauncher(s), o.then(async (c) => {
475
479
  await Ne(n, c), this.initRoktLauncher(c);
476
480
  }).catch((c) => {
477
481
  console.error("Error creating Rokt launcher:", c);
@@ -487,7 +491,7 @@ const f = class f {
487
491
  try {
488
492
  if (e.length > 0 && window.optimizely) {
489
493
  const t = window.optimizely.get("state");
490
- return !t || !t.getActiveExperimentIds ? {} : t.getActiveExperimentIds().reduce((o, s) => (o["rokt.custom.optimizely.experiment." + s + ".variationId"] = t.getVariationMap()[s].id, o), {});
494
+ return !t || !t.getActiveExperimentIds ? {} : t.getActiveExperimentIds().reduce((s, o) => (s["rokt.custom.optimizely.experiment." + o + ".variationId"] = t.getVariationMap()[o].id, s), {});
491
495
  }
492
496
  } catch (t) {
493
497
  console.error("Error fetching Optimizely attributes:", t);
@@ -515,37 +519,37 @@ const f = class f {
515
519
  /**
516
520
  * Initializes the Rokt forwarder with settings from the mParticle server.
517
521
  */
518
- init(e, t, n, r, o) {
519
- const s = e, c = s.accountId;
520
- this.userAttributes = b(o), this._onboardingExpProvider = s.onboardingExpProvider;
521
- const u = T(s.placementEventMapping);
522
+ init(e, t, n, r, s) {
523
+ const o = e, c = o.accountId;
524
+ this.userAttributes = b(s), this._onboardingExpProvider = o.onboardingExpProvider;
525
+ const u = T(o.placementEventMapping);
522
526
  this.placementEventMappingLookup = z(u);
523
527
  const l = T(
524
- s.placementEventAttributeMapping
528
+ o.placementEventAttributeMapping
525
529
  );
526
- this.placementEventAttributeMappingLookup = J(l), s.hashedEmailUserIdentityType && (this._mappedEmailSha256Key = s.hashedEmailUserIdentityType.toLowerCase()), this._workspaceIdSyncApiKey = m(s.workspaceIdSyncApiKey) ? s.workspaceIdSyncApiKey : void 0;
527
- const g = a().Rokt?.domain, { roktExtensionsQueryParams: O, legacyRoktExtensions: A, loadThankYouElement: R } = V(
528
- s.roktExtensions
530
+ this.placementEventAttributeMappingLookup = J(l), o.hashedEmailUserIdentityType && (this._mappedEmailSha256Key = o.hashedEmailUserIdentityType.toLowerCase()), this._workspaceIdSyncApiKey = m(o.workspaceIdSyncApiKey) ? o.workspaceIdSyncApiKey : void 0;
531
+ const g = a().Rokt?.domain, { roktExtensionsQueryParams: P, legacyRoktExtensions: A, loadThankYouElement: R } = V(
532
+ o.roktExtensions
529
533
  ), p = {
530
534
  ...a().Rokt?.launcherOptions || {}
531
535
  };
532
536
  this.integrationName = Oe(p.integrationName), p.integrationName = this.integrationName, this.domain = g;
533
537
  const v = {
534
- loggingUrl: s.loggingUrl,
535
- errorUrl: s.errorUrl,
538
+ loggingUrl: o.loggingUrl,
539
+ errorUrl: o.errorUrl,
536
540
  integrationDomain: g,
537
541
  isLoggingEnabled: a().config?.isLoggingEnabled === !0
538
- }, E = new Q(
542
+ }, E = new $(
539
543
  v,
540
544
  this.integrationName,
541
545
  window.__rokt_li_guid__,
542
- s.accountId
543
- ), w = new $(
546
+ o.accountId
547
+ ), w = new Q(
544
548
  v,
545
549
  E,
546
550
  this.integrationName,
547
551
  window.__rokt_li_guid__,
548
- s.accountId
552
+ o.accountId
549
553
  );
550
554
  if (this.errorReportingService = E, this.loggingService = w, this.isTargetingDisabled())
551
555
  try {
@@ -567,16 +571,16 @@ const f = class f {
567
571
  generateMappedEventLookup: z,
568
572
  generateMappedEventAttributeLookup: J,
569
573
  sendAdBlockMeasurementSignals: q,
570
- createAutoRemovedIframe: C,
574
+ createAutoRemovedIframe: M,
571
575
  djb2: re,
572
576
  setAllowedOriginHashes: (h) => {
573
577
  f._allowedOriginHashes = h;
574
578
  },
575
579
  ReportingTransport: F,
576
- ErrorReportingService: Q,
577
- LoggingService: $,
578
- RateLimiter: oe,
579
- ErrorCodes: K,
580
+ ErrorReportingService: $,
581
+ LoggingService: Q,
582
+ RateLimiter: se,
583
+ ErrorCodes: D,
580
584
  WSDKErrorSeverity: _
581
585
  }, this.attachLauncher(c, p), "Successfully initialized: " + d) : (R && (a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this), H(Ie, j(g), {
582
586
  onLoad: () => {
@@ -585,7 +589,7 @@ const f = class f {
585
589
  onError: (h) => {
586
590
  console.error("Error loading Rokt Thank You Element script:", h);
587
591
  }
588
- })), this.isLauncherReadyToAttach() ? this.attachLauncher(c, p, A) : (H(ye, W(g, O), {
592
+ })), this.isLauncherReadyToAttach() ? this.attachLauncher(c, p, A) : (H(ye, W(g, P), {
589
593
  onLoad: () => {
590
594
  this.isLauncherReadyToAttach() ? this.attachLauncher(c, p, A) : console.error("Rokt object is not available after script load.");
591
595
  },
@@ -597,7 +601,7 @@ const f = class f {
597
601
  process(e) {
598
602
  if (this.isTargetingDisabled() || (e.EventDataType === ke && this.capturePageView(e), e.EventDataType === Ae && (ie(this.loggingService), G())), !this.isKitReady())
599
603
  return "Kit not ready for forwarder: " + d;
600
- if (typeof a().Rokt?.setLocalSessionAttribute == "function" && (P(this.placementEventAttributeMappingLookup) || this.applyPlacementEventAttributeMapping(e), !P(this.placementEventMappingLookup))) {
604
+ if (typeof a().Rokt?.setLocalSessionAttribute == "function" && (U(this.placementEventAttributeMappingLookup) || this.applyPlacementEventAttributeMapping(e), !U(this.placementEventMappingLookup))) {
601
605
  const t = B(e.EventDataType, e.EventCategory, e.EventName ?? "");
602
606
  this.placementEventMappingLookup[String(t)] && a().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(t)], !0);
603
607
  }
@@ -630,19 +634,19 @@ const f = class f {
630
634
  const n = a().Identity?.search;
631
635
  if (typeof n != "function")
632
636
  return this.userIdentifiedInWorkspace = !1, this._workspaceLastSearchedIdentitiesKey = void 0, Promise.resolve();
633
- const r = e.getUserIdentities ? e.getUserIdentities().userIdentities : null, o = {};
637
+ const r = e.getUserIdentities ? e.getUserIdentities().userIdentities : null, s = {};
634
638
  if (r)
635
639
  for (const u of Object.keys(r)) {
636
640
  const l = r[u];
637
- m(l) && l.length > 0 && (o[u] = l);
641
+ m(l) && l.length > 0 && (s[u] = l);
638
642
  }
639
- const s = Object.keys(o);
640
- if (s.length === 0)
643
+ const o = Object.keys(s);
644
+ if (o.length === 0)
641
645
  return this.userIdentifiedInWorkspace = !1, this._workspaceLastSearchedIdentitiesKey = void 0, Promise.resolve();
642
- const c = s.sort().map((u) => `${u}=${o[u]}`).join("&");
646
+ const c = o.sort().map((u) => `${u}=${s[u]}`).join("&");
643
647
  return c === this._workspaceLastSearchedIdentitiesKey ? this._workspaceSearchInFlightPromise || Promise.resolve() : (this.userIdentifiedInWorkspace = !1, this._workspaceLastSearchedIdentitiesKey = c, new Promise((u) => {
644
648
  try {
645
- n(t, o, (l) => {
649
+ n(t, s, (l) => {
646
650
  l?.httpCode === 200 && (this.userIdentifiedInWorkspace = !0), u();
647
651
  });
648
652
  } catch (l) {
@@ -693,11 +697,11 @@ const f = class f {
693
697
  return this._dispatchPlacements(e);
694
698
  }
695
699
  _dispatchPlacements(e) {
696
- 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;
700
+ const t = e && e.attributes || {}, r = { ...b(this.userAttributes), ...t }, s = this.filters || {}, o = s.userAttributeFilters || [], c = s.filteredUser || null, u = c ? c.getMPID() : null;
697
701
  let l;
698
- 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);
699
- const g = this._onboardingExpProvider === "Optimizely" ? this.fetchOptimizely() : {}, O = this.returnUserIdentities(c), A = this.returnLocalSessionAttributes(), R = ge(Y(this.loggingService)), p = {
700
- ...O,
702
+ s ? s.filterUserAttributes ? l = s.filterUserAttributes(r, o) : l = r : (console.warn("Rokt Kit: No filters available, using user attributes"), l = r), this.userAttributes = b(l);
703
+ const g = this._onboardingExpProvider === "Optimizely" ? this.fetchOptimizely() : {}, P = this.returnUserIdentities(c), A = this.returnLocalSessionAttributes(), R = ge(Y(this.loggingService)), p = {
704
+ ...P,
701
705
  ...l,
702
706
  ...g,
703
707
  ...A,
@@ -705,7 +709,7 @@ const f = class f {
705
709
  ...this.userIdentifiedInWorkspace ? { [Se]: !0 } : {},
706
710
  mpid: u
707
711
  }, v = { ...e, attributes: p }, E = this.launcher.selectPlacements(v), w = () => this.logSelectPlacementsEvent(p);
708
- return Promise.resolve(E).then((h) => h?.context?.sessionId?.then((se) => this.setRoktSessionId(se))).catch(() => {
712
+ return Promise.resolve(E).then((h) => h?.context?.sessionId?.then((oe) => this.setRoktSessionId(oe))).catch(() => {
709
713
  }).finally(w), E;
710
714
  }
711
715
  /**
@@ -1,2 +1,2 @@
1
- var RoktKit=(function(O){"use strict";const ae=["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"],ce=new Set(ae);function x(i){return ce.has(i.toLowerCase())}function A(i){const e={},t=i||{},n=Object.keys(t);for(let r=0;r<n.length;r++){const o=n[r];x(o)||(e[o]=t[o])}return e}function E(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function m(i){return typeof i=="string"}function P(i){return i==null?!0:typeof i=="object"?Object.keys(i).length===0:!1}function U(i){try{const e=new URL(i);return e.search="",e.toString()}catch{return i}}function R(i){try{const e=window.localStorage.getItem(i);return e===null?null:JSON.parse(e)}catch{return null}}function G(i,e){try{return window.localStorage.setItem(i,JSON.stringify(e)),!0}catch{return!1}}function W(i){try{window.localStorage.removeItem(i)}catch{}}function j(i,e){const t=R(i);return E(t)?t[e]:void 0}function C(i,e,t){const n=R(i),r=E(n)?{...n}:{};return r[e]=t,G(i,r)}function le(i,e){const t=R(i);if(!E(t)||!(e in t))return;const n={...t};delete n[e],Object.keys(n).length===0?W(i):G(i,n)}function ue(i,e,t,n){const r=t.slice(),o=()=>r.length<=1?!1:(r.shift(),!0);let s=JSON.stringify(r).length>n;for(;s&&o();)s=JSON.stringify(r).length>n;let c=C(i,e,r);for(;!c&&o();)c=C(i,e,r);return c}const S="mp-rokt-kit",k="pageViews",H="mpPageViews",de=100*1024;function V(i){const e=R(H);if(e===null)return;if(!(j(S,k)!==void 0)&&Array.isArray(e)&&!C(S,k,e)){i?.log({message:"Rokt Kit: Failed to migrate legacy page-view storage; retaining legacy key for retry",code:"PAGE_VIEW_CAPTURE_FAILED"});return}W(H)}function z(i){V(i);const e=j(S,k);return Array.isArray(e)?e:[]}function he(i){return ue(S,k,i,de)}function J(){le(S,k)}function ge(i){return i.map((e,t)=>{const n=e.activeTimeOnSite,r=n!==void 0&&Number.isFinite(n),s=i[t+1]?.activeTimeOnSite,c=s!==void 0&&Number.isFinite(s),u=r&&c?s-n:void 0;return{pageUrl:e.pageUrl,sourceMessageId:e.sourceMessageId,timestamp:e.timestamp,...e.pageTitle!==void 0?{pageTitle:e.pageTitle}:{},...e.canonicalUrl!==void 0?{canonicalUrl:e.canonicalUrl}:{},...r?{activeTimeOnSite:n}:{},...u!==void 0&&u>=0?{activeTimeOnPage:u}:{}}})}function pe(){const e=document.querySelector('link[rel="canonical"]')?.href;if(e)return U(e)}const d="Rokt",v=181,fe="selectPlacements",me="apps.roktecommerce.com",Ee=.1,_e="ThankYouPageJourney",ye="rokt-launcher",Ie="rokt-thank-you-element",Se="userIdentifiedInWorkspace",ke=3,Ae=2,Re="page_events",ve=500,M={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST",LOG_DELIVERY_FAILURE:"LOG_DELIVERY_FAILURE"},_={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},we="apps.rokt-api.com",be="/v1/log",Le="/v1/errors",Te=10;function a(){return window.mParticle}function B(i,e){const n=[K(i),"/wsdk/integrations/launcher.js"].join("");return!e||e.length===0?n:n+"?extensions="+e.join(",")}function q(i){return[K(i),"/rokt-elements/rokt-element-thank-you.js"].join("")}function K(i){return["https://",typeof i<"u"?i:we].join("")}function Q(i,e,t){return i?i.startsWith("http://")||i.startsWith("https://")?i:"https://"+i:K(e)+t}function $(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 w(i){if(!i)return[];try{return JSON.parse(i.replace(/&quot;/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function X(i){const e=i?w(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(_e)):t.push(s)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:n,loadThankYouElement:r}}async function Ne(i,e){const t=[];if(e)for(const n of i)t.push(e.use(n));return Promise.all(t)}function Z(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 ee(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,o=n.map;e[r]||(e[r]=[]),e[r].push({eventAttributeKey:o,conditions:Array.isArray(n.conditions)?n.conditions:[]})}return e}function te(i,e,t){return a().generateHash([i,e,t].join(""))}function Oe(i){let n="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"1.31.0";return i&&(n+="_"+i),n}function ie(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=ie(window.location.origin);if(y._allowedOriginHashes.indexOf(t)===-1||Math.random()>=Ee)return;const r=window.__rokt_li_guid__;if(!r)return;const o=window.location.href.split("?")[0].split("#")[0],s="version="+encodeURIComponent(e??"")+"&launcherInstanceGuid="+encodeURIComponent(r)+"&pageUrl="+encodeURIComponent(o);D("https://"+(i||"apps.rokt.com")+"/v1/wsdk-init/index.html?"+s),D("https://"+me+"/v1/wsdk-init/index.html?"+s+"&isControl=true")}function Pe(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function Ue(){return typeof window<"u"?window.location?.href:void 0}function Ce(){return typeof window<"u"?window.navigator?.userAgent:void 0}class re{constructor(){this._logCount={}}incrementAndCheck(e){const n=(this._logCount[e]||0)+1;return this._logCount[e]=n,n>Te}}class F{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 re,this._isEnabled=Pe()||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||M.UNKNOWN_ERROR,url:Ue(),deviceInfo:Ce(),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 oe{constructor(e,t,n,r,o){this._transport=new F(e,t,n,r,o),this._errorUrl=Q(e?.errorUrl,e?.integrationDomain,Le)}report(e){if(!e)return;const t=e.severity||_.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class se{constructor(e,t,n,r,o,s){this._transport=new F(e,n,r,o,s),this._loggingUrl=Q(e?.loggingUrl,e?.integrationDomain,be),this._errorReportingService=t}log(e){e&&this._transport.send(this._loggingUrl,_.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:M.LOG_DELIVERY_FAILURE,severity:n?_.ERROR:_.WARNING})}})}}function Me(i){const e=U(window.location.href),t=i.EventAttributes?.title||document.title,n=pe(),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 p=class p{constructor(){this.name=d,this.id=v,this.moduleId=v,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}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 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(P(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=U(window.location.href);const n=z(this.loggingService),r=Me(e);n.push(r),he(n)||this.loggingService?.log({message:`Rokt Kit: Failed to persist page view for ${t}`,code:"PAGE_VIEW_CAPTURE_FAILED"})}catch(n){this.loggingService?.log({message:`Rokt Kit: Failed to capture page view for ${t}: ${n instanceof Error?n.message:String(n)}`,code:"PAGE_VIEW_CAPTURE_FAILED"})}}isLauncherReadyToAttach(){return!!window.Rokt&&typeof window.Rokt.createLauncher=="function"}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[p.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(fe,t,e)}setRoktSessionId(e){if(!(!e||typeof e!="string"))try{const t=a().getInstance();t&&typeof t.setIntegrationAttribute=="function"&&t.setIntegrationAttribute(v,{roktSessionId:e})}catch{}}attachLauncher(e,t,n=[]){const r=a()&&a().sessionManager&&typeof a().sessionManager.getSession=="function"?a().sessionManager.getSession():void 0,o={accountId:e,...t||{},...r?{mpSessionId:r}:{}};let s;this.isPartnerInLocalLauncherTestGroup()?s=Promise.resolve(window.Rokt.createLocalLauncher(o)):s=window.Rokt.createLauncher(o),s.then(async c=>{await Ne(n,c),this.initRoktLauncher(c)}).catch(c=>{console.error("Error creating Rokt launcher:",c)})}initRoktLauncher(e){window.Rokt&&(window.Rokt.currentLauncher=e),this.launcher=e;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=A(o),this._onboardingExpProvider=s.onboardingExpProvider;const u=w(s.placementEventMapping);this.placementEventMappingLookup=Z(u);const l=w(s.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=ee(l),s.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=s.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=m(s.workspaceIdSyncApiKey)?s.workspaceIdSyncApiKey:void 0;const g=a().Rokt?.domain,{roktExtensionsQueryParams:Y,legacyRoktExtensions:b,loadThankYouElement:L}=X(s.roktExtensions),f={...a().Rokt?.launcherOptions||{}};this.integrationName=Oe(f.integrationName),f.integrationName=this.integrationName,this.domain=g;const T={loggingUrl:s.loggingUrl,errorUrl:s.errorUrl,integrationDomain:g,isLoggingEnabled:a().config?.isLoggingEnabled===!0},I=new oe(T,this.integrationName,window.__rokt_li_guid__,s.accountId),N=new se(T,I,this.integrationName,window.__rokt_li_guid__,s.accountId);if(this.errorReportingService=I,this.loggingService=N,this.isTargetingDisabled())try{J()}catch(h){this.errorReportingService?.report({message:"Rokt Kit: Failed to clear page views when targeting is disabled",code:"PAGE_VIEW_CAPTURE_FAILED",severity:_.INFO,stackTrace:h instanceof Error?h.stack:void 0})}return a()._registerErrorReportingService&&a()._registerErrorReportingService(I),a()._registerLoggingService&&a()._registerLoggingService(N),n?(this.testHelpers={generateLauncherScript:B,generateThankYouElementScript:q,extractRoktExtensionConfig:X,hashEventMessage:te,parseSettingsString:w,generateMappedEventLookup:Z,generateMappedEventAttributeLookup:ee,sendAdBlockMeasurementSignals:ne,createAutoRemovedIframe:D,djb2:ie,setAllowedOriginHashes:h=>{p._allowedOriginHashes=h},ReportingTransport:F,ErrorReportingService:oe,LoggingService:se,RateLimiter:re,ErrorCodes:M,WSDKErrorSeverity:_},this.attachLauncher(c,f),"Successfully initialized: "+d):(L&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),$(Ie,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,b):($(ye,B(g,Y),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,f,b):console.error("Rokt object is not available after script load.")},onError:h=>{console.error("Error loading Rokt launcher script:",h)}}),this.captureTiming(p.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+d)}process(e){if(this.isTargetingDisabled()||(e.EventDataType===ke&&this.capturePageView(e),e.EventDataType===Ae&&(V(this.loggingService),J())),!this.isKitReady())return"Kit not ready for forwarder: "+d;if(typeof a().Rokt?.setLocalSessionAttribute=="function"&&(P(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!P(this.placementEventMappingLookup))){const t=te(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 x(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=A(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];m(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){if(this._workspaceSearchInFlightPromise){const t=this._workspaceSearchInFlightPromise;return Promise.race([t,new Promise(n=>setTimeout(n,ve))]).then(()=>this._dispatchPlacements(e))}return this._dispatchPlacements(e)}_dispatchPlacements(e){const t=e&&e.attributes||{},r={...A(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=A(l);const g=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},Y=this.returnUserIdentities(c),b=this.returnLocalSessionAttributes(),L=ge(z(this.loggingService)),f={...Y,...l,...g,...b,...L.length?{[Re]:JSON.stringify(L)}:{},...this.userIdentifiedInWorkspace?{[Se]:!0}:{},mpid:u},T={...e,attributes:f},I=this.launcher.selectPlacements(T),N=()=>this.logSelectPlacementsEvent(f);return Promise.resolve(I).then(h=>h?.context?.sessionId?.then(Fe=>this.setRoktSessionId(Fe))).catch(()=>{}).finally(N),I}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")))}onShoppableAdsReady(e){this._isThankYouElementLoaded?e():this._thankYouElementOnLoadCallback=e}};p._allowedOriginHashes=[-553112570,549508659],p.PERFORMANCE_MARKS={RoktScriptAppended:"mp:RoktScriptAppended"},p.EMAIL_SHA256_KEY="emailsha256";let y=p;function Ke(){return v}function De(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")}return typeof window<"u"&&window.mParticle&&a().addForwarder&&a().addForwarder({name:d,constructor:y,getId:Ke}),O.register=De,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"}),O})({});
1
+ var RoktKit=(function(P){"use strict";const ae=["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"],ce=new Set(ae);function G(i){return ce.has(i.toLowerCase())}function A(i){const e={},t=i||{},n=Object.keys(t);for(let r=0;r<n.length;r++){const s=n[r];G(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 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}}function R(i){try{const e=window.localStorage.getItem(i);return e===null?null:JSON.parse(e)}catch{return null}}function x(i,e){try{return window.localStorage.setItem(i,JSON.stringify(e)),!0}catch{return!1}}function W(i){try{window.localStorage.removeItem(i)}catch{}}function j(i,e){const t=R(i);return E(t)?t[e]:void 0}function M(i,e,t){const n=R(i),r=E(n)?{...n}:{};return r[e]=t,x(i,r)}function le(i,e){const t=R(i);if(!E(t)||!(e in t))return;const n={...t};delete n[e],Object.keys(n).length===0?W(i):x(i,n)}function ue(i,e,t,n){const r=t.slice(),s=()=>r.length<=1?!1:(r.shift(),!0);let o=JSON.stringify(r).length>n;for(;o&&s();)o=JSON.stringify(r).length>n;let c=M(i,e,r);for(;!c&&s();)c=M(i,e,r);return c}const I="mp-rokt-kit",k="pageViews",H="mpPageViews",de=100*1024;function V(i){const e=R(H);if(e===null)return;if(!(j(I,k)!==void 0)&&Array.isArray(e)&&!M(I,k,e)){i?.log({message:"Rokt Kit: Failed to migrate legacy page-view storage; retaining legacy key for retry",code:"PAGE_VIEW_CAPTURE_FAILED"});return}W(H)}function z(i){V(i);const e=j(I,k);return Array.isArray(e)?e:[]}function he(i){return ue(I,k,i,de)}function J(){le(I,k)}function ge(i){return i.map((e,t)=>{const n=e.activeTimeOnSite,r=n!==void 0&&Number.isFinite(n),o=i[t+1]?.activeTimeOnSite,c=o!==void 0&&Number.isFinite(o),u=r&&c?o-n:void 0;return{pageUrl:e.pageUrl,sourceMessageId:e.sourceMessageId,timestamp:e.timestamp,...e.pageTitle!==void 0?{pageTitle:e.pageTitle}:{},...e.canonicalUrl!==void 0?{canonicalUrl:e.canonicalUrl}:{},...r?{activeTimeOnSite:n}:{},...u!==void 0&&u>=0?{activeTimeOnPage:u}:{}}})}function pe(){const e=document.querySelector('link[rel="canonical"]')?.href;if(e)return C(e)}const d="Rokt",v=181,fe="selectPlacements",me="apps.roktecommerce.com",Ee=.1,_e="ThankYouPageJourney",ye="rokt-launcher",Se="rokt-thank-you-element",Ie="userIdentifiedInWorkspace",ke=3,Ae=2,Re="page_events",ve=500,K={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST",LOG_DELIVERY_FAILURE:"LOG_DELIVERY_FAILURE"},_={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},we="apps.rokt-api.com",be="/v1/log",Le="/v1/errors",Te=10;function a(){return window.mParticle}function B(i,e){const n=[w(i),"/wsdk/integrations/launcher.js"].join("");return!e||e.length===0?n:n+"?extensions="+e.join(",")}function q(i){return[w(i),"/rokt-elements/rokt-element-thank-you.js"].join("")}function w(i){const e=typeof i<"u"?i:we;return e.includes("://")?e.replace(/\/+$/,""):["https://",e].join("")}function $(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 w(r)+t}function Q(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 b(i){if(!i)return[];try{return JSON.parse(i.replace(/&quot;/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function X(i){const e=i?b(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(_e)):t.push(o)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:n,loadThankYouElement:r}}async function Ne(i,e){const t=[];if(e)for(const n of i)t.push(e.use(n));return Promise.all(t)}function Z(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 ee(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 te(i,e,t){return a().generateHash([i,e,t].join(""))}function Oe(i){let n="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"1.32.0";return i&&(n+="_"+i),n}function ie(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=ie(window.location.origin);if(y._allowedOriginHashes.indexOf(t)===-1||Math.random()>=Ee)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?w(i):"https://apps.rokt.com";D(c+"/v1/wsdk-init/index.html?"+o),D("https://"+me+"/v1/wsdk-init/index.html?"+o+"&isControl=true")}function Pe(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function Ue(){return typeof window<"u"?window.location?.href:void 0}function Ce(){return typeof window<"u"?window.navigator?.userAgent:void 0}class re{constructor(){this._logCount={}}incrementAndCheck(e){const n=(this._logCount[e]||0)+1;return this._logCount[e]=n,n>Te}}class F{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 re,this._isEnabled=Pe()||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||K.UNKNOWN_ERROR,url:Ue(),deviceInfo:Ce(),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 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),o&&o(l)})}catch(c){console.error("ReportingTransport: Failed to send log",c),o&&o(c)}}}class se{constructor(e,t,n,r,s){this._transport=new F(e,t,n,r,s),this._errorUrl=$(e?.errorUrl,e?.integrationDomain,Le)}report(e){if(!e)return;const t=e.severity||_.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class oe{constructor(e,t,n,r,s,o){this._transport=new F(e,n,r,s,o),this._loggingUrl=$(e?.loggingUrl,e?.integrationDomain,be),this._errorReportingService=t}log(e){e&&this._transport.send(this._loggingUrl,_.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:K.LOG_DELIVERY_FAILURE,severity:n?_.ERROR:_.WARNING})}})}}function Me(i){const e=C(window.location.href),t=i.EventAttributes?.title||document.title,n=pe(),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 p=class p{constructor(){this.name=d,this.id=v,this.moduleId=v,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}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=C(window.location.href);const n=z(this.loggingService),r=Me(e);n.push(r),he(n)||this.loggingService?.log({message:`Rokt Kit: Failed to persist page view for ${t}`,code:"PAGE_VIEW_CAPTURE_FAILED"})}catch(n){this.loggingService?.log({message:`Rokt Kit: Failed to capture page view for ${t}: ${n instanceof Error?n.message:String(n)}`,code:"PAGE_VIEW_CAPTURE_FAILED"})}}isLauncherReadyToAttach(){return!!window.Rokt&&typeof window.Rokt.createLauncher=="function"}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[p.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(fe,t,e)}setRoktSessionId(e){if(!(!e||typeof e!="string"))try{const t=a().getInstance();t&&typeof t.setIntegrationAttribute=="function"&&t.setIntegrationAttribute(v,{roktSessionId:e})}catch{}}attachLauncher(e,t,n=[]){const r=a()&&a().sessionManager&&typeof a().sessionManager.getSession=="function"?a().sessionManager.getSession():void 0,s={accountId:e,...t||{},...r?{mpSessionId:r}:{}};let o;this.isPartnerInLocalLauncherTestGroup()?o=Promise.resolve(window.Rokt.createLocalLauncher(s)):o=window.Rokt.createLauncher(s),o.then(async c=>{await Ne(n,c),this.initRoktLauncher(c)}).catch(c=>{console.error("Error creating Rokt launcher:",c)})}initRoktLauncher(e){window.Rokt&&(window.Rokt.currentLauncher=e),this.launcher=e;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((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=A(s),this._onboardingExpProvider=o.onboardingExpProvider;const u=b(o.placementEventMapping);this.placementEventMappingLookup=Z(u);const l=b(o.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=ee(l),o.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=o.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=m(o.workspaceIdSyncApiKey)?o.workspaceIdSyncApiKey:void 0;const g=a().Rokt?.domain,{roktExtensionsQueryParams:Y,legacyRoktExtensions:L,loadThankYouElement:T}=X(o.roktExtensions),f={...a().Rokt?.launcherOptions||{}};this.integrationName=Oe(f.integrationName),f.integrationName=this.integrationName,this.domain=g;const N={loggingUrl:o.loggingUrl,errorUrl:o.errorUrl,integrationDomain:g,isLoggingEnabled:a().config?.isLoggingEnabled===!0},S=new se(N,this.integrationName,window.__rokt_li_guid__,o.accountId),O=new oe(N,S,this.integrationName,window.__rokt_li_guid__,o.accountId);if(this.errorReportingService=S,this.loggingService=O,this.isTargetingDisabled())try{J()}catch(h){this.errorReportingService?.report({message:"Rokt Kit: Failed to clear page views when targeting is disabled",code:"PAGE_VIEW_CAPTURE_FAILED",severity:_.INFO,stackTrace:h instanceof Error?h.stack:void 0})}return a()._registerErrorReportingService&&a()._registerErrorReportingService(S),a()._registerLoggingService&&a()._registerLoggingService(O),n?(this.testHelpers={generateLauncherScript:B,generateThankYouElementScript:q,extractRoktExtensionConfig:X,hashEventMessage:te,parseSettingsString:b,generateMappedEventLookup:Z,generateMappedEventAttributeLookup:ee,sendAdBlockMeasurementSignals:ne,createAutoRemovedIframe:D,djb2:ie,setAllowedOriginHashes:h=>{p._allowedOriginHashes=h},ReportingTransport:F,ErrorReportingService:se,LoggingService:oe,RateLimiter:re,ErrorCodes:K,WSDKErrorSeverity:_},this.attachLauncher(c,f),"Successfully initialized: "+d):(T&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),Q(Se,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,L):(Q(ye,B(g,Y),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,f,L):console.error("Rokt object is not available after script load.")},onError:h=>{console.error("Error loading Rokt launcher script:",h)}}),this.captureTiming(p.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+d)}process(e){if(this.isTargetingDisabled()||(e.EventDataType===ke&&this.capturePageView(e),e.EventDataType===Ae&&(V(this.loggingService),J())),!this.isKitReady())return"Kit not ready for forwarder: "+d;if(typeof a().Rokt?.setLocalSessionAttribute=="function"&&(U(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!U(this.placementEventMappingLookup))){const t=te(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 G(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=A(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){if(this._workspaceSearchInFlightPromise){const t=this._workspaceSearchInFlightPromise;return Promise.race([t,new Promise(n=>setTimeout(n,ve))]).then(()=>this._dispatchPlacements(e))}return this._dispatchPlacements(e)}_dispatchPlacements(e){const t=e&&e.attributes||{},r={...A(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=A(l);const g=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},Y=this.returnUserIdentities(c),L=this.returnLocalSessionAttributes(),T=ge(z(this.loggingService)),f={...Y,...l,...g,...L,...T.length?{[Re]:JSON.stringify(T)}:{},...this.userIdentifiedInWorkspace?{[Ie]:!0}:{},mpid:u},N={...e,attributes:f},S=this.launcher.selectPlacements(N),O=()=>this.logSelectPlacementsEvent(f);return Promise.resolve(S).then(h=>h?.context?.sessionId?.then(Fe=>this.setRoktSessionId(Fe))).catch(()=>{}).finally(O),S}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")))}onShoppableAdsReady(e){this._isThankYouElementLoaded?e():this._thankYouElementOnLoadCallback=e}};p._allowedOriginHashes=[-553112570,549508659],p.PERFORMANCE_MARKS={RoktScriptAppended:"mp:RoktScriptAppended"},p.EMAIL_SHA256_KEY="emailsha256";let y=p;function Ke(){return v}function De(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")}return typeof window<"u"&&window.mParticle&&a().addForwarder&&a().addForwarder({name:d,constructor:y,getId:Ke}),P.register=De,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"}),P})({});
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.31.0",
3
+ "version": "1.32.0",
4
4
  "description": "mParticle integration kit for Rokt",
5
5
  "main": "dist/Rokt-Kit.common.js",
6
6
  "module": "dist/Rokt-Kit.esm.js",